feat(moderation): added warn command

This commit is contained in:
Seaswimmer 2023-10-04 16:39:58 -04:00
parent 6fba47ea56
commit e66a902442
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -174,7 +174,20 @@ class Moderation(commands.Cog):
database.close()
logging.debug("MySQL row inserted into moderation_%s!\n%s, %s, %s, %s, %s, %s, %s, %s, 0, NULL", guild_id, moderation_id, timestamp, moderation_type, target_id, author_id, duration, end_timestamp, reason)
@commands.hybrid_command(name="mute", aliases=['timeout'])
@commands.hybrid_command(name="warn")
@commands.mod()
async def warn(self, ctx: commands.Context, target: discord.Member, *, reason: str):
"""Warn a user."""
response = await ctx.send(content=f"{target.mention} has been warned!\n**Reason** - `{reason}`")
try:
embed = discord.Embed(title="Warned", description=f"You have been warned in [{ctx.guild.name}]({response.jump_url}).", color=await self.bot.get_embed_color(None))
embed.add_field(name='Reason', value=f"`{reason}`")
await target.send(embed=embed)
except discord.errors.HTTPException:
await response.edit(content=f"{response.content}\n*Failed to send DM, user likely has the bot blocked.*")
await self.mysql_log(ctx.guild.id, ctx.author.id, 'WARN', target.id, 'NULL', reason)
@commands.hybrid_command(name="mute", aliases=['timeout', 'tm'])
@commands.mod()
async def mute(self, ctx: commands.Context, target: discord.Member, duration: str, *, reason: str):
"""Mute a user."""