У меня не работает разбан после бана с ошибкой:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\user\Desktop\RIMOбот\RIMO.py", line 152, in ban
await unban(member)
File "C:\Users\user\Desktop\RIMOбот\RIMO.py", line 117, in unban
for ban in users:
TypeError: 'async_generator' object is not iterable
код:
@client.command(pass_context=True)
@commands.has_permissions( administrator=True )
async def ban( ctx, member: discord.Member = None, time = None, *, reason: str = None ):
async def unban(member):
users = ctx.guild.bans()
for ban in users:
ban = ban.user
await ctx.guild.unban(ban)
if member:
if time:
time_letter = time[-1:]
time_numbers = int(time[:-1])
def t(time_letter):
if time_letter == 's':
return 1
if time_letter == 'm':
return 60
if time_letter == 'h':
return 60*60
if time_letter == 'd':
return 60*60*24
if reason:
await member.ban(reason=reason)
await ctx.send(embed=discord.Embed(description=f'Пользователь {member.mention} был забанен \nВремя: {time} \nПричина: {reason}'))
await asyncio.sleep(time_numbers*t(time_letter))
await unban(member)
await ctx.send(embed=discord.Embed(description=f'Пользователь {member.mention} был разбанен'))
else:
await member.ban()
await ctx.send(embed=discord.Embed(description=f'Пользователь {member.mention} был забанен \nВремя: {time}'))
await asyncio.sleep(time_numbers*t(time_letter))
await unban(member)
await ctx.send(embed=discord.Embed(description=f'Пользователь {member.mention} был разбанен'))
else:
await member.ban()
await ctx.send(embed=discord.Embed(description=f'Пользователь {member.mention} был забанен'))
else:
await ctx.send(embed=discord.Embed('Введите имя пользователя!'))