[3.4] [Core] Add more APIs for allowlists and blocklists (#5206) (#5295)

* [Core] Blacklist api

* [Core] Use to_add, remove star from other method calls

* various touch ups

* style

* fix doc style

* [Core] Remove iterable import

* [Core] Update commands to use the blacklist/whitelist api

* Change signatures to not use `*args`

* Update all usage of private cache to the new public APIs

* Update the docstrings

* Update the usage in diagnoser

(cherry picked from commit 0dded8aa47)

Co-authored-by: Just-Jojo <62262765+Just-Jojo@users.noreply.github.com>
Co-authored-by: Kreusada <67752638+Kreusada@users.noreply.github.com>
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

Co-authored-by: Just-Jojo <62262765+Just-Jojo@users.noreply.github.com>
Co-authored-by: Kreusada <67752638+Kreusada@users.noreply.github.com>
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
Red-GitHubBot
2021-09-08 22:43:45 +02:00
committed by GitHub
parent 373c04de11
commit c739500a13
3 changed files with 184 additions and 39 deletions

View File

@@ -166,7 +166,7 @@ class DetailedGlobalCallOnceChecksMixin(IssueDiagnoserBase):
)
async def _get_detailed_global_whitelist_blacklist_result(self, label: str) -> CheckResult:
global_whitelist = await self.bot._whiteblacklist_cache.get_whitelist()
global_whitelist = await self.bot.get_whitelist()
if global_whitelist:
return CheckResult(
False,
@@ -206,7 +206,7 @@ class DetailedGlobalCallOnceChecksMixin(IssueDiagnoserBase):
async def _get_detailed_local_whitelist_blacklist_result(self, label: str) -> CheckResult:
# this method skips guild owner check as the earlier checks wouldn't fail
# if the user were guild owner
guild_whitelist = await self.bot._whiteblacklist_cache.get_whitelist(self.guild)
guild_whitelist = await self.bot.get_whitelist(self.guild)
if guild_whitelist:
return CheckResult(
False,
@@ -227,7 +227,7 @@ class DetailedGlobalCallOnceChecksMixin(IssueDiagnoserBase):
)
details = _("Local blocklist prevents the user from running this command.")
guild_blacklist = await self.bot._whiteblacklist_cache.get_blacklist(self.guild)
guild_blacklist = await self.bot.get_blacklist(self.guild)
ids = {role.id for role in self.author.roles if not role.is_default()}
ids.add(self.author.id)
intersection = ids & guild_blacklist