2929import functools
3030import itertools
3131import re
32- from typing import TYPE_CHECKING
32+ from typing import TYPE_CHECKING , Any
3333
3434import discord .utils
35+ from discord .ext import bridge
3536
3637from .core import Command , Group
3738from .errors import CommandError
@@ -550,7 +551,9 @@ def subcommand_not_found(self, command, string):
550551 )
551552 return f'Command "{ command .qualified_name } " has no subcommands.'
552553
553- 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+ ):
554557 """|coro|
555558
556559 Returns a filtered list of commands and optionally sorts them.
@@ -568,6 +571,8 @@ async def filter_commands(self, commands, *, sort=False, key=None):
568571 An optional key function to pass to :func:`py:sorted` that
569572 takes a :class:`Command` as its sole parameter. If ``sort`` is
570573 passed as ``True`` then this will default as the command name.
574+ exclude: Optional[Tuple[Any, ...]]
575+ A tuple of command types to exclude from the filter.
571576
572577 Returns
573578 -------
@@ -579,15 +584,18 @@ async def filter_commands(self, commands, *, sort=False, key=None):
579584 key = lambda c : c .name
580585
581586 # Ignore Application Commands because they don't have hidden/docs
582- prefix_commands = [
587+ new_commands = [
583588 command
584589 for command in commands
585- if not isinstance (command , discord .commands .ApplicationCommand )
590+ if not isinstance (
591+ command ,
592+ (discord .commands .ApplicationCommand , * (exclude if exclude else ())),
593+ )
586594 ]
587595 iterator = (
588- prefix_commands
596+ new_commands
589597 if self .show_hidden
590- else filter (lambda c : not c .hidden , prefix_commands )
598+ else filter (lambda c : not c .hidden , new_commands )
591599 )
592600
593601 if self .verify_checks is False :
@@ -1107,7 +1115,9 @@ async def send_cog_help(self, cog):
11071115 self .paginator .add_line (cog .description , empty = True )
11081116
11091117 filtered = await self .filter_commands (
1110- cog .get_commands (), sort = self .sort_commands
1118+ cog .get_commands (),
1119+ sort = self .sort_commands ,
1120+ exclude = (bridge .BridgeExtCommand ,),
11111121 )
11121122 self .add_indented_commands (filtered , heading = self .commands_heading )
11131123
@@ -1357,7 +1367,9 @@ async def send_cog_help(self, cog):
13571367 self .paginator .add_line (cog .description , empty = True )
13581368
13591369 filtered = await self .filter_commands (
1360- cog .get_commands (), sort = self .sort_commands
1370+ cog .get_commands (),
1371+ sort = self .sort_commands ,
1372+ exclude = (bridge .BridgeExtCommand ,),
13611373 )
13621374 if filtered :
13631375 self .paginator .add_line (f"**{ cog .qualified_name } { self .commands_heading } **" )
0 commit comments