egerheheherherh
egerheheherherh

Reputation: 39

Server greetings

I tried to make server greetings message but it doesn't even work for me, I saw that you can try to do this using ch.name === 'name' but I want my bot to send message to channel with specific id

client.on("guildMemberAdd", (member) => {
  const channel = member.guild.channels.cache.find((ch) => ch.id === `channel-id`);
  if (!channel) return;
  channel.send(`Welcome to the server, ${member}!`);
});

Upvotes: 0

Views: 86

Answers (2)

Zafir Hasan Anogh
Zafir Hasan Anogh

Reputation: 11

You have to enable intents for the guildMemberAdd event to emit. Make sure to enable them at here

after enabling intents, you can add intents to your client by doing

 const client = new Client({ ws: { intents: ['GUILD_MEMBERS', 'GUILD_MESSAGES', 'GUILD_MESSAGE_REACTIONS']} });

Upvotes: 0

beans
beans

Reputation: 57

I believe you need to turn on Privileged Gateway Intents on the Dev Portal (https://discord.com/developers/applications) gateway intents on

Upvotes: 1

Related Questions