28 lines
1.1 KiB
JavaScript
28 lines
1.1 KiB
JavaScript
|
const Revolt = require('revolt.js');
|
||
|
const { client, logger, config } = require('..');
|
||
|
const { levels, levelups } = require('../util/levels');
|
||
|
|
||
|
module.exports.meta = {
|
||
|
name: 'rank',
|
||
|
aliases: [ 'level', 'xp' ],
|
||
|
description: 'See your level and XP.'
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* @param { Revolt.Message } message
|
||
|
* @param { string[] } args
|
||
|
*/
|
||
|
module.exports.run = async (message, args) => new Promise(async (resolve, reject) => {
|
||
|
const channel = await client.channels.fetch(message.channel);
|
||
|
if (channel.channel_type != "Group") return client.channels.sendMessage(message.channel, `You can't earn XP in this channel.`);
|
||
|
let groupLevels = levels.get(message.channel);
|
||
|
const { xp, level, enabled } = (groupLevels?.[message.author] || {});
|
||
|
|
||
|
const response = `You are level **${level}** with **${xp}** XP. `
|
||
|
+ `XP required for level up: **${levelups.find(l => l > xp) - xp}**.\n`
|
||
|
+ (enabled === false ? '**Note: Leveling up is currently disabled in this channel.**' : '');
|
||
|
|
||
|
client.channels.sendMessage(message.channel, response)
|
||
|
.catch(console.warn);
|
||
|
});
|