const Discord = require ( 'discord.js' ) ;
const XP = require ( '../../models/localxp' ) ;
module . exports = {
name : "leaderboard" ,
aliases : [ 'lb' , 'rank' ] ,
meta : {
category : 'Leveling' ,
description : "Find your place in the server's ranks and see the top-ranking members in the server." ,
syntax : '`leaderboard`' ,
extra : null ,
guildOnly : true
} ,
help : "Find your place in the server's ranks and see the top-ranking members in the server." ,
async execute ( message , msg , args , cmd , prefix , mention , client ) {
let cfmh = '<a:xp:870418598047387668>' ;
let gxp = await XP . findOne ( { gid : message . guild . id } ) ;
if ( ! gxp ) { return message . channel . send ( "Your server doesn't have XP enabled! If it's something you want to use, you can enable it with the `setupleveling` command" ) ; }
let xp = gxp . xp ;
let lvlp = Object . keys ( xp ) . sort ( ( a , b ) => { return xp [ a ] [ 1 ] - xp [ b ] [ 1 ] ; } ) . reverse ( ) ;
let lvl = lvlp . slice ( 0 , Object . keys ( xp ) . length >= 10 ? 10 : Object . keys ( xp ) . length ) ;
let lvls = ` ` ;
let i ; for ( i = 0 ; i < lvl . length ; i ++ ) { lvls += ` ${ i + 1 } . <@ ${ lvl [ i ] } > -> **Level ${ xp [ lvl [ i ] ] [ 1 ] } ** \n ` ; }
lvls += ` \n ${ cfmh } *You are ranked **# ${ lvlp . indexOf ( message . author . id ) + 1 } ** at Level ${ xp [ lvlp [ lvlp . indexOf ( message . author . id ) ] ] [ 1 ] } .* ` ;
return message . channel . send ( { embeds : [ new Discord . MessageEmbed ( )
. setTitle ( "Server Leaderboard" )
. setThumbnail ( message . guild . iconURL ( { size : 2048 , dynamic : true } ) )
. addField ( "Level" , lvls )
. setColor ( 'c375f0' )
. setFooter ( { text : "Natsuki | Stats may be up to 2 minutes out of sync" } )
. setTimestamp ( )
] } ) ;
/ * u = O b j e c t . k e y s ( t m . m e s s a g e s . m e m b e r s ) . s o r t ( ( a , b ) = > { r e t u r n t m . m e s s a g e s . m e m b e r s [ a ] - t m . m e s s a g e s . m e m b e r s [ b ] ; } ) . r e v e r s e ( ) . s l i c e ( 0 , O b j e c t . k e y s ( t m . m e s s a g e s . m e m b e r s ) . l e n g t h > = 5 ? 5 : O b j e c t . k e y s ( t m . m e s s a g e s . m e m b e r s ) . l e n g t h ) ;
us = ` ` ;
let i2 ; for ( i2 = 0 ; i2 < u . length ; i2 ++ ) { us += ` ${ i2 + 1 } . <@ ${ u [ i2 ] } > -> ** ${ tm . messages . members [ u [ i2 ] ] } Messages** \n ` ; } * /
//if (args[0] && ['mooners', 'currency', 'balance', 'bal'].includes(args[0].toLowerCase())) {}
//else {}
}
} ;