thecatcore / Fabric---Discord-Link

MIT License
75 stars 31 forks source link

Update the chat and log channel descriptions if configured to do so #109

Closed kwvanderlinde closed 4 years ago

kwvanderlinde commented 4 years ago

The customChannelDescription option for chat and log channels has had no effect since the move to JDA. This change re-enables the option so that, if enabled, the bot will attempt to set the chat or log channel topics every five minutes.

This change also fixes a weakness in the scheduling logic. Due to the way integer division is used in the check, the previous implementation would actually try to set the topic for every tick that happened to land on the 300th second. This would mean up to 20 calls being attempted on a well running server, which immediately eats up the rate limit. The new check instead uses a target time, after which the topic is updated and a new target time is set for five minutes in the future.

The README.md has been updated to mention the <Manage Channels> permission that the bot requires for this feature. If the permission is missing, a message is logged instructing the server admin to add the permission or else disable the feature.

thecatcore commented 4 years ago

Thanks for fixing it! I couldn't find where the method was located after I switched to JDA.