Skip to content

Commit 20515ed

Browse files
committed
fix(command_discovery): exclude view-only commands from permission assignment
- Introduced a new constant to identify commands that do not require permission assignment, specifically excluding the 'level' command. - Updated the command discovery logic to ensure these excluded commands are not included in the permission assignment UI, enhancing clarity and functionality.
1 parent fb899cd commit 20515ed

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/tux/ui/views/config/command_discovery.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
# command permissions list (e.g. moderation, levels/lvls/XP/blacklist).
1919
_PERMISSION_COG_MODULES = ("moderation", "levels")
2020

21+
# Commands from those modules that do not use @requires_command_permission()
22+
# and must not appear in the permission assignment UI (e.g. level is view-only).
23+
_EXCLUDED_FROM_PERMISSION_ASSIGNMENT = frozenset({"level"})
24+
2125

2226
def get_moderation_commands(bot: Tux) -> list[str]:
2327
"""
@@ -47,7 +51,11 @@ def get_moderation_commands(bot: Tux) -> list[str]:
4751
for command in cog.get_commands():
4852
# Only add the main command name, not aliases
4953
# Exclude restricted commands (owner/sysadmin only)
50-
if command.name.lower() not in RESTRICTED_COMMANDS:
54+
# Exclude commands that don't use the permission decorator (e.g. level is view-only)
55+
if (
56+
command.name.lower() not in RESTRICTED_COMMANDS
57+
and command.name.lower() not in _EXCLUDED_FROM_PERMISSION_ASSIGNMENT
58+
):
5159
command_names.add(command.name)
5260

5361
# Fallback: Known commands that require permission assignment

0 commit comments

Comments
 (0)