import type ColumnTypes from '../../typings/ColumnTypes' ; import type { GuildMessage } from '../../Constants' ; import type { HelpObj } from '../../structures/commandhandler' ; import { MessageEmbed } from 'discord.js' ; import type { PermissionString } from 'discord.js' ; import type ReknownClient from '../../structures/client' ; import { tables } from '../../Constants' ; export async function run ( client , message , args ) { const rows = await client . sql < ColumnTypes [ 'LEVEL' ] > `SELECT * FROM ${ client . sql ( tables . LEVELS ) } WHERE guildid = ${ message . guild . id } ORDER BY points DESC` ; if ( rows . count === 0 ) return message . reply ( 'There was no levelling data found for this server.' ) ; const users = rows . map ( async ( r , i ) => { const user = await client . users . fetch ( r . userid ) ; let place ; if ( i === 0 ) place = ':first_place:' ; else if ( i === 1 ) place = ':second_place:' ; else if ( i === 2 ) place = ':third_place:' ; else place = ':ribbon:' ; return `${ place } ${ client . escMD ( user . tag ) } | Level: **${ r . level }** | XP: **${ r . points }**` ; } ) ; const desc = ( await Promise . all ( users ) ) . join ( '\n' ) ; const embed = new MessageEmbed ( ) . setColor ( client . config . embedColor ) . setDescription ( desc ) . setFooter ( `Requested by ${ message . author . tag }` , message . author . displayAvatarURL ( ) ) . setTimestamp ( ) . setTitle ( `Levelling Leaderboard for ${ message . guild . name }` ) ; message . channel . send ( embed ) ; } export const help = { aliases : [ 'toplevel' ] , category : 'Levelling' , desc : 'Shows the levelling leaderboard for the current server.' , togglable : true , usage : 'leaderboard' } ; export const memberPerms = [ ] ; export const permissions = [ 'EMBED_LINKS' ] ;