fix(moderation): hopefully fixed embed_factory
Some checks failed
Pylint / Pylint (3.10) (push) Failing after 47s

This commit is contained in:
Seaswimmer 2023-12-17 03:33:09 -05:00
parent 31fa5eb937
commit dbb3e7b278
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

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