From ef76affd7701a4cad669fcc6d330344592734289 Mon Sep 17 00:00:00 2001 From: Neuro Assassin <42872277+NeuroAssassin@users.noreply.github.com> Date: Mon, 18 May 2020 20:22:05 -0400 Subject: [PATCH] Fix local blacklist and whitelist commands (#3857) --- redbot/core/core_commands.py | 20 ++++++++++---------- redbot/core/settings_caches.py | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 80aa7ecbe..5697c2fd8 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -1945,8 +1945,8 @@ class Core(commands.Cog, CoreLogic): await ctx.send_help() return - names = [getattr(users_or_roles, "name", users_or_roles) for u_or_r in users_or_roles] - uids = [getattr(users_or_roles, "id", users_or_roles) for u_or_r in users_or_roles] + names = [getattr(u_or_r, "name", u_or_r) for u_or_r in users_or_roles] + uids = [getattr(u_or_r, "id", u_or_r) for u_or_r in users_or_roles] await self.bot._whiteblacklist_cache.add_to_whitelist(ctx.guild, uids) await ctx.send(_("{names} added to whitelist.").format(names=humanize_list(names))) @@ -1980,8 +1980,8 @@ class Core(commands.Cog, CoreLogic): await ctx.send_help() return - names = [getattr(users_or_roles, "name", users_or_roles) for u_or_r in users_or_roles] - uids = [getattr(users_or_roles, "id", users_or_roles) for u_or_r in users_or_roles] + names = [getattr(u_or_r, "name", u_or_r) for u_or_r in users_or_roles] + uids = [getattr(u_or_r, "id", u_or_r) for u_or_r in users_or_roles] await self.bot._whiteblacklist_cache.remove_from_whitelist(ctx.guild, uids) await ctx.send( @@ -2027,8 +2027,8 @@ class Core(commands.Cog, CoreLogic): if await ctx.bot.is_owner(uid): await ctx.send(_("You cannot blacklist a bot owner!")) return - names = [getattr(users_or_roles, "name", users_or_roles) for u_or_r in users_or_roles] - uids = [getattr(users_or_roles, "id", users_or_roles) for u_or_r in users_or_roles] + names = [getattr(u_or_r, "name", u_or_r) for u_or_r in users_or_roles] + uids = [getattr(u_or_r, "id", u_or_r) for u_or_r in users_or_roles] await self.bot._whiteblacklist_cache.add_to_blacklist(ctx.guild, uids) await ctx.send( @@ -2064,9 +2064,9 @@ class Core(commands.Cog, CoreLogic): await ctx.send_help() return - names = [getattr(users_or_roles, "name", users_or_roles) for u_or_r in users_or_roles] - uids = [getattr(users_or_roles, "id", users_or_roles) for u_or_r in users_or_roles] - await self.bot._whiteblacklist_cache.remove_from_whitelist(ctx.guild, uids) + names = [getattr(u_or_r, "name", u_or_r) for u_or_r in users_or_roles] + uids = [getattr(u_or_r, "id", u_or_r) for u_or_r in users_or_roles] + await self.bot._whiteblacklist_cache.remove_from_blacklist(ctx.guild, uids) await ctx.send( _("{names} removed from the local blacklist.").format(names=humanize_list(names)) @@ -2077,7 +2077,7 @@ class Core(commands.Cog, CoreLogic): """ Clears the blacklist. """ - await ctx.bot._config.guild(ctx.guild).blacklist.set([]) + await self.bot._whiteblacklist_cache.clear_blacklist(ctx.guild) await ctx.send(_("Local blacklist has been cleared.")) @checks.guildowner_or_permissions(administrator=True) diff --git a/redbot/core/settings_caches.py b/redbot/core/settings_caches.py index da2748004..0ccceb39f 100644 --- a/redbot/core/settings_caches.py +++ b/redbot/core/settings_caches.py @@ -238,7 +238,7 @@ class WhitelistBlacklistManager: curr_list.append(obj_id) else: if gid not in self._cached_blacklist: - self._cached_blacklist[gid] = self._config.guild_from_id(gid).blacklist() + self._cached_blacklist[gid] = await self._config.guild_from_id(gid).blacklist() for obj_id in role_or_user: if obj_id not in self._cached_blacklist[gid]: self._cached_blacklist[gid].append(obj_id) @@ -270,7 +270,7 @@ class WhitelistBlacklistManager: curr_list.remove(obj_id) else: if gid not in self._cached_blacklist: - self._cached_blacklist[gid] = self._config.guild_from_id(gid).blacklist() + self._cached_blacklist[gid] = await self._config.guild_from_id(gid).blacklist() for obj_id in role_or_user: if obj_id in self._cached_blacklist[gid]: self._cached_blacklist[gid].remove(obj_id)