【发布时间】:2021-10-07 12:23:35
【问题描述】:
所以我正在使用 discord.js 编写一个不和谐的机器人,其中一个功能是当新用户加入服务器时,机器人会发送一条消息。我暂时不做嵌入,以后可以自己做。
这是我专门为此功能制作的主要welcome.js 文件:
module.exports = (client) => {
const channelId = '868192573011931185' //welcome channel
client.on('guildMemberAdd', (member) => {
console.log(member.name)
const message = `Hello <@${member.id}> and welcome to ${guild.name}!
Please verify through the Server Captcha Bot in your DMs,
then read the rules in <#868192573263605884>
and lastly pick your roles in <#868192573263605880>!`
const channel = member.guild.channels.cache.get(channelId)
channel.send(message)
})
}
在我的index.js 文件中,我刚刚导入了该文件,并添加了welcome(client)。
但由于某种原因,我的代码没有出现在欢迎频道中...任何帮助将不胜感激。
【问题讨论】:
-
事件不应该在函数中
标签: javascript discord.js bots