From b7ec53a11eff20d7ac48eab3e656e3f31e280b14 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Mon, 14 Jan 2019 11:33:01 +0100 Subject: [PATCH] Show the missing permissions --- event/listeners/commandblocked.js | 13 ++++++------- event/listeners/missingPermissions.js | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 event/listeners/missingPermissions.js diff --git a/event/listeners/commandblocked.js b/event/listeners/commandblocked.js index 6fed8c79..f3ecd683 100644 --- a/event/listeners/commandblocked.js +++ b/event/listeners/commandblocked.js @@ -8,25 +8,24 @@ class CommandBlockedListener extends Listener { }); } - exec(message, command, reason) { + async exec(message, command, reason) { console.log(`${message.author.username} was blocked from using ${command.id} because of ${reason}!`); let ownerMessage; switch(reason) { - case 'Owner': + case 'owner': ownerMessage = ['Nice try but you aren\'t the owner ', 'LOADING SUPER SECRET COMMAND Wait a minute... you aren\'t the owner!', 'uhm, how about no']; ownerMessage = ownerMessage[Math.floor( Math.random() * ownerMessage.length )]; message.reply(ownerMessage); break; - case 'clientPermissions': - message.reply('Im missing the required permissions for this command!'); + case 'guild': + message.reply('You can\'t use this command in a guild!'); break; - case 'userPermissions': - message.reply('You are missing some permissions to use this command!'); + case 'dm': + message.reply('You can\'t use this command in DM!'); break; case 'blacklist': message.reply('You can\'t use this command because you have been blacklisted!'); break; - } } } diff --git a/event/listeners/missingPermissions.js b/event/listeners/missingPermissions.js new file mode 100644 index 00000000..4e1a945b --- /dev/null +++ b/event/listeners/missingPermissions.js @@ -0,0 +1,23 @@ +const { Listener } = require('discord-akairo'); + +class missingPermissionsListener extends Listener { + constructor() { + super('missingPermissions', { + emitter: 'commandHandler', + event: 'missingPermissions' + }); + } + + async exec(message, command, type, missing) { + switch(type) { + case 'client': + message.reply(`Im missing the required permissions for this command!, \`${missing}\``); + break; + case 'user': + message.reply(`You are missing some permissions to use this command!, \`${missing}\``); + break; + } + } +} + +module.exports = missingPermissionsListener; \ No newline at end of file