Я не могу понять, как активировать мои фоновые задачи во время выполнения.Предполагается изменить цвет роли, что успешно, если я заставлю код работать после события.Но настроить его на работу в фоновом режиме не удается.Нет ошибок, я думаю, что задача никогда не загружается.
#Login and bot initializer
@client.event
async def on_ready():
print('Logged in as')
print(f"Username: {client.user.name}")
print(f"User ID: {client.user.id}")
print('---------------------------------')
#Runtime Background Tasks
async def runtime_background_task():
id=client.get_guild(564683412699480094)
colours = [discord.Colour(0xe91e63),discord.Colour(0x0000FF0),discord.Colour(0x00FF00),discord.Colour(0xFF0000)]
print("BACKGROUND TASK>> Functional")
await client.wait_until_ready()
while not client.is_closed:
i = random.randint(0, len(colours))
await asyncio.sleep(1)
print(i)
for role in id.roles:
if role.name == 'bot':
await role.edit(server=id, role=role, colour=colours[i])
break