diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/arguments/abbreviatedNumber.ts | 2 | ||||
-rw-r--r-- | src/commands/info/userInfo.ts | 4 | ||||
-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 | ||||
-rw-r--r-- | src/lib/extensions/discord.js/BushClientEvents.d.ts | 1 | ||||
-rw-r--r-- | src/listeners/message/autoThread.ts | 2 | ||||
-rw-r--r-- | src/listeners/message/level.ts | 3 |
8 files changed, 23 insertions, 4 deletions
diff --git a/src/arguments/abbreviatedNumber.ts b/src/arguments/abbreviatedNumber.ts index 99f6df7..e6791e6 100644 --- a/src/arguments/abbreviatedNumber.ts +++ b/src/arguments/abbreviatedNumber.ts @@ -5,7 +5,7 @@ export const abbreviatedNumberTypeCaster: BushArgumentTypeCaster = (_, phrase): if (!phrase) return null; const num = numeral(phrase?.toLowerCase()).value(); - if (!num || isNaN(num)) return null; + if (num === undefined || num === null || isNaN(num)) return null; return num; }; diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 9450e96..745dcf0 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -50,6 +50,8 @@ export default class UserInfoCommand extends BushCommand { const emojis = []; const superUsers = client.cache.global.superUsers; + await user.fetch(true); // gets banner info and accent color + const userEmbed: MessageEmbed = new MessageEmbed() .setTitle(user.tag) .setThumbnail( @@ -97,7 +99,7 @@ export default class UserInfoCommand extends BushCommand { `**Created: **${createdAt} (${createdAtDelta} ago)` ]; if (user.accentColor !== null) generalInfo.push(`**Accent Color:** ${user.hexAccentColor}`); - if (user.banner) generalInfo.push(`**Banner**: [link](${user.bannerURL({ dynamic: true, format: 'png' })})`); + if (user.banner) generalInfo.push(`**Banner**: [link](${user.bannerURL({ dynamic: true, format: 'png', size: 4096 })})`); const pronouns = await util.getPronounsOf(user); if (pronouns) generalInfo.push(`**Pronouns:** ${pronouns}`); 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, diff --git a/src/lib/extensions/discord.js/BushClientEvents.d.ts b/src/lib/extensions/discord.js/BushClientEvents.d.ts index 0406015..96dc4c5 100644 --- a/src/lib/extensions/discord.js/BushClientEvents.d.ts +++ b/src/lib/extensions/discord.js/BushClientEvents.d.ts @@ -230,6 +230,7 @@ export interface BushClientEvents extends ClientEvents { caseID: string, dmSuccess: boolean ]; + bushLevelUp: []; } type Setting = diff --git a/src/listeners/message/autoThread.ts b/src/listeners/message/autoThread.ts index ec8bfcb..04f6bcf 100644 --- a/src/listeners/message/autoThread.ts +++ b/src/listeners/message/autoThread.ts @@ -6,7 +6,7 @@ import { BushClientEvents } from '../../lib/extensions/discord.js/BushClientEven export default class autoThreadListener extends BushListener { public constructor() { super('autoThread', { - emitter: 'client', + emitter: 'commandHandler', event: 'messageInvalid', category: 'message' }); diff --git a/src/listeners/message/level.ts b/src/listeners/message/level.ts index 7004d52..aff8190 100644 --- a/src/listeners/message/level.ts +++ b/src/listeners/message/level.ts @@ -28,12 +28,15 @@ export default class LevelListener extends BushListener { xp: 0 } }); + const previousLevel = Level.convertXpToLevel(user.xp); const xpToGive = Level.genRandomizedXp(); user.xp = user.xp + xpToGive; const success = await user.save().catch((e) => { void util.handleError('level', e); return false; }); + const newLevel = Level.convertXpToLevel(user.xp); + if (previousLevel < newLevel) client.emit('bushLevelUp'); if (success) void client.logger.verbose(`level`, `Gave <<${xpToGive}>> XP to <<${message.author.tag}>> in <<${message.guild}>>.`); this.#levelCooldowns.add(`${message.guild.id}-${message.author.id}`); |