aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moulberry-bush/level.ts
diff options
context:
space:
mode:
authorTymanWasTaken <32660892+tymanwastaken@users.noreply.github.com>2021-05-12 02:24:20 -0600
committerTymanWasTaken <32660892+tymanwastaken@users.noreply.github.com>2021-05-12 02:24:20 -0600
commit6cae6bf5faf97b7be15ef282f8d86c6db349036b (patch)
treefcb4b9f178c1c7c497fd083429749a1bef9dc3e3 /src/commands/moulberry-bush/level.ts
parentca380193453a1bfa12d3da38bb7a0ea96d8577b9 (diff)
downloadtanzanite-6cae6bf5faf97b7be15ef282f8d86c6db349036b.tar.gz
tanzanite-6cae6bf5faf97b7be15ef282f8d86c6db349036b.tar.bz2
tanzanite-6cae6bf5faf97b7be15ef282f8d86c6db349036b.zip
add actual level calculation and level command, no actual leveling yet though
Diffstat (limited to 'src/commands/moulberry-bush/level.ts')
-rw-r--r--src/commands/moulberry-bush/level.ts46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/commands/moulberry-bush/level.ts b/src/commands/moulberry-bush/level.ts
new file mode 100644
index 0000000..6dda91a
--- /dev/null
+++ b/src/commands/moulberry-bush/level.ts
@@ -0,0 +1,46 @@
+import { Message } from 'discord.js';
+import { User } from 'discord.js';
+import { BotCommand } from '../../lib/extensions/BotCommand';
+import { Level } from '../../lib/models';
+
+export default class LevelCommand extends BotCommand {
+ constructor() {
+ super('level', {
+ aliases: ['level', 'rank'],
+ description: {
+ content: 'Shows the level of a user',
+ usage: 'level [user]',
+ examples: ['level', 'level @Tyman']
+ },
+ args: [
+ {
+ id: 'user',
+ type: 'user',
+ prompt: {
+ start: 'What user would you like to see the level of?',
+ retry:
+ 'Invalid user. What user would you like to see the level of?',
+ optional: true
+ }
+ }
+ ]
+ });
+ }
+
+ async exec(message: Message, { user }: { user?: User }): Promise<void> {
+ const userLevelRow = await Level.findByPk(
+ user ? user.id : message.author.id
+ );
+ if (userLevelRow) {
+ await message.reply(
+ `${user ? `${user.tag}'s` : 'Your'} level is ${userLevelRow.level} (${
+ userLevelRow.xp
+ } XP)`
+ );
+ } else {
+ await message.reply(
+ `${user ? `${user.tag} does` : 'You do'} not have a level yet!`
+ );
+ }
+ }
+}