Skip to content

Commit aa13d82

Browse files
fix: 🐛 Fix duplicate bridge cmds in default help cmd (#2656)
Signed-off-by: Paillat <me@paillat.dev> Signed-off-by: Lala Sabathil <lala@pycord.dev> Co-authored-by: Lala Sabathil <lala@pycord.dev>
1 parent 8c3a621 commit aa13d82

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ These changes are available on the `master` branch, but have not yet been releas
8787
([#2679](https://github.com/Pycord-Development/pycord/pull/2679))
8888
- Fixed unexpected backoff behavior in the handling of task failures
8989
([#2700](https://github.com/Pycord-Development/pycord/pull/2700)).
90+
- Fixed `BridgeCommand` duplicate in default help command.
91+
([#2656](https://github.com/Pycord-Development/pycord/pull/2656))
9092

9193
### Changed
9294

discord/ext/commands/help.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
import functools
3030
import itertools
3131
import re
32-
from typing import TYPE_CHECKING
32+
from typing import TYPE_CHECKING, Any
3333

3434
import discord.utils
35+
from discord.ext import bridge
3536

3637
from .core import Command, Group
3738
from .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

Comments
 (0)