mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 14:18:36 +02:00
Rewrite Permission Checks and Validators
This commit is contained in:
@@ -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!');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user