Open the1337g33k opened 4 years ago
on_ready
is triggered after the cache has filled, so this should be easy peasy to implement
Yeah actually I was thinking of a second thing too just now. We want to consider a backoff in case discord, whilst known for it's rock solid stability just happens to get all flappy and cause the bot to fire on_ready multiple times in quick succession. We'd want to keep a record of the last time the process ran, check if a task is already scheduled to run and if not already scheduled, setup a task to run no less then an hour after the last time it ran.
I believe (citation needed) that when Discord reconnects it fires on_resumed()
rather than on_ready()
, so it's definitely possible to log that data. However, I don't really see a need to not run the task. Worst case scenario it'll just error out quietly while Discord reconnects and then retry on connection
I'll need to further research it. I know on_ready()
firing multiple times was a problem in the v2 days. I have scars from tasks stepping on themselves repeatedly and causing inconsistency.
As this cog doesn't utilise tasks that shouldn't be an issue. Though, in that instance it is generally best practice to have a on_disconnect()
event that will cancel any running tasks
When the bot is offline people still react to the role post expecting their actions to be carried out. On startup the bot doesn't check the post and compare the current reactions against a user's roles to ensure everything is properly synchronized. Users may be unaware the bot is offline and become confused when it doesn't ever carry out their directives.
Only one thing I am aware needs to be considered when making this. Need to figure out if member cache is ready by the time the on_ready event is fired. We will want to make sure the member cache is fully built before running this process as we don't want to increase startup time or put the bot queue minutes behind right out of the gate after startup is complete.