Server greetings

旧时模样 提交于 2021-02-11 14:21:46

问题


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}!`);
});

回答1:


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




回答2:


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']} });


来源:https://stackoverflow.com/questions/65646327/server-greetings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!