feat(moderation): format case numbers
Some checks failed
Pylint / Pylint (3.10) (push) Failing after 54s
Some checks failed
Pylint / Pylint (3.10) (push) Failing after 54s
This commit is contained in:
parent
e9e2c20a58
commit
cef337132b
1 changed files with 19 additions and 19 deletions
|
@ -476,7 +476,7 @@ class Moderation(commands.Cog):
|
|||
embed = discord.Embed(title=str.title(moderation_type), description=f"You have {embed_desc} {moderation_type}{embed_duration} in {guild_name}.", color=await self.bot.get_embed_color(None), timestamp=datetime.now())
|
||||
embed.add_field(name='Reason', value=f"`{reason}`")
|
||||
embed.set_author(name=guild.name, icon_url=guild.icon.url)
|
||||
embed.set_footer(text=f"Case #{await self.get_next_case_number(guild.id)}", icon_url="https://cdn.discordapp.com/attachments/1070822161389994054/1159469476773904414/arrow-right-circle-icon-512x512-2p1e2aaw.png?ex=65312319&is=651eae19&hm=3cebdd28e805c13a79ec48ef87c32ca532ffa6b9ede2e48d0cf8e5e81f3a6818&")
|
||||
embed.set_footer(text=f"Case #{await self.get_next_case_number(guild.id):n}", icon_url="https://cdn.discordapp.com/attachments/1070822161389994054/1159469476773904414/arrow-right-circle-icon-512x512-2p1e2aaw.png?ex=65312319&is=651eae19&hm=3cebdd28e805c13a79ec48ef87c32ca532ffa6b9ede2e48d0cf8e5e81f3a6818&")
|
||||
|
||||
return embed
|
||||
|
||||
|
@ -487,7 +487,7 @@ class Moderation(commands.Cog):
|
|||
target_name = f"`{target_user['name']}`" if target_user['discriminator'] == "0" else f"`{target_user['name']}#{target_user['discriminator']}`"
|
||||
moderator_name = f"`{moderator_user['name']}`" if moderator_user['discriminator'] == "0" else f"`{moderator_user['name']}#{moderator_user['discriminator']}`"
|
||||
|
||||
embed = discord.Embed(title=f"📕 Case #{case_dict['moderation_id']}", color=await self.bot.get_embed_color(None))
|
||||
embed = discord.Embed(title=f"📕 Case #{case_dict['moderation_id']:n}", color=await self.bot.get_embed_color(None))
|
||||
embed.description = f"**Type:** {str.title(case_dict['moderation_type'])}\n**Target:** {target_name} ({target_user['id']})\n**Moderator:** {moderator_name} ({moderator_user['id']})\n**Resolved:** {bool(case_dict['resolved'])}\n**Timestamp:** <t:{case_dict['timestamp']}> | <t:{case_dict['timestamp']}:R>"
|
||||
|
||||
if case_dict['duration'] != 'NULL':
|
||||
|
@ -507,7 +507,7 @@ class Moderation(commands.Cog):
|
|||
return embed
|
||||
|
||||
if embed_type == 'changes':
|
||||
embed = discord.Embed(title=f"📕 Case #{case_dict['moderation_id']} Changes", color=await self.bot.get_embed_color(None))
|
||||
embed = discord.Embed(title=f"📕 Case #{case_dict['moderation_id']:n} Changes", color=await self.bot.get_embed_color(None))
|
||||
|
||||
memory_dict = {}
|
||||
|
||||
|
@ -543,7 +543,7 @@ class Moderation(commands.Cog):
|
|||
target_name = f"`{target_user['name']}`" if target_user['discriminator'] == "0" else f"`{target_user['name']}#{target_user['discriminator']}`"
|
||||
moderator_name = moderator_user['name'] if moderator_user['discriminator'] == "0" else f"{moderator_user['name']}#{moderator_user['discriminator']}"
|
||||
|
||||
embed = discord.Embed(title=f"📕 Case #{case_dict['moderation_id']} Resolved", color=await self.bot.get_embed_color(None))
|
||||
embed = discord.Embed(title=f"📕 Case #{case_dict['moderation_id']:n} Resolved", color=await self.bot.get_embed_color(None))
|
||||
|
||||
embed.description = f"**Type:** {str.title(case_dict['moderation_type'])}\n**Target:** {target_name} ({target_user['id']})\n**Moderator:** {moderator_name} ({moderator_user['id']})\n**Timestamp:** <t:{case_dict['timestamp']}> | <t:{case_dict['timestamp']}:R>"
|
||||
|
||||
|
@ -564,7 +564,7 @@ class Moderation(commands.Cog):
|
|||
target_name = f"`{target_user['name']}`" if target_user['discriminator'] == "0" else f"`{target_user['name']}#{target_user['discriminator']}`"
|
||||
moderator_name = moderator_user['name'] if moderator_user['discriminator'] == "0" else f"{moderator_user['name']}#{moderator_user['discriminator']}"
|
||||
|
||||
embed = discord.Embed(title=f"📕 Case #{case_dict['moderation_id']}", color=await self.bot.get_embed_color(None))
|
||||
embed = discord.Embed(title=f"📕 Case #{case_dict['moderation_id']:n}", color=await self.bot.get_embed_color(None))
|
||||
embed.description = f"**Type:** {str.title(case_dict['moderation_type'])}\n**Target:** {target_name} ({target_user['id']})\n**Moderator:** {moderator_name} ({moderator_user['id']})\n**Timestamp:** <t:{case_dict['timestamp']}> | <t:{case_dict['timestamp']}:R>"
|
||||
|
||||
if case_dict['duration'] != 'NULL':
|
||||
|
@ -635,7 +635,7 @@ class Moderation(commands.Cog):
|
|||
pass
|
||||
|
||||
moderation_id = await self.mysql_log(interaction.guild.id, interaction.user.id, 'NOTE', target.id, 0, 'NULL', reason)
|
||||
await interaction.edit_original_response(content=f"{target.mention} has received a note! (Case `#{moderation_id}`)\n**Reason** - `{reason}`")
|
||||
await interaction.edit_original_response(content=f"{target.mention} has received a note! (Case `#{moderation_id:n}`)\n**Reason** - `{reason}`")
|
||||
await self.log(interaction, moderation_id)
|
||||
|
||||
@app_commands.command(name="warn")
|
||||
|
@ -665,7 +665,7 @@ class Moderation(commands.Cog):
|
|||
pass
|
||||
|
||||
moderation_id = await self.mysql_log(interaction.guild.id, interaction.user.id, 'WARN', target.id, 0, 'NULL', reason)
|
||||
await interaction.edit_original_response(content=f"{target.mention} has been warned! (Case `#{moderation_id}`)\n**Reason** - `{reason}`")
|
||||
await interaction.edit_original_response(content=f"{target.mention} has been warned! (Case `#{moderation_id:n}`)\n**Reason** - `{reason}`")
|
||||
await self.log(interaction, moderation_id)
|
||||
|
||||
# @app_commands.group(name="blacklist")
|
||||
|
@ -721,7 +721,7 @@ class Moderation(commands.Cog):
|
|||
pass
|
||||
|
||||
moderation_id = await self.mysql_log(interaction.guild.id, interaction.user.id, 'MUTE', target.id, 0, parsed_time, reason)
|
||||
await interaction.edit_original_response(content=f"{target.mention} has been muted for {humanize.precisedelta(parsed_time)}! (Case `#{moderation_id}`)\n**Reason** - `{reason}`")
|
||||
await interaction.edit_original_response(content=f"{target.mention} has been muted for {humanize.precisedelta(parsed_time)}! (Case `#{moderation_id:n}`)\n**Reason** - `{reason}`")
|
||||
await self.log(interaction, moderation_id)
|
||||
|
||||
@app_commands.command(name="unmute")
|
||||
|
@ -761,7 +761,7 @@ class Moderation(commands.Cog):
|
|||
pass
|
||||
|
||||
moderation_id = await self.mysql_log(interaction.guild.id, interaction.user.id, 'UNMUTE', target.id, 0, 'NULL', reason)
|
||||
await interaction.edit_original_response(content=f"{target.mention} has been unmuted! (Case `#{moderation_id}`)\n**Reason** - `{reason}`")
|
||||
await interaction.edit_original_response(content=f"{target.mention} has been unmuted! (Case `#{moderation_id:n}`)\n**Reason** - `{reason}`")
|
||||
await self.log(interaction, moderation_id)
|
||||
|
||||
@app_commands.command(name="kick")
|
||||
|
@ -793,7 +793,7 @@ class Moderation(commands.Cog):
|
|||
await target.kick(f"Kicked by {interaction.user.id} for: {reason}")
|
||||
|
||||
moderation_id = await self.mysql_log(interaction.guild.id, interaction.user.id, 'KICK', target.id, 0, 'NULL', reason)
|
||||
await interaction.edit_original_response(content=f"{target.mention} has been kicked! (Case `#{moderation_id}`)\n**Reason** - `{reason}`")
|
||||
await interaction.edit_original_response(content=f"{target.mention} has been kicked! (Case `#{moderation_id:n}`)\n**Reason** - `{reason}`")
|
||||
await self.log(interaction, moderation_id)
|
||||
|
||||
@app_commands.command(name="ban")
|
||||
|
@ -865,7 +865,7 @@ class Moderation(commands.Cog):
|
|||
await interaction.guild.ban(target, reason=f"Banned by {interaction.user.id} for: {reason}", delete_message_seconds=delete_messages)
|
||||
|
||||
moderation_id = await self.mysql_log(interaction.guild.id, interaction.user.id, 'BAN', target.id, 0, 'NULL', reason)
|
||||
await interaction.edit_original_response(content=f"{target.mention} has been banned! (Case `#{moderation_id}`)\n**Reason** - `{reason}`")
|
||||
await interaction.edit_original_response(content=f"{target.mention} has been banned! (Case `#{moderation_id:n}`)\n**Reason** - `{reason}`")
|
||||
await self.log(interaction, moderation_id)
|
||||
|
||||
@app_commands.command(name="unban")
|
||||
|
@ -907,7 +907,7 @@ class Moderation(commands.Cog):
|
|||
pass
|
||||
|
||||
moderation_id = await self.mysql_log(interaction.guild.id, interaction.user.id, 'UNBAN', target.id, 0, 'NULL', reason)
|
||||
await interaction.edit_original_response(content=f"{target.mention} has been unbanned! (Case `#{moderation_id}`)\n**Reason** - `{reason}`")
|
||||
await interaction.edit_original_response(content=f"{target.mention} has been unbanned! (Case `#{moderation_id:n}`)\n**Reason** - `{reason}`")
|
||||
await self.log(interaction, moderation_id)
|
||||
|
||||
@app_commands.command(name="history")
|
||||
|
@ -1026,7 +1026,7 @@ class Moderation(commands.Cog):
|
|||
target_name = target_user['name'] if target_user['discriminator'] == "0" else f"{target_user['name']}#{target_user['discriminator']}"
|
||||
moderator_name = moderator_user['name'] if moderator_user['discriminator'] == "0" else f"{moderator_user['name']}#{moderator_user['discriminator']}"
|
||||
|
||||
field_name = f"Case #{case['moderation_id']} ({str.title(case['moderation_type'])})"
|
||||
field_name = f"Case #{case['moderation_id']:n} ({str.title(case['moderation_type'])})"
|
||||
field_value = f"**Target:** `{target_name}` ({target_user['id']})\n**Moderator:** `{moderator_name}` ({moderator_user['id']})"
|
||||
|
||||
if len(case['reason']) > 125:
|
||||
|
@ -1119,7 +1119,7 @@ class Moderation(commands.Cog):
|
|||
try:
|
||||
member = await interaction.guild.fetch_member(case_dict['target_id'])
|
||||
|
||||
await member.timeout(None, reason=f"Case #{case} resolved by {interaction.user.id}")
|
||||
await member.timeout(None, reason=f"Case #{case:n} resolved by {interaction.user.id}")
|
||||
except discord.NotFound:
|
||||
pass
|
||||
|
||||
|
@ -1139,7 +1139,7 @@ class Moderation(commands.Cog):
|
|||
database.commit()
|
||||
|
||||
embed = await self.embed_factory('case', interaction=interaction, case_dict=await self.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:n} resolved!", embed=embed)
|
||||
await self.log(interaction, case, True)
|
||||
|
||||
cursor.close()
|
||||
|
@ -1184,9 +1184,9 @@ class Moderation(commands.Cog):
|
|||
json.dump(case_dict, f, indent=2)
|
||||
|
||||
if export.value == 'codeblock':
|
||||
content = f"Case #{case} exported.\n*Case was too large to export as codeblock, so it has been uploaded as a `.json` file.*"
|
||||
content = f"Case #{case:n} exported.\n*Case was too large to export as codeblock, so it has been uploaded as a `.json` file.*"
|
||||
else:
|
||||
content = f"Case #{case} exported."
|
||||
content = f"Case #{case:n} exported."
|
||||
|
||||
await interaction.response.send_message(content=content, file=discord.File(filename, f"moderation_{interaction.guild.id}_case_{case}.json"), ephemeral=ephemeral)
|
||||
|
||||
|
@ -1244,7 +1244,7 @@ class Moderation(commands.Cog):
|
|||
try:
|
||||
member = await interaction.guild.fetch_member(case_dict['target_id'])
|
||||
|
||||
await member.timeout(parsed_time, reason=f"Case #{case} edited by {interaction.user.id}")
|
||||
await member.timeout(parsed_time, reason=f"Case #{case:n} edited by {interaction.user.id}")
|
||||
except discord.NotFound:
|
||||
pass
|
||||
|
||||
|
@ -1301,7 +1301,7 @@ class Moderation(commands.Cog):
|
|||
new_case = await self.fetch_case(case, interaction.guild.id)
|
||||
embed = await self.embed_factory('case', 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:n} edited!", embed=embed, ephemeral=True)
|
||||
await self.log(interaction, case)
|
||||
|
||||
cursor.close()
|
||||
|
|
Loading…
Reference in a new issue