最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - guildMemberAdd and guildMemberRemove Embeds not sending anymore (Discord.js) - Stack Overflow

programmeradmin3浏览0评论

I'm very confused about this because they were once working, but now I don't even get any error messages. Here's the code:

(Wele Embed)

bot.on("guildMemberAdd", (member) => {
    let welembed = new Discord.MessageEmbed()
        .setAuthor(`${member.user.tag} just joined!`, member.user.avatarURL())
        .setDescription("Wele to Angry Birds Economy Server! Don't forget to read the <#748333038294794241>! <:WelePigHappy:777683105863041054>")
        .setColor("FF0000");
    member.guild.channels.cache.get("channelid").send(welembed)

        .catch((err) => console.log(err));
});

(Goodbye Embed)

bot.on("guildMemberRemove", (member) => {
    let goodbyembed = new Discord.MessageEmbed()
.setAuthor(`${member.user.tag} just left!`, member.user.avatarURL())
.setDescription("Sad! Let's just hope that they enjoyed their stay <:WelePigSad:777683637830680586>")
.setColor("FF0000");
member.guild.channels.cache.get("samechannelid").send(goodbyembed)

        .catch((err) => console.log(err));
});

Screenshot of it working:

I also have a guildCreate and guildRemove underneath it as well, but I don't know if that's the reason why.

I'm very confused about this because they were once working, but now I don't even get any error messages. Here's the code:

(Wele Embed)

bot.on("guildMemberAdd", (member) => {
    let welembed = new Discord.MessageEmbed()
        .setAuthor(`${member.user.tag} just joined!`, member.user.avatarURL())
        .setDescription("Wele to Angry Birds Economy Server! Don't forget to read the <#748333038294794241>! <:WelePigHappy:777683105863041054>")
        .setColor("FF0000");
    member.guild.channels.cache.get("channelid").send(welembed)

        .catch((err) => console.log(err));
});

(Goodbye Embed)

bot.on("guildMemberRemove", (member) => {
    let goodbyembed = new Discord.MessageEmbed()
.setAuthor(`${member.user.tag} just left!`, member.user.avatarURL())
.setDescription("Sad! Let's just hope that they enjoyed their stay <:WelePigSad:777683637830680586>")
.setColor("FF0000");
member.guild.channels.cache.get("samechannelid").send(goodbyembed)

        .catch((err) => console.log(err));
});

Screenshot of it working:

I also have a guildCreate and guildRemove underneath it as well, but I don't know if that's the reason why.

Share Improve this question edited Dec 27, 2020 at 21:48 chickenloveryt asked Dec 26, 2020 at 15:42 chickenloverytchickenloveryt 432 gold badges2 silver badges8 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

The issue is most likely Discord API's relatively new intents feature. You need to subscribe to specific intents in order to reliably receive the affiliated events. guildMemberAdd and guildMemberRemove are on the list of events that will require subscription to an intent.

Here's one possible fix you'll need to implement wherever you are defining your client:

const intents = ["GUILDS", "GUILD_MEMBERS"];
const bot = new Discord.Client({intents: intents, ws:{intents: intents}});

Note that you must use discord.js v12.x.x to use intents, so if you're using an older version you'll need to update to fix your issue.

You will also need to enable the below setting for your bot on its discord developers page, since the guild member join/leave events are a privileged intent:

Relevant resources:
List of intents and associated events
General info about intents

发布评论

评论列表(0)

  1. 暂无评论