Home > Mobile >  Discord.js V13 Welcome Message
Discord.js V13 Welcome Message

Time:11-12

I'm still fairly new to creating bots, so this welcome message worked back in discord.js v12 but no longer works for me in v13. I am trying to send a message in a specific channel when someone joins the server, but I checked, and .send does not exist on GuildChannel. I checked to documentation but they all talk about sending message embeds, but I'm just trying to send a plain message to TextChannel Here is the code.

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
client.on('guildMemberAdd', guildMember => {
    guildMember.guild.channels.cache.get('474431129613762571').send(`**Welcome to the discord server, <@${guildMember.user.id}>!**`);
});

I can provide more information if needed. Any help will be appreciated.

CodePudding user response:

You need GUILD_MEMBERS intent in both the code and discord developer portal.

const client = new Client({ 
    intents: [
        Intents.FLAGS.GUILDS,
        Intents.FLAGS.GUILD_MESSAGES,
        Intents.FLAGS.GUILD_MEMBERS //also enable in discord developer portal
    ] 
})

To answer the other part of your other question, the .send exists on TextChannels. TextChannel extends BaseGuildTextChannel which extends GuildChannel. It's like this because it can be a VoiceChannel!

  • Related