From 533f448eb3ac40b1d9aca16034c0a85aa384c829 Mon Sep 17 00:00:00 2001 From: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> Date: Fri, 20 Nov 2026 20:51:43 +0000 Subject: [PATCH] Fix check-failure error messages never being shown --- utils/command_checks.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/utils/command_checks.py b/utils/command_checks.py index f1510ae66..3f0307658 100644 --- a/utils/command_checks.py +++ b/utils/command_checks.py @@ -28,14 +28,19 @@ def check_interaction_user_in_main_guild[T: TeXBotBaseCog, **P]( Instead, an error message will be sent to the user. """ # noqa: D401 - async def _check(ctx: TeXBotApplicationContext) -> bool: + # NOTE: The check function shares this decorator's name, so that `is_interaction_user_in_main_guild_failure()` can identify it within a `CheckAnyFailure` + async def check_interaction_user_in_main_guild(ctx: TeXBotApplicationContext) -> bool: try: await ctx.bot.get_main_guild_member(ctx.user) except DiscordMemberNotInMainGuildError: return False return True - return commands.check_any(commands.check(_check))(func) # type: ignore[arg-type] + return commands.check_any( + commands.check( + check_interaction_user_in_main_guild # type: ignore[arg-type] + ) + )(func) @staticmethod def check_interaction_user_has_committee_role[T: TeXBotBaseCog, **P]( @@ -48,10 +53,17 @@ def check_interaction_user_has_committee_role[T: TeXBotBaseCog, **P]( Instead, an error message will be sent to the user. """ - async def _check(ctx: TeXBotApplicationContext) -> bool: + # NOTE: The check function shares this decorator's name, so that `is_interaction_user_has_committee_role_failure()` can identify it within a `CheckAnyFailure` + async def check_interaction_user_has_committee_role( + ctx: TeXBotApplicationContext, + ) -> bool: return await ctx.bot.check_user_has_committee_role(ctx.user) - return commands.check_any(commands.check(_check))(func) # type: ignore[arg-type] + return commands.check_any( + commands.check( + check_interaction_user_has_committee_role # type: ignore[arg-type] + ) + )(func) @classmethod def is_interaction_user_in_main_guild_failure(cls, check: CheckFailure) -> bool: