Files
xiao/commands/settings/clear-setting.js
T
Daniel Odendahl Jr 208652d270 Custom hasPermission
2017-05-28 02:30:06 +00:00

37 lines
1.2 KiB
JavaScript

const { Command } = require('discord.js-commando');
const settings = require('../../assets/json/clear-setting');
module.exports = class ClearSettingCommand extends Command {
constructor(client) {
super(client, {
name: 'clear-setting',
group: 'settings',
memberName: 'clear-setting',
description: 'Removes a custom setting from your server.',
guildOnly: true,
args: [
{
key: 'setting',
prompt: 'What setting do you want to clear?',
type: 'string',
validate: setting => {
if (settings.includes(setting)) return true;
return `Please enter one of the following: ${settings.join(', ')}.`;
}
}
]
});
}
hasPermission(msg) {
if (!msg.member.hasPermission('ADMINISTRATOR')) return 'You do not have the `Administrator` Permission.';
else return true;
}
run(msg, args) {
const { setting } = args;
msg.guild.settings.remove(setting);
return msg.say(`${setting} has been removed from your server settings.`);
}
};