Ошибка с разбаном :c nextcord
Код
@commands.command()
@commands.has_permissions(ban_members=True)
async def unban(self, ctx, member, reason=None):
banned_users = await ctx.guild.bans()
channel = self.bot.get_channel(config.log_mes_channel_id)
member_name, member_discriminator = member.split("#")
for ban_entry in banned_users:
user = ban_entry.user
if (user.name, user.discriminator) == (member_name, member_discriminator):
await ctx.guild.unban(user)
embed = nextcord.Embed(title=f"Пользователя {user} разбанили", color=0xfac400)
embed.set_author(name=f"{ctx.author}", icon_url=f"{ctx.author.avatar_url}")
embed.set_footer(text=f"Silence. • {time.asctime()}")
await channel.send(embed=embed)
await ctx.channel.purge(limit=1)
await ctx.send(embed=embed, delete_after=30)
return
Ошибка
Ignoring exception in command unban:
Traceback (most recent call last):
File "C:\Users\Krosrs\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\ext\commands\core.py", line 165, in wrapped
ret = await coro(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\Krosrs\Desktop\SOLO\cogs\moder.py", line 72, in unban
banned_users = await ctx.guild.bans()
^^^^^^^^^^^^^^^^^^^^^^
TypeError: object BanIterator can't be used in 'await' expression
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Krosrs\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\ext\commands\bot.py", line 1381, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Krosrs\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\ext\commands\core.py", line 948, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Krosrs\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\ext\commands\core.py", line 174, in wrapped
raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object BanIterator can't be used in 'await' expression
Источник: Stack Overflow на русском