Haha-Yes/event/listeners/missingPermissions.js

39 lines
1 KiB
JavaScript
Raw Permalink Normal View History

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':
if (missing == 'SEND_MESSAGES') {
2019-11-29 22:29:56 +01:00
return;
} else {
2020-03-02 19:53:25 +01:00
message.reply(Embed);
}
2019-01-14 11:33:01 +01:00
break;
case 'user':
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);
} 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-01-14 11:33:01 +01:00
break;
}
}
}
module.exports = missingPermissionsListener;