mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-02 20:23:12 +00:00
Use EmbedBuilder in the rank command.
This commit is contained in:
parent
6b1722c253
commit
9d3524186a
3 changed files with 28 additions and 17 deletions
|
@ -52,7 +52,10 @@
|
|||
"ping_uptime": "I've been online since <t:{0}:R>.",
|
||||
"ping_footer": "Latency: {0}ms",
|
||||
|
||||
|
||||
"xp_progress": "Progress to next level",
|
||||
"xp_level": "Level {0}",
|
||||
"xp_server_rank": "Server Rank: #{0}",
|
||||
|
||||
"error_hierarchy": "❌ | **{0}** you can't perform this action because the target user is equal or higher than you in the role hierarchy.",
|
||||
"error_missing_permissions": "❌ | **{0}** you are missing permissions to run this command.",
|
||||
"error_mod_invoke_error": "❌ | **{0}** I couldn't perform this action, most likely because I don't have the required permissions.",
|
||||
|
@ -94,4 +97,4 @@
|
|||
"birthday_set": "✅ | **{0}** your birthday was set to **{1} {2}**.",
|
||||
"birthday_override": "✅ | **{0}** you set the birthday of user **{1}** to **{2} {3}**.",
|
||||
"uptime": "\uD83D\uDD52 | **{0}** I have been online for **{1}**"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ from modules.levels import level, leaderboard
|
|||
|
||||
|
||||
class Levels(commands.Cog):
|
||||
|
||||
def __init__(self, client):
|
||||
self.client = client
|
||||
|
||||
|
@ -14,20 +13,20 @@ class Levels(commands.Cog):
|
|||
aliases=["rank", "xp"],
|
||||
description="Displays your level and server rank.",
|
||||
help="Displays your level and server rank.",
|
||||
guild_only=True
|
||||
guild_only=True,
|
||||
)
|
||||
@commands.guild_only()
|
||||
@checks.allowed_in_channel()
|
||||
@commands.cooldown(1, 30, commands.BucketType.user)
|
||||
async def level_command(self, ctx):
|
||||
await level.cmd(ctx)
|
||||
await level.rank(ctx)
|
||||
|
||||
@bridge.bridge_command(
|
||||
name="leaderboard",
|
||||
aliases=["lb", "xplb"],
|
||||
description="See the Lumi leaderboards.",
|
||||
help="Shows three different leaderboards: levels, currency and daily streaks.",
|
||||
guild_only=True
|
||||
guild_only=True,
|
||||
)
|
||||
@commands.guild_only()
|
||||
@checks.allowed_in_channel()
|
||||
|
|
|
@ -1,18 +1,27 @@
|
|||
import discord
|
||||
|
||||
from discord import Embed
|
||||
from discord.ext import commands
|
||||
from lib.constants import CONST
|
||||
from lib.embed_builder import EmbedBuilder
|
||||
from services.xp_service import XpService
|
||||
|
||||
|
||||
async def cmd(ctx):
|
||||
xp_data = XpService(ctx.author.id, ctx.guild.id)
|
||||
rank = xp_data.calculate_rank()
|
||||
needed_xp_for_next_level = XpService.xp_needed_for_next_level(xp_data.level)
|
||||
async def rank(ctx: commands.Context) -> None:
|
||||
xp_data: XpService = XpService(ctx.author.id, ctx.guild.id)
|
||||
|
||||
embed = discord.Embed(color=0xadcca6, title=f"Level {xp_data.level}")
|
||||
embed.add_field(name=f"Progress to next level",
|
||||
value=XpService.generate_progress_bar(xp_data.xp, needed_xp_for_next_level), inline=False)
|
||||
rank: str = str(xp_data.calculate_rank())
|
||||
needed_xp_for_next_level: int = XpService.xp_needed_for_next_level(xp_data.level)
|
||||
|
||||
embed.set_footer(text=f"Server Rank: #{rank}")
|
||||
embed.set_thumbnail(url=ctx.author.display_avatar)
|
||||
embed: Embed = EmbedBuilder.create_success_embed(
|
||||
ctx=ctx,
|
||||
title=CONST.STRINGS["xp_level"].format(xp_data.level),
|
||||
footer_text=CONST.STRINGS["xp_server_rank"].format(rank or "NaN"),
|
||||
show_name=False,
|
||||
thumbnail_url=ctx.author.display_avatar.url,
|
||||
)
|
||||
embed.add_field(
|
||||
name=CONST.STRINGS["xp_progress"],
|
||||
value=XpService.generate_progress_bar(xp_data.xp, needed_xp_for_next_level),
|
||||
inline=False,
|
||||
)
|
||||
|
||||
await ctx.respond(embed=embed, content=ctx.author.mention)
|
||||
|
|
Loading…
Reference in a new issue