Haha-Yes/commands/fun/fakebot.js

54 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-08-12 13:47:15 +02:00
const { Command } = require('discord-akairo');
class fakebotCommand extends Command {
constructor() {
super('fakebot', {
aliases: ['fakebot', 'fakeuser', 'fakemember'],
category: 'fun',
clientPermissions: ['MANAGE_WEBHOOKS'],
args: [
{
id: 'member',
type: 'user',
prompt: {
start: 'Who should i fake?',
2019-08-13 23:31:35 +02:00
retry: 'Didn\'t find any user named like that, please say the name again.'
2019-08-12 13:47:15 +02:00
}
},
{
id: 'message',
type: 'string',
prompt: {
2019-08-12 14:18:45 +02:00
start: 'What message should i send?',
2019-08-12 13:47:15 +02:00
},
match: 'rest',
}
],
description: {
content: 'Fake a bot/user with webhook',
2019-08-12 18:41:15 +02:00
usage: '[user] [message]',
examples: ['Supositware#1616 hello!']
2019-08-12 13:47:15 +02:00
}
});
}
async exec(message, args) {
2019-08-12 18:07:03 +02:00
message.channel.createWebhook(args.member.username, args.member.displayAvatarURL())
.then(webhook => {
2019-08-12 18:46:33 +02:00
// Have to edit after creation otherwise the picture doesn't get applied
2019-08-12 18:07:03 +02:00
webhook.edit({
name: args.member.username,
avatar: args.member.displayAvatarURL()
2019-08-12 13:47:15 +02:00
});
2019-08-12 18:07:03 +02:00
this.client.fetchWebhook(webhook.id, webhook.token)
.then(webhook => {
message.delete();
webhook.send(args.message);
setTimeout(() => {
webhook.delete();
}, 3000);
2019-08-12 14:05:39 +02:00
});
2019-08-12 18:07:03 +02:00
});
2019-08-12 13:47:15 +02:00
}
}
module.exports = fakebotCommand;