Rewrite Permission Checks and Validators

This commit is contained in:
Daniel Odendahl Jr
2017-04-25 02:37:14 +00:00
parent 9a75ee549b
commit 3ccce0ba66
105 changed files with 248 additions and 581 deletions
+10 -8
View File
@@ -32,14 +32,16 @@ module.exports = class KickCommand extends Command {
}
async run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!');
if (!message.channel.permissionsFor(this.client.user).hasPermission('KICK_MEMBERS')) return message.say(':x: Error! I don\'t have the Kick Members Permission!');
}
if (!message.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
if (!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS'))
return message.say(':x: Error! I don\'t have the Ban Members Permission!');
const modlogs = message.guild.channels.find('name', 'mod_logs');
if (!modlogs)
return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
if (!modlogs.permissionsFor(this.client.user).hasPermission('EMBED_LINKS'))
return message.say(':x: Error! I don\'t have the Embed Links Permission!');
const { member, reason } = args;
if (!member.bannable) return message.say(':x: Error! This member cannot be kicked! Perhaps they have a higher role than me?');
if (!member.bannable)
return message.say(':x: Error! This member cannot be kicked! Perhaps they have a higher role than me?');
try {
await member.kick();
await message.say(':ok_hand:');
@@ -48,7 +50,7 @@ module.exports = class KickCommand extends Command {
.setColor(0xFFA500)
.setTimestamp()
.setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Kick\n**Reason:** ${reason}`);
return message.guild.channels.find('name', 'mod_logs').send({embed});
return modlogs.send({embed});
} catch (err) {
return message.say(':x: Error! Something went wrong!');
}