This commit is contained in:
Erik 2022-05-11 13:51:35 +03:00
parent e20ea7372a
commit d066818e36
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
2 changed files with 18 additions and 4 deletions

View File

@ -136,4 +136,8 @@ Successfully gave you **{roles}**.
Successfully removed **{roles}** from you.
[COMMAND_SELFROLE_CLEAR_SUCCESS]
Successfully removed all your selfroles.
Successfully removed all your selfroles.
[COMMAND_SELFROLE_INVALID]
{emoji_failure} The following roles are not self-assignable:
**{roles}**

View File

@ -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) {