From a7fcbc4daba057c88921f53fd79eed1e27943a68 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:08:57 -0400 Subject: [PATCH 01/22] feat(aurora): implemented removerole command --- aurora/aurora.py | 123 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 119 insertions(+), 4 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 5d8ead0..758d549 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -18,7 +18,8 @@ from redbot.core import app_commands, commands, data_manager from redbot.core.app_commands import Choice from redbot.core.bot import Red from redbot.core.commands.converter import parse_relativedelta, parse_timedelta -from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning +from redbot.core.utils.chat_formatting import (box, error, humanize_list, + humanize_timedelta, warning) from aurora.importers.aurora import ImportAuroraView from aurora.importers.galacticbot import ImportGalacticBotView @@ -27,10 +28,18 @@ from aurora.menus.guild import Guild from aurora.menus.immune import Immune from aurora.menus.overrides import Overrides from aurora.utilities.config import config, register_config -from aurora.utilities.database import connect, create_guild_table, fetch_case, mysql_log -from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed +from aurora.utilities.database import (connect, create_guild_table, fetch_case, + mysql_log) +from aurora.utilities.factory import (addrole_embed, case_factory, + changes_factory, evidenceformat_factory, + guild_embed, immune_embed, + message_factory, overrides_embed) from aurora.utilities.logger import logger -from aurora.utilities.utils import check_moddable, check_permissions, convert_timedelta_to_str, fetch_channel_dict, fetch_user_dict, generate_dict, log, send_evidenceformat, timedelta_from_relativedelta +from aurora.utilities.utils import (check_moddable, check_permissions, + convert_timedelta_to_str, + fetch_channel_dict, fetch_user_dict, + generate_dict, log, send_evidenceformat, + timedelta_from_relativedelta) class Aurora(commands.Cog): @@ -396,6 +405,112 @@ class Aurora(commands.Cog): case = await fetch_case(moderation_id, interaction.guild.id) await send_evidenceformat(interaction, case) + @app_commands.command(name="removerole") + async def removerole( + self, + interaction: discord.Interaction, + target: discord.Member, + role: discord.Role, + reason: str, + duration: str = None, + silent: bool = None, + ): + """Add a role to a user. + + Parameters + ----------- + target: discord.Member + Who are you removing a role from? + role: discord.Role + What role are you removing from the target? + reason: str + Why are you removing a role from this user? + duration: str + How long are you removing this role for? + silent: bool + Should the user be messaged?""" + addrole_whitelist = await config.guild(interaction.guild).addrole_whitelist() + + if not addrole_whitelist: + await interaction.response.send_message( + content=error("There are no whitelisted roles set for this server!"), + ephemeral=True, + ) + return + + if duration is not None: + parsed_time = parse_timedelta(duration) + if parsed_time is None: + await interaction.response.send_message( + content=error("Please provide a valid duration!"), ephemeral=True + ) + return + else: + parsed_time = "NULL" + + if role.id not in addrole_whitelist: + await interaction.response.send_message( + content=error("That role isn't whitelisted!"), ephemeral=True + ) + return + + if not await check_moddable( + target, interaction, ["moderate_members", "manage_roles"] + ): + return + + if role.id not in [user_role.id for user_role in target.roles]: + await interaction.response.send_message( + content=error(f"{target.mention} does not have this role!"), + ephemeral=True, + ) + return + + await interaction.response.defer() + if silent is None: + silent = not await config.guild(interaction.guild).dm_users() + if silent is False: + try: + embed = await message_factory( + await self.bot.get_embed_color(interaction.channel), + guild=interaction.guild, + moderator=interaction.user, + reason=reason, + moderation_type="addrole", + response=await interaction.original_response(), + duration=parsed_time, + role=role, + ) + await target.send(embed=embed) + except discord.errors.HTTPException: + pass + + await target.add_roles( + role, + reason=f"Role removed by {interaction.user.id}{(' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else '')} for: {reason}", + ) + response: discord.WebhookMessage = await interaction.followup.send( + content=f"{target.mention} has had the {role.mention} role removed{(' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else '')}!\n**Reason** - `{reason}`" + ) + + moderation_id = await mysql_log( + interaction.guild.id, + interaction.user.id, + "REMOVEROLE", + "USER", + target.id, + role.id, + parsed_time, + reason, + ) + await response.edit( + content=f"{target.mention} has had the {role.mention} role removed{(' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else '')}! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`", + ) + await log(interaction, moderation_id) + + case = await fetch_case(moderation_id, interaction.guild.id) + await send_evidenceformat(interaction, case) + @app_commands.command(name="mute") async def mute( self, From b8a4d247f876016a641c349c8ad22babd8ecfb12 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:09:23 -0400 Subject: [PATCH 02/22] fix(aurora): fixed a bug in /case with exports to codeblocks being improperly formatted --- aurora/aurora.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 758d549..42804a7 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -1421,7 +1421,7 @@ class Aurora(commands.Cog): os.remove(filename) return await interaction.response.send_message( - content=box({json.dumps(case_dict, indent=2)}), + content=box(json.dumps(case_dict, indent=2), 'json'), ephemeral=ephemeral, ) return From f6b827c64fce78cc0f623e81f74ea7091687b734 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:09:48 -0400 Subject: [PATCH 03/22] feat(aurora): added expiry handling for addrole and removerole --- aurora/aurora.py | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 42804a7..144b2a8 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -1670,12 +1670,9 @@ class Aurora(commands.Cog): e, ) - expiry_query = f"UPDATE `moderation_{guild.id}` SET expired = 1 WHERE (end_timestamp != 0 AND end_timestamp <= ? AND expired = 0 AND moderation_type != 'BLACKLIST') OR (expired = 0 AND resolved = 1 AND moderation_type != 'BLACKLIST')" - cursor.execute(expiry_query, (time.time(),)) - - blacklist_query = f"SELECT target_id, moderation_id, role_id FROM moderation_{guild.id} WHERE end_timestamp != 0 AND end_timestamp <= ? AND moderation_type = 'BLACKLIST' AND expired = 0" + addrole_query = f"SELECT target_id, moderation_id, role_id FROM moderation_{guild.id} WHERE end_timestamp != 0 AND end_timestamp <= ? AND moderation_type = 'ADDROLE' AND expired = 0" try: - cursor.execute(blacklist_query, (time.time(),)) + cursor.execute(addrole_query, (time.time(),)) result = cursor.fetchall() except sqlite3.OperationalError: continue @@ -1687,11 +1684,15 @@ class Aurora(commands.Cog): target_ids, moderation_ids, role_ids ): try: - # member: discord.Member = await guild.fetch_member(target_id) + member = await guild.fetch_member(target_id) - role: discord.Role = guild.get_role(role_id) + role = guild.get_role(role_id) if role is None: raise discord.errors.NotFound + + await member.remove_roles( + role, reason=f"Automatic role removal from case #{moderation_id}" + ) except ( discord.errors.NotFound, discord.errors.Forbidden, @@ -1699,6 +1700,39 @@ class Aurora(commands.Cog): ): continue + removerole_query = f"SELECT target_id, moderation_id, role_id FROM moderation_{guild.id} WHERE end_timestamp != 0 AND end_timestamp <= ? AND moderation_type = 'REMOVEROLE' AND expired = 0" + try: + cursor.execute(removerole_query, (time.time(),)) + result = cursor.fetchall() + except sqlite3.OperationalError: + continue + target_ids = [row[0] for row in result] + moderation_ids = [row[1] for row in result] + role_ids = [row[2] for row in result] + + for target_id, moderation_id, role_id in zip( + target_ids, moderation_ids, role_ids + ): + try: + member = await guild.fetch_member(target_id) + + role = guild.get_role(role_id) + if role is None: + raise discord.errors.NotFound + + await member.add_roles( + role, reason=f"Automatic role addition from case #{moderation_id}" + ) + except ( + discord.errors.NotFound, + discord.errors.Forbidden, + discord.errors.HTTPException, + ): + continue + + expiry_query = f"UPDATE `moderation_{guild.id}` SET expired = 1 WHERE (end_timestamp != 0 AND end_timestamp <= ? AND expired = 0) OR (expired = 0 AND resolved = 1" + cursor.execute(expiry_query, (time.time(),)) + per_guild_completion_time = (time.time() - time_per_guild) * 1000 logger.debug( "Completed expiry loop for %s (%s) in %sms with %s users unbanned", From ebf739b563530d30e2d08f8f134cef410f962217 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:10:26 -0400 Subject: [PATCH 04/22] feat(aurora): added a listener to readd roles to a user on guild join --- aurora/aurora.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/aurora/aurora.py b/aurora/aurora.py index 144b2a8..c890109 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -122,6 +122,20 @@ class Aurora(commands.Cog): except ConnectionRefusedError: return + @commands.Cog.listener("on_member_join") + async def addrole_on_member_join(self, member: discord.Member): + """This method automatically adds roles to users when they join the server.""" + if not await self.bot.cog_disabled_in_guild(self, member.guild): + query = f"""SELECT moderation_id, role_id, reason FROM moderation_{member.guild.id} WHERE target_id = ? AND action = 'ADDROLE' AND expired = 0 AND resolved = 0;""" + database = connect() + cursor = database.cursor() + cursor.execute(query, (member.id,)) + results = cursor.fetchall() + for result in results: + role = member.guild.get_role(result[1]) + reason = result[2] + await member.add_roles(role, reason=f"Role automatically added on member rejoin for: {reason} (Case #{result[0]:,})") + @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").""" From 0642d5eb42189665c86146c13d5e057f9bc9d602 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:18:29 -0400 Subject: [PATCH 05/22] fix(aurora): fixed a bug in addrole and removerole with string concatenation --- aurora/aurora.py | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index c890109..532fea8 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -18,8 +18,7 @@ from redbot.core import app_commands, commands, data_manager from redbot.core.app_commands import Choice from redbot.core.bot import Red from redbot.core.commands.converter import parse_relativedelta, parse_timedelta -from redbot.core.utils.chat_formatting import (box, error, humanize_list, - humanize_timedelta, warning) +from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning from aurora.importers.aurora import ImportAuroraView from aurora.importers.galacticbot import ImportGalacticBotView @@ -28,18 +27,10 @@ from aurora.menus.guild import Guild from aurora.menus.immune import Immune from aurora.menus.overrides import Overrides from aurora.utilities.config import config, register_config -from aurora.utilities.database import (connect, create_guild_table, fetch_case, - mysql_log) -from aurora.utilities.factory import (addrole_embed, case_factory, - changes_factory, evidenceformat_factory, - guild_embed, immune_embed, - message_factory, overrides_embed) +from aurora.utilities.database import connect, create_guild_table, fetch_case, mysql_log +from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed from aurora.utilities.logger import logger -from aurora.utilities.utils import (check_moddable, check_permissions, - convert_timedelta_to_str, - fetch_channel_dict, fetch_user_dict, - generate_dict, log, send_evidenceformat, - timedelta_from_relativedelta) +from aurora.utilities.utils import check_moddable, check_permissions, convert_timedelta_to_str, fetch_channel_dict, fetch_user_dict, generate_dict, log, send_evidenceformat, timedelta_from_relativedelta class Aurora(commands.Cog): @@ -395,10 +386,10 @@ class Aurora(commands.Cog): await target.add_roles( role, - reason=f"Role added by {interaction.user.id}{(' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else '')} for: {reason}", + reason=f"Role added by {interaction.user.id}{' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else ''} for: {reason}", ) response: discord.WebhookMessage = await interaction.followup.send( - content=f"{target.mention} has been given the {role.mention} role{(' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else '')}!\n**Reason** - `{reason}`" + content=f"{target.mention} has been given the {role.mention} role{' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else ''}!\n**Reason** - `{reason}`" ) moderation_id = await mysql_log( @@ -412,7 +403,7 @@ class Aurora(commands.Cog): reason, ) await response.edit( - content=f"{target.mention} has been given the {role.mention} role{(' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else '')}! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`", + content=f"{target.mention} has been given the {role.mention} role{' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else ''}! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`", ) await log(interaction, moderation_id) @@ -501,10 +492,10 @@ class Aurora(commands.Cog): await target.add_roles( role, - reason=f"Role removed by {interaction.user.id}{(' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else '')} for: {reason}", + reason=f"Role removed by {interaction.user.id}{' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else ''} for: {reason}", ) response: discord.WebhookMessage = await interaction.followup.send( - content=f"{target.mention} has had the {role.mention} role removed{(' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else '')}!\n**Reason** - `{reason}`" + content=f"{target.mention} has had the {role.mention} role removed{' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else ''}!\n**Reason** - `{reason}`" ) moderation_id = await mysql_log( @@ -518,7 +509,7 @@ class Aurora(commands.Cog): reason, ) await response.edit( - content=f"{target.mention} has had the {role.mention} role removed{(' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else '')}! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`", + content=f"{target.mention} has had the {role.mention} role removed{' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else ''}! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`", ) await log(interaction, moderation_id) From 752a41855ae4203c7f118061de38736fce22e005 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:21:30 -0400 Subject: [PATCH 06/22] fix(aurora): actually fixed the string concatenation bug --- aurora/aurora.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 532fea8..25c5cd4 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -18,7 +18,8 @@ from redbot.core import app_commands, commands, data_manager from redbot.core.app_commands import Choice from redbot.core.bot import Red from redbot.core.commands.converter import parse_relativedelta, parse_timedelta -from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning +from redbot.core.utils.chat_formatting import (box, error, humanize_list, + humanize_timedelta, warning) from aurora.importers.aurora import ImportAuroraView from aurora.importers.galacticbot import ImportGalacticBotView @@ -27,10 +28,18 @@ from aurora.menus.guild import Guild from aurora.menus.immune import Immune from aurora.menus.overrides import Overrides from aurora.utilities.config import config, register_config -from aurora.utilities.database import connect, create_guild_table, fetch_case, mysql_log -from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed +from aurora.utilities.database import (connect, create_guild_table, fetch_case, + mysql_log) +from aurora.utilities.factory import (addrole_embed, case_factory, + changes_factory, evidenceformat_factory, + guild_embed, immune_embed, + message_factory, overrides_embed) from aurora.utilities.logger import logger -from aurora.utilities.utils import check_moddable, check_permissions, convert_timedelta_to_str, fetch_channel_dict, fetch_user_dict, generate_dict, log, send_evidenceformat, timedelta_from_relativedelta +from aurora.utilities.utils import (check_moddable, check_permissions, + convert_timedelta_to_str, + fetch_channel_dict, fetch_user_dict, + generate_dict, log, send_evidenceformat, + timedelta_from_relativedelta) class Aurora(commands.Cog): @@ -386,10 +395,10 @@ class Aurora(commands.Cog): await target.add_roles( role, - reason=f"Role added by {interaction.user.id}{' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else ''} for: {reason}", + reason=f"Role added by {interaction.user.id}{' for ' + humanize_timedelta(timedelta=parsed_time) if parsed_time != 'NULL' else ''} for: {reason}", ) response: discord.WebhookMessage = await interaction.followup.send( - content=f"{target.mention} has been given the {role.mention} role{' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else ''}!\n**Reason** - `{reason}`" + content=f"{target.mention} has been given the {role.mention} role{' for ' + humanize_timedelta(timedelta=parsed_time) if parsed_time != 'NULL' else ''}!\n**Reason** - `{reason}`" ) moderation_id = await mysql_log( @@ -403,7 +412,7 @@ class Aurora(commands.Cog): reason, ) await response.edit( - content=f"{target.mention} has been given the {role.mention} role{' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else ''}! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`", + content=f"{target.mention} has been given the {role.mention} role{' for ' + humanize_timedelta(timedelta=parsed_time) if parsed_time != 'NULL' else ''}! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`", ) await log(interaction, moderation_id) @@ -492,10 +501,10 @@ class Aurora(commands.Cog): await target.add_roles( role, - reason=f"Role removed by {interaction.user.id}{' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else ''} for: {reason}", + reason=f"Role removed by {interaction.user.id}{' for ' + humanize_timedelta(timedelta=parsed_time) if parsed_time != 'NULL' else ''} for: {reason}", ) response: discord.WebhookMessage = await interaction.followup.send( - content=f"{target.mention} has had the {role.mention} role removed{' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else ''}!\n**Reason** - `{reason}`" + content=f"{target.mention} has had the {role.mention} role removed{' for ' + humanize_timedelta(timedelta=parsed_time) if parsed_time != 'NULL' else ''}!\n**Reason** - `{reason}`" ) moderation_id = await mysql_log( @@ -509,7 +518,7 @@ class Aurora(commands.Cog): reason, ) await response.edit( - content=f"{target.mention} has had the {role.mention} role removed{' for ' + {humanize_timedelta(timedelta=parsed_time)} if parsed_time != 'NULL' else ''}! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`", + content=f"{target.mention} has had the {role.mention} role removed{' for ' + humanize_timedelta(timedelta=parsed_time) if parsed_time != 'NULL' else ''}! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`", ) await log(interaction, moderation_id) From 6966ea161390563d0cf6e9f2bba69e983da55a48 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:24:16 -0400 Subject: [PATCH 07/22] fix(aurora): added a missing `)` in an sql query --- aurora/aurora.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 25c5cd4..4101a2b 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -18,8 +18,7 @@ from redbot.core import app_commands, commands, data_manager from redbot.core.app_commands import Choice from redbot.core.bot import Red from redbot.core.commands.converter import parse_relativedelta, parse_timedelta -from redbot.core.utils.chat_formatting import (box, error, humanize_list, - humanize_timedelta, warning) +from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning from aurora.importers.aurora import ImportAuroraView from aurora.importers.galacticbot import ImportGalacticBotView @@ -28,18 +27,10 @@ from aurora.menus.guild import Guild from aurora.menus.immune import Immune from aurora.menus.overrides import Overrides from aurora.utilities.config import config, register_config -from aurora.utilities.database import (connect, create_guild_table, fetch_case, - mysql_log) -from aurora.utilities.factory import (addrole_embed, case_factory, - changes_factory, evidenceformat_factory, - guild_embed, immune_embed, - message_factory, overrides_embed) +from aurora.utilities.database import connect, create_guild_table, fetch_case, mysql_log +from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed from aurora.utilities.logger import logger -from aurora.utilities.utils import (check_moddable, check_permissions, - convert_timedelta_to_str, - fetch_channel_dict, fetch_user_dict, - generate_dict, log, send_evidenceformat, - timedelta_from_relativedelta) +from aurora.utilities.utils import check_moddable, check_permissions, convert_timedelta_to_str, fetch_channel_dict, fetch_user_dict, generate_dict, log, send_evidenceformat, timedelta_from_relativedelta class Aurora(commands.Cog): @@ -1744,7 +1735,7 @@ class Aurora(commands.Cog): ): continue - expiry_query = f"UPDATE `moderation_{guild.id}` SET expired = 1 WHERE (end_timestamp != 0 AND end_timestamp <= ? AND expired = 0) OR (expired = 0 AND resolved = 1" + expiry_query = f"UPDATE `moderation_{guild.id}` SET expired = 1 WHERE (end_timestamp != 0 AND end_timestamp <= ? AND expired = 0) OR (expired = 0 AND resolved = 1)" cursor.execute(expiry_query, (time.time(),)) per_guild_completion_time = (time.time() - time_per_guild) * 1000 From 8e59b5a4bdfd16499d35e5d55703ad1e9b0fa8dd Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:25:42 -0400 Subject: [PATCH 08/22] fix(aurora): added a missing `;` to an sql statement --- aurora/aurora.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 4101a2b..446c9a6 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -18,7 +18,8 @@ from redbot.core import app_commands, commands, data_manager from redbot.core.app_commands import Choice from redbot.core.bot import Red from redbot.core.commands.converter import parse_relativedelta, parse_timedelta -from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning +from redbot.core.utils.chat_formatting import (box, error, humanize_list, + humanize_timedelta, warning) from aurora.importers.aurora import ImportAuroraView from aurora.importers.galacticbot import ImportGalacticBotView @@ -27,10 +28,18 @@ from aurora.menus.guild import Guild from aurora.menus.immune import Immune from aurora.menus.overrides import Overrides from aurora.utilities.config import config, register_config -from aurora.utilities.database import connect, create_guild_table, fetch_case, mysql_log -from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed +from aurora.utilities.database import (connect, create_guild_table, fetch_case, + mysql_log) +from aurora.utilities.factory import (addrole_embed, case_factory, + changes_factory, evidenceformat_factory, + guild_embed, immune_embed, + message_factory, overrides_embed) from aurora.utilities.logger import logger -from aurora.utilities.utils import check_moddable, check_permissions, convert_timedelta_to_str, fetch_channel_dict, fetch_user_dict, generate_dict, log, send_evidenceformat, timedelta_from_relativedelta +from aurora.utilities.utils import (check_moddable, check_permissions, + convert_timedelta_to_str, + fetch_channel_dict, fetch_user_dict, + generate_dict, log, send_evidenceformat, + timedelta_from_relativedelta) class Aurora(commands.Cog): @@ -1735,7 +1744,7 @@ class Aurora(commands.Cog): ): continue - expiry_query = f"UPDATE `moderation_{guild.id}` SET expired = 1 WHERE (end_timestamp != 0 AND end_timestamp <= ? AND expired = 0) OR (expired = 0 AND resolved = 1)" + expiry_query = f"UPDATE `moderation_{guild.id}` SET expired = 1 WHERE (end_timestamp != 0 AND end_timestamp <= ? AND expired = 0) OR (expired = 0 AND resolved = 1);" cursor.execute(expiry_query, (time.time(),)) per_guild_completion_time = (time.time() - time_per_guild) * 1000 From f9e807957f6ef211f36cf1254b915dc16e3a0803 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:28:26 -0400 Subject: [PATCH 09/22] fix(aurora): why was I trying to raise an exception???? --- aurora/aurora.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 446c9a6..64987a6 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -1702,7 +1702,7 @@ class Aurora(commands.Cog): role = guild.get_role(role_id) if role is None: - raise discord.errors.NotFound + continue await member.remove_roles( role, reason=f"Automatic role removal from case #{moderation_id}" @@ -1732,7 +1732,7 @@ class Aurora(commands.Cog): role = guild.get_role(role_id) if role is None: - raise discord.errors.NotFound + continue await member.add_roles( role, reason=f"Automatic role addition from case #{moderation_id}" From dc8138bd89a7f3981370a98f7a36a795f0048deb Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:32:02 -0400 Subject: [PATCH 10/22] fix(aurora): added warning logging to the expiry task --- aurora/aurora.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 64987a6..b767ff7 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -18,8 +18,7 @@ from redbot.core import app_commands, commands, data_manager from redbot.core.app_commands import Choice from redbot.core.bot import Red from redbot.core.commands.converter import parse_relativedelta, parse_timedelta -from redbot.core.utils.chat_formatting import (box, error, humanize_list, - humanize_timedelta, warning) +from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning from aurora.importers.aurora import ImportAuroraView from aurora.importers.galacticbot import ImportGalacticBotView @@ -28,18 +27,10 @@ from aurora.menus.guild import Guild from aurora.menus.immune import Immune from aurora.menus.overrides import Overrides from aurora.utilities.config import config, register_config -from aurora.utilities.database import (connect, create_guild_table, fetch_case, - mysql_log) -from aurora.utilities.factory import (addrole_embed, case_factory, - changes_factory, evidenceformat_factory, - guild_embed, immune_embed, - message_factory, overrides_embed) +from aurora.utilities.database import connect, create_guild_table, fetch_case, mysql_log +from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed from aurora.utilities.logger import logger -from aurora.utilities.utils import (check_moddable, check_permissions, - convert_timedelta_to_str, - fetch_channel_dict, fetch_user_dict, - generate_dict, log, send_evidenceformat, - timedelta_from_relativedelta) +from aurora.utilities.utils import check_moddable, check_permissions, convert_timedelta_to_str, fetch_channel_dict, fetch_user_dict, generate_dict, log, send_evidenceformat, timedelta_from_relativedelta class Aurora(commands.Cog): @@ -1702,6 +1693,7 @@ class Aurora(commands.Cog): role = guild.get_role(role_id) if role is None: + logger.warning("Role %s does not exist in %s, unable to remove role from user %s", role_id, guild.id, target_id) continue await member.remove_roles( @@ -1732,6 +1724,7 @@ class Aurora(commands.Cog): role = guild.get_role(role_id) if role is None: + logger.warning("Role %s does not exist in %s, unable to add role to user %s", role_id, guild.id, target_id) continue await member.add_roles( From 67142c64589739024716c7d00c14652fbd9770b1 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:37:01 -0400 Subject: [PATCH 11/22] fix(aurora): added more verbose debug logging to the expiry task --- aurora/aurora.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index b767ff7..73bbf62 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -1628,7 +1628,7 @@ class Aurora(commands.Cog): target_ids = [row[0] for row in result] moderation_ids = [row[1] for row in result] - num = 0 + unban_num = 0 for target_id, moderation_id in zip(target_ids, moderation_ids): user: discord.User = await self.bot.fetch_user(target_id) name = ( @@ -1660,7 +1660,7 @@ class Aurora(commands.Cog): guild.name, guild.id, ) - num = num + 1 + unban_num = unban_num + 1 except ( discord.errors.NotFound, discord.errors.Forbidden, @@ -1675,6 +1675,7 @@ class Aurora(commands.Cog): e, ) + removerole_num = 0 addrole_query = f"SELECT target_id, moderation_id, role_id FROM moderation_{guild.id} WHERE end_timestamp != 0 AND end_timestamp <= ? AND moderation_type = 'ADDROLE' AND expired = 0" try: cursor.execute(addrole_query, (time.time(),)) @@ -1699,6 +1700,8 @@ class Aurora(commands.Cog): await member.remove_roles( role, reason=f"Automatic role removal from case #{moderation_id}" ) + + removerole_num = removerole_num + 1 except ( discord.errors.NotFound, discord.errors.Forbidden, @@ -1706,6 +1709,7 @@ class Aurora(commands.Cog): ): continue + addrole_num = 0 removerole_query = f"SELECT target_id, moderation_id, role_id FROM moderation_{guild.id} WHERE end_timestamp != 0 AND end_timestamp <= ? AND moderation_type = 'REMOVEROLE' AND expired = 0" try: cursor.execute(removerole_query, (time.time(),)) @@ -1730,6 +1734,8 @@ class Aurora(commands.Cog): await member.add_roles( role, reason=f"Automatic role addition from case #{moderation_id}" ) + + addrole_num = addrole_num + 1 except ( discord.errors.NotFound, discord.errors.Forbidden, @@ -1742,13 +1748,15 @@ class Aurora(commands.Cog): per_guild_completion_time = (time.time() - time_per_guild) * 1000 logger.debug( - "Completed expiry loop for %s (%s) in %sms with %s users unbanned", + "Completed expiry loop for %s (%s) in %sms with %s users unbanned, %s roles added, and %s roles removed", guild.name, guild.id, f"{per_guild_completion_time:.6f}", - num, + unban_num, + addrole_num, + removerole_num, ) - global_num = global_num + num + global_num = global_num + unban_num + addrole_num + removerole_num database.commit() cursor.close() @@ -1756,7 +1764,7 @@ class Aurora(commands.Cog): completion_time = (time.time() - current_time) * 1000 logger.debug( - "Completed expiry loop in %sms with %s users unbanned", + "Completed expiry loop in %sms with %s users unbanned, %s roles added, and %s roles removed", f"{completion_time:.6f}", global_num, ) From 1a74ce9130bfbc3908cd34f5d87fb1f927c54afc Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:38:07 -0400 Subject: [PATCH 12/22] fix(aurora): fixed a broken logging statement --- aurora/aurora.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 73bbf62..6a79224 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -1610,7 +1610,9 @@ class Aurora(commands.Cog): current_time = time.time() database = connect() cursor = database.cursor() - global_num = 0 + global_unban_num = 0 + global_addrole_num = 0 + global_removerole_num = 0 guilds: list[discord.Guild] = self.bot.guilds for guild in guilds: @@ -1756,7 +1758,9 @@ class Aurora(commands.Cog): addrole_num, removerole_num, ) - global_num = global_num + unban_num + addrole_num + removerole_num + global_unban_num = global_unban_num + unban_num + global_addrole_num = global_addrole_num + addrole_num + global_removerole_num = global_removerole_num + removerole_num database.commit() cursor.close() @@ -1766,7 +1770,9 @@ class Aurora(commands.Cog): logger.debug( "Completed expiry loop in %sms with %s users unbanned, %s roles added, and %s roles removed", f"{completion_time:.6f}", - global_num, + global_unban_num, + global_addrole_num, + global_removerole_num, ) ######################################################################################################################## From bcef643349bf3ba71c1689021598cb296f5aedf6 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:44:04 -0400 Subject: [PATCH 13/22] fix(aurora): fixed an incorrectly named column in on_member_join --- aurora/aurora.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 6a79224..e42f394 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -117,7 +117,7 @@ class Aurora(commands.Cog): async def addrole_on_member_join(self, member: discord.Member): """This method automatically adds roles to users when they join the server.""" if not await self.bot.cog_disabled_in_guild(self, member.guild): - query = f"""SELECT moderation_id, role_id, reason FROM moderation_{member.guild.id} WHERE target_id = ? AND action = 'ADDROLE' AND expired = 0 AND resolved = 0;""" + query = f"""SELECT moderation_id, role_id, reason FROM moderation_{member.guild.id} WHERE target_id = ? AND moderation_type = 'ADDROLE' AND expired = 0 AND resolved = 0;""" database = connect() cursor = database.cursor() cursor.execute(query, (member.id,)) From 877f5e00d30264adde59afcf308b52394ca9a662 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:47:19 -0400 Subject: [PATCH 14/22] fix(aurora): adding some more logging to the expiry task --- aurora/aurora.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index e42f394..3d7d3da 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -1694,13 +1694,8 @@ class Aurora(commands.Cog): try: member = await guild.fetch_member(target_id) - role = guild.get_role(role_id) - if role is None: - logger.warning("Role %s does not exist in %s, unable to remove role from user %s", role_id, guild.id, target_id) - continue - await member.remove_roles( - role, reason=f"Automatic role removal from case #{moderation_id}" + role_id, reason=f"Automatic role removal from case #{moderation_id}" ) removerole_num = removerole_num + 1 @@ -1708,7 +1703,13 @@ class Aurora(commands.Cog): discord.errors.NotFound, discord.errors.Forbidden, discord.errors.HTTPException, - ): + ) as e: + logger.error( + "Removing the role %s from user %s failed due to: \n%s", + role_id, + target_id, + e, + ) continue addrole_num = 0 @@ -1728,13 +1729,8 @@ class Aurora(commands.Cog): try: member = await guild.fetch_member(target_id) - role = guild.get_role(role_id) - if role is None: - logger.warning("Role %s does not exist in %s, unable to add role to user %s", role_id, guild.id, target_id) - continue - await member.add_roles( - role, reason=f"Automatic role addition from case #{moderation_id}" + role_id, reason=f"Automatic role addition from case #{moderation_id}" ) addrole_num = addrole_num + 1 @@ -1742,7 +1738,8 @@ class Aurora(commands.Cog): discord.errors.NotFound, discord.errors.Forbidden, discord.errors.HTTPException, - ): + ) as e: + logger.error("Adding the role %s to user %s failed due to: \n%s", role_id, target_id, e) continue expiry_query = f"UPDATE `moderation_{guild.id}` SET expired = 1 WHERE (end_timestamp != 0 AND end_timestamp <= ? AND expired = 0) OR (expired = 0 AND resolved = 1);" From 7ef13016d95c922a1e6681e96f3cd0919bfc79f0 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:51:02 -0400 Subject: [PATCH 15/22] fix(aurora): fixed an AttributeError in the expiry handler --- aurora/aurora.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 3d7d3da..c113b42 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -13,12 +13,14 @@ from datetime import datetime, timedelta, timezone from math import ceil import discord +from discord import Object from discord.ext import tasks from redbot.core import app_commands, commands, data_manager from redbot.core.app_commands import Choice from redbot.core.bot import Red from redbot.core.commands.converter import parse_relativedelta, parse_timedelta -from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning +from redbot.core.utils.chat_formatting import (box, error, humanize_list, + humanize_timedelta, warning) from aurora.importers.aurora import ImportAuroraView from aurora.importers.galacticbot import ImportGalacticBotView @@ -27,10 +29,18 @@ from aurora.menus.guild import Guild from aurora.menus.immune import Immune from aurora.menus.overrides import Overrides from aurora.utilities.config import config, register_config -from aurora.utilities.database import connect, create_guild_table, fetch_case, mysql_log -from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed +from aurora.utilities.database import (connect, create_guild_table, fetch_case, + mysql_log) +from aurora.utilities.factory import (addrole_embed, case_factory, + changes_factory, evidenceformat_factory, + guild_embed, immune_embed, + message_factory, overrides_embed) from aurora.utilities.logger import logger -from aurora.utilities.utils import check_moddable, check_permissions, convert_timedelta_to_str, fetch_channel_dict, fetch_user_dict, generate_dict, log, send_evidenceformat, timedelta_from_relativedelta +from aurora.utilities.utils import (check_moddable, check_permissions, + convert_timedelta_to_str, + fetch_channel_dict, fetch_user_dict, + generate_dict, log, send_evidenceformat, + timedelta_from_relativedelta) class Aurora(commands.Cog): @@ -1695,7 +1705,7 @@ class Aurora(commands.Cog): member = await guild.fetch_member(target_id) await member.remove_roles( - role_id, reason=f"Automatic role removal from case #{moderation_id}" + roles=[Object(role_id)], reason=f"Automatic role removal from case #{moderation_id}" ) removerole_num = removerole_num + 1 @@ -1730,7 +1740,7 @@ class Aurora(commands.Cog): member = await guild.fetch_member(target_id) await member.add_roles( - role_id, reason=f"Automatic role addition from case #{moderation_id}" + roles=[Object(role_id)], reason=f"Automatic role addition from case #{moderation_id}" ) addrole_num = addrole_num + 1 From 908fed37bcc838a5e90ccf8403a49083f16fb981 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:52:29 -0400 Subject: [PATCH 16/22] fix(aurora): fixed a TypeError in the expiry handler task --- aurora/aurora.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index c113b42..8bfef83 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -19,8 +19,7 @@ from redbot.core import app_commands, commands, data_manager from redbot.core.app_commands import Choice from redbot.core.bot import Red from redbot.core.commands.converter import parse_relativedelta, parse_timedelta -from redbot.core.utils.chat_formatting import (box, error, humanize_list, - humanize_timedelta, warning) +from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning from aurora.importers.aurora import ImportAuroraView from aurora.importers.galacticbot import ImportGalacticBotView @@ -29,18 +28,10 @@ from aurora.menus.guild import Guild from aurora.menus.immune import Immune from aurora.menus.overrides import Overrides from aurora.utilities.config import config, register_config -from aurora.utilities.database import (connect, create_guild_table, fetch_case, - mysql_log) -from aurora.utilities.factory import (addrole_embed, case_factory, - changes_factory, evidenceformat_factory, - guild_embed, immune_embed, - message_factory, overrides_embed) +from aurora.utilities.database import connect, create_guild_table, fetch_case, mysql_log +from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed from aurora.utilities.logger import logger -from aurora.utilities.utils import (check_moddable, check_permissions, - convert_timedelta_to_str, - fetch_channel_dict, fetch_user_dict, - generate_dict, log, send_evidenceformat, - timedelta_from_relativedelta) +from aurora.utilities.utils import check_moddable, check_permissions, convert_timedelta_to_str, fetch_channel_dict, fetch_user_dict, generate_dict, log, send_evidenceformat, timedelta_from_relativedelta class Aurora(commands.Cog): @@ -1705,7 +1696,7 @@ class Aurora(commands.Cog): member = await guild.fetch_member(target_id) await member.remove_roles( - roles=[Object(role_id)], reason=f"Automatic role removal from case #{moderation_id}" + Object(role_id), reason=f"Automatic role removal from case #{moderation_id}" ) removerole_num = removerole_num + 1 @@ -1740,7 +1731,7 @@ class Aurora(commands.Cog): member = await guild.fetch_member(target_id) await member.add_roles( - roles=[Object(role_id)], reason=f"Automatic role addition from case #{moderation_id}" + Object(role_id), reason=f"Automatic role addition from case #{moderation_id}" ) addrole_num = addrole_num + 1 From cd514d05354818fd9a892f69d593944058a17658 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:56:07 -0400 Subject: [PATCH 17/22] fix(aurora): fixed removerole adding roles instead of removing them --- aurora/aurora.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 8bfef83..324b32a 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -19,7 +19,8 @@ from redbot.core import app_commands, commands, data_manager from redbot.core.app_commands import Choice from redbot.core.bot import Red from redbot.core.commands.converter import parse_relativedelta, parse_timedelta -from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning +from redbot.core.utils.chat_formatting import (box, error, humanize_list, + humanize_timedelta, warning) from aurora.importers.aurora import ImportAuroraView from aurora.importers.galacticbot import ImportGalacticBotView @@ -28,10 +29,18 @@ from aurora.menus.guild import Guild from aurora.menus.immune import Immune from aurora.menus.overrides import Overrides from aurora.utilities.config import config, register_config -from aurora.utilities.database import connect, create_guild_table, fetch_case, mysql_log -from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed +from aurora.utilities.database import (connect, create_guild_table, fetch_case, + mysql_log) +from aurora.utilities.factory import (addrole_embed, case_factory, + changes_factory, evidenceformat_factory, + guild_embed, immune_embed, + message_factory, overrides_embed) from aurora.utilities.logger import logger -from aurora.utilities.utils import check_moddable, check_permissions, convert_timedelta_to_str, fetch_channel_dict, fetch_user_dict, generate_dict, log, send_evidenceformat, timedelta_from_relativedelta +from aurora.utilities.utils import (check_moddable, check_permissions, + convert_timedelta_to_str, + fetch_channel_dict, fetch_user_dict, + generate_dict, log, send_evidenceformat, + timedelta_from_relativedelta) class Aurora(commands.Cog): @@ -421,7 +430,7 @@ class Aurora(commands.Cog): duration: str = None, silent: bool = None, ): - """Add a role to a user. + """Remove a role from a user. Parameters ----------- @@ -491,7 +500,7 @@ class Aurora(commands.Cog): except discord.errors.HTTPException: pass - await target.add_roles( + await target.remove_roles( role, reason=f"Role removed by {interaction.user.id}{' for ' + humanize_timedelta(timedelta=parsed_time) if parsed_time != 'NULL' else ''} for: {reason}", ) From 38b0580228f8531c969100b0faa46d64ba67d46f Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 21:01:11 -0400 Subject: [PATCH 18/22] fix(aurora): updated message_factory for addrole support --- aurora/utilities/factory.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/aurora/utilities/factory.py b/aurora/utilities/factory.py index 3cfaf9e..86aee24 100644 --- a/aurora/utilities/factory.py +++ b/aurora/utilities/factory.py @@ -2,16 +2,12 @@ from datetime import datetime, timedelta from typing import Union -from discord import (Color, Embed, Guild, Interaction, InteractionMessage, - Member, Role, User) +from discord import Color, Embed, Guild, Interaction, InteractionMessage, Member, Role, User from redbot.core import commands -from redbot.core.utils.chat_formatting import (bold, box, error, - humanize_timedelta, warning) +from redbot.core.utils.chat_formatting import bold, box, error, humanize_timedelta, warning from aurora.utilities.config import config -from aurora.utilities.utils import (fetch_channel_dict, fetch_user_dict, - get_bool_emoji, get_next_case_number, - get_pagesize_str) +from aurora.utilities.utils import fetch_channel_dict, fetch_user_dict, get_bool_emoji, get_next_case_number, get_pagesize_str async def message_factory( @@ -50,6 +46,8 @@ async def message_factory( else: guild_name = guild.name + title = moderation_type + if moderation_type in ["tempbanned", "muted"] and duration: embed_duration = f" for {humanize_timedelta(timedelta=duration)}" else: @@ -59,13 +57,17 @@ async def message_factory( embed_desc = "received a" elif moderation_type == "addrole": embed_desc = f"received the {role.name} role" + title = "Role Added" + moderation_type = "" elif moderation_type == "removerole": embed_desc = f"lost the {role.name} role" + title = "Role Removed" + moderation_type = "" else: embed_desc = "been" embed = Embed( - title=str.title(moderation_type), + title=str.title(title), description=f"You have {embed_desc} {moderation_type}{embed_duration} in {guild_name}.", color=color, timestamp=datetime.now(), From a641b11daab74dcdfeefd132d82bb18b4858f968 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 21:02:16 -0400 Subject: [PATCH 19/22] fix(aurora): fixed the incorrect moderation type being passed to message_factory in /removerole --- aurora/aurora.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 324b32a..065bafe 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -19,8 +19,7 @@ from redbot.core import app_commands, commands, data_manager from redbot.core.app_commands import Choice from redbot.core.bot import Red from redbot.core.commands.converter import parse_relativedelta, parse_timedelta -from redbot.core.utils.chat_formatting import (box, error, humanize_list, - humanize_timedelta, warning) +from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning from aurora.importers.aurora import ImportAuroraView from aurora.importers.galacticbot import ImportGalacticBotView @@ -29,18 +28,10 @@ from aurora.menus.guild import Guild from aurora.menus.immune import Immune from aurora.menus.overrides import Overrides from aurora.utilities.config import config, register_config -from aurora.utilities.database import (connect, create_guild_table, fetch_case, - mysql_log) -from aurora.utilities.factory import (addrole_embed, case_factory, - changes_factory, evidenceformat_factory, - guild_embed, immune_embed, - message_factory, overrides_embed) +from aurora.utilities.database import connect, create_guild_table, fetch_case, mysql_log +from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed from aurora.utilities.logger import logger -from aurora.utilities.utils import (check_moddable, check_permissions, - convert_timedelta_to_str, - fetch_channel_dict, fetch_user_dict, - generate_dict, log, send_evidenceformat, - timedelta_from_relativedelta) +from aurora.utilities.utils import check_moddable, check_permissions, convert_timedelta_to_str, fetch_channel_dict, fetch_user_dict, generate_dict, log, send_evidenceformat, timedelta_from_relativedelta class Aurora(commands.Cog): @@ -491,7 +482,7 @@ class Aurora(commands.Cog): guild=interaction.guild, moderator=interaction.user, reason=reason, - moderation_type="addrole", + moderation_type="removerole", response=await interaction.original_response(), duration=parsed_time, role=role, From af108519f99792061ad93ac6f6c7c1d1a815206d Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 21:35:29 -0400 Subject: [PATCH 20/22] feat(aurora): imma be real chief i have no idea what i did this commit --- aurora/aurora.py | 39 +++++++++++++++++++++++------------- aurora/data/arrow.png | Bin 0 -> 6319 bytes aurora/utilities/factory.py | 12 +++++++---- aurora/utilities/utils.py | 9 +++++++-- 4 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 aurora/data/arrow.png diff --git a/aurora/aurora.py b/aurora/aurora.py index 065bafe..89664c0 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -19,7 +19,8 @@ from redbot.core import app_commands, commands, data_manager from redbot.core.app_commands import Choice from redbot.core.bot import Red from redbot.core.commands.converter import parse_relativedelta, parse_timedelta -from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning +from redbot.core.utils.chat_formatting import (box, error, humanize_list, + humanize_timedelta, warning) from aurora.importers.aurora import ImportAuroraView from aurora.importers.galacticbot import ImportGalacticBotView @@ -28,10 +29,19 @@ from aurora.menus.guild import Guild from aurora.menus.immune import Immune from aurora.menus.overrides import Overrides from aurora.utilities.config import config, register_config -from aurora.utilities.database import connect, create_guild_table, fetch_case, mysql_log -from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed +from aurora.utilities.database import (connect, create_guild_table, fetch_case, + mysql_log) +from aurora.utilities.factory import (addrole_embed, case_factory, + changes_factory, evidenceformat_factory, + guild_embed, immune_embed, + message_factory, overrides_embed) from aurora.utilities.logger import logger -from aurora.utilities.utils import check_moddable, check_permissions, convert_timedelta_to_str, fetch_channel_dict, fetch_user_dict, generate_dict, log, send_evidenceformat, timedelta_from_relativedelta +from aurora.utilities.utils import (check_moddable, check_permissions, + convert_timedelta_to_str, + fetch_channel_dict, fetch_user_dict, + generate_dict, get_footer_image, log, + send_evidenceformat, + timedelta_from_relativedelta) class Aurora(commands.Cog): @@ -224,7 +234,7 @@ class Aurora(commands.Cog): moderation_type="note", response=await interaction.original_response(), ) - await target.send(embed=embed) + await target.send(embed=embed, file=get_footer_image(self)) except discord.errors.HTTPException: pass @@ -283,7 +293,7 @@ class Aurora(commands.Cog): moderation_type="warned", response=await interaction.original_response(), ) - await target.send(embed=embed) + await target.send(embed=embed, file=get_footer_image(self)) except discord.errors.HTTPException: pass @@ -381,7 +391,7 @@ class Aurora(commands.Cog): duration=parsed_time, role=role, ) - await target.send(embed=embed) + await target.send(embed=embed, file=get_footer_image(self)) except discord.errors.HTTPException: pass @@ -487,7 +497,7 @@ class Aurora(commands.Cog): duration=parsed_time, role=role, ) - await target.send(embed=embed) + await target.send(embed=embed, file=get_footer_image(self)) except discord.errors.HTTPException: pass @@ -583,7 +593,7 @@ class Aurora(commands.Cog): response=await interaction.original_response(), duration=parsed_time, ) - await target.send(embed=embed) + await target.send(embed=embed, file=get_footer_image(self)) except discord.errors.HTTPException: pass @@ -658,7 +668,7 @@ class Aurora(commands.Cog): moderation_type="unmuted", response=await interaction.original_response(), ) - await target.send(embed=embed) + await target.send(embed=embed, file=get_footer_image(self)) except discord.errors.HTTPException: pass @@ -717,7 +727,7 @@ class Aurora(commands.Cog): moderation_type="kicked", response=await interaction.original_response(), ) - await target.send(embed=embed) + await target.send(embed=embed, file=get_footer_image(self)) except discord.errors.HTTPException: pass @@ -821,7 +831,7 @@ class Aurora(commands.Cog): response=await interaction.original_response(), duration=parsed_time, ) - await target.send(embed=embed) + await target.send(embed=embed, file=get_footer_image(self)) except discord.errors.HTTPException: pass @@ -865,7 +875,7 @@ class Aurora(commands.Cog): moderation_type="banned", response=await interaction.original_response(), ) - await target.send(embed=embed) + await target.send(embed=embed, file=get_footer_image(self)) except discord.errors.HTTPException: pass @@ -948,7 +958,7 @@ class Aurora(commands.Cog): moderation_type="unbanned", response=await interaction.original_response(), ) - await target.send(embed=embed) + await target.send(embed=embed, file=get_footer_image(self)) except discord.errors.HTTPException: pass @@ -1646,6 +1656,7 @@ class Aurora(commands.Cog): embed = await message_factory( await self.bot.get_embed_color(guild.channels[0]), + file=get_footer_image(self), guild=guild, reason=f"Automatic unban from case #{moderation_id}", moderation_type="unbanned", diff --git a/aurora/data/arrow.png b/aurora/data/arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..aedf12e53c700e75179027e0f7eca965547166d9 GIT binary patch literal 6319 zcmb_=X*kqh`1f~KjKNs4WG7o$CS_MMNcJszwy|W(R(8pJZ7ot1qHL2SehDqs$jFjJ z6j9kmlqE4jCdPc9`TyTNFP?YL{o>r8bDw*=&bhC1?(1B)w>9Iz9K-+sz++*4>I?wD z*$@tJBG|0E>QFzMA%l!;i~!(S4mZ;m#h%Ofo1d`(fFwl#05bq!mn{O903a3*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ztb6m9W%j3v)e!vjfUS;b5`6dLM4HSt6}c7vn>+0=`n;>r_HS?Oib{S>&bgU~Sw^3w ztkYV1#|YnKm5bBka;*VEk@8B!wBGN+sDCD-$i>SmU1Mbqo89M(ocUN6yGER--f61J zE8|bq-L5vNkNmU}M4L`y^VI%$-E`MzcUAqbZS6|xyu?s_%Y-THc72_8dthedM_#h& z=5FV3JtR|S4N2E1zfP_{SO_r2oqxJTf38F!BFw(Cl_ td: now = datetime.now() then = now - relativedelta return now - then + +def get_footer_image(coginstance: commands.Cog) -> File: + """Returns the footer image for the embeds.""" + image_path = data_manager.bundled_data_path(coginstance) / "arrow.png" + return File(image_path, filename="arrow.png", description="arrow") From 1d1795c26224806dfe97ae4f525661e59c88d18b Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 21:42:02 -0400 Subject: [PATCH 21/22] fix(aurora): added addrole/removerole support to case_factory --- aurora/utilities/factory.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/aurora/utilities/factory.py b/aurora/utilities/factory.py index af827e8..d7f4eb7 100644 --- a/aurora/utilities/factory.py +++ b/aurora/utilities/factory.py @@ -2,16 +2,12 @@ from datetime import datetime, timedelta from typing import Union -from discord import (Color, Embed, Guild, Interaction, InteractionMessage, - Member, Role, User) +from discord import Color, Embed, Guild, Interaction, InteractionMessage, Member, Role, User from redbot.core import commands -from redbot.core.utils.chat_formatting import (bold, box, error, - humanize_timedelta, warning) +from redbot.core.utils.chat_formatting import bold, box, error, humanize_timedelta, warning from aurora.utilities.config import config -from aurora.utilities.utils import (fetch_channel_dict, fetch_user_dict, - get_bool_emoji, get_next_case_number, - get_pagesize_str) +from aurora.utilities.utils import fetch_channel_dict, fetch_user_dict, get_bool_emoji, get_next_case_number, get_pagesize_str async def message_factory( @@ -273,6 +269,9 @@ async def case_factory(interaction: Interaction, case_dict: dict) -> Embed: else "\n**Changes:** 0" ) + if case_dict["role_id"]: + embed.description += f"\n**Role:** <@&{case_dict['role_id']}>" + if case_dict["metadata"]: if case_dict["metadata"]["imported_from"]: embed.description += ( From 6c859d72a8c7d5604ab618449c3b3a1ea792493c Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 21:45:04 -0400 Subject: [PATCH 22/22] fix(aurora): pylint fix --- aurora/aurora.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 89664c0..bff9976 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -19,8 +19,7 @@ from redbot.core import app_commands, commands, data_manager from redbot.core.app_commands import Choice from redbot.core.bot import Red from redbot.core.commands.converter import parse_relativedelta, parse_timedelta -from redbot.core.utils.chat_formatting import (box, error, humanize_list, - humanize_timedelta, warning) +from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning from aurora.importers.aurora import ImportAuroraView from aurora.importers.galacticbot import ImportGalacticBotView @@ -29,19 +28,10 @@ from aurora.menus.guild import Guild from aurora.menus.immune import Immune from aurora.menus.overrides import Overrides from aurora.utilities.config import config, register_config -from aurora.utilities.database import (connect, create_guild_table, fetch_case, - mysql_log) -from aurora.utilities.factory import (addrole_embed, case_factory, - changes_factory, evidenceformat_factory, - guild_embed, immune_embed, - message_factory, overrides_embed) +from aurora.utilities.database import connect, create_guild_table, fetch_case, mysql_log +from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed from aurora.utilities.logger import logger -from aurora.utilities.utils import (check_moddable, check_permissions, - convert_timedelta_to_str, - fetch_channel_dict, fetch_user_dict, - generate_dict, get_footer_image, log, - send_evidenceformat, - timedelta_from_relativedelta) +from aurora.utilities.utils import check_moddable, check_permissions, convert_timedelta_to_str, fetch_channel_dict, fetch_user_dict, generate_dict, get_footer_image, log, send_evidenceformat, timedelta_from_relativedelta class Aurora(commands.Cog): @@ -1656,14 +1646,13 @@ class Aurora(commands.Cog): embed = await message_factory( await self.bot.get_embed_color(guild.channels[0]), - file=get_footer_image(self), guild=guild, reason=f"Automatic unban from case #{moderation_id}", moderation_type="unbanned", ) try: - await user.send(embed=embed) + await user.send(embed=embed, file=get_footer_image(self)) except discord.errors.HTTPException: pass