This command tell the message author what level they are and how much XP they have.
const xpService = require('../services/xpService')
//Help Text enables the bot to show this command as part of !fsc help command
const helpText = `
Command: xp
Description: The 'xp' command can be used to fetch the users current Xp.
Subcommands: none
Examples:
- Input: !fsc xp
Output: @brianmmdev You are level 15 with 1445xp
`
module.exports = {
command: 'xp',
isEnabled: true,
helpText,
fn: async msg => {
//Get the message authors XP from the database using the xpService
let currentXp = xpService.getXpForUserId(msg.author.id)
if(currentXp) {
//Calculate the message author's level based on XP
let currentLevel = xpService.getLevelForUserId(msg.author.id)
//Reply to message author with their current level and XP
msg.reply(`You are level ${currentLevel} with ${currentXp}xp`)
} else {
msg.reply("I cant find you :(")
}
}
}