Skip to content

Commit

Permalink
Remove main_task()
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Oct 2, 2023
1 parent cdebaa3 commit 41f33d2
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions discord_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,7 @@ async def on_ready():
global_channel = client.get_channel(DISCORD_CHANNEL_ID)

loop = asyncio.get_event_loop()
loop.create_task(main_task()) # Run main_task() as a separate task when the client is ready.


async def main_task():
while True:
if client.is_ready(): # This ensures the client is ready before starting the background task.
await background_task()
else:
await asyncio.sleep(10) # Wait a bit before rechecking.
loop.create_task(background_task()) # Run main_task() as a separate task when the client is ready.


with open('./discord_bot_token', 'r') as file:
Expand Down

0 comments on commit 41f33d2

Please sign in to comment.