Revert "fix(moderation): hopefully fixed embed_factory"
Some checks failed
Pylint / Pylint (3.10) (push) Has been cancelled

This reverts commit dbb3e7b278.
This commit is contained in:
Seaswimmer 2023-12-17 03:35:59 -05:00
parent dbb3e7b278
commit 920e70d7b1
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

@ -197,8 +197,7 @@ class Moderation(commands.Cog):
silent = not await self.config.guild(interaction.guild).dm_users()
if silent is False:
try:
color = await self.bot.get_embed_color(None)
embed = await embed_factory('message', color, guild=interaction.guild, reason=reason, moderation_type='note', response=await interaction.original_response())
embed = await embed_factory('message', await self.bot.get_embed_color(None), guild=interaction.guild, reason=reason, moderation_type='note', response=await interaction.original_response())
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -228,8 +227,7 @@ class Moderation(commands.Cog):
silent = not await self.config.guild(interaction.guild).dm_users()
if silent is False:
try:
color = await self.bot.get_embed_color(None)
embed = await embed_factory('message', color, guild=interaction.guild, reason=reason, moderation_type='warned', response=await interaction.original_response())
embed = await embed_factory('message', await self.bot.get_embed_color(None), guild=interaction.guild, reason=reason, moderation_type='warned', response=await interaction.original_response())
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -289,8 +287,7 @@ class Moderation(commands.Cog):
silent = not await self.config.guild(interaction.guild).dm_users()
if silent is False:
try:
color = await self.bot.get_embed_color(None)
embed = await embed_factory('message', color, guild=interaction.guild, reason=reason, moderation_type='blacklisted', response=await interaction.original_response(), duration=matching_role['duration'])
embed = await embed_factory('message', await self.bot.get_embed_color(None), guild=interaction.guild, reason=reason, moderation_type='blacklisted', response=await interaction.original_response(), duration=matching_role['duration'])
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -342,8 +339,7 @@ class Moderation(commands.Cog):
silent = not await self.config.guild(interaction.guild).dm_users()
if silent is False:
try:
color = await self.bot.get_embed_color(None)
embed = await embed_factory('message', color, guild=interaction.guild, reason=reason, moderation_type='muted', response=await interaction.original_response(), duration=parsed_time)
embed = await embed_factory('message', await self.bot.get_embed_color(None), guild=interaction.guild, reason=reason, moderation_type='muted', response=await interaction.original_response(), duration=parsed_time)
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -383,8 +379,7 @@ class Moderation(commands.Cog):
silent = not await self.config.guild(interaction.guild).dm_users()
if silent is False:
try:
color = await self.bot.get_embed_color(None)
embed = await embed_factory('message', color, guild=interaction.guild, reason=reason, moderation_type='unmuted', response=await interaction.original_response())
embed = await embed_factory('message', await self.bot.get_embed_color(None), guild=interaction.guild, reason=reason, moderation_type='unmuted', response=await interaction.original_response())
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -414,8 +409,7 @@ class Moderation(commands.Cog):
silent = not await self.config.guild(interaction.guild).dm_users()
if silent is False:
try:
color = await self.bot.get_embed_color(None)
embed = await embed_factory('message', color, guild=interaction.guild, reason=reason, moderation_type='kicked', response=await interaction.original_response())
embed = await embed_factory('message', await self.bot.get_embed_color(None), guild=interaction.guild, reason=reason, moderation_type='kicked', response=await interaction.original_response())
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -470,8 +464,7 @@ class Moderation(commands.Cog):
await interaction.response.send_message(content=f"{target.mention} has been banned for {humanize.precisedelta(parsed_time)}!\n**Reason** - `{reason}`")
try:
color = await self.bot.get_embed_color(None)
embed = await embed_factory('message', color, guild=interaction.guild, reason=reason, moderation_type='tempbanned', response=await interaction.original_response(), duration=parsed_time)
embed = await embed_factory('message', await self.bot.get_embed_color(None), guild=interaction.guild, reason=reason, moderation_type='tempbanned', response=await interaction.original_response(), duration=parsed_time)
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -488,8 +481,7 @@ class Moderation(commands.Cog):
silent = not await self.config.guild(interaction.guild).dm_users()
if silent is False:
try:
color = await self.bot.get_embed_color(None)
embed = embed = await embed_factory('message', color, guild=interaction.guild, reason=reason, moderation_type='banned', response=await interaction.original_response())
embed = embed = await embed_factory('message', await self.bot.get_embed_color(None), guild=interaction.guild, reason=reason, moderation_type='banned', response=await interaction.original_response())
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -533,8 +525,7 @@ class Moderation(commands.Cog):
silent = not await self.config.guild(interaction.guild).dm_users()
if silent is False:
try:
color = await self.bot.get_embed_color(None)
embed = await embed_factory('message', color, guild=interaction.guild, reason=reason, moderation_type='unbanned', response=await interaction.original_response())
embed = await embed_factory('message', await self.bot.get_embed_color(None), guild=interaction.guild, reason=reason, moderation_type='unbanned', response=await interaction.original_response())
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
@ -771,8 +762,7 @@ class Moderation(commands.Cog):
cursor.execute(resolve_query, (json.dumps(changes), interaction.user.id, reason, case_dict['moderation_id']))
database.commit()
color = await self.bot.get_embed_color(None)
embed = await embed_factory('case', color, interaction=interaction, case_dict=await fetch_case(case, interaction.guild.id))
embed = await embed_factory('case', await self.bot.get_embed_color(None), 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)
@ -828,11 +818,10 @@ class Moderation(commands.Cog):
return
await interaction.response.send_message(content=f"```json\n{json.dumps(case_dict, indent=2)}```", ephemeral=ephemeral)
return
color = await self.bot.get_embed_color(None)
if changes:
embed = await embed_factory('changes', color, interaction=interaction, case_dict=case_dict)
embed = await embed_factory('changes', await self.bot.get_embed_color(None), interaction=interaction, case_dict=case_dict)
else:
embed = await embed_factory('case', color, interaction=interaction, case_dict=case_dict)
embed = await embed_factory('case', await self.bot.get_embed_color(None), 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)
@ -934,8 +923,7 @@ class Moderation(commands.Cog):
database.commit()
new_case = await fetch_case(case, interaction.guild.id)
color = await self.bot.get_embed_color(None)
embed = await embed_factory('case', color, interaction=interaction, case_dict=new_case)
embed = await embed_factory('case', await self.bot.get_embed_color(None), interaction=interaction, case_dict=new_case)
await interaction.response.send_message(content=f"✅ Moderation #{case:,} edited!", embed=embed, ephemeral=True)
await log(interaction, case)
@ -975,8 +963,7 @@ class Moderation(commands.Cog):
try:
await guild.unban(user, reason=f"Automatic unban from case #{moderation_id}")
color = await self.bot.get_embed_color(None)
embed = await embed_factory('message', color, guild, f'Automatic unban from case #{moderation_id}', 'unbanned')
embed = await embed_factory('message', self.bot.get_embed_color(None), guild, f'Automatic unban from case #{moderation_id}', 'unbanned')
try:
await user.send(embed=embed)