From c8ac210ca919fcbe00238af5f159ae956ed9a461 Mon Sep 17 00:00:00 2001 From: Supositware Date: Mon, 15 Apr 2019 22:23:26 +0200 Subject: [PATCH] Send a message when DM could not be sent and fix when sending attachment --- commands/owner/dm.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/commands/owner/dm.js b/commands/owner/dm.js index 2f785ff..2e3f752 100644 --- a/commands/owner/dm.js +++ b/commands/owner/dm.js @@ -31,12 +31,22 @@ class EvalCommand extends Command { let Attachment = (message.attachments).array(); if (Attachment[0]) { - this.client.users.get(user).send(`**Message from the dev:**\n${text}\n${Attachment[0].url}\n**If you wish to respond use the feedback command**`); - message.channel.send(`DM sent to ${user.username}`); + this.client.users.get(user.id).send(`**Message from the dev:**\n${text}\n**If you wish to respond use the feedback command**`, {files: [Attachment[0].url]}) + .then(() => { + return message.channel.send(`DM sent to ${user.username}`); + }) + .catch(() => { + return message.channel.send(`Could not send a DM to ${user.username}`); + }); } else { - this.client.users.get(user.id).send(`**Message from the dev:**\n${text}\n**If you wish to respond use the feedback command**`); - message.channel.send(`DM sent to ${user.username}`); + this.client.users.get(user.id).send(`**Message from the dev:**\n${text}\n**If you wish to respond use the feedback command**`) + .then(() => { + return message.channel.send(`DM sent to ${user.username}`); + }) + .catch(() => { + return message.channel.send(`Could not send a DM to ${user.username}`); + }); } }