【发布时间】:2021-05-04 04:56:57
【问题描述】:
当有人加入我的服务器时,我的机器人会发送这条欢迎消息,它在 90% 的时间里都能正常工作,但它会在随机时间使机器人崩溃,非常感谢任何帮助!
client.on('guildMemberAdd', guildMember => {
const guild = client.guilds.cache.get('694107369436741702');
const memberCount = guild.memberCount;
const embed = new Discord.MessageEmbed()
.setColor('#8397A7')
.setTitle(`Welcome <@${guildMember.user.id}> to Radiant Community!`)
.setDescription(`Welcome to **Radiant Community!** :hugging: We hope you enjoy your stay and make sure to read <#694124118487990362> before chatting anywhere, and remember to get your self the role you want to get updates from in <#707274437896175676> otherwise you might not be notified of updates and announcements! :wink: You are our **${memberCount}th** member! :tada:`)
guildMember.guild.channels.cache.get('801321793129414676').send(embed)
});
【问题讨论】:
-
能否请您显示完整的错误?你确定不是“无法读取未定义的属性发送”而不是“发送未定义”?
-
补充@Lioness100 的推测,很可能缓存的公会是未定义的,因为公会没有被缓存。
-
您好!这是我可以输入的错误:` /home/container/bot3/index.js:84 guildMember.guild.channels.cache.get('801321793129414676').send(embed) ^ TypeError: Cannot read property在 Client.
(/home/container/bot3/index.js:84:63) 在 Object.module.exports [as GUILD_MEMBER_ADD] 的 Client.emit (events.js:314:20) '发送'未定义(/home/container/bot3/node_modules/discord.js/src/client/websocket/handlers/GUILD_MEMBER_ADD.js:16:14) 在WebSocketManager.handlePacket`
标签: javascript discord discord.js