Botanism / Botanist

A bot for a healthier experience on discord servers. Provides lots of moderation utilities and improved sharing features!

Home Page:https://discord.gg/mpGM5cg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reminders are not safe

s0lst1ce opened this issue · comments

Describe the bug
remind function is not subject to failure when one of the following events occur:

  • timeout
  • critical loop failure
  • reloading of Time cog
  • bot is restarted

Steps to reproduce
Have one of the previous events occur. You will see that the reminder will never get sent.

Expected behavior
reminders should always continue to work for the user, whatever happens to the bot.

Additional context
To solve this it would be required to "save" the reminders messages in a file (or memory but that wouldn't protect from reboots) and have a clock checking if it should send some reminders.
For optimization this clock could be an asyncio event that would awake after a given amount of time. If something happens to it, you would simply need a new one that would get configured from the timestamps saved to the file which could like like this:
{ "time": "message"}

It would be wise to add an entry to the TIMES_FOLDER just as #48 did.

Along with this it would be nice to look for currently muted users on startup so that they can be unmuted even though the bot rebooted.