Haha-Yes/commands/admin/commandblock.js

45 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2020-03-18 02:28:29 +01:00
const { Command } = require('discord-akairo');
const commandblock = require('../../models').commandBlock;
class commandblockCommand extends Command {
constructor() {
super('commandblock', {
aliases: ['commandblock', 'blockcommand'],
category: 'admin',
args: [
{
id: 'command',
type: 'command',
prompt: {
start: 'What command do you want to block?',
retry: 'Not a valid command, please try again'
}
}
],
clientPermissions: ['SEND_MESSAGES'],
userPermissions: ['ADMINISTRATOR'],
2020-03-19 23:24:31 +01:00
channel: 'guild',
2020-03-18 02:28:29 +01:00
description: {
2020-03-18 02:38:25 +01:00
content: 'Block a command. Execute that command again to unblock a command',
2020-03-18 02:28:29 +01:00
usage: '[command name]',
examples: ['owned']
}
});
}
async exec(message, args) {
if (args.command.id == 'commandblock') return message.channel.send('Whoa there, i can\'t let you block this command or else how would you unblock it?');
2020-04-07 00:17:36 +02:00
const blocked = await commandblock.findOne({where: {serverID: message.guild.id, command: args.command.id}});
2020-03-18 02:28:29 +01:00
if (!blocked) {
const body = {serverID: message.guild.id, command: args.command.id};
commandblock.create(body);
return message.channel.send(`Blocked command ${args.command.id}`);
} else {
commandblock.destroy({where: {serverID: message.guild.id, command: args.command.id}});
return message.channel.send(`The command ${args.command.id} has been unblocked`);
}
}
}
module.exports = commandblockCommand;