fix conflicts between two cogs

This commit is contained in:
brandons209 2020-11-06 03:40:11 -05:00
parent e68ebc7875
commit 2fa28c1f7d
2 changed files with 32 additions and 0 deletions

View file

@ -999,6 +999,22 @@ class Isolate(commands.Cog):
await ctx.send("You can't isolate the bot.")
return
# check if user is isolated, fix conflict with isolate cog
punish = self.bot.get_cog("Punish")
if punish:
punished = await punish.config.guild(guild).PUNISHED()
if str(member.id) in punished:
await ctx.send(
warning("This person is punished, I will remove it now before isolating to avoid conflicts.")
)
await ctx.invoke(punish.punish_end, user=member, reason="Conflict with isolate cog.")
# double check it actually worked
punished = await punish.config.guild(guild).PUNISHED()
if str(member.id) in punished:
await ctx.send(error("Couldn't remove punish from user, please do it manually."))
return
if duration and duration.lower() in ["forever", "inf", "infinite"]:
duration = None
else:

View file

@ -1069,6 +1069,22 @@ class Punish(commands.Cog):
await ctx.send("You can't punish the bot.")
return
# check if user is isolated, fix conflict with isolate cog
isolate = self.bot.get_cog("Isolate")
if isolate:
isolated = await isolate.config.guild(guild).ISOLATED()
if str(member.id) in isolated:
await ctx.send(
warning("This person is isolated, I will remove it now before punishing to avoid conflicts.")
)
await ctx.invoke(isolate.isolate_end, user=member, reason="Conflict with punish cog.")
# double check it actually worked
isolated = await isolate.config.guild(guild).ISOLATED()
if str(member.id) in isolated:
await ctx.send(error("Couldn't remove isolation from user, please do it manually."))
return
if duration and duration.lower() in ["forever", "inf", "infinite"]:
duration = None
else: