From e7986dacfd62308b3d6d6b845d1a4738c66a8324 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 1 Nov 2019 02:37:27 +0100 Subject: [PATCH] Allow sending attachment --- commands/fun/fakebot.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index 119a840..149ec55 100644 --- a/commands/fun/fakebot.js +++ b/commands/fun/fakebot.js @@ -33,7 +33,13 @@ class fakebotCommand extends Command { } async exec(message, args) { - + let Attachment = (message.attachments).array(); + let url; + // Get attachment link + if (Attachment[0]) { + url = Attachment[0].url; + } + message.channel.createWebhook(args.member.username, { avatar: args.member.displayAvatarURL(), reason: `Fakebot/user command triggered by: ${message.author.username}` @@ -48,7 +54,12 @@ class fakebotCommand extends Command { this.client.fetchWebhook(webhook.id, webhook.token) .then(webhook => { message.delete(); - webhook.send(args.message); + + if (url) + webhook.send(args.message, {files: [url]}); + else + webhook.send(args.message); + setTimeout(() => { webhook.delete(); }, 3000);