I have bot which get user message content, delete user message, then send private message to message.author and then send content of user message in embed. After few messages bot sends 2 messages instead of 1 and warn appears. Any idea how to fix it?
Warn:
superadmin@vps-XXXXXX:~/path$ node test.js (node:1059) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message at RequestHandler.execute (path/node_modules/discord.js/src/rest/RequestHandler.js:170:25) at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:1059) 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: 1) (node:1059) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Script:
const discord = require('discord.js');
const client = new discord.Client;
client.on('message', message => {
if (message.author === client.user && message.channel.id !== (508728211837026325)) {
return;
}
if (message.channel.id == (508728211837026325)) {
message.delete();
message.author.send("Success!");
message.channel.send({
"embed": {
"color": 61183,
"description": message.content + "\n\nCreated by: " + "<@" + message.author.id + ">",
"author": {
"icon_url": "imgururl;",
"url": "imgururl",
"name": "test",
},
timestamp: new Date()
}
})
}
})
client.login('token');