feat: add rank

This commit is contained in:
tramoc
2025-06-25 13:41:59 +07:00
parent 59f1e477e4
commit 9ebaac578a
4 changed files with 54 additions and 5 deletions
+19 -1
View File
@@ -17,4 +17,22 @@ async def currency_check(ctx: commands.Context):
await ctx.send("Có lỗi xảy ra khi tạo tài khoản currency")
return
await ctx.send(f"Thông tin tài khoản của bạn: {currency.balance}")
await ctx.send(f"Thông tin tài khoản của bạn: {currency.balance}")
@bot.command(name="rank", description="list rank")
async def list_rank(ctx: commands.Context):
"""Kiểm tra thông tin tài khoản của bạn"""
# Check if user is registered in database. If not, create a new one
balances = await currency_repo.get_all()
msg = "```\n"
msg += f"{'No.':<4} {'Name':<20} {'Win':>8}\n"
msg += "-" * 34 + "\n"
for i, b in enumerate(balances, start=1):
msg += f"{i:<4} {b.user_name:<20} {b.balance:>8}\n"
msg += "```"
await ctx.send(msg)
async def incr(user_id, user_name, amount):
await currency_repo.upsert_or_increment_balance(user_id, user_name, amount)