misc(aurora): reworked embed_factory
All checks were successful
Build Documentation and Lint Code / build and lint (push) Successful in 22s

This commit is contained in:
SeaswimmerTheFsh 2024-01-08 09:18:54 +00:00
parent e4d7c5757a
commit aefb68e913
Signed by: cswimr
GPG key ID: D74DDDDF420E13DF
4 changed files with 246 additions and 239 deletions

View file

@ -24,7 +24,7 @@ from .importers.galacticbot import ImportGalacticBotView
from .importers.aurora import ImportAuroraView
from .utilities.config import config, register_config
from .utilities.database import connect, create_guild_table, fetch_case, mysql_log
from .utilities.embed_factory import embed_factory
from .utilities.factory import case_factory, changes_factory, evidenceformat_factory, message_factory
from .utilities.logger import logger
from .utilities.utils import convert_timedelta_to_str, check_moddable, check_permissions, fetch_channel_dict, fetch_user_dict, generate_dict, log, send_evidenceformat
@ -35,7 +35,7 @@ class Aurora(commands.Cog):
This cog stores all of its data in an SQLite database."""
__author__ = "SeaswimmerTheFsh"
__version__ = "2.0.0"
__version__ = "2.0.1"
async def red_delete_data_for_user(self, *, requester, user_id: int):
if requester == "discord_deleted_user":
@ -162,7 +162,7 @@ class Aurora(commands.Cog):
silent = not await config.guild(interaction.guild).dm_users()
if silent is False:
try:
embed = await embed_factory('message', await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='note', response=await interaction.original_response())
embed = await message_factory(await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='note', response=await interaction.original_response())
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -195,7 +195,7 @@ class Aurora(commands.Cog):
silent = not await config.guild(interaction.guild).dm_users()
if silent is False:
try:
embed = await embed_factory('message', await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='warned', response=await interaction.original_response())
embed = await message_factory(await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='warned', response=await interaction.original_response())
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -251,7 +251,7 @@ class Aurora(commands.Cog):
silent = not await config.guild(interaction.guild).dm_users()
if silent is False:
try:
embed = await embed_factory('message', await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='blacklisted', response=await interaction.original_response(), duration=matching_role['duration'])
embed = await message_factory(await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='blacklisted', response=await interaction.original_response(), duration=matching_role['duration'])
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -306,7 +306,7 @@ class Aurora(commands.Cog):
silent = not await config.guild(interaction.guild).dm_users()
if silent is False:
try:
embed = await embed_factory('message', await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='muted', response=await interaction.original_response(), duration=parsed_time)
embed = await message_factory(await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='muted', response=await interaction.original_response(), duration=parsed_time)
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -349,7 +349,7 @@ class Aurora(commands.Cog):
silent = not await config.guild(interaction.guild).dm_users()
if silent is False:
try:
embed = await embed_factory('message', await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='unmuted', response=await interaction.original_response())
embed = await message_factory(await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='unmuted', response=await interaction.original_response())
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -382,7 +382,7 @@ class Aurora(commands.Cog):
silent = not await config.guild(interaction.guild).dm_users()
if silent is False:
try:
embed = await embed_factory('message', await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='kicked', response=await interaction.original_response())
embed = await message_factory(await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='kicked', response=await interaction.original_response())
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -445,7 +445,7 @@ class Aurora(commands.Cog):
await interaction.response.send_message(content=f"{target.mention} has been banned for {humanize.precisedelta(parsed_time)}!\n**Reason** - `{reason}`")
try:
embed = await embed_factory('message', await self.bot.get_embed_color(interaction.channel) , guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='tempbanned', response=await interaction.original_response(), duration=parsed_time)
embed = await message_factory(await self.bot.get_embed_color(interaction.channel) , guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='tempbanned', response=await interaction.original_response(), duration=parsed_time)
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -465,7 +465,7 @@ class Aurora(commands.Cog):
silent = not await config.guild(interaction.guild).dm_users()
if silent is False:
try:
embed = embed = await embed_factory('message', await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='banned', response=await interaction.original_response())
embed = embed = await message_factory(await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='banned', response=await interaction.original_response())
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -512,7 +512,7 @@ class Aurora(commands.Cog):
silent = not await config.guild(interaction.guild).dm_users()
if silent is False:
try:
embed = await embed_factory('message', await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='unbanned', response=await interaction.original_response())
embed = await message_factory(await self.bot.get_embed_color(interaction.channel), guild=interaction.guild, moderator=interaction.user, reason=reason, moderation_type='unbanned', response=await interaction.original_response())
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -765,7 +765,7 @@ class Aurora(commands.Cog):
cursor.execute(resolve_query, (json.dumps(changes), interaction.user.id, reason, case_dict['moderation_id']))
database.commit()
embed = await embed_factory('case', await self.bot.get_embed_color(interaction.channel), interaction=interaction, case_dict=await fetch_case(case, interaction.guild.id))
embed = await case_factory(interaction=interaction, case_dict=await fetch_case(case, interaction.guild.id))
await interaction.response.send_message(content=f"✅ Moderation #{case:,} resolved!", embed=embed)
await log(interaction, case, resolved=True)
@ -822,13 +822,13 @@ class Aurora(commands.Cog):
await interaction.response.send_message(content=box({json.dumps(case_dict, indent=2)}), ephemeral=ephemeral)
return
if changes:
embed = await embed_factory('changes', await self.bot.get_embed_color(interaction.channel), interaction=interaction, case_dict=case_dict)
embed = await changes_factory(interaction=interaction, case_dict=case_dict)
await interaction.response.send_message(embed=embed, ephemeral=ephemeral)
elif evidenceformat:
content = await embed_factory('evidenceformat', await self.bot.get_embed_color(interaction.channel), interaction=interaction, case_dict=case_dict)
content = await evidenceformat_factory(interaction=interaction, case_dict=case_dict)
await interaction.response.send_message(content=content, ephemeral=ephemeral)
else:
embed = await embed_factory('case', await self.bot.get_embed_color(interaction.channel), interaction=interaction, case_dict=case_dict)
embed = await case_factory(interaction=interaction, case_dict=case_dict)
await interaction.response.send_message(embed=embed, ephemeral=ephemeral)
return
await interaction.response.send_message(content=f"No case with case number `{case}` found.", ephemeral=True)
@ -925,7 +925,7 @@ class Aurora(commands.Cog):
database.commit()
new_case = await fetch_case(case, interaction.guild.id)
embed = await embed_factory('case', await self.bot.get_embed_color(interaction.channel), interaction=interaction, case_dict=new_case)
embed = await case_factory(interaction=interaction, case_dict=new_case)
await interaction.response.send_message(content=f"✅ Moderation #{case:,} edited!", embed=embed, ephemeral=True)
await log(interaction, case)
@ -965,7 +965,7 @@ class Aurora(commands.Cog):
try:
await guild.unban(user, reason=f"Automatic unban from case #{moderation_id}")
embed = await embed_factory('message', await self.bot.get_embed_color(guild.channels[0]), guild=guild, reason=f'Automatic unban from case #{moderation_id}', moderation_type='unbanned')
embed = await message_factory(await self.bot.get_embed_color(guild.channels[0]), guild=guild, reason=f'Automatic unban from case #{moderation_id}', moderation_type='unbanned')
try:
await user.send(embed=embed)