TrustyJAID / Trusty-cogs

A variety of utility cogs and fun cogs including Hockey information from the NHL, badge creation from discord user information, starboard for use on Redbot, twitch follow notifications and more.
MIT License
168 stars 119 forks source link

Hockey score delays #333

Closed kjchrz03 closed 8 months ago

kjchrz03 commented 8 months ago

Describe the bug Pretty significant delay over the last few weeks in reporting hockey game stats. Eg, results of shoot out posted over an hour after game ended

To Reproduce All /hockey settings for a specific teams goals and the end of period and final score for all teams (these are the only two in use)

Expected behavior Posts made within 5 min or so of the event

Screenshots In this one, the game ended at around 11:45pm est and the shoot out goals were posted after 1am Screenshot_20240224_080430_Discord

Additional context Add any other context about the problem here.

TrustyJAID commented 8 months ago

This isn't really the place for this. However, I will explain what is happening. TrustyBot has grown to be a pretty significant bot for the hockey communities. As such more and more servers want their score updates. Discord has recently transitioned to a new ideology on what bots can and should do. With the introduction of slash commands they intend bots to respond only to user input. Some bots, like TrustyBot, have been granted extra permission to continue running off traditional text commands in addition to working with the new slash commands. However, discord has been a bit more stringent on their rate limiting as a result. So there are days where the bot is getting a temporary 1 hour rate limit attempting to post goal updates across it's 2000+ saved channels. Since the bot is being used for more than hockey updates especially for all the hockey servers that 1 hour rate limit timeout means there's an hour where a mod can potentially not mute or ban someone who is acting out. This is obviously not good because the bots usage is muscle memory for some people and figuring out alternatives can take time not to mention reduces reliability of TrustyBot meaning people might look elsewhere for their solutions which I don't want. Since the main culprit appears to be hockey updates posting too quickly I have had to make adjustments to the code to reduce how quickly I post the goal updates. They shouldn't be an hour late and by some rough calculations I estimate that it's currently about a 5 minute wait. This is dependent on the specific game and which teams are setup to post on the bot in each channel. A few weeks ago I attempted solving this and made an error that caused game updates to post up to 24 hours late. I quickly reverted that change to investigate a different approach. More recently there was about a 1 hour delay in posting one day but since it seems to have been resolved. I am unsure what specifically caused it though I have a few ideas. It's difficult to track some of this as these are scaling issues that I can't easily resolve or even test for. Needless to say I am entirely aware of the issues and am prioritizing bot up-time over speed of game updates simply because the game updates are always going to be slower than watching the game broadcast live.