aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moderation/role.ts
diff options
context:
space:
mode:
authorTymanWasTaken <32660892+tymanwastaken@users.noreply.github.com>2021-05-11 11:03:24 -0600
committerTymanWasTaken <32660892+tymanwastaken@users.noreply.github.com>2021-05-11 11:03:24 -0600
commit35389d9e41d4a5ddf66fdf64210a334a56281f41 (patch)
treeda6d947662db44f52a190116ce1d36e3a13d8334 /src/commands/moderation/role.ts
parentccd25403da46b68bae2126bd7d56512107bd4459 (diff)
downloadtanzanite-35389d9e41d4a5ddf66fdf64210a334a56281f41.tar.gz
tanzanite-35389d9e41d4a5ddf66fdf64210a334a56281f41.tar.bz2
tanzanite-35389d9e41d4a5ddf66fdf64210a334a56281f41.zip
formatting moment
Diffstat (limited to 'src/commands/moderation/role.ts')
-rw-r--r--src/commands/moderation/role.ts123
1 files changed, 92 insertions, 31 deletions
diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts
index 8bf8827..60fe369 100644
--- a/src/commands/moderation/role.ts
+++ b/src/commands/moderation/role.ts
@@ -6,14 +6,28 @@ import { Message, Role, GuildMember } from 'discord.js';
export default class RoleCommand extends BotCommand {
private roleWhitelist: Record<string, string[]> = {
'Partner': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
- 'Suggester': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator', 'Helper', 'Trial Helper', 'Contributor'],
+ 'Suggester': [
+ '*',
+ 'Admin Perms',
+ 'Sr. Moderator',
+ 'Moderator',
+ 'Helper',
+ 'Trial Helper',
+ 'Contributor'
+ ],
'Level Locked': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
'No Files': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
'No Reactions': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
'No Links': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
'No Bots': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
'No VC': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
- 'No Giveaways': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator', 'Helper'],
+ 'No Giveaways': [
+ '*',
+ 'Admin Perms',
+ 'Sr. Moderator',
+ 'Moderator',
+ 'Helper'
+ ],
'No Support': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
'Giveaway Donor': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
'Giveaway (200m)': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
@@ -44,7 +58,8 @@ export default class RoleCommand extends BotCommand {
type: [['add'], ['remove']],
prompt: {
start: 'Would you like to `add` or `remove` a role?',
- retry: '<:error:837123021016924261> Choose whether you would you like to `add` or `remove` a role.'
+ retry:
+ '<:error:837123021016924261> Choose whether you would you like to `add` or `remove` a role.'
}
};
let actionWord: string;
@@ -72,51 +87,97 @@ export default class RoleCommand extends BotCommand {
}
// eslint-disable-next-line require-await
- public async exec(message: Message, { action, user, role }: { action: 'add' | 'remove'; user: GuildMember; role: Role }): Promise<unknown> {
- if (!message.member.permissions.has('MANAGE_ROLES') && !this.client.ownerID.includes(message.author.id)) {
- const mappedRole = this.client.util.moulberryBushRoleMap.find(m => m.id === role.id);
+ public async exec(
+ message: Message,
+ {
+ action,
+ user,
+ role
+ }: { action: 'add' | 'remove'; user: GuildMember; role: Role }
+ ): Promise<unknown> {
+ if (
+ !message.member.permissions.has('MANAGE_ROLES') &&
+ !this.client.ownerID.includes(message.author.id)
+ ) {
+ const mappedRole = this.client.util.moulberryBushRoleMap.find(
+ (m) => m.id === role.id
+ );
if (!mappedRole || !this.roleWhitelist[mappedRole.name]) {
- return message.util.reply(`<:error:837123021016924261> <@&${role.id}> is not whitelisted, and you do not have manage roles permission.`, {
- allowedMentions: AllowedMentions.none()
- });
+ return message.util.reply(
+ `<:error:837123021016924261> <@&${role.id}> is not whitelisted, and you do not have manage roles permission.`,
+ {
+ allowedMentions: AllowedMentions.none()
+ }
+ );
}
- const allowedRoles = this.roleWhitelist[mappedRole.name].map(r => {
- return this.client.util.moulberryBushRoleMap.find(m => m.name === r).id;
+ const allowedRoles = this.roleWhitelist[mappedRole.name].map((r) => {
+ return this.client.util.moulberryBushRoleMap.find((m) => m.name === r)
+ .id;
});
- if (!message.member.roles.cache.some(role => allowedRoles.includes(role.id))) {
- return message.util.reply(`<:error:837123021016924261> <@&${role.id}> is whitelisted, but you do not have any of the roles required to manage it.`, {
- allowedMentions: AllowedMentions.none()
- });
+ if (
+ !message.member.roles.cache.some((role) =>
+ allowedRoles.includes(role.id)
+ )
+ ) {
+ return message.util.reply(
+ `<:error:837123021016924261> <@&${role.id}> is whitelisted, but you do not have any of the roles required to manage it.`,
+ {
+ allowedMentions: AllowedMentions.none()
+ }
+ );
}
}
if (!this.client.ownerID.includes(message.author.id)) {
if (role.comparePositionTo(message.member.roles.highest) >= 0) {
- return message.util.reply(`<:error:837123021016924261> <@&${role.id}> is higher or equal to your highest role.`, {
- allowedMentions: AllowedMentions.none()
- });
+ return message.util.reply(
+ `<:error:837123021016924261> <@&${role.id}> is higher or equal to your highest role.`,
+ {
+ allowedMentions: AllowedMentions.none()
+ }
+ );
}
if (role.comparePositionTo(message.guild.me.roles.highest) >= 0) {
- return message.util.reply(`<:error:837123021016924261> <@&${role.id}> is higher or equal to my highest role.`, {
- allowedMentions: AllowedMentions.none()
- });
+ return message.util.reply(
+ `<:error:837123021016924261> <@&${role.id}> is higher or equal to my highest role.`,
+ {
+ allowedMentions: AllowedMentions.none()
+ }
+ );
}
if (role.managed) {
- await message.util.reply(`<:error:837123021016924261> <@&${role.id}> is managed by an integration and cannot be managed.`, {
- allowedMentions: AllowedMentions.none()
- });
+ await message.util.reply(
+ `<:error:837123021016924261> <@&${role.id}> is managed by an integration and cannot be managed.`,
+ {
+ allowedMentions: AllowedMentions.none()
+ }
+ );
}
}
// no checks if the user has MANAGE_ROLES
if (action == 'remove') {
- const success = await user.roles.remove(role.id).catch(() => { });
+ const success = await user.roles.remove(role.id).catch(() => {});
if (success)
- return message.util.reply(`<:checkmark:837109864101707807> Successfully removed <@&${role.id}> from <@${user.id}>!`, { allowedMentions: AllowedMentions.none() });
- else return message.util.reply(`<:error:837123021016924261> Could not remove <@&${role.id}> from <@${user.id}>.`, { allowedMentions: AllowedMentions.none() });
+ return message.util.reply(
+ `<:checkmark:837109864101707807> Successfully removed <@&${role.id}> from <@${user.id}>!`,
+ { allowedMentions: AllowedMentions.none() }
+ );
+ else
+ return message.util.reply(
+ `<:error:837123021016924261> Could not remove <@&${role.id}> from <@${user.id}>.`,
+ { allowedMentions: AllowedMentions.none() }
+ );
} else if (action == 'add') {
- const success = await user.roles.add(role.id).catch(() => { });
+ const success = await user.roles.add(role.id).catch(() => {});
if (success) {
- return message.util.reply(`<:checkmark:837109864101707807> Successfully added <@&${role.id}> to <@${user.id}>!`, { allowedMentions: AllowedMentions.none() });
- } else return message.util.reply(`<:error:837123021016924261> Could not add <@&${role.id}> to <@${user.id}>.`, { allowedMentions: AllowedMentions.none() });
+ return message.util.reply(
+ `<:checkmark:837109864101707807> Successfully added <@&${role.id}> to <@${user.id}>!`,
+ { allowedMentions: AllowedMentions.none() }
+ );
+ } else
+ return message.util.reply(
+ `<:error:837123021016924261> Could not add <@&${role.id}> to <@${user.id}>.`,
+ { allowedMentions: AllowedMentions.none() }
+ );
}
}
-} \ No newline at end of file
+}