bugfix
This commit is contained in:
parent
e20ea7372a
commit
d066818e36
@ -137,3 +137,7 @@ Successfully removed **{roles}** from you.
|
||||
|
||||
[COMMAND_SELFROLE_CLEAR_SUCCESS]
|
||||
Successfully removed all your selfroles.
|
||||
|
||||
[COMMAND_SELFROLE_INVALID]
|
||||
{emoji_failure} The following roles are not self-assignable:
|
||||
**{roles}**
|
@ -36,22 +36,32 @@ class SelfroleCommand extends SlashCommand {
|
||||
if (!selfrole.roles.length) return { index: 'COMMAND_SELFROLE_NONE', emoji: 'failure' };
|
||||
|
||||
const memberRoles = member.roles.cache.map((r) => r.id);
|
||||
const invalid = roles.value.filter((r) => !selfrole.roles.includes(r.id));
|
||||
const _roles = roles.value.filter((r) => selfrole.roles.includes(r.id));
|
||||
let warning = null;
|
||||
if (invalid.length) warning = guild.format('COMMAND_SELFROLE_INVALID', { roles: invalid.map((r) => r.name).join('**, **') });
|
||||
if(!_roles.length) return { content: warning };
|
||||
|
||||
let index = null,
|
||||
params = {};
|
||||
if (subcommand === 'add') {
|
||||
await member.roles.set([...new Set([...memberRoles, ..._roles.map((r) => r.id)])]);
|
||||
return { index: 'COMMAND_SELFROLE_ADD_SUCCESS', emoji: 'success', params: { roles: _roles.map((r) => r.name).join('**, **') } };
|
||||
index = 'COMMAND_SELFROLE_ADD_SUCCESS';
|
||||
params = { roles: _roles.map((r) => r.name).join('**, **') };
|
||||
} else if (subcommand === 'remove') {
|
||||
const ids = _roles.map((r) => r.id);
|
||||
const set = memberRoles.filter((r) => !ids.includes(r));
|
||||
await member.roles.set([...new Set(set)]);
|
||||
return { index: 'COMMAND_SELFROLE_REMOVE_SUCCESS', emoji: 'success', params: { roles: _roles.map((r) => r.name).join('**, **') } };
|
||||
index = 'COMMAND_SELFROLE_REMOVE_SUCCESS';
|
||||
params= { roles: _roles.map((r) => r.name).join('**, **') };
|
||||
} else if (subcommand === 'clear') {
|
||||
const set = memberRoles.filter((r) => !selfrole.roles.includes(r));
|
||||
await member.roles.set([...new Set(set)]);
|
||||
return { index: 'COMMAND_SELFROLE_CLEAR_SUCCESS', emoji: 'success', };
|
||||
index= 'COMMAND_SELFROLE_CLEAR_SUCCESS';
|
||||
}
|
||||
|
||||
return { content: guild.format(index, params) + warning? `\n\n${warning}` : '', emoji: 'success' };
|
||||
|
||||
}
|
||||
|
||||
async _listRoles(invoker) {
|
||||
|
Loading…
Reference in New Issue
Block a user