Trying to make a system where, when you say a blacklisted word, it deletes it and goes DMs the person to tell him which channel it got deleted, the reason why and the message that he said. But my code keeps telling me this:
2020-02-25T02:05:30.557281+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user
2020-02-25T02:05:30.557293+00:00 app[worker.1]: at /app/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15
2020-02-25T02:05:30.557294+00:00 app[worker.1]: at /app/node_modules/snekfetch/src/index.js:215:21
2020-02-25T02:05:30.557295+00:00 app[worker.1]: at processTicksAndRejections (internal/process/task_queues.js:97:5)
2020-02-25T02:05:30.557358+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 6)
And here is my code :
bot.on('message', async message => {
var sender = message.author
var channel = message.channel.id
if(sender.id === 'BOT ID') {
return;
}
if(message.content.includes('discord.gg/')) {
message.delete();
message.author.send(`**Your message in <#${channel}> had been deleted.**
\n**__Reason:__** *Promotion*
\n**__Your Message:__** *${message.content}*`)
};