简体   繁体   中英

My Discord.js Bot welcome message suddenly stopped working

so I made a Discord bot, the welcome message was working for the first 3 months or so but suddenly it stopped working, can I asks why? I had been searching as to why it does not work but I couldn't find why. Thank You before.

client.on('guildMemberAdd', member => {
    const channel = member.guild.channels.find(
        ch => ch.name === '•chat-kalem•'
    );

    const redirch = member.guild.channel.cache.find(ch => ch.name === "•rules•");

    channel.send(`Welcome, ${member}! Please read the ${redirch} first.`);
});

Hey there your issue is because of recent gateway changes of the Discord Api that you need to enable the intents here is a fix for you -

  • Head over to Discord Developers Portal
  • Choose your application
  • Inside the bot section if yiu scroll a little bit down, you will see a section named Privileged Gateway Intents
  • Enable the SERVER MEMBERS INTENT and restart the bot and your bot will start recieving the guildMemberAdd event!

Learn more about intents at Discord.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM