reworked permissions handler
This commit is contained in:
parent
33773b6b37
commit
023d630606
1 changed files with 14 additions and 8 deletions
|
@ -83,24 +83,30 @@ module.exports = class {
|
||||||
|
|
||||||
// Permission handler, for both Woomy and the user
|
// Permission handler, for both Woomy and the user
|
||||||
if (message.guild) {
|
if (message.guild) {
|
||||||
var missingUserPerms = cmd.conf.userPerms.filter(perms => {
|
// User
|
||||||
!message.channel.permissionsFor(message.author).has(perms)
|
let missingUserPerms = new Array();
|
||||||
|
|
||||||
|
cmd.conf.userPerms.forEach((p) => {
|
||||||
|
if (!message.channel.permissionsFor(message.member).has(p)) missingUserPerms.push(p);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (missingUserPerms.length > 0) {
|
if (missingUserPerms.length > 0) {
|
||||||
missingUserPerms = '`' + (missingUserPerms.join('`, `')) + '`'
|
missingUserPerms = '`' + (missingUserPerms.join('`, `')) + '`'
|
||||||
return message.channel.send(`You don't have sufficient permissions to run this command! Missing: ${missingBotPerms}`);
|
return message.channel.send(`You don't have sufficient permissions to run this command! Missing: ${missingUserPerms}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
var missingBotPerms = cmd.conf.botPerms.filter(perms => {
|
// Bot
|
||||||
!message.channel.permissionsFor(this.client.user).has(perms)
|
let missingBotPerms = new Array();
|
||||||
|
|
||||||
|
cmd.conf.botPerms.forEach((p) => {
|
||||||
|
if (!message.channel.permissionsFor(message.guild.member(this.client.user)).has(p)) missingBotPerms.push(p);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (missingBotPerms.length > 0) {
|
if (missingBotPerms.length > 0) {
|
||||||
missingBotPerms = '`' + (missingBotPerms.join('`, `')) + '`';
|
missingBotPerms = '`' + (missingBotPerms.join('`, `')) + '`'
|
||||||
return message.channel.send(`Failed to run this command because I am missing the following permissions: ${missingBotPerms}`);
|
return message.channel.send(`I can't run this command because I'm missing these permissions: ${missingBotPerms}`);
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
// Cooldown
|
// Cooldown
|
||||||
if (this.client.cooldown.get(cmd.help.name).has(message.author.id)) {
|
if (this.client.cooldown.get(cmd.help.name).has(message.author.id)) {
|
||||||
|
|
Loading…
Reference in a new issue