Skip to content

Commit

Permalink
Add user level XP targets in /rank command
Browse files Browse the repository at this point in the history
This will provide a little bit more info on how much more XP is required for the user to level up, from their current level.
  • Loading branch information
notsniped committed Apr 19, 2024
1 parent 83aaf2c commit 7e30489
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cogs/levelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ def __init__(self, bot):
async def rank(self, ctx: ApplicationContext, user: discord.User=None):
if user is None: user = ctx.author
try:
xpreq = int()
for level in range(levelling.get_level(ctx.author.id)):
xpreq += 50
if xpreq >= 5000: break
localembed = discord.Embed(title=f"{user.display_name}'s rank", color=color)
localembed.add_field(name="Level", value=levelling.get_level(user.id))
localembed.add_field(name="XP", value=levelling.get_xp(user.id))
localembed.add_field(name="XP", value=f"{levelling.get_xp(user.id)}/{xpreq} gained")
localembed.set_footer(text="Keep chatting to earn levels!")
await ctx.respond(embed = localembed)
except KeyError: return await ctx.respond("Looks like that user isn't indexed yet. Try again later.", ephemeral=True)
Expand Down

0 comments on commit 7e30489

Please sign in to comment.