@commands.slash_command()
async def level(self, ctx, member: disnake.Member = None):
if member is None:
member = ctx.author
async with self.bot.db.cursor() as cursor:
await cursor.execute("SELECT xp FROM levels WHERE user = ? AND guild = ?", (member.id, ctx.guild.id,))
xp = await cursor.fetchone()
await cursor.execute("SELECT level FROM levels WHERE user = ? AND guild = ?", (member.id, ctx.guild.id,))
level = await cursor.fetchone()
if not xp or not level:
await cursor.execute("INSERT INTO levels (level, xp, user, guild) VALUES (?, ?, ?, ?)", (0, 0, member.id, ctx.guild.id,))
try:
xp = xp[0]
level = level[0]
except TypeError:
xp = 0
level = 0
name = member.name
tag = member.discriminator
card_settings = Settings(
background= "https://i.pinimg.com/originals/e8/6c/e1/e86ce1bdea500d72d8e495b37488838c.jpg",
text_color="white",
bar_color="#5865f2"
)
await ctx.response.defer()
a = RankCard(
settings=card_settings,
avatar=member.display_avatar.url,
level= level,
current_exp= xp,
max_exp=100,
username=f"{name}#{tag}"
)
image = await a.card1()
await ctx.edit_original_message(file=disnake.File(image, filename="rank.png"))
<img src="https://habrastorage.org/webt/64/04/9e/64049ea0cfc23777095268.jpeg" alt="image"/>
<img src="https://habrastorage.org/webt/64/04/9e/64049eae949ff201036142.jpeg" alt="image"/>