diff options
author | TymanWasTaken <32660892+tymanwastaken@users.noreply.github.com> | 2021-05-12 02:41:34 -0600 |
---|---|---|
committer | TymanWasTaken <32660892+tymanwastaken@users.noreply.github.com> | 2021-05-12 02:41:34 -0600 |
commit | 8d6ebd83b16a465b11edfeb43f6a5e58da0076e8 (patch) | |
tree | 47be45c7cfad070eb3b07ecc64d26f2d3da83f87 /src/commands/moulberry-bush | |
parent | 6cae6bf5faf97b7be15ef282f8d86c6db349036b (diff) | |
download | tanzanite-8d6ebd83b16a465b11edfeb43f6a5e58da0076e8.tar.gz tanzanite-8d6ebd83b16a465b11edfeb43f6a5e58da0076e8.tar.bz2 tanzanite-8d6ebd83b16a465b11edfeb43f6a5e58da0076e8.zip |
add level slash command
Diffstat (limited to 'src/commands/moulberry-bush')
-rw-r--r-- | src/commands/moulberry-bush/level.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/commands/moulberry-bush/level.ts b/src/commands/moulberry-bush/level.ts index 6dda91a..a70ebf1 100644 --- a/src/commands/moulberry-bush/level.ts +++ b/src/commands/moulberry-bush/level.ts @@ -1,4 +1,5 @@ import { Message } from 'discord.js'; +import { CommandInteraction } from 'discord.js'; import { User } from 'discord.js'; import { BotCommand } from '../../lib/extensions/BotCommand'; import { Level } from '../../lib/models'; @@ -23,6 +24,14 @@ export default class LevelCommand extends BotCommand { optional: true } } + ], + slashCommandOptions: [ + { + type: 6, + name: 'user', + description: 'The user to get the level of', + required: false + } ] }); } @@ -43,4 +52,22 @@ export default class LevelCommand extends BotCommand { ); } } + async execSlash(message: CommandInteraction): Promise<void> { + const user = + message.options.find((o) => o.name === 'user')?.user || message.user; + const userLevelRow = await Level.findByPk(user.id); + if (userLevelRow) { + await message.reply( + `${user.id !== message.user.id ? `${user.tag}'s` : 'Your'} level is ${ + userLevelRow.level + } (${userLevelRow.xp} XP)` + ); + } else { + await message.reply( + `${ + user.id !== message.user.id ? `${user.tag} does` : 'You do' + } not have a level yet!` + ); + } + } } |