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