diff --git a/commands/owner/serverblacklist.js b/commands/owner/serverblacklist.js new file mode 100644 index 0000000..4cbfbf6 --- /dev/null +++ b/commands/owner/serverblacklist.js @@ -0,0 +1,55 @@ +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?', + } + } + ], + channelRestriction: 'guild', + description: { + content: 'Create custom autoresponse', + usage: '[trigger] [response]', + examples: ['"do you know da wea" Fuck off dead meme', 'hello Hello [author], how are you today?'] + } + }); + } + + async exec(message, args) { + const blacklist = await guildBlacklist.findOne({where: {guildID:message.author.id}}); + + 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); + if (messageContent == 'y' || messageContent == 'yes') { + 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; \ No newline at end of file