woomy-v2/bot/commands/Configuration/disable.js

94 lines
3.5 KiB
JavaScript
Raw Normal View History

2020-10-23 08:11:14 +00:00
module.exports = class {
constructor (name, category) {
this.name = name,
this.category = category,
this.enabled = true,
this.devOnly = false,
2020-10-28 01:18:23 +00:00
this.aliases = ['disabled'],
this.userPerms = ['administrator'],
2020-10-23 08:11:14 +00:00
this.botPerms = [],
this.cooldown = 2000,
this.help = {
description: 'description',
usage: 'usage',
examples: 'examples'
};
}
2020-10-28 01:18:23 +00:00
async run (client, message, args, data) {
2020-10-25 08:29:01 +00:00
const essential = {
categories: ['Configuration', 'Developer'],
commands: ['help']
};
2020-10-28 01:18:23 +00:00
if (!args[0] || args[0].toLowerCase() === 'list') {
2020-10-25 08:29:01 +00:00
return;
}
2020-10-28 01:18:23 +00:00
if (!args[1]) return message.channel.createMessage(
2020-10-25 08:29:01 +00:00
`${client.constants.emojis.userError} You didn't specify what command/category to disable. Usage: \`${this.help.usage}\``
);
2020-10-28 01:18:23 +00:00
if (args[0].toLowerCase() === 'command' || args[0].toLowerCase() === 'cmd') {
2020-10-25 08:29:01 +00:00
const disabled = data.guild.disabledcommands;
2020-10-28 01:18:23 +00:00
let command;
if (client.commands.has(args[1])) {
command = client.commands.get(args[1]);
} else if (client.aliases.has(args[1])) {
command = client.commands.get(client.aliases.get(args[1]));
2020-10-25 08:29:01 +00:00
}
2020-10-28 01:18:23 +00:00
if (!command) return message.channel.createMessage(
`${client.constants.emojis.userError} ${args[1]} isn't a command or an alias, are you sure you spelt it correctly?`
);
if (essential.commands.includes(command.name) || essential.categories.includes(command.category)) {
return message.channel.createMessage(
`${client.constants.emojis.userError} This command is essential and cannot be disabled. Sorry!`
);
2020-10-25 08:29:01 +00:00
}
2020-10-28 01:18:23 +00:00
if (disabled.includes(command.name)) return message.channel.createMessage(
`${client.constants.emojis.userError} This command is already disabled.`
);
disabled.push(command.name);
await client.db.updateGuild(message.channel.guild.id, 'disabledcommands', disabled);
return message.channel.createMessage(
`${client.constants.emojis.success} Added **${args[1]}** to the list of disabled commands for this server.`
);
}
if (args[0].toLowerCase() === 'category' || args[0].toLowerCase() === 'cat') {
const disabled = data.guild.disabledcommands;
let command;
if (client.commands.has(args[1])) {
command = client.commands.get(args[1]);
} else if (client.aliases.has(args[1])) {
command = client.commands.get(client.aliases.get(args[1]));
}
if (!command) return message.channel.createMessage(
`${client.constants.emojis.userError} ${args[1]} isn't a category, are you sure you spelt it correctly?`
);
if (!disabled.includes(command.name)) return message.channel.createMessage(
`${client.constants.emojis.userError} This category isn't disabled.`
);
disabled.remove(command.name);
await client.db.updateGuild(message.channel.guild.id, 'disabledcommands', disabled);
2020-10-25 08:29:01 +00:00
2020-10-28 01:18:23 +00:00
return message.channel.createMessage(
`${client.constants.emojis.success} Added **${args[1]}** to the list of disabled category for this server!`
);
2020-10-25 08:29:01 +00:00
}
2020-10-23 08:11:14 +00:00
}
2020-10-28 01:18:23 +00:00
};