2019-10-06 20:29:56 +02:00
|
|
|
const { Command } = require('discord-akairo');
|
|
|
|
const guildBlacklist = require('../../models').guildBlacklist;
|
|
|
|
|
|
|
|
class serverBlacklistCommand extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('serverBlacklist', {
|
|
|
|
aliases: ['serverblacklist', 'sBlacklist'],
|
|
|
|
category: 'owner',
|
|
|
|
ownerOnly: 'true',
|
|
|
|
userPermissions: ['MANAGE_MESSAGES'],
|
|
|
|
args: [
|
|
|
|
{
|
|
|
|
id: 'guildID',
|
|
|
|
type: 'string',
|
|
|
|
prompt: {
|
|
|
|
start: 'Who do you want to blacklist?',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
2020-03-19 23:24:31 +01:00
|
|
|
channel: 'guild',
|
2019-10-06 20:29:56 +02:00
|
|
|
description: {
|
2019-10-06 20:38:06 +02:00
|
|
|
content: 'Blacklist guild from the bot',
|
|
|
|
usage: '[GuildID]',
|
|
|
|
examples: ['']
|
2019-10-06 20:29:56 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async exec(message, args) {
|
2020-04-27 19:39:40 +02:00
|
|
|
const blacklist = await guildBlacklist.findOne({where: {guildID:args.guildID}});
|
2019-10-06 20:29:56 +02:00
|
|
|
|
|
|
|
if (!blacklist) {
|
|
|
|
const body = {guildID: args.guildID};
|
|
|
|
guildBlacklist.create(body);
|
|
|
|
return message.channel.send(`The guild with the following id have been blacklisted: ${args.guildID}`);
|
|
|
|
} else {
|
|
|
|
message.channel.send('This guild is already blacklisted, do you want to unblacklist it? y/n');
|
|
|
|
const filter = m => m.content && m.author.id == message.author.id;
|
|
|
|
message.channel.awaitMessages(filter, {time: 5000 * 1000, max: 1, errors: ['time'] })
|
|
|
|
.then(messages => {
|
|
|
|
let messageContent = messages.map(messages => messages.content);
|
2020-05-08 01:26:09 +02:00
|
|
|
if (messageContent[0] === 'y' || messageContent[0] === 'yes') {
|
2019-10-06 20:29:56 +02:00
|
|
|
guildBlacklist.destroy({where: {guildID:args.guildID}});
|
|
|
|
return message.channel.send(`The guild with the following id have been unblacklisted: ${args.guildID}`);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
console.error(err);
|
|
|
|
return message.channel.send('Took too long to answer. didin\'t unblacklist anyone.');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = serverBlacklistCommand;
|