mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-09 04:38:55 -05:00
Fix local blacklist and whitelist commands (#3857)
This commit is contained in:
parent
38a034e59b
commit
ef76affd77
@ -1945,8 +1945,8 @@ class Core(commands.Cog, CoreLogic):
|
|||||||
await ctx.send_help()
|
await ctx.send_help()
|
||||||
return
|
return
|
||||||
|
|
||||||
names = [getattr(users_or_roles, "name", 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(users_or_roles, "id", users_or_roles) 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 self.bot._whiteblacklist_cache.add_to_whitelist(ctx.guild, uids)
|
||||||
|
|
||||||
await ctx.send(_("{names} added to whitelist.").format(names=humanize_list(names)))
|
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()
|
await ctx.send_help()
|
||||||
return
|
return
|
||||||
|
|
||||||
names = [getattr(users_or_roles, "name", 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(users_or_roles, "id", users_or_roles) 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 self.bot._whiteblacklist_cache.remove_from_whitelist(ctx.guild, uids)
|
||||||
|
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
@ -2027,8 +2027,8 @@ class Core(commands.Cog, CoreLogic):
|
|||||||
if await ctx.bot.is_owner(uid):
|
if await ctx.bot.is_owner(uid):
|
||||||
await ctx.send(_("You cannot blacklist a bot owner!"))
|
await ctx.send(_("You cannot blacklist a bot owner!"))
|
||||||
return
|
return
|
||||||
names = [getattr(users_or_roles, "name", 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(users_or_roles, "id", users_or_roles) 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 self.bot._whiteblacklist_cache.add_to_blacklist(ctx.guild, uids)
|
||||||
|
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
@ -2064,9 +2064,9 @@ class Core(commands.Cog, CoreLogic):
|
|||||||
await ctx.send_help()
|
await ctx.send_help()
|
||||||
return
|
return
|
||||||
|
|
||||||
names = [getattr(users_or_roles, "name", 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(users_or_roles, "id", users_or_roles) 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 self.bot._whiteblacklist_cache.remove_from_blacklist(ctx.guild, uids)
|
||||||
|
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_("{names} removed from the local blacklist.").format(names=humanize_list(names))
|
_("{names} removed from the local blacklist.").format(names=humanize_list(names))
|
||||||
@ -2077,7 +2077,7 @@ class Core(commands.Cog, CoreLogic):
|
|||||||
"""
|
"""
|
||||||
Clears the blacklist.
|
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."))
|
await ctx.send(_("Local blacklist has been cleared."))
|
||||||
|
|
||||||
@checks.guildowner_or_permissions(administrator=True)
|
@checks.guildowner_or_permissions(administrator=True)
|
||||||
|
|||||||
@ -238,7 +238,7 @@ class WhitelistBlacklistManager:
|
|||||||
curr_list.append(obj_id)
|
curr_list.append(obj_id)
|
||||||
else:
|
else:
|
||||||
if gid not in self._cached_blacklist:
|
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:
|
for obj_id in role_or_user:
|
||||||
if obj_id not in self._cached_blacklist[gid]:
|
if obj_id not in self._cached_blacklist[gid]:
|
||||||
self._cached_blacklist[gid].append(obj_id)
|
self._cached_blacklist[gid].append(obj_id)
|
||||||
@ -270,7 +270,7 @@ class WhitelistBlacklistManager:
|
|||||||
curr_list.remove(obj_id)
|
curr_list.remove(obj_id)
|
||||||
else:
|
else:
|
||||||
if gid not in self._cached_blacklist:
|
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:
|
for obj_id in role_or_user:
|
||||||
if obj_id in self._cached_blacklist[gid]:
|
if obj_id in self._cached_blacklist[gid]:
|
||||||
self._cached_blacklist[gid].remove(obj_id)
|
self._cached_blacklist[gid].remove(obj_id)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user