Ensure cache is updated wherever needed
This commit is contained in:
parent
a612d4231b
commit
99f8d19cef
|
@ -299,8 +299,10 @@ guild=$2
|
||||||
)
|
)
|
||||||
except UniqueViolationError:
|
except UniqueViolationError:
|
||||||
# If it's already inserted, then nothing needs to be updated
|
# If it's already inserted, then nothing needs to be updated
|
||||||
# It just meansthis particular restriction is already set
|
# It just means this particular restriction is already set
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
ctx.bot.cache.add_restriction(ctx.guild, from_to, {"source": source, "destination": destination})
|
||||||
elif overwrites:
|
elif overwrites:
|
||||||
channel = overwrites.pop('channel')
|
channel = overwrites.pop('channel')
|
||||||
for target, setting in overwrites.items():
|
for target, setting in overwrites.items():
|
||||||
|
@ -364,6 +366,7 @@ WHERE
|
||||||
destination=$2 AND
|
destination=$2 AND
|
||||||
from_to=$3 AND
|
from_to=$3 AND
|
||||||
guild=$4""", source, destination, arg2, ctx.guild.id)
|
guild=$4""", source, destination, arg2, ctx.guild.id)
|
||||||
|
ctx.bot.cache.remove_restriction(ctx.guild.id, arg2, {"source": source, "destination": destination})
|
||||||
|
|
||||||
# If this isn't a blacklist/whitelist, then we are attempting to remove an overwrite
|
# If this isn't a blacklist/whitelist, then we are attempting to remove an overwrite
|
||||||
else:
|
else:
|
||||||
|
@ -524,6 +527,8 @@ WHERE
|
||||||
perm_value
|
perm_value
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ctx.bot.cache.update_custom_permission(ctx.guild, cmd.qualified_name, perm_value)
|
||||||
|
|
||||||
await ctx.send("I have just added your custom permissions; "
|
await ctx.send("I have just added your custom permissions; "
|
||||||
"you now need to have `{}` permissions to use the command `{}`".format(permission, command))
|
"you now need to have `{}` permissions to use the command `{}`".format(permission, command))
|
||||||
|
|
||||||
|
@ -547,6 +552,8 @@ WHERE
|
||||||
"DELETE FROM custom_permissions WHERE guild=$1 AND command=$2", ctx.guild.id, cmd.qualified_name
|
"DELETE FROM custom_permissions WHERE guild=$1 AND command=$2", ctx.guild.id, cmd.qualified_name
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ctx.bot.cache.update_custom_permission(ctx.guild, cmd.qualified_name, None)
|
||||||
|
|
||||||
await ctx.send("I have just removed the custom permissions for {}!".format(cmd))
|
await ctx.send("I have just removed the custom permissions for {}!".format(cmd))
|
||||||
|
|
||||||
@commands.command(aliases=['nick'])
|
@commands.command(aliases=['nick'])
|
||||||
|
|
|
@ -279,10 +279,7 @@ class GuildConfiguration(commands.Cog):
|
||||||
if setting.lower().strip() == "none":
|
if setting.lower().strip() == "none":
|
||||||
setting = None
|
setting = None
|
||||||
|
|
||||||
result = await self._set_db_guild_opt("prefix", setting, ctx)
|
return await self._set_db_guild_opt("prefix", setting, ctx)
|
||||||
# We want to update our cache for prefixes
|
|
||||||
ctx.bot.cache.update_prefix(ctx.guild, setting)
|
|
||||||
return result
|
|
||||||
|
|
||||||
async def _handle_set_default_alerts(self, ctx, setting):
|
async def _handle_set_default_alerts(self, ctx, setting):
|
||||||
channel = await self._get_channel(ctx, setting)
|
channel = await self._get_channel(ctx, setting)
|
||||||
|
|
|
@ -86,6 +86,17 @@ FROM
|
||||||
from_restrictions.append(opt)
|
from_restrictions.append(opt)
|
||||||
self.restrictions[row['guild']][row['from_to']] = from_restrictions
|
self.restrictions[row['guild']][row['from_to']] = from_restrictions
|
||||||
|
|
||||||
|
def add_restriction(self, guild, from_to, restriction):
|
||||||
|
restrictions = self.restrictions[guild.id].get(from_to, [])
|
||||||
|
restrictions.append(restriction)
|
||||||
|
self.restrictions[guild.id][from_to] = restrictions
|
||||||
|
|
||||||
|
def remove_restriction(self, guild, from_to, restriction):
|
||||||
|
restrictions = self.restrictions[guild.id].get(from_to, [])
|
||||||
|
if restriction in restrictions:
|
||||||
|
restrictions.remove(restriction)
|
||||||
|
self.restrictions[guild.id][from_to] = restrictions
|
||||||
|
|
||||||
|
|
||||||
class DB:
|
class DB:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
Loading…
Reference in a new issue