[Starboard] Separate blocked/allowed roles and channels #528
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR separates roles and channels in blacklist and whitelist by creating additional blacklists and whitelists for roles and channels, and lets the cog check if both the star-giver role and the channel are good before posting a starboard post. This should fix TrustyJAID/Trusty-cogs#261 and fix TrustyJAID/Trusty-cogs#269.
Details
Before this PR
When a post is starred, before posting to an appropriate starboard, the cog checks if either:
A permitted role is a Discord role, and, satisfies at least one of these conditions (in that order*):
The same logic applies for checking whether a Discord (text/category) channel is a permitted channel.
After this PR
When a post is starred, before posting to an appropriate starboard, the cog checks if the person who starred the post has both a permitted role and the channel containing the starred post is a permitted channel.
A permitted role is a Discord role, and, satisfies all of these conditions (in that order*):
The similar logic applies for checking whether a Discord (text/category) channel is a permitted channel. The only difference is that the channel blacklist/whitelist in which case contains only (zero or more) channels.
* The latter checks get evaluted only after the former checks have been evaluated.
Notes
This PR only adds additional blacklists and whitelists for roles and channels, and still lets the cog add/remove channels/roles to/from its existing whitelist and blacklist. Also, a large portion of the existing code is kept undeleted. We can clean things up when there is a fix for TrustyJAID/Trusty-cogs#261 and TrustyJAID/Trusty-cogs#269 from upstream (TrustyJAID/Trusty-cogs).