问题
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