-2

I'm having trouble trying to get my Discord BOT to send a message to the server at an exact time every day.

I am trying to get my discord BOT to send a message every day at a specific time.

For example: I want every day at 12:00, BOT will send a message to a channel with this message: "The server will be restarted in 5 minutes!".

I've searched all over the internet for this, none of the attempts I've had worked, I'm almost racking my brain here, can anyone help me?

  • Have a look here for how to set up a background task/loop in Discord. You just need to write logic to check time of day. https://stackoverflow.com/questions/54495679/how-to-make-a-loop-in-discord-py-rewrite/54501491#54501491 – Benjin Aug 14 '19 at 11:34

2 Answers2

0

You could try this Python package: https://pypi.org/project/schedule/

Simple make a function that uses the client to send a message to a specific channel by id.

I'm not sure how the Discord python library works, but I'm sure there's a way if you do some digging.

Ezray
  • 136
  • 8
0

you can use the datetime library to do this, by making a loop and checking if the current time is equal to the time which you want the code to execute, I haven't used datetime in a while so I can't provide an example here but I have done it in my previous discord bots

Swies
  • 1
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – MD. RAKIB HASAN Dec 09 '21 at 07:01