feat(moderation): added note command

This commit is contained in:
Seaswimmer 2023-10-05 10:46:52 -04:00
parent 1ff7f35785
commit 27c12c6307
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -200,13 +200,28 @@ class Moderation(commands.Cog):
embed_duration = f" for {humanize.precisedelta(duration)}" embed_duration = f" for {humanize.precisedelta(duration)}"
else: else:
embed_duration = "" embed_duration = ""
embed = discord.Embed(title=str.title(moderation_type), description=f"You have been {moderation_type}{embed_duration} in {guild_name}.", color=await self.bot.get_embed_color(None), timestamp=datetime.now()) if moderation_type == "note":
embed_desc = "recieved a"
else:
embed_desc = "been"
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.add_field(name='Reason', value=f"`{reason}`")
embed.set_author(name=guild.name, icon_url=guild.icon.url) 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)}", icon_url="https://cdn.discordapp.com/attachments/1070822161389994054/1159469476773904414/arrow-right-circle-icon-512x512-2p1e2aaw.png?ex=65312319&is=651eae19&hm=3cebdd28e805c13a79ec48ef87c32ca532ffa6b9ede2e48d0cf8e5e81f3a6818&")
return embed return embed
raise(TypeError("'type' argument is invalid!")) raise(TypeError("'type' argument is invalid!"))
@app_commands.command(name="note")
async def note(self, interaction: discord.Interaction, target: discord.Member, reason: str):
"""Add a note to a user."""
await interaction.response.send_message(content=f"{target.mention} has recieved a note!\n**Reason** - `{reason}`")
try:
embed = await self.embed_factory('message', interaction.guild, reason, 'note', await interaction.original_response())
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
await self.mysql_log(interaction.guild.id, interaction.user.id, 'NOTE', target.id, 'NULL', reason)
@app_commands.command(name="warn") @app_commands.command(name="warn")
async def warn(self, interaction: discord.Interaction, target: discord.Member, reason: str): async def warn(self, interaction: discord.Interaction, target: discord.Member, reason: str):
"""Warn a user.""" """Warn a user."""