2020-11-28 16:38:23 +00:00
|
|
|
const Discord = require('discord.js');
|
|
|
|
|
|
|
|
module.exports.meta = {
|
|
|
|
name: 'top',
|
|
|
|
aliases: ['leaderboard'],
|
|
|
|
staffOnly: false
|
|
|
|
}
|
|
|
|
|
|
|
|
const karma = require('../util/karma').karma;
|
|
|
|
const coins = require('../util/karma').coins;
|
|
|
|
|
2020-12-27 12:59:54 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {Discord.Message} message
|
|
|
|
* @param {Array<string>} args
|
|
|
|
*/
|
2020-11-28 16:38:23 +00:00
|
|
|
module.exports.run = async (message, args) => {
|
2020-12-27 12:59:54 +00:00
|
|
|
const karmaID = '733339045463064607';
|
|
|
|
const karmaEmote = message.guild.emojis.cache.get(karmaID).toString();
|
2020-11-28 16:38:23 +00:00
|
|
|
let karmaboard = [];
|
|
|
|
karma.keyArray().forEach(uid => {
|
|
|
|
karmaboard.push({id: uid, karma: karma.get(uid)});
|
|
|
|
});
|
|
|
|
|
|
|
|
karmaboard.sort((a, b) => a.karma - b.karma);
|
|
|
|
karmaboard.reverse();
|
|
|
|
|
|
|
|
let embed = new Discord.MessageEmbed()
|
|
|
|
.setTitle('Karma Leaderboard')
|
2020-12-27 12:59:54 +00:00
|
|
|
.setDescription(karmaEmote + ' Karma leaderboard - Top 12 for ' + message.guild.name);
|
2020-11-28 16:38:23 +00:00
|
|
|
|
|
|
|
for (let x=0; x < 12; x += 1) {
|
|
|
|
if (!karmaboard[x]) break;
|
|
|
|
let u = message.guild.members.cache.get(karmaboard[x].id);
|
2020-12-27 12:59:54 +00:00
|
|
|
if (!u) embed.addField(`${x+1}. [Unknown user]`, `${karmaEmote} ${karmaboard[x].karma} Karma`, true); else embed.addField(`${x+1}. ${u.user.username}#${u.user.discriminator} ${u.user.bot ? '(Bot)' : ''}`, `${karmaEmote} ${karmaboard[x].karma} Karma`, true);
|
2020-11-28 16:38:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message.channel.send(embed);
|
|
|
|
}
|