Advertisement
yasi04

Untitled

Apr 3rd, 2024
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. @bot.slash_command(name='top10', description='Show top 10 users')
  2. async def showtop10(ctx):
  3. top10 = {}
  4. c.execute("SELECT name FROM users")
  5. names = c.fetchall()
  6. for name in names:
  7. c.execute("SELECT winrate FROM users WHERE name=?", (name[0],))
  8. top10[name] = c.fetchone()[0]
  9. sort_top10 = dict(sorted(top10.items(), key=lambda x: x[1], reverse=True))
  10. for item in sort_top10:
  11. top1 = item
  12. break
  13. embed = disnake.Embed(
  14. title=f"Top 10 users",
  15. description=f"1) {top1[0]} score {sort_top10[top1]}",
  16. color=0x00ff00
  17. )
  18. del sort_top10[top1]
  19. count = 2
  20. for item in sort_top10:
  21. if count != 10:
  22. embed.add_field(name='', value=f"{count}) {item[0]} score {sort_top10[item]}", inline=False)
  23. count += 1
  24. await ctx.send(embed=embed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement