diff options
Diffstat (limited to 'src/commands/leveling/levelRoles.ts')
-rw-r--r-- | src/commands/leveling/levelRoles.ts | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/commands/leveling/levelRoles.ts b/src/commands/leveling/levelRoles.ts index afa4ab6..470cf58 100644 --- a/src/commands/leveling/levelRoles.ts +++ b/src/commands/leveling/levelRoles.ts @@ -1,4 +1,13 @@ -import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; +import { + AllowedMentions, + BushCommand, + clientSendAndPermCheck, + emojis, + type ArgType, + type CommandMessage, + type OptArgType, + type SlashMessage +} from '#lib'; import assert from 'assert'; import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; @@ -33,7 +42,7 @@ export default class LevelRolesCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles]), + clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles]), userPermissions: [PermissionFlagsBits.ManageGuild, PermissionFlagsBits.ManageRoles] }); } @@ -46,20 +55,20 @@ export default class LevelRolesCommand extends BushCommand { assert(message.member); if (!(await message.guild.hasFeature('leveling'))) { - return await reply(`${util.emojis.error} This command can only be run in servers with the leveling feature enabled.`); + return await reply(`${emojis.error} This command can only be run in servers with the leveling feature enabled.`); } - if (args.level < 1) return await reply(`${util.emojis.error} You cannot set a level role less than **1**.`); + if (args.level < 1) return await reply(`${emojis.error} You cannot set a level role less than **1**.`); if (args.role) { if (args.role.managed) - return await reply(`${util.emojis.error} You cannot set <@${args.role.id}> as a level role since it is managed.`); + return await reply(`${emojis.error} You cannot set <@${args.role.id}> as a level role since it is managed.`); else if (args.role.id === message.guild.id) - return await reply(`${util.emojis.error} You cannot set the @everyone role as a level role.`); + return await reply(`${emojis.error} You cannot set the @everyone role as a level role.`); else if (args.role.comparePositionTo(message.member.roles.highest) >= 0) - return await reply(`${util.emojis.error} <@${args.role.id}> is higher or equal to your highest role.`); + return await reply(`${emojis.error} <@${args.role.id}> is higher or equal to your highest role.`); else if (args.role.comparePositionTo(message.guild.members.me!.roles.highest) >= 0) - return await reply(`${util.emojis.error} <@${args.role.id}> is higher or equal to my highest role.`); + return await reply(`${emojis.error} <@${args.role.id}> is higher or equal to my highest role.`); } const oldRoles = Object.freeze(await message.guild.getSetting('levelRoles')); @@ -74,17 +83,17 @@ export default class LevelRolesCommand extends BushCommand { const success = await message.guild.setSetting('levelRoles', newRoles, message.member).catch(() => false); - if (!success) return await reply(`${util.emojis.error} An error occurred while setting the level roles.`); + if (!success) return await reply(`${emojis.error} An error occurred while setting the level roles.`); if (!oldRoles[args.level] && newRoles[args.level]) { - return await reply(`${util.emojis.success} The level role for **${args.level}** is now <@&${newRoles[args.level]}>.`); + return await reply(`${emojis.success} The level role for **${args.level}** is now <@&${newRoles[args.level]}>.`); } else if (oldRoles[args.level] && !newRoles[args.level]) { return await reply( - `${util.emojis.success} The level role for **${args.level}** was <@&${oldRoles[args.level]}> but is now disabled.` + `${emojis.success} The level role for **${args.level}** was <@&${oldRoles[args.level]}> but is now disabled.` ); } else if (oldRoles[args.level] && newRoles[args.level]) { return await reply( - `${util.emojis.success} The level role for **${args.level}** has been updated from <@&${oldRoles[args.level]}> to <@&${ + `${emojis.success} The level role for **${args.level}** has been updated from <@&${oldRoles[args.level]}> to <@&${ newRoles[args.level] }>.` ); |