I am writing a bot discord. I need to create a top function that will display the top users on the server, and here is my code:
@bot.command()
async def top(ctx):
"""The top function returns a list of the top 10
members of the server by quantity xp.
"""
emb = discord.Embed(title="Топ 10 участников сервера:")
cursor.execute(f"""SELECT name, xp FROM users ORDER BY xp DESC LIMIT 10;""")
top_users = cursor.fetchall()
counter = 0
for row in top_users:
counter += 1
emb.add_field(
name=f"{counter}. {row[0]}",
value=f"Опыт: {row[1]}XP",
inline=False
)
await ctx.send(embed=emb)
But instead of data from different users, I get data from one user:
[('Poliak228#8755', 100), ('Poliak228#8755', 100), ('Poliak228#8755', 100), ('Poliak228#8755', 100), ('Poliak228#8755', 100), ('Poliak228#8755', 100), ('Poliak228#8755', 100), ('Poliak228#8755', 100), ('Poliak228#8755', 100), ('Poliak228#8755', 100)]
I checked and there were no identical records in the database. So why is this happening?