From 67669bf796b559268fcb1550ab2b8463ce819048 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 12 Aug 2019 18:07:03 +0200 Subject: [PATCH] Made the command WAAAAAAAAAAAAY better --- commands/fun/fakebot.js | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/commands/fun/fakebot.js b/commands/fun/fakebot.js index 325516e3..4fff07dc 100644 --- a/commands/fun/fakebot.js +++ b/commands/fun/fakebot.js @@ -1,6 +1,4 @@ const { Command } = require('discord-akairo'); -const fs = require('fs'); -const reload = require('auto-reload'); class fakebotCommand extends Command { constructor() { @@ -34,29 +32,21 @@ class fakebotCommand extends Command { } async exec(message, args) { - if (!fs.existsSync(`./webhook/${message.guild.id}_${message.channel.id}.json`)) { - message.channel.createWebhook('fakebot') - .then(webhook => { - fs.writeFile(`./webhook/${message.guild.id}_${message.channel.id}.json`, `{"id": "${webhook.id}", "token": "${webhook.token}", "channel": "${message.channel.id}"}`, function (err) { - if (err) { - console.log(err); - } - return message.channel.send('Please run me again to send the message!'); - }); + message.channel.createWebhook(args.member.username, args.member.displayAvatarURL()) + .then(webhook => { + webhook.edit({ + name: args.member.username, + avatar: args.member.displayAvatarURL() }); - } else { - let webhook = reload(`../../webhook/${message.guild.id}_${message.channel.id}.json`); - this.client.fetchWebhook(webhook.id, webhook.token) - .then(webhook => { - webhook.edit({ - name: args.member.username, - avatar: args.member.displayAvatarURL() + this.client.fetchWebhook(webhook.id, webhook.token) + .then(webhook => { + message.delete(); + webhook.send(args.message); + setTimeout(() => { + webhook.delete(); + }, 3000); }); - - message.delete(); - return webhook.send(args.message); - }); - } + }); } } module.exports = fakebotCommand; \ No newline at end of file