DiscordAPIError: Cannot send messages to this user

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

}

Im not sure but the persons dm might be closed. Can you check it?

Hey there, bot’s can only send messages to users who share a mutual server with them. However, when a user leaves the server, they no longer share a mutual server with your bot. Which is the reason why your bot is unable to DM the user that left the server.

Oh… I am so dumb
Thanks!

They are enable

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.