From 5cfcfb098e678554fd4566d758dbd0aa111c211a Mon Sep 17 00:00:00 2001 From: Thatsmusic99 <25277367+Thatsmusic99@users.noreply.github.com> Date: Sat, 24 May 2025 13:31:31 +0100 Subject: [PATCH 01/19] Allow committee-elect to update actions (and appear in auto-complete) --- cogs/committee_actions_tracking.py | 11 +++++++++-- utils/command_checks.py | 13 +++++++++++++ utils/tex_bot.py | 4 ++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index 35c1fee9e..a6f579db0 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -129,11 +129,18 @@ async def autocomplete_get_committee_members( except CommitteeRoleDoesNotExistError: return set() + try: + committee_elect_role: discord.Role = await ctx.bot.committee_elect_role + except CommitteeElectRoleDoesNotExistError: + pass # We'll just continue with the fact that committee exists + return { discord.OptionChoice( name=f"{member.display_name} ({member.global_name})", value=str(member.id) ) - for member in committee_role.members + for member in committee_role.members and + ((for member in committee_elect_role.members and not in committee_role.members) + if committee_elect_role else []) if not member.bot } @@ -281,7 +288,7 @@ async def create( required=True, parameter_name="status", ) - @CommandChecks.check_interaction_user_has_committee_role + @CommandChecks.check_interaction_user_has_committee_or_elect_role @CommandChecks.check_interaction_user_in_main_guild async def update_status( self, ctx: "TeXBotApplicationContext", action_id: str, status: str diff --git a/utils/command_checks.py b/utils/command_checks.py index 620c99c17..83a03105b 100644 --- a/utils/command_checks.py +++ b/utils/command_checks.py @@ -65,6 +65,19 @@ async def _check(ctx: "TeXBotApplicationContext") -> bool: ) )(func) + @staticmethod + def check_interation_user_has_committee_or_elect_role[T: TeXBotBaseCog, **P]( + func: "Callable[Concatenate[T, P], Awaitable[None]]", + ) -> "Callable[Concatenate[T, P], Awaitable[None]]": + async def _check(ctx: "TeXBotApplicationContext") -> bool: + return await ctx.bot.check_user_has_committee_or_elect_role(ctx.user) + + return commands.check_any( + commands.check( + _check # type: ignore[arg-type] + ) + )(func) + @classmethod def is_interaction_user_in_main_guild_failure(cls, check: "CheckFailure") -> bool: """Whether the check failed due to the user not being in your Discord guild.""" diff --git a/utils/tex_bot.py b/utils/tex_bot.py index 175765cdf..728a4da81 100644 --- a/utils/tex_bot.py +++ b/utils/tex_bot.py @@ -450,6 +450,10 @@ async def check_user_has_committee_role(self, user: discord.Member | discord.Use """Util method to validate whether the given user has the "Committee" role.""" return await self.committee_role in (await self.get_main_guild_member(user)).roles + async def check_user_has_committee_or_elect_role(self, user: discord.Member | discord.User) -> bool: + """Util method to validate whether the given user has the "Committee" or "Committee-Elect" role.""" + return await check_user_has_committee_role(self, user) or await self.committee_elect_role in (await self.get_main_guild_member(user)).roles + def set_main_guild(self, main_guild: discord.Guild) -> None: """ Set the main_guild value that TeX-Bot will reference in the future. From aa327c44c6e56e240a00212adb305607150fefd9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sat, 24 May 2025 12:34:57 +0000 Subject: [PATCH 02/19] [pre-commit.ci lite] apply automatic fixes --- cogs/committee_actions_tracking.py | 4 ++-- utils/tex_bot.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index a6f579db0..0d915fb10 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -138,9 +138,9 @@ async def autocomplete_get_committee_members( discord.OptionChoice( name=f"{member.display_name} ({member.global_name})", value=str(member.id) ) - for member in committee_role.members and + for member in committee_role.members and ((for member in committee_elect_role.members and not in committee_role.members) - if committee_elect_role else []) + if committee_elect_role else []) if not member.bot } diff --git a/utils/tex_bot.py b/utils/tex_bot.py index 728a4da81..d8c971674 100644 --- a/utils/tex_bot.py +++ b/utils/tex_bot.py @@ -450,9 +450,15 @@ async def check_user_has_committee_role(self, user: discord.Member | discord.Use """Util method to validate whether the given user has the "Committee" role.""" return await self.committee_role in (await self.get_main_guild_member(user)).roles - async def check_user_has_committee_or_elect_role(self, user: discord.Member | discord.User) -> bool: + async def check_user_has_committee_or_elect_role( + self, user: discord.Member | discord.User + ) -> bool: """Util method to validate whether the given user has the "Committee" or "Committee-Elect" role.""" - return await check_user_has_committee_role(self, user) or await self.committee_elect_role in (await self.get_main_guild_member(user)).roles + return ( + await check_user_has_committee_role(self, user) + or await self.committee_elect_role + in (await self.get_main_guild_member(user)).roles + ) def set_main_guild(self, main_guild: discord.Guild) -> None: """ From 87e097c2e83ca24bf516d278e0200e0aae93b092 Mon Sep 17 00:00:00 2001 From: Thatsmusic99 <25277367+Thatsmusic99@users.noreply.github.com> Date: Sat, 24 May 2025 15:10:12 +0100 Subject: [PATCH 03/19] Address some Ruff errors --- cogs/committee_actions_tracking.py | 15 ++++++++++----- utils/tex_bot.py | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index 0d915fb10..6333e9de9 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -134,14 +134,20 @@ async def autocomplete_get_committee_members( except CommitteeElectRoleDoesNotExistError: pass # We'll just continue with the fact that committee exists + committee_members = [member for member in committee_role.members if not member.bot] + + # Add committee-elect if the role is found + if committee_elect_role: + for member in committee_elect_role.members: + if member in committee_members or member.bot: + continue + committee_members.append(member) + return { discord.OptionChoice( name=f"{member.display_name} ({member.global_name})", value=str(member.id) ) - for member in committee_role.members and - ((for member in committee_elect_role.members and not in committee_role.members) - if committee_elect_role else []) - if not member.bot + for member in committee_members } @staticmethod @@ -288,7 +294,6 @@ async def create( required=True, parameter_name="status", ) - @CommandChecks.check_interaction_user_has_committee_or_elect_role @CommandChecks.check_interaction_user_in_main_guild async def update_status( self, ctx: "TeXBotApplicationContext", action_id: str, status: str diff --git a/utils/tex_bot.py b/utils/tex_bot.py index d8c971674..114a2a9e6 100644 --- a/utils/tex_bot.py +++ b/utils/tex_bot.py @@ -455,7 +455,7 @@ async def check_user_has_committee_or_elect_role( ) -> bool: """Util method to validate whether the given user has the "Committee" or "Committee-Elect" role.""" return ( - await check_user_has_committee_role(self, user) + await self.check_user_has_committee_role(self, user) or await self.committee_elect_role in (await self.get_main_guild_member(user)).roles ) From 17b1db283a86f0e536538311349b9504ffa84c62 Mon Sep 17 00:00:00 2001 From: Thatsmusic99 <25277367+Thatsmusic99@users.noreply.github.com> Date: Sat, 24 May 2025 15:12:38 +0100 Subject: [PATCH 04/19] Remove committee-elect check --- utils/tex_bot.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/utils/tex_bot.py b/utils/tex_bot.py index 114a2a9e6..175765cdf 100644 --- a/utils/tex_bot.py +++ b/utils/tex_bot.py @@ -450,16 +450,6 @@ async def check_user_has_committee_role(self, user: discord.Member | discord.Use """Util method to validate whether the given user has the "Committee" role.""" return await self.committee_role in (await self.get_main_guild_member(user)).roles - async def check_user_has_committee_or_elect_role( - self, user: discord.Member | discord.User - ) -> bool: - """Util method to validate whether the given user has the "Committee" or "Committee-Elect" role.""" - return ( - await self.check_user_has_committee_role(self, user) - or await self.committee_elect_role - in (await self.get_main_guild_member(user)).roles - ) - def set_main_guild(self, main_guild: discord.Guild) -> None: """ Set the main_guild value that TeX-Bot will reference in the future. From b1729461a3eb7f7a0fc788626c9baba90a325185 Mon Sep 17 00:00:00 2001 From: Holly <25277367+Thatsmusic99@users.noreply.github.com> Date: Sat, 24 May 2025 15:13:04 +0100 Subject: [PATCH 05/19] Remove committee-elect check Co-authored-by: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> Signed-off-by: Holly <25277367+Thatsmusic99@users.noreply.github.com> --- utils/command_checks.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/utils/command_checks.py b/utils/command_checks.py index 83a03105b..620c99c17 100644 --- a/utils/command_checks.py +++ b/utils/command_checks.py @@ -65,19 +65,6 @@ async def _check(ctx: "TeXBotApplicationContext") -> bool: ) )(func) - @staticmethod - def check_interation_user_has_committee_or_elect_role[T: TeXBotBaseCog, **P]( - func: "Callable[Concatenate[T, P], Awaitable[None]]", - ) -> "Callable[Concatenate[T, P], Awaitable[None]]": - async def _check(ctx: "TeXBotApplicationContext") -> bool: - return await ctx.bot.check_user_has_committee_or_elect_role(ctx.user) - - return commands.check_any( - commands.check( - _check # type: ignore[arg-type] - ) - )(func) - @classmethod def is_interaction_user_in_main_guild_failure(cls, check: "CheckFailure") -> bool: """Whether the check failed due to the user not being in your Discord guild.""" From ce5c6a5dda0befb577f071435dadbe6a09da9ba9 Mon Sep 17 00:00:00 2001 From: Holly <25277367+Thatsmusic99@users.noreply.github.com> Date: Sat, 24 May 2025 15:15:11 +0100 Subject: [PATCH 06/19] Suppress CommitteeElectRoleDoesNotExistError Co-authored-by: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> Signed-off-by: Holly <25277367+Thatsmusic99@users.noreply.github.com> --- cogs/committee_actions_tracking.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index 6333e9de9..25481fa44 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -129,10 +129,8 @@ async def autocomplete_get_committee_members( except CommitteeRoleDoesNotExistError: return set() - try: - committee_elect_role: discord.Role = await ctx.bot.committee_elect_role - except CommitteeElectRoleDoesNotExistError: - pass # We'll just continue with the fact that committee exists + with contextlib.suppress(CommitteeElectRoleDoesNotExistError): + committee_elect_role: discord.Role | None = await ctx.bot.committee_elect_role committee_members = [member for member in committee_role.members if not member.bot] From de3c50891961f3994266f24f36830658b484fe87 Mon Sep 17 00:00:00 2001 From: Thatsmusic99 <25277367+Thatsmusic99@users.noreply.github.com> Date: Sat, 24 May 2025 15:18:34 +0100 Subject: [PATCH 07/19] Fix final Ruff errors --- cogs/committee_actions_tracking.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index 25481fa44..bc188e368 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -1,5 +1,6 @@ """Contains cog classes for tracking committee-actions.""" +import contextlib import logging import random from enum import Enum @@ -11,6 +12,7 @@ from db.core.models import AssignedCommitteeAction, DiscordMember from exceptions import ( + CommitteeElectRoleDoesNotExistError, CommitteeRoleDoesNotExistError, InvalidActionDescriptionError, InvalidActionTargetError, From 8e78b0a25f12bc7ffee7c988a6b85615e58bdf3e Mon Sep 17 00:00:00 2001 From: Thatsmusic99 <25277367+Thatsmusic99@users.noreply.github.com> Date: Sat, 24 May 2025 16:20:55 +0100 Subject: [PATCH 08/19] Shorten expression for collecting committee/elect members --- cogs/committee_actions_tracking.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index bc188e368..276272c19 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -134,20 +134,13 @@ async def autocomplete_get_committee_members( with contextlib.suppress(CommitteeElectRoleDoesNotExistError): committee_elect_role: discord.Role | None = await ctx.bot.committee_elect_role - committee_members = [member for member in committee_role.members if not member.bot] - - # Add committee-elect if the role is found - if committee_elect_role: - for member in committee_elect_role.members: - if member in committee_members or member.bot: - continue - committee_members.append(member) - return { discord.OptionChoice( name=f"{member.display_name} ({member.global_name})", value=str(member.id) ) - for member in committee_members + for member in set(committee_role.members) + | set((committee_elect_role.members) if committee_elect_role else set()) + if not member.bot } @staticmethod From cbc99e5477f64c79a1dc3cea9371be47948216c8 Mon Sep 17 00:00:00 2001 From: MattyTheHacker <18513864+MattyTheHacker@users.noreply.github.com> Date: Sat, 24 May 2025 17:36:30 +0100 Subject: [PATCH 09/19] Make list command also non-committee --- cogs/committee_actions_tracking.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index bc188e368..bde801af2 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -573,7 +573,6 @@ async def action_all_committee( default=None, parameter_name="status", ) - @CommandChecks.check_interaction_user_has_committee_role @CommandChecks.check_interaction_user_in_main_guild async def list_user_actions( self, @@ -589,6 +588,7 @@ async def list_user_actions( Takes in a user and lists out their current actions. """ action_member: discord.Member | discord.User + committee_role: discord.Role = await self.bot.committee_role if action_member_id: action_member = await self.bot.get_member_from_str_id( @@ -597,6 +597,13 @@ async def list_user_actions( else: action_member = ctx.user + if committee_role not in ctx.user.roles and action_member != ctx.user: + await ctx.respond( + content="Committee role required to list actions for other users.", + ephemeral=True, + ) + return + user_actions: list[AssignedCommitteeAction] if not status: From d05940bfd5e2dd2d762ca8c3e3c10035813cdba7 Mon Sep 17 00:00:00 2001 From: MattyTheHacker <18513864+MattyTheHacker@users.noreply.github.com> Date: Sat, 24 May 2025 17:37:39 +0100 Subject: [PATCH 10/19] Add a logging message --- cogs/committee_actions_tracking.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index bde801af2..0ff703ed6 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -602,6 +602,12 @@ async def list_user_actions( content="Committee role required to list actions for other users.", ephemeral=True, ) + logger.debug( + "User: %s, tried to list actions for user: %s, " + "but did not have the committee role.", + ctx.user, + action_member, + ) return user_actions: list[AssignedCommitteeAction] From 9730625e466b51de68b81a9896941704cd7ba306 Mon Sep 17 00:00:00 2001 From: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> Date: Tue, 27 May 2025 09:05:18 +0100 Subject: [PATCH 11/19] Update cogs/committee_actions_tracking.py Co-authored-by: Matt Norton Signed-off-by: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> --- cogs/committee_actions_tracking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index 4bfbae7b8..2e6d8cced 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -592,7 +592,7 @@ async def list_user_actions( if committee_role not in ctx.user.roles and action_member != ctx.user: await ctx.respond( - content="Committee role required to list actions for other users.", + content="Committee role is required to list actions for other users.", ephemeral=True, ) logger.debug( From e9d6dbfa2f597a55f54f18e2aede518db7c2eeba Mon Sep 17 00:00:00 2001 From: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> Date: Tue, 27 May 2025 09:07:17 +0100 Subject: [PATCH 12/19] Apply suggestions from code review Co-authored-by: Matt Norton Signed-off-by: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> --- cogs/committee_actions_tracking.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index 2e6d8cced..e440ecc3a 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -131,15 +131,18 @@ async def autocomplete_get_committee_members( except CommitteeRoleDoesNotExistError: return set() + committee_elect_role: discord.Role | None = None with contextlib.suppress(CommitteeElectRoleDoesNotExistError): - committee_elect_role: discord.Role | None = await ctx.bot.committee_elect_role + committee_elect_role = await ctx.bot.committee_elect_role return { discord.OptionChoice( name=f"{member.display_name} ({member.global_name})", value=str(member.id) ) - for member in set(committee_role.members) - | set((committee_elect_role.members) if committee_elect_role else set()) + for member in ( + set(committee_role.members) + | set(committee_elect_role.members if committee_elect_role is not None else set()) + ) if not member.bot } @@ -590,7 +593,7 @@ async def list_user_actions( else: action_member = ctx.user - if committee_role not in ctx.user.roles and action_member != ctx.user: + if action_member != ctx.user and committee_role not in ctx.user.roles: await ctx.respond( content="Committee role is required to list actions for other users.", ephemeral=True, From cfac9367844a10addca1d6a7a34f10653d051c2e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Tue, 27 May 2025 08:07:53 +0000 Subject: [PATCH 13/19] [pre-commit.ci lite] apply automatic fixes --- cogs/committee_actions_tracking.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index e440ecc3a..6a5e0e8e9 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -141,7 +141,9 @@ async def autocomplete_get_committee_members( ) for member in ( set(committee_role.members) - | set(committee_elect_role.members if committee_elect_role is not None else set()) + | set( + committee_elect_role.members if committee_elect_role is not None else set() + ) ) if not member.bot } From bddc4b5eda02730b51ca2f2e45492757cb87f4a3 Mon Sep 17 00:00:00 2001 From: MattyTheHacker <18513864+MattyTheHacker@users.noreply.github.com> Date: Tue, 27 May 2025 09:14:57 +0100 Subject: [PATCH 14/19] Refactor fetching --- cogs/committee_actions_tracking.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index 6a5e0e8e9..42d7d40f5 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -585,15 +585,13 @@ async def list_user_actions( Takes in a user and lists out their current actions. """ - action_member: discord.Member | discord.User committee_role: discord.Role = await self.bot.committee_role - if action_member_id: - action_member = await self.bot.get_member_from_str_id( - action_member_id, - ) - else: - action_member = ctx.user + action_member: discord.Member | discord.User = ( + await self.bot.get_member_from_str_id(action_member_id) + if action_member_id.strip() + else ctx.user + ) if action_member != ctx.user and committee_role not in ctx.user.roles: await ctx.respond( From 3db178619a72ed917e5075b5db508b85bba5fe07 Mon Sep 17 00:00:00 2001 From: MattyTheHacker <18513864+MattyTheHacker@users.noreply.github.com> Date: Fri, 13 Jun 2025 07:45:32 +0100 Subject: [PATCH 15/19] Add note about committee check --- cogs/committee_actions_tracking.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index 42d7d40f5..e25c4e87a 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -301,6 +301,8 @@ async def update_status( Takes in an action object and a Status string, sets the status of the provided action to be the provided status. + Committee role check is not present because non-committee can have actions + and must be able to update their own action status. """ try: action_id_int: int = int(action_id) @@ -584,6 +586,9 @@ async def list_user_actions( Definition and callback of the "/list" command. Takes in a user and lists out their current actions. + If no user is specified, the user issuing the command will be used. + If a user has the committee role, they can list actions for other users. + If a user does not have the committee role, they can only list their own actions. """ committee_role: discord.Role = await self.bot.committee_role From 8d88100d98b886eee2f62830b0fe3be5c1ee2306 Mon Sep 17 00:00:00 2001 From: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> Date: Fri, 13 Jun 2025 21:46:18 +0000 Subject: [PATCH 16/19] Fix suggestions --- cogs/committee_actions_tracking.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index e25c4e87a..823779475 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -140,10 +140,9 @@ async def autocomplete_get_committee_members( name=f"{member.display_name} ({member.global_name})", value=str(member.id) ) for member in ( - set(committee_role.members) - | set( - committee_elect_role.members if committee_elect_role is not None else set() - ) + set(committee_role.members) | set(committee_elect_role.members) + if committee_elect_role is not None + else set() ) if not member.bot } @@ -292,8 +291,7 @@ async def create( required=True, parameter_name="status", ) - @CommandChecks.check_interaction_user_in_main_guild - async def update_status( + async def update_status( # NOTE: Committee role check is not present because non-committee can have actions, and need to be able to list their own actions. self, ctx: "TeXBotApplicationContext", action_id: str, status: str ) -> None: """ @@ -301,7 +299,6 @@ async def update_status( Takes in an action object and a Status string, sets the status of the provided action to be the provided status. - Committee role check is not present because non-committee can have actions and must be able to update their own action status. """ try: @@ -573,8 +570,7 @@ async def action_all_committee( default=None, parameter_name="status", ) - @CommandChecks.check_interaction_user_in_main_guild - async def list_user_actions( + async def list_user_actions( # NOTE: Committee role check is not present because non-committee can have actions, and need to be able to list their own actions. self, ctx: "TeXBotApplicationContext", *, @@ -590,15 +586,17 @@ async def list_user_actions( If a user has the committee role, they can list actions for other users. If a user does not have the committee role, they can only list their own actions. """ - committee_role: discord.Role = await self.bot.committee_role + action_member_id = action_member_id.strip() action_member: discord.Member | discord.User = ( await self.bot.get_member_from_str_id(action_member_id) - if action_member_id.strip() + if action_member_id else ctx.user ) - if action_member != ctx.user and committee_role not in ctx.user.roles: + if action_member != ctx.user and not await self.bot.check_user_has_committee_role( + ctx.user + ): await ctx.respond( content="Committee role is required to list actions for other users.", ephemeral=True, From d5358197333eb786efebce0ca016e34dd88f0a3c Mon Sep 17 00:00:00 2001 From: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> Date: Sat, 14 Jun 2025 15:19:08 +0100 Subject: [PATCH 17/19] Update cogs/committee_actions_tracking.py Co-authored-by: Matt Norton Signed-off-by: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> --- cogs/committee_actions_tracking.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index 823779475..557a0a345 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -299,7 +299,6 @@ async def update_status( # NOTE: Committee role check is not present because no Takes in an action object and a Status string, sets the status of the provided action to be the provided status. - and must be able to update their own action status. """ try: action_id_int: int = int(action_id) From 09d6414207699c73cfb4fb448fd4d77a3813fead Mon Sep 17 00:00:00 2001 From: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> Date: Sat, 14 Jun 2025 15:19:18 +0100 Subject: [PATCH 18/19] Update cogs/committee_actions_tracking.py Co-authored-by: Matt Norton Signed-off-by: Matty Widdop <18513864+MattyTheHacker@users.noreply.github.com> --- cogs/committee_actions_tracking.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index 557a0a345..9e4d0eb8a 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -140,9 +140,9 @@ async def autocomplete_get_committee_members( name=f"{member.display_name} ({member.global_name})", value=str(member.id) ) for member in ( - set(committee_role.members) | set(committee_elect_role.members) + set(committee_role.members) | (set(committee_elect_role.members) if committee_elect_role is not None - else set() + else set()) ) if not member.bot } From b02350e6eb7a815eeeef89d53efdfd1aa0285d80 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 14:19:55 +0000 Subject: [PATCH 19/19] [pre-commit.ci lite] apply automatic fixes --- cogs/committee_actions_tracking.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cogs/committee_actions_tracking.py b/cogs/committee_actions_tracking.py index 9e4d0eb8a..ccea5bc98 100644 --- a/cogs/committee_actions_tracking.py +++ b/cogs/committee_actions_tracking.py @@ -140,9 +140,12 @@ async def autocomplete_get_committee_members( name=f"{member.display_name} ({member.global_name})", value=str(member.id) ) for member in ( - set(committee_role.members) | (set(committee_elect_role.members) - if committee_elect_role is not None - else set()) + set(committee_role.members) + | ( + set(committee_elect_role.members) + if committee_elect_role is not None + else set() + ) ) if not member.bot }