You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Haha-Yes/commands/admin/commandblock.js

45 lines
1.4 KiB
JavaScript

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'],
channel: 'guild',
description: {
content: 'Block a command. Execute that command again to unblock a command',
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?');
const blocked = await commandblock.findOne({where: {serverID: message.guild.id}});
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;