MrAugu / discord-xp

A lightweight and easy to use economy framework for discord bots, uses MongoDB.
MIT License
117 stars 31 forks source link

Help With Rank #40

Closed ArcheryLuna closed 3 years ago

ArcheryLuna commented 3 years ago

How do I add a working rank for my rank command

asusplayer commented 3 years ago

Hi there is an example in the readme. This works with canvacord. The rank of the user is user.position and you need to add the true statement to the Levels.fetch command. `const canvacord = require('canvacord');

const target = message.mentions.users.first() || message.author; // Grab the target.

const user = await Levels.fetch(target.id, message.guild.id, true); // Selects the target from the database.

const rank = new canvacord.Rank() // Build the Rank Card
    .setAvatar(target.displayAvatarURL({format: 'png', size: 512}))
    .setCurrentXP(user.xp) // Current User Xp
    .setRequiredXP(Levels.xpFor(user.level + 1)) // We calculate the required Xp for the next level
    .setRank(user.position) // Position of the user on the leaderboard
    .setLevel(user.level) // Current Level of the user
    .setStatus(target.presence.status)
    .setProgressBar("#FFFFFF")
    .setUsername(target.username)
    .setDiscriminator(target.discriminator);

rank.build()
    .then(data => {
    const attachment = new Discord.MessageAttachment(data, "RankCard.png");
    message.channel.send(attachment);
});`
MrAugu commented 3 years ago

Closing issues due to no further activity after being answered.