galactic-bot/structure/client/components/commands/moderation/Removerole.js

62 lines
1.9 KiB
JavaScript
Raw Normal View History

const { Command } = require('../../../../interfaces/');
2020-07-16 09:54:39 +02:00
const { RemoveRole } = require('../../../../moderation/infractions/');
class RemoveroleCommand extends Command {
constructor(client) {
super(client, {
name: 'removerole',
module: 'moderation',
aliases: [
'roleremove'
],
usage: "<member..> <role..> [reason]",
clientPermissions: ['MANAGE_ROLES'],
memberPermissions: ['MANAGE_ROLES'],
examples: [],
arguments: [
{
name: 'silent',
type: 'BOOLEAN',
types: ['FLAG'],
default: true
}
],
guildOnly: true,
2020-07-16 09:54:39 +02:00
showUsage: true
});
}
async execute(message, { params }) {
const { parsed: members, parameters: temporaryParameters } = await this.client.resolver.infinite(params, [
this.client.resolver.resolveMember.bind(this.client.resolver)
], true, message.guild);
if(members.length === 0) return message.respond(message.format('C_ADDROLE_MISSINGMEMBERS'), {
emoji: 'failure'
});
const { parsed: roles, parameters } = await this.client.resolver.infinite(temporaryParameters, [
this.client.resolver.resolveRole.bind(this.client.resolver)
], true, message.guild);
if(roles.length === 0) return message.respond(message.format('C_ADDROLE_MISSINGROLES'), {
emoji: 'failure'
});
return this.client.moderationManager
2020-07-16 09:54:39 +02:00
.handleInfraction(RemoveRole, message, {
targets: members,
data: {
roles
},
reason: parameters.join(' ')
});
}
}
module.exports = RemoveroleCommand;