diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bda9a0ecc..7e8067a0aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,8 @@ These changes are available on the `master` branch, but have not yet been releas apps. ([#2650](https://github.com/Pycord-Development/pycord/pull/2650)) - Fixed type annotations of cached properties. ([#2635](https://github.com/Pycord-Development/pycord/issues/2635)) +- Fixed `BridgeCommand` duplicate in default help command. + ([#2656](https://github.com/Pycord-Development/pycord/pull/2656)) ### Changed diff --git a/discord/ext/commands/help.py b/discord/ext/commands/help.py index 25b44388bd..4c2f1ab9fd 100644 --- a/discord/ext/commands/help.py +++ b/discord/ext/commands/help.py @@ -29,9 +29,10 @@ import functools import itertools import re -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Any import discord.utils +from discord.ext import bridge from .core import Command, Group from .errors import CommandError @@ -550,7 +551,9 @@ def subcommand_not_found(self, command, string): ) return f'Command "{command.qualified_name}" has no subcommands.' - async def filter_commands(self, commands, *, sort=False, key=None): + async def filter_commands( + self, commands, *, sort=False, key=None, exclude: tuple[Any] | None = None + ): """|coro| Returns a filtered list of commands and optionally sorts them. @@ -568,6 +571,8 @@ async def filter_commands(self, commands, *, sort=False, key=None): An optional key function to pass to :func:`py:sorted` that takes a :class:`Command` as its sole parameter. If ``sort`` is passed as ``True`` then this will default as the command name. + exclude: Optional[Tuple[Any, ...]] + A tuple of command types to exclude from the filter. Returns ------- @@ -579,15 +584,18 @@ async def filter_commands(self, commands, *, sort=False, key=None): key = lambda c: c.name # Ignore Application Commands because they don't have hidden/docs - prefix_commands = [ + new_commands = [ command for command in commands - if not isinstance(command, discord.commands.ApplicationCommand) + if not isinstance( + command, + (discord.commands.ApplicationCommand, *(exclude if exclude else ())), + ) ] iterator = ( - prefix_commands + new_commands if self.show_hidden - else filter(lambda c: not c.hidden, prefix_commands) + else filter(lambda c: not c.hidden, new_commands) ) if self.verify_checks is False: @@ -1107,7 +1115,9 @@ async def send_cog_help(self, cog): self.paginator.add_line(cog.description, empty=True) filtered = await self.filter_commands( - cog.get_commands(), sort=self.sort_commands + cog.get_commands(), + sort=self.sort_commands, + exclude=(bridge.BridgeExtCommand,), ) self.add_indented_commands(filtered, heading=self.commands_heading) @@ -1357,7 +1367,9 @@ async def send_cog_help(self, cog): self.paginator.add_line(cog.description, empty=True) filtered = await self.filter_commands( - cog.get_commands(), sort=self.sort_commands + cog.get_commands(), + sort=self.sort_commands, + exclude=(bridge.BridgeExtCommand,), ) if filtered: self.paginator.add_line(f"**{cog.qualified_name} {self.commands_heading}**")