|
29 | 29 | import functools
|
30 | 30 | import itertools
|
31 | 31 | import re
|
32 |
| -from typing import TYPE_CHECKING |
| 32 | +from typing import TYPE_CHECKING, Any |
33 | 33 |
|
34 | 34 | import discord.utils
|
35 | 35 | from discord.ext import bridge
|
@@ -551,7 +551,9 @@ def subcommand_not_found(self, command, string):
|
551 | 551 | )
|
552 | 552 | return f'Command "{command.qualified_name}" has no subcommands.'
|
553 | 553 |
|
554 |
| - async def filter_commands(self, commands, *, sort=False, key=None): |
| 554 | + async def filter_commands( |
| 555 | + self, commands, *, sort=False, key=None, exclude: tuple[Any] | None = None |
| 556 | + ): |
555 | 557 | """|coro|
|
556 | 558 |
|
557 | 559 | Returns a filtered list of commands and optionally sorts them.
|
@@ -580,17 +582,18 @@ async def filter_commands(self, commands, *, sort=False, key=None):
|
580 | 582 | key = lambda c: c.name
|
581 | 583 |
|
582 | 584 | # Ignore Application Commands because they don't have hidden/docs
|
583 |
| - prefix_commands = [ |
| 585 | + new_commands = [ |
584 | 586 | command
|
585 | 587 | for command in commands
|
586 | 588 | if not isinstance(
|
587 |
| - command, (discord.commands.ApplicationCommand, bridge.BridgeExtCommand) |
| 589 | + command, |
| 590 | + (discord.commands.ApplicationCommand, *(exclude if exclude else ())), |
588 | 591 | )
|
589 | 592 | ]
|
590 | 593 | iterator = (
|
591 |
| - prefix_commands |
| 594 | + new_commands |
592 | 595 | if self.show_hidden
|
593 |
| - else filter(lambda c: not c.hidden, prefix_commands) |
| 596 | + else filter(lambda c: not c.hidden, new_commands) |
594 | 597 | )
|
595 | 598 |
|
596 | 599 | if self.verify_checks is False:
|
@@ -1110,7 +1113,9 @@ async def send_cog_help(self, cog):
|
1110 | 1113 | self.paginator.add_line(cog.description, empty=True)
|
1111 | 1114 |
|
1112 | 1115 | filtered = await self.filter_commands(
|
1113 |
| - cog.get_commands(), sort=self.sort_commands |
| 1116 | + cog.get_commands(), |
| 1117 | + sort=self.sort_commands, |
| 1118 | + exclude=(bridge.BridgeExtCommand,), |
1114 | 1119 | )
|
1115 | 1120 | self.add_indented_commands(filtered, heading=self.commands_heading)
|
1116 | 1121 |
|
@@ -1360,7 +1365,9 @@ async def send_cog_help(self, cog):
|
1360 | 1365 | self.paginator.add_line(cog.description, empty=True)
|
1361 | 1366 |
|
1362 | 1367 | filtered = await self.filter_commands(
|
1363 |
| - cog.get_commands(), sort=self.sort_commands |
| 1368 | + cog.get_commands(), |
| 1369 | + sort=self.sort_commands, |
| 1370 | + exclude=(bridge.BridgeExtCommand,), |
1364 | 1371 | )
|
1365 | 1372 | if filtered:
|
1366 | 1373 | self.paginator.add_line(f"**{cog.qualified_name} {self.commands_heading}**")
|
|
0 commit comments