Devlog 2
Once /clock was working, I started adding the other two commands. I wanted each command to do something different so the bot would meet the requirement of having at least three functions rather than having three commands that were basically the same.
The first one I added was /remindme. The command takes a number of minutes followed by some text, for example /remindme 5 Finish my homework. I used split(maxsplit=1) so that the first part can be treated as the time while everything after it stays as the reminder message.
For the actual delay, I used Python’s threading.Timer. This lets the bot continue running normally while it waits for the reminder. When the timer finishes, the bot sends a DM to the person who created the reminder.
I then added /weather. Instead of using an API that needs an account/API key, I used the free wttr.in service. The city is taken directly from what the user types after the command and the response is sent back to the person as a DM.
After adding both commands, I tested different inputs, including leaving out the city for the weather command and entering something that wasn’t a number for the reminder. This helped me add some basic messages for incorrect input instead of letting the program crash.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.