[英](Discord.JS) Bot not sending DM message when a user join
For sending the DM Message, i use:为了发送 DM 消息,我使用:
bot.on('guildMemberAdd', (member) => {
member.send('a');
});
I cannot understand what is wrong with this code so that the private message that should be sent is not being sent.我无法理解此代码有什么问题,因此没有发送应该发送的私人消息。 Help-me, please!
请帮帮我!
The problem here is that you used member.send which is unnecessary and that's why the result is bad.这里的问题是您使用了没有必要的member.send ,这就是结果不好的原因。
Use message.author.send('your text here');
使用
message.author.send('your text here');
Also, for the welcome code to work, this is my code:另外,为了让欢迎代码起作用,这是我的代码:
client.on('guildMemberAdd', guildMember => { let welcome = guildMember.guild.roles.cache.find(role => role.name === 'Verified'); guildMember.roles.add(welcome); guildMember.guild.channels.cache.get('welcome channel id').send(Welcome <@${guildMember.user.id}> to my server! Make sure to check the rules channel!
); }) client.on('guildMemberAdd', guildMember => { let welcome = guildMember.guild.roles.cache.find(role => role.name === 'Verified'); guildMember.roles.add(welcome); guildMember.guild.channels.cache.get('welcome channel id').send(Welcome <@${guildMember.user.id}> to my server! Make sure to check the rules channel!
); })
Also, replace client with bot.另外,用bot替换客户端。 I named it differently.
我给它起了不同的名字。
Hope this helps!希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.