Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @bot.slash_command(name='top10', description='Show top 10 users')
- async def showtop10(ctx):
- top10 = {}
- c.execute("SELECT name FROM users")
- names = c.fetchall()
- for name in names:
- c.execute("SELECT winrate FROM users WHERE name=?", (name[0],))
- top10[name] = c.fetchone()[0]
- sort_top10 = dict(sorted(top10.items(), key=lambda x: x[1], reverse=True))
- for item in sort_top10:
- top1 = item
- break
- embed = disnake.Embed(
- title=f"Top 10 users",
- description=f"1) {top1[0]} score {sort_top10[top1]}",
- color=0x00ff00
- )
- del sort_top10[top1]
- count = 2
- for item in sort_top10:
- if count != 10:
- embed.add_field(name='', value=f"{count}) {item[0]} score {sort_top10[item]}", inline=False)
- count += 1
- await ctx.send(embed=embed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement