Mongodb 级别系统,用户名不可检索
无法获取用户,它检索为“无”。如果我添加{temp.name}AttributeError:'NoneType'对象没有属性'name'Mongodb 级别系统,用户名不可检索,mongodb,discord.py,Mongodb,Discord.py,无法获取用户,它检索为“无”。如果我添加{temp.name}AttributeError:'NoneType'对象没有属性'name' 使用Mongodb是否启用了意向。成员?是的,这解决了问题。谢谢@Łukaszkwiecinski @commands.command() async def lboard(self, ctx): if (ctx.channel.id == bot_channel): rankings = leveling
使用Mongodb是否启用了
意向。成员
?是的,这解决了问题。谢谢@Łukaszkwiecinski
@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)