WIP: Make Aurora commands hybrid commands #17

Closed
cswimr wants to merge 11 commits from aurora-hybrid into main
Showing only changes of commit 416d67bf65 - Show all commits

View file

@ -486,29 +486,26 @@ class Aurora(commands.Cog):
case = await fetch_case(moderation_id, ctx.guild.id) case = await fetch_case(moderation_id, ctx.guild.id)
await send_evidenceformat(ctx, case) await send_evidenceformat(ctx, case)
@app_commands.command(name="unmute") @commands.hybrid_command(name="unmute")
@commands.mod_or_permissions(moderate_members=True)
@app_commands.describe(
target="Who are you unmuting?",
reason="Why are you unmuting this user?",
silent="Should the user be messaged?",
)
async def unmute( async def unmute(
self, self,
interaction: discord.Interaction, ctx: commands.Context,
target: discord.Member, target: discord.Member,
reason: str = None, reason: str = None,
silent: bool = None, silent: bool = None,
): ):
"""Unmute a user. """Unmute a user."""
if not await check_moddable(target, ctx, ["moderate_members"]):
Parameters
-----------
target: discord.user
Who are you unmuting?
reason: str
Why are you unmuting this user?
silent: bool
Should the user be messaged?"""
if not await check_moddable(target, interaction, ["moderate_members"]):
return return
if target.is_timed_out() is False: if target.is_timed_out() is False:
await interaction.response.send_message( await ctx.send(
error(f"{target.mention} is not muted!"), error(f"{target.mention} is not muted!"),
allowed_mentions=discord.AllowedMentions(users=False), allowed_mentions=discord.AllowedMentions(users=False),
ephemeral=True, ephemeral=True,
@ -517,35 +514,35 @@ class Aurora(commands.Cog):
if reason: if reason:
await target.timeout( await target.timeout(
None, reason=f"Unmuted by {interaction.user.id} for: {reason}" None, reason=f"Unmuted by {ctx.author.id} for: {reason}"
) )
else: else:
await target.timeout(None, reason=f"Unbanned by {interaction.user.id}") await target.timeout(None, reason=f"Unmuted by {ctx.author.id}")
reason = "No reason given." reason = "No reason given."
await interaction.response.send_message( message = await ctx.send(
content=f"{target.mention} has been unmuted!\n**Reason** - `{reason}`" content=f"{target.mention} has been unmuted!\n**Reason** - `{reason}`"
) )
if silent is None: if silent is None:
silent = not await config.guild(interaction.guild).dm_users() silent = not await config.guild(ctx.guild).dm_users()
if silent is False: if silent is False:
try: try:
embed = await message_factory( embed = await message_factory(
await self.bot.get_embed_color(interaction.channel), await ctx.embed_color(),
guild=interaction.guild, guild=ctx.guild,
moderator=interaction.user, moderator=ctx.author,
reason=reason, reason=reason,
moderation_type="unmuted", moderation_type="unmuted",
response=await interaction.original_response(), response=message,
) )
await target.send(embed=embed) await target.send(embed=embed)
except discord.errors.HTTPException: except discord.errors.HTTPException:
pass pass
moderation_id = await mysql_log( moderation_id = await mysql_log(
interaction.guild.id, ctx.guild.id,
interaction.user.id, ctx.author.id,
"UNMUTE", "UNMUTE",
"USER", "USER",
target.id, target.id,
@ -553,13 +550,13 @@ class Aurora(commands.Cog):
"NULL", "NULL",
reason, reason,
) )
await interaction.edit_original_response( await message.edit(
content=f"{target.mention} has been unmuted! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`" content=f"{target.mention} has been unmuted! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`"
) )
await log(interaction, moderation_id) await log(ctx, moderation_id)
case = await fetch_case(moderation_id, interaction.guild.id) case = await fetch_case(moderation_id, ctx.guild.id)
await send_evidenceformat(interaction, case) await send_evidenceformat(ctx, case)
@app_commands.command(name="kick") @app_commands.command(name="kick")
async def kick( async def kick(