From 2fa28c1f7d1675c7f7fe34ffc13c79f95b708c53 Mon Sep 17 00:00:00 2001 From: brandons209 Date: Fri, 6 Nov 2020 03:40:11 -0500 Subject: [PATCH] fix conflicts between two cogs --- isolate/isolate.py | 16 ++++++++++++++++ punish/punish.py | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/isolate/isolate.py b/isolate/isolate.py index 6c90fab..e623985 100644 --- a/isolate/isolate.py +++ b/isolate/isolate.py @@ -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: diff --git a/punish/punish.py b/punish/punish.py index f352338..4d3687d 100644 --- a/punish/punish.py +++ b/punish/punish.py @@ -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: