From 90e0a4b153861e9b4f5795ef96a05d3193552242 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Thu, 5 Oct 2023 20:09:42 -0400 Subject: [PATCH] fix(moderation): made dm_users and ignore_other_bots guild-dependent --- moderation/moderation.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/moderation/moderation.py b/moderation/moderation.py index 68d0d1c..2c45523 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -21,7 +21,9 @@ class Moderation(commands.Cog): mysql_address= " ", mysql_database = " ", mysql_username = " ", - mysql_password = " ", + mysql_password = " " + ) + self.config.register_guild( ignore_other_bots = True, dm_users = True ) @@ -69,7 +71,7 @@ class Moderation(commands.Cog): @commands.Cog.listener('on_audit_log_entry_create') async def autologger(self, entry: discord.AuditLogEntry): """This method automatically logs moderations done by users manually ("right clicks").""" - if await self.config.ignore_other_bots() is True: + if await self.config.guild(entry.guild.id).ignore_other_bots() is True: if entry.user.bot or entry.target.bot: return else: @@ -223,7 +225,7 @@ class Moderation(commands.Cog): """Add a note to a user.""" await interaction.response.send_message(content=f"{target.mention} has recieved a note!\n**Reason** - `{reason}`") if silent is None: - silent = not await self.config.dm_users() + silent = not await self.config.guild(interaction.guild.id).dm_users() if silent is False: try: embed = await self.embed_factory('message', interaction.guild, reason, 'note', await interaction.original_response()) @@ -237,7 +239,7 @@ class Moderation(commands.Cog): """Warn a user.""" await interaction.response.send_message(content=f"{target.mention} has been warned!\n**Reason** - `{reason}`") if silent is None: - silent = not await self.config.dm_users() + silent = not await self.config.guild(interaction.guild.id).dm_users() if silent is False: try: embed = await self.embed_factory('message', interaction.guild, reason, 'warned', await interaction.original_response()) @@ -263,7 +265,7 @@ class Moderation(commands.Cog): await target.timeout(parsed_time, reason=f"Muted by {interaction.user.id} for: {reason}") await interaction.response.send_message(content=f"{target.mention} has been muted for {humanize.precisedelta(parsed_time)}!\n**Reason** - `{reason}`") if silent is None: - silent = not await self.config.dm_users() + silent = not await self.config.guild(interaction.guild.id).dm_users() if silent is False: try: embed = await self.embed_factory('message', interaction.guild, reason, 'muted', await interaction.original_response(), parsed_time) @@ -285,7 +287,7 @@ class Moderation(commands.Cog): reason = "No reason given." await interaction.response.send_message(content=f"{target.mention} has been unmuted!\n**Reason** - `{reason}`") if silent is None: - silent = not await self.config.dm_users() + silent = not await self.config.guild(interaction.guild.id).dm_users() if silent is False: try: embed = await self.embed_factory('message', interaction.guild, reason, 'unmuted', await interaction.original_response()) @@ -299,7 +301,7 @@ class Moderation(commands.Cog): """Kick a user.""" await interaction.response.send_message(content=f"{target.mention} has been kicked!\n**Reason** - `{reason}`") if silent is None: - silent = not await self.config.dm_users() + silent = not await self.config.guild(interaction.guild.id).dm_users() if silent is False: try: embed = await self.embed_factory('message', interaction.guild, reason, 'kicked', await interaction.original_response()) @@ -343,7 +345,7 @@ class Moderation(commands.Cog): else: await interaction.response.send_message(content=f"{target.mention} has been banned!\n**Reason** - `{reason}`") if silent is None: - silent = not await self.config.dm_users() + silent = not await self.config.guild(interaction.guild.id).dm_users() if silent is False: try: embed = await self.embed_factory('message', interaction.guild, reason, 'banned', await interaction.original_response()) @@ -368,7 +370,7 @@ class Moderation(commands.Cog): reason = "No reason given." await interaction.response.send_message(content=f"{target.mention} has been unbanned!\n**Reason** - `{reason}`") if silent is None: - silent = not await self.config.dm_users() + silent = not await self.config.guild(interaction.guild.id).dm_users() if silent is False: try: embed = await self.embed_factory('message', interaction.guild, reason, 'unbanned', await interaction.original_response()) @@ -505,8 +507,8 @@ class Moderation(commands.Cog): @checks.admin() async def moderationset_ignorebots(self, ctx: commands.Context): """Toggle if the cog should ignore other bots' moderations.""" - await self.config.ignore_other_bots.set(not await self.config.ignore_other_bots()) - await ctx.send(f"Ignore bots setting set to {await self.config.ignore_other_bots()}") + await self.config.guild(ctx.guild.id).ignore_other_bots.set(not await self.config.guild(ctx.guild.id).ignore_other_bots()) + await ctx.send(f"Ignore bots setting set to {await self.config.guild(ctx.guild.id).ignore_other_bots()}") @moderationset.command(name="dm") @checks.admin() @@ -514,8 +516,8 @@ class Moderation(commands.Cog): """Toggle automatically messaging moderated users. This option can be overridden by specifying the `silent` argument in any moderation command.""" - await self.config.dm_users.set(not await self.config.dm_users()) - await ctx.send(f"DM users setting set to {await self.config.dm_users()}") + await self.config.guild(ctx.guild.id).dm_users.set(not await self.config.guild(ctx.guild.id).dm_users()) + await ctx.send(f"DM users setting set to {await self.config.guild(ctx.guild.id).dm_users()}") @moderationset.command(name="mysql") @checks.is_owner()