2020-07-04 12:23:10 +02:00
|
|
|
const { Command } = require('../../../../interfaces/');
|
2020-07-16 09:54:39 +02:00
|
|
|
const { AddRole } = require('../../../../moderation/infractions/');
|
2020-07-04 12:23:10 +02:00
|
|
|
|
|
|
|
class AddroleCommand extends Command {
|
|
|
|
|
|
|
|
constructor(client) {
|
|
|
|
|
|
|
|
super(client, {
|
|
|
|
name: 'addrole',
|
|
|
|
module: 'moderation',
|
|
|
|
aliases: [
|
2020-07-20 00:42:21 +02:00
|
|
|
'roleadd',
|
|
|
|
'addroles',
|
|
|
|
'rolesadd'
|
2020-07-04 12:23:10 +02:00
|
|
|
],
|
|
|
|
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
|
2020-07-04 12:23:10 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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(AddRole, message, {
|
2020-07-04 12:23:10 +02:00
|
|
|
targets: members,
|
|
|
|
data: {
|
2021-05-10 22:09:03 +02:00
|
|
|
roleIds: roles.map((r) => r.id),
|
|
|
|
roleNames: roles.map((r) => r.display),
|
2020-07-04 12:23:10 +02:00
|
|
|
roles
|
|
|
|
},
|
|
|
|
reason: parameters.join(' ')
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = AddroleCommand;
|