2019-01-14 11:33:01 +01:00
|
|
|
const { Listener } = require('discord-akairo');
|
|
|
|
|
|
|
|
class missingPermissionsListener extends Listener {
|
|
|
|
constructor() {
|
|
|
|
super('missingPermissions', {
|
|
|
|
emitter: 'commandHandler',
|
|
|
|
event: 'missingPermissions'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async exec(message, command, type, missing) {
|
2020-03-02 19:53:25 +01:00
|
|
|
let Embed = this.client.util.embed()
|
|
|
|
.setColor('RED')
|
|
|
|
.setTitle('Missing permission')
|
|
|
|
.setDescription(`Im missing the required permissions for the ${command.id} command!`)
|
|
|
|
.addField('Missing permission:', missing);
|
|
|
|
|
2019-01-14 11:33:01 +01:00
|
|
|
switch(type) {
|
|
|
|
case 'client':
|
2019-11-09 12:14:54 +01:00
|
|
|
if (missing == 'SEND_MESSAGES') {
|
2019-11-29 22:29:56 +01:00
|
|
|
return;
|
2019-11-09 12:14:54 +01:00
|
|
|
} else {
|
2020-03-02 19:53:25 +01:00
|
|
|
message.reply(Embed);
|
2019-11-09 12:14:54 +01:00
|
|
|
}
|
2019-01-14 11:33:01 +01:00
|
|
|
break;
|
|
|
|
case 'user':
|
2019-11-09 12:14:54 +01:00
|
|
|
if (missing == 'SEND_MESSAGES') {
|
2020-03-02 19:53:25 +01:00
|
|
|
Embed.setDescription(`You are missing the required permissions for the ${command.id} command!`);
|
|
|
|
return message.author.send(Embed);
|
2019-11-09 12:14:54 +01:00
|
|
|
} else {
|
2020-03-02 19:53:25 +01:00
|
|
|
Embed.setDescription(`You are missing the required permissions for the ${command.id} command!`);
|
|
|
|
message.reply(Embed);
|
2019-11-09 12:14:54 +01:00
|
|
|
}
|
2019-01-14 11:33:01 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = missingPermissionsListener;
|