Skip to content

Commit 227830b

Browse files
Fix check-failure error messages never being shown (#856)
1 parent 89fb5a4 commit 227830b

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

‎utils/command_checks.py‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,19 @@ def check_interaction_user_in_main_guild[T: TeXBotBaseCog, **P](
2828
Instead, an error message will be sent to the user.
2929
""" # noqa: D401
3030

31-
async def _check(ctx: TeXBotApplicationContext) -> bool:
31+
# NOTE: The check function shares this decorator's name, so that `is_interaction_user_in_main_guild_failure()` can identify it within a `CheckAnyFailure`
32+
async def check_interaction_user_in_main_guild(ctx: TeXBotApplicationContext) -> bool:
3233
try:
3334
await ctx.bot.get_main_guild_member(ctx.user)
3435
except DiscordMemberNotInMainGuildError:
3536
return False
3637
return True
3738

38-
return commands.check_any(commands.check(_check))(func) # type: ignore[arg-type]
39+
return commands.check_any(
40+
commands.check(
41+
check_interaction_user_in_main_guild # type: ignore[arg-type]
42+
)
43+
)(func)
3944

4045
@staticmethod
4146
def check_interaction_user_has_committee_role[T: TeXBotBaseCog, **P](
@@ -48,10 +53,17 @@ def check_interaction_user_has_committee_role[T: TeXBotBaseCog, **P](
4853
Instead, an error message will be sent to the user.
4954
"""
5055

51-
async def _check(ctx: TeXBotApplicationContext) -> bool:
56+
# NOTE: The check function shares this decorator's name, so that `is_interaction_user_has_committee_role_failure()` can identify it within a `CheckAnyFailure`
57+
async def check_interaction_user_has_committee_role(
58+
ctx: TeXBotApplicationContext,
59+
) -> bool:
5260
return await ctx.bot.check_user_has_committee_role(ctx.user)
5361

54-
return commands.check_any(commands.check(_check))(func) # type: ignore[arg-type]
62+
return commands.check_any(
63+
commands.check(
64+
check_interaction_user_has_committee_role # type: ignore[arg-type]
65+
)
66+
)(func)
5567

5668
@classmethod
5769
def is_interaction_user_in_main_guild_failure(cls, check: CheckFailure) -> bool:

0 commit comments

Comments
 (0)