Want to run discord.py in parallel thread

Asked 2 years ago, Updated 2 years ago, 151 views

I'm making a Bot like this.

  • Bot greeting every day
  • You can set what time and what time to greet each build

I'm thinking of using the while True loop on_ready, but the problem is that there are so many notification builds in the bot that I can't handle with a simple loop.
You must run it in parallel.

If you have or have not made a Bot like this, please tell me the solution.

python python3 discord

2022-09-30 13:51

2 Answers

client.loop.create_task(function).
Thank you.


2022-09-30 13:51

  • Create a class of greeting time, greeting partner, and greeting content (+supplementary information)
  • Define the greeting method to post to the class above based on the self information
  • Once the instance is created, register the time to greet with the Dictionary key
  • nIn the main loop or the Timer loop that you switch every minute, get an instance of the current time key from the Dictionary
  • Do nothing if the current time key instance is not in Dictionary
  • Run the Greeting method if an instance exists

I feel like I can botize with just one thread using the above method.Try it.


2022-09-30 13:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.