0

因此,当我的机器人加入新服务器时,我希望它告诉我并说它确实做到了,但是当我试图让它通过我的公会和我的 id 找到我时,它说未定义

const test = await client.guilds.cache.get('my guilds id').client.users.cache.get("my id").send(yo i joined a new server')

4

1 回答 1

0

您可能希望将“guildCreate”事件与缓存一起使用,就像这样。

client.on('guildCreate', _ => {
    let you = client.users.cache.get(/* Your User ID */)
    if (you) you.send('Yo, I joined a new server!')
    else console.log(`I can't find you in my cache`)
});
于 2021-12-22T22:01:19.710 回答