Alright so I created a leaderboard and I made it to display the players with the most wins. For some reason when there is multiple people with the same amount of wins it just displays one persons name over and over again.
Here is the main.py
@client.command()
@commands.cooldown(1,5, BucketType.user)
async def leaderboard(ctx, x = 1):
users = await get_win_data()
leader_board = {}
total = []
for user in users:
name = int(user)
total_amount = users[user]["Wins"]
leader_board[total_amount] = name
total.append(total_amount)
total = sorted(total, reverse=True)
demb = discord.Embed(title = f"Top winners!", descripition = "These are the people with the most amount of wins.", color=discord.Color.red())
index = 1
for wins in total:
id_ = leader_board[wins]
member = client.get_user(id_)
name = member.name
demb.add_field(name = f"{index}. {name}", value=f"Won **{wins}** times", inline=False)
if index == x:
break
else:
index += 1
await ctx.send(embed = demb)
Here is the json
{
"427924596164132864": {
"Wins": 1
},
"441638109587832842": {
"Wins": 1
},
"479527342860140544": {
"Wins": 1
}
}
I was wondering if there was any way to make it display all 3 players even though they're all at the same win count.