如何检测用户加入discord.js的行会?

时间:2020-06-30 02:54:58

标签: javascript node.js discord.js

我在这里使用此代码来检测用户何时加入并发送消息,但是我希望它仅在加入公会“ Bongo's Diner”时发送消息:

client.on('guildMemberAdd', member =>{

    const welcomeChannel = client.channels.cache.get('713215120305815612');
    welcomeChannel.send(`Welcome to the server, <@${member.id}>. I hope you enjoy your stay here at Bongo's Diner.

Be sure to check out <#713227378306056244> to grab a color and learn how to get ping roles. If you have a question, check out <#713194923909972159>.`);

});

1 个答案:

答案 0 :(得分:0)

由于您已经在使用guildMemberAdd并有权访问member实例,所以只需调用member.guild

const guild = member.guild;
console.log(guild);

https://discord.js.org/#/docs/main/stable/class/GuildMember