Код:
@bot.command(name='start')
async def _start(ctx):
mbrs = ctx.guild.member_count
online = len(list(filter(lambda x: x.status == discord.Status.online, mbrs)))
guild = ctx.guild
members = await guild.create_text_channel(f"members: {guild.member_count}")
onlines = await guild.create_text_channel(f"Online: {online}")
await ctx.reply('Отслеживание статистики началось\nПодробности:\nСтатистика отслеживаеться каждые 30 секунд')
while True:
await members.edit(name=f"members: {guild.member_count}")
await onlines.edit(name=f"online: {online}")
await sleep(30)
Но всё закончилось ошибкой:
Ignoring exception in command start:
Traceback (most recent call last):
File "C:\Users\shits\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\shits\Desktop\Статистика\main.py", line 10, in _start
online = len(list(filter(lambda x: x.status == discord.Status.online, mbrs)))
TypeError: 'int' object is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\shits\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\shits\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\shits\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'int' object is not iterable