mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-19 00:54:13 +02:00
feat(arabot): add more information on ranks
This commit is contained in:
parent
f1453d5691
commit
528f592733
@ -20,7 +20,7 @@
|
||||
import { Args, Command, RegisterBehavior } from '@sapphire/framework';
|
||||
import type { User, Guild, Message } from 'discord.js';
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { getRank } from '#utils/database/xp';
|
||||
import { getRank, xpToNextLevel } from '#utils/database/xp';
|
||||
|
||||
export class RankCommand extends Command {
|
||||
public constructor(context: Command.Context, options: Command.Options) {
|
||||
@ -119,13 +119,16 @@ export class RankCommand extends Command {
|
||||
|
||||
const rank = await getRank(user.id);
|
||||
|
||||
const xpNextLevel = xpToNextLevel(rank.level, 0);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor('#00ff7d')
|
||||
.setAuthor({ name: `${member.displayName}'s Rank`, iconURL: `${user.displayAvatarURL()}` })
|
||||
.addFields(
|
||||
{ name: 'Rank', value: `${rank.rank}` },
|
||||
{ name: 'Level', value: `${rank.level}`, inline: true },
|
||||
{ name: 'XP', value: `${rank.xp}`, inline: true },
|
||||
{ name: 'Level', value: `${rank.level} (${rank.xpNextLevel}/${xpNextLevel} XP)`, inline: true },
|
||||
{ name: 'Total XP', value: `${rank.xp}`, inline: true },
|
||||
{ name: 'Total messages', value: `${rank.xpNextLevel}` },
|
||||
);
|
||||
|
||||
info.success = true;
|
||||
|
@ -2,7 +2,7 @@ import { container } from '@sapphire/framework';
|
||||
import { Time } from '@sapphire/time-utilities';
|
||||
import type { Snowflake } from 'discord.js';
|
||||
|
||||
function xpToNextLevel(level: number, xp: number) {
|
||||
export function xpToNextLevel(level: number, xp: number) {
|
||||
return 5 * (level * level) + (50 * level) + 100 - xp;
|
||||
}
|
||||
|
||||
@ -90,6 +90,7 @@ export async function getRank(userId: Snowflake) {
|
||||
rank: 0,
|
||||
level: 0,
|
||||
xp: 0,
|
||||
xpNextLevel: 0,
|
||||
};
|
||||
|
||||
if (user === null) {
|
||||
@ -109,6 +110,7 @@ export async function getRank(userId: Snowflake) {
|
||||
|
||||
info.level = user.level;
|
||||
info.xp = user.xp;
|
||||
info.xpNextLevel = user.xpForNextLevel;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user