В базе данных записываются все наказания, я делаю команду чтобы смотреть свои наказания, но почему-то я сталкиваюсь с ошибкой:
Мой код:
@bot.slash_command(description="История наказаний")
async def history(ctx, member: discord.Member = None):
if member == None:
member = ctx.author
nakaz = nakazania.find({"member_id": member.id})
embed = discord.Embed(title="История наказаний", color = 0x2f3236)
for x in nakaz:
embed.add_field(name="Наказание:", value=f"{str(x['type'])}", inline=True)
embed.add_field(name="Причина:", value=f"`{str(x['reason'])}`", inline=True)
embed.add_field(name="Выдал:", value=f"<@{str(x['moder_id'])}>", inline=True)
await ctx.respond(embed=embed)
И получаю в консоли это:
TypeError: 'AsyncIOMotorCursor' object is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\dima1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\bot.py", line 992, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\dima1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\commands\core.py", line 358, in invoke
await injected(ctx)
File "C:\Users\dima1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\commands\core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: 'AsyncIOMotorCursor' object is not iterable