-
Hi everyone! from discord.ext import tasks
from discord.ext.commands import Bot
import aiohttp.client_exceptions
TOKEN = "blablabla"
client = Bot(command_prefix=">")
@tasks.loop(minutes=10)
async def main0():
# code
some_condition = True
await client.logout() #to end to the client after excution of all those code in main0 and execute the rest of clients in while loop
client1 = Bot(command_prefix=">")
@tasks.loop(minutes=10)
async def main1():
# code
some_condition = False
while True:
try:
main0.start()
client.run(TOKEN)
if some_condition == True: #if some conditions happens:
main1.start()
client1.run(TOKEN)
else:
continue # to execute the first client again
except aiohttp.client_exceptions.ClientConnectorError:
print("You don't have internet access!") As you can see, I used client.logout to get out of the first client; but it doesn't work properly and I think this is probably logout method problem not my code... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
Client.run
takes ownership of the event loop and closes it when it terminates. If you want control over the event loop you'll have to useClient.login
withClient.connect
. For more information you can see this issue comment.