1
0
Fork 0
mirror of synced 2024-05-19 20:12:30 +12:00

Fixed enable/disable not correcting cache values

This commit is contained in:
Dan Hess 2020-03-12 15:03:08 -05:00
parent 1fd5362177
commit 2770d49b07

View file

@ -16,13 +16,11 @@ class Admin(commands.Cog):
async def disable(self, ctx, *, command): async def disable(self, ctx, *, command):
"""Disables the use of a command on this server""" """Disables the use of a command on this server"""
if command == "disable" or command == "enable": if command == "disable" or command == "enable":
await ctx.send("You cannot disable `{}`".format(command)) return await ctx.send("You cannot disable `{}`".format(command))
return
cmd = ctx.bot.get_command(command) cmd = ctx.bot.get_command(command)
if cmd is None: if cmd is None:
await ctx.send("No command called `{}`".format(command)) return await ctx.send("No command called `{}`".format(command))
return
try: try:
await ctx.bot.db.execute( await ctx.bot.db.execute(
@ -34,6 +32,11 @@ class Admin(commands.Cog):
await ctx.send(f"{cmd.qualified_name} is already disabled") await ctx.send(f"{cmd.qualified_name} is already disabled")
else: else:
await ctx.send(f"{cmd.qualified_name} is now disabled") await ctx.send(f"{cmd.qualified_name} is now disabled")
ctx.bot.cache.add_restriction(
ctx.guild,
"from",
{"source": cmd.qualified_name, "destination": "everyone"}
)
@commands.command() @commands.command()
@commands.guild_only() @commands.guild_only()
@ -53,6 +56,11 @@ destination='everyone' AND
guild=$2 guild=$2
""" """
await ctx.bot.db.execute(query, cmd.qualified_name, ctx.guild.id) await ctx.bot.db.execute(query, cmd.qualified_name, ctx.guild.id)
ctx.bot.cache.remove_restriction(
ctx.guild,
"from",
{"source": cmd.qualified_name, "destination": "everyone"}
)
await ctx.send(f"{cmd.qualified_name} is no longer disabled") await ctx.send(f"{cmd.qualified_name} is no longer disabled")
@commands.command() @commands.command()
@ -362,9 +370,9 @@ guild=$2
DELETE FROM DELETE FROM
restrictions restrictions
WHERE WHERE
source=$1 AND source=$1 AND
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, arg2, {"source": source, "destination": destination}) ctx.bot.cache.remove_restriction(ctx.guild, arg2, {"source": source, "destination": destination})