aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moderation/role.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-10-21 23:35:13 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-10-21 23:35:13 -0400
commit44521f4560dc8b0bab055685437d8fa65a34377f (patch)
tree4750c8cf696a2489964edc409e640f6792ed92b6 /src/commands/moderation/role.ts
parenta8b3f2d258d6ef19aeff2c9d60d6b08a91277b2b (diff)
downloadtanzanite-44521f4560dc8b0bab055685437d8fa65a34377f.tar.gz
tanzanite-44521f4560dc8b0bab055685437d8fa65a34377f.tar.bz2
tanzanite-44521f4560dc8b0bab055685437d8fa65a34377f.zip
misc
Diffstat (limited to 'src/commands/moderation/role.ts')
-rw-r--r--src/commands/moderation/role.ts23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts
index fe34d75..d6a85af 100644
--- a/src/commands/moderation/role.ts
+++ b/src/commands/moderation/role.ts
@@ -18,14 +18,8 @@ export default class RoleCommand extends BushCommand {
description: 'Would you like to add or remove a role?',
type: 'STRING',
choices: [
- {
- name: 'add',
- value: 'add'
- },
- {
- name: 'remove',
- value: 'remove'
- }
+ { name: 'add', value: 'add' },
+ { name: 'remove', value: 'remove' }
],
required: true
},
@@ -97,7 +91,7 @@ export default class RoleCommand extends BushCommand {
message: BushMessage | BushSlashMessage,
{
action,
- user,
+ user: member,
role,
duration
}: { action: 'add' | 'remove'; user: BushGuildMember; role: BushRole; duration?: number | null }
@@ -114,7 +108,7 @@ export default class RoleCommand extends BushCommand {
const a = mappings.roleMap[i];
if (a.id == role.id) mappedRole = a;
}
- if (!mappedRole! || !mappings.roleWhitelist[mappedRole.name as keyof typeof mappings.roleWhitelist]) {
+ if (!mappedRole! || !Reflect.has(mappings.roleWhitelist, mappedRole.name)) {
return await message.util.reply({
content: `${util.emojis.error} <@&${role.id}> is not whitelisted, and you do not have manage roles permission.`,
allowedMentions: AllowedMentions.none()
@@ -138,10 +132,11 @@ export default class RoleCommand extends BushCommand {
const responseCode =
action === 'add'
- ? await user.addRole({ moderator: message.member!, addToModlog: shouldLog, role, duration })
- : await user.removeRole({ moderator: message.member!, addToModlog: shouldLog, role, duration });
+ ? await member.addRole({ moderator: message.member!, addToModlog: shouldLog, role, duration })
+ : await member.removeRole({ moderator: message.member!, addToModlog: shouldLog, role, duration });
const responseMessage = () => {
+ const victim = util.format.bold(member.user.tag);
switch (responseCode) {
case 'user hierarchy':
return `${util.emojis.error} <@&${role.id}> is higher or equal to your highest role.`;
@@ -158,11 +153,11 @@ export default class RoleCommand extends BushCommand {
case 'error adding role' || 'error removing role':
return `${util.emojis.error} An error occurred while trying to ${action} <@&${role.id}> ${
action === 'add' ? 'to' : 'from'
- } **${user.user.tag}**.`;
+ } ${victim}.`;
case 'success':
return `${util.emojis.success} Successfully ${action === 'add' ? 'added' : 'removed'} <@&${role.id}> ${
action === 'add' ? 'to' : 'from'
- } **${user.user.tag}**${duration ? ` for ${util.humanizeDuration(duration)}` : ''}.`;
+ } ${victim}${duration ? ` for ${util.humanizeDuration(duration)}` : ''}.`;
}
};