Skip to content

Commit

Permalink
Add rank image & remove global rank
Browse files Browse the repository at this point in the history
  • Loading branch information
DonovanDMC committed Jun 3, 2024
1 parent 82de47e commit 677a844
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 5 deletions.
204 changes: 203 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"cheweyapi": "^2.0.4",
"chunk": "^0.0.3",
"debug": "^4.3.5",
"discord-arts": "^0.6.1",
"discord-command-parser": "^1.5.3",
"e621": "^2.2.6",
"eslint-plugin-unicorn": "^53.0.0",
Expand Down
24 changes: 20 additions & 4 deletions src/interactions/applicationCommands/misc/rank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Leveling from "../../../util/Leveling.js";
import Util from "../../../util/Util.js";
import UserConfig from "../../../db/Models/UserConfig.js";
import { ApplicationCommandOptionTypes } from "oceanic.js";
import { profileImage } from "discord-arts";

export default new Command(import.meta.url, "rank")
.setDescription("Get a user's rank")
Expand All @@ -16,18 +17,33 @@ export default new Command(import.meta.url, "rank")
.setValidLocation(ValidLocation.GUILD)
.setExecutor(async function(interaction, { user }) {
const { rank, total } = await Leveling.getUserRank(user.id, interaction.guildID);
const { rank: globalRank, total: globalTotal } = await Leveling.getUserRank(user.id, null);
const xp = await UserConfig.getXP(user.id, interaction.guildID);
const { level, leftover, needed } = Leveling.calcLevel(xp);
const img = await profileImage("242843345402069002", {
badgesFrame: true,
rankData: {
currentXp: leftover,
requiredXp: leftover + needed,
rank,
level,
barColor: "#A7A4AA",
autoColorRank: true
}
});
return interaction.reply({
embeds: Util.makeEmbed(true, interaction.user)
.setTitle(`Rank Info For ${user.tag}`)
.setDescription([
`Level: **${level}** (${leftover}/${leftover + needed})`,
`EXP: ${xp.toLocaleString()}`,
`Local Rank: **${rank}**/**${total}**`,
`Global Rank: **${globalRank}**/**${globalTotal}**`
`Local Rank: **${rank}**/**${total}**`
])
.toJSON(true)
.toJSON(true),
files: [
{
name: "rank.png",
contents: img
}
]
});
});

0 comments on commit 677a844

Please sign in to comment.