【问题标题】:Cannot read properties of undefined (reading 'send')无法读取未定义的属性(读取“发送”)
【发布时间】:2022-01-24 01:20:49
【问题描述】:

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

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

【问题讨论】:

  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: discord discord.js dm


【解决方案1】:

您可能希望将 '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`)
});

【讨论】:

  • 感谢我在 guildCreate 上提出的建议,我刚刚尝试了你所说的,但它无法以其他方式在他们的缓存中找到我?
猜你喜欢
  • 1970-01-01
  • 2020-12-19
  • 2022-01-10
  • 2023-03-09
  • 2021-04-16
  • 2020-06-05
  • 2021-04-26
相关资源
最近更新 更多