当有人加入/离开服务器时,我试图让我的机器人向特定频道发送消息 但它要么不起作用,要么成员返回未定义
client.on("guildMemberRemove", member => {
console.log(member)
const welcomeChannel = member.guild.channels.cache.find(channel => channel.name === 'newcomers')
welcomeChannel.send (`Goodbye! ${member}`)
})
client.on("guildMemberAdd", member => {
const welcomeChannel = member.guild.channels.cache.find(channel => channel.name === 'newcomers')
welcomeChannel.send (`Welcome to Helix Bot Support Server ${member} Check out <#779221752021778443>`)
})
这是我的代码
答案 0 :(得分:0)
也许尝试使用:
welcomeChannel.send(`Goodbye! ${member.user.tag}`)
并将“welcomeChannel.send (Welcome to Helix Bot Support Server ${member} Check out <#779221752021778443>
)”替换为:
welcomeChannel.send (`Welcome to Helix Bot Support Server ${member.user.tag} Check out <#779221752021778443>`)