1
0
Fork 0

Made the command WAAAAAAAAAAAAY better

akairo
loicbersier 5 years ago
parent 7a1c55e935
commit 67669bf796

@ -1,6 +1,4 @@
const { Command } = require('discord-akairo'); const { Command } = require('discord-akairo');
const fs = require('fs');
const reload = require('auto-reload');
class fakebotCommand extends Command { class fakebotCommand extends Command {
constructor() { constructor() {
@ -34,29 +32,21 @@ class fakebotCommand extends Command {
} }
async exec(message, args) { async exec(message, args) {
if (!fs.existsSync(`./webhook/${message.guild.id}_${message.channel.id}.json`)) { message.channel.createWebhook(args.member.username, args.member.displayAvatarURL())
message.channel.createWebhook('fakebot') .then(webhook => {
.then(webhook => { webhook.edit({
fs.writeFile(`./webhook/${message.guild.id}_${message.channel.id}.json`, `{"id": "${webhook.id}", "token": "${webhook.token}", "channel": "${message.channel.id}"}`, function (err) { name: args.member.username,
if (err) { avatar: args.member.displayAvatarURL()
console.log(err);
}
return message.channel.send('Please run me again to send the message!');
});
}); });
} else { this.client.fetchWebhook(webhook.id, webhook.token)
let webhook = reload(`../../webhook/${message.guild.id}_${message.channel.id}.json`); .then(webhook => {
this.client.fetchWebhook(webhook.id, webhook.token) message.delete();
.then(webhook => { webhook.send(args.message);
webhook.edit({ setTimeout(() => {
name: args.member.username, webhook.delete();
avatar: args.member.displayAvatarURL() }, 3000);
}); });
});
message.delete();
return webhook.send(args.message);
});
}
} }
} }
module.exports = fakebotCommand; module.exports = fakebotCommand;
Loading…
Cancel
Save