You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Luno/commands/leveling/stats.js

44 lines
2.4 KiB

4 years ago
const Discord = require('discord.js');
const LXP = require('../../models/localxp');
3 years ago
const Monners = require('../../models/monners');
4 years ago
module.exports = {
name: "stats",
3 years ago
aliases: ['level', 'xp', 'lvl', '$', 'bal', 'balance', 'mooners', 'muni', 'currency'],
4 years ago
meta: {
category: 'Leveling',
description: "View your rank in the server",
syntax: '`stats [@user|userID]`',
extra: null,
guildOnly: true
},
help: new Discord.MessageEmbed()
.setTitle("Help -> Stats")
3 years ago
.setDescription("View your level, XP, and Mooners in the server, or someone else's")
4 years ago
.addField("Syntax", "`stats [@user|userID]`"),
async execute(message, msg, args, cmd, prefix, mention, client) {
if (!client.misc.cache.lxp.enabled.includes(message.guild.id)) {return message.channel.send("Your server doesn't have leveling enabled!");}
let u = args[0] ? (message.mentions.members.first() || message.guild.members.cache.get(args[0])) : message.member;
if (!u) {return message.channel.send("I can't find that user!");}
let xp;
if (!client.misc.cache.lxp.xp[message.guild.id] || !client.misc.cache.lxp.xp[message.guild.id][u.id]) {
let txp = await LXP.findOne({gid: message.guild.id});
if (!txp) {return message.channel.send("Your server doesn't have leveling enabled!");}
if (!txp.xp[u.id]) {return message.channel.send(`${u.id === message.author.id ? "You" : "That user"} doesn't have any leveling info available!`);}
xp = {xp: txp.xp[u.id][0], level: txp.xp[u.id][1]};
} else {xp = client.misc.cache.lxp.xp[message.guild.id][u.id];}
3 years ago
let tmoon = client.misc.cache.monners[u.id] ? {currency: client.misc.cache.monners[u.id]} : await Monners.findOne({uid: u.id});
4 years ago
return message.channel.send(new Discord.MessageEmbed()
.setTitle(`${u.displayName}${u.displayName.toLowerCase().endsWith('s') ? "'" : "'s"} Stats`)
.setDescription("Local leveling stats")
.addField("Level", xp.level, true)
4 years ago
.addField("XP", `**${xp.xp}** of **${Math.ceil(100 + (((xp.level / 2.85) ** 2.2) * 2.5))}** needed to level up`, true)
3 years ago
.addField("Mooners", `<a:CF_mooners:868652679717589012> ${tmoon ? tmoon.currency : 0}`)
4 years ago
.setThumbnail(client.users.cache.get(u.id).avatarURL({size: 2048}))
.setColor("328ba8")
.setFooter("Luno")
.setTimestamp()
)
}
};