如何使用 replit db 使用 discord.py 制作排行榜命令

时间:2021-05-11 17:16:23

标签: python discord discord.py

我不知道这段代码有什么问题。我没有成功,我从 Github 上得到的,它总是输出同一个用户。我在 Python Discord 中找了人帮忙。他们无法对其进行测试,但最终得到了:

@bot.command(name="leaderboard", brief="richest users list", description="list all of the richest users from richest to poorest.")
async def leaderboard(ctx):
    users = db.keys()
    total = {}

    for user in users:
      total[user] += db[f"{user}"]
    
    total = sorted(total.items(), key=lambda x: x[1], reverse=True)
    await ctx.send("the top 5 richest users are...")

    for count, amt in enumerate(total, start=1):
        await ctx.send(f"{count}. {amt} {total[amt]}")

我不知道发生了什么,也不知道为什么它没有输出任何东西。请帮忙。

0 个答案:

没有答案