im currently trying to make a leaderboard command for discord, and im coming across an error when trying to get the data from my Mongo database.
@commands.command()
async def leaderboard(self, ctx):
rankings = levelling.find().sort("xp"), -1
i = 1
embed = discord.Embed(title="Rankings")
for x in rankings:
temp = ctx.guild.get_member(x["id"])
tempxp = x["xp"]
print(embed.add_field(name=f'{i}: {temp.name}', value=f'Total XP: {tempxp}', inline=False))
i += 1
if i == 11:
break
await ctx.send(embed=embed)
Command raised an exception: TypeError: index 'id' cannot be applied to Cursor instances