fix(aurora): assume that ctx is a commands.Context object before trying to use it in moderate
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Failing after 25s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 38s

This commit is contained in:
Seaswimmer 2024-07-06 11:32:33 -04:00
parent 9f068bba6f
commit aeec616be5
Signed by: cswimr
GPG key ID: 3813315477F26F82

View file

@ -22,10 +22,6 @@ async def moderate(ctx: Union[commands.Context, discord.Interaction], target: di
moderation_type (Type): The moderation type (handler) to use. See `aurora.models.moderation_types` for some examples.
**kwargs: The keyword arguments to pass to the handler method.
"""
if not await check_moddable(target, ctx, permissions):
return
if silent is None:
silent = not await config.guild(ctx.guild).dm_users()
if isinstance(moderation_type, str):
moderation_type = type_registry[str.lower(moderation_type)]
if isinstance(ctx, discord.Interaction):
@ -33,6 +29,10 @@ async def moderate(ctx: Union[commands.Context, discord.Interaction], target: di
ctx = await commands.Context.from_interaction(interaction)
if isinstance(interaction.command, app_commands.ContextMenu):
ctx.author = interaction.user
if not await check_moddable(target, ctx, permissions):
return
if silent is None:
silent = not await config.guild(ctx.guild).dm_users()
return await moderation_type.handler(
ctx,
target,