@commands.command()
async def lboard(self, ctx):
if (ctx.channel.id == bot_channel):
rankings = leveling.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"]
embed.add_field(name=f'{i}: {temp}', value=f'Total XP: {tempxp}', inline=False)
i += 1
if i == 5:
break
await ctx.send(embed=embed)
无法获取用户,它检索为 None。如果我添加 {temp.name} AttributeError: 'NoneType' object has no attribute 'name'
使用MongoDB