diff options
Diffstat (limited to 'src/commands/leveling')
-rw-r--r-- | src/commands/leveling/level.ts | 1 | ||||
-rw-r--r-- | src/commands/leveling/setLevel.ts | 8 | ||||
-rw-r--r-- | src/commands/leveling/setXp.ts | 6 |
3 files changed, 14 insertions, 1 deletions
diff --git a/src/commands/leveling/level.ts b/src/commands/leveling/level.ts index 223a590..f14c005 100644 --- a/src/commands/leveling/level.ts +++ b/src/commands/leveling/level.ts @@ -60,6 +60,7 @@ export default class LevelCommand extends BushCommand { const currentLevelXP = Level.convertLevelToXp(userLevel); const currentLevelXPProgress = userLevelRow.xp - currentLevelXP; const xpForNextLevel = Level.convertLevelToXp(userLevelRow.level + 1) - currentLevelXP; + await user.fetch(true); // get accent color const white = '#FFFFFF', gray = '#23272A', highlight = user.hexAccentColor ?? '#5865F2'; diff --git a/src/commands/leveling/setLevel.ts b/src/commands/leveling/setLevel.ts index f312356..2cd9099 100644 --- a/src/commands/leveling/setLevel.ts +++ b/src/commands/leveling/setLevel.ts @@ -59,6 +59,11 @@ export default class SetLevelCommand extends BushCommand { return await message.util.reply(`${util.emojis.error} This command is Bestower proof.`); if (!user.id) throw new Error('user.id is null'); + if (isNaN(level)) + return await message.util.reply(`${util.emojis.error} Provide a valid number to set the user's level to.`); + if (level > 6553 || level < 0) + return await message.util.reply(`${util.emojis.error} You cannot set a level higher than \`6553\`.`); + const [levelEntry] = await Level.findOrBuild({ where: { user: user.id, @@ -66,7 +71,8 @@ export default class SetLevelCommand extends BushCommand { }, defaults: { user: user.id, - guild: message.guild.id + guild: message.guild.id, + xp: 0 } }); await levelEntry.update({ xp: Level.convertLevelToXp(level), user: user.id, guild: message.guild.id }); diff --git a/src/commands/leveling/setXp.ts b/src/commands/leveling/setXp.ts index fdfd74f..8be3a10 100644 --- a/src/commands/leveling/setXp.ts +++ b/src/commands/leveling/setXp.ts @@ -62,6 +62,12 @@ export default class SetXpCommand extends BushCommand { return await message.util.reply(`${util.emojis.error} This command is Bestower proof.`); if (!user.id) throw new Error('user.id is null'); + if (isNaN(xp)) return await message.util.reply(`${util.emojis.error} Provide a valid number.`); + if (xp > 2147483647 || xp < 0) + return await message.util.reply( + `${util.emojis.error} Provide an positive integer under \`2147483647\` to set the user's xp to.` + ); + const [levelEntry] = await Level.findOrBuild({ where: { user: user.id, |