I am having a problem will trying to make my bot send a message to a user who have left
Here is my code:
const Discord = require(‘discord.js’);
const bot = new Client({ disableMentions: ‘everyone’ });
bot.on('guildMemberRemove', member => {
member.send("Bye").catch(console.error);
});
bot.login('My Token');
Here is the error (With catch):
DiscordAPIError: Cannot send messages to this user
at RequestHandler.execute (/rbd/pnpm-volume/16525bb6-dbbe-4958-b828-3b1d10d691cc/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
at processTicksAndRejections (internal/process/task_queues.js:88:5)
at async RequestHandler.push (/rbd/pnpm-volume/16525bb6-dbbe-4958-b828-3b1d10d691cc/node_modules/discord.js/src/rest/RequestHandler.js:39:14) {
name: 'DiscordAPIError',
message: 'Cannot send messages to this user',
method: 'post',
path: '/channels/812009421735460904/messages',
code: 50007,
httpStatus: 403
}