Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Duplication in bridge command help #2415

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2407](https://github.com/Pycord-Development/pycord/pull/2407))
- Fixed invalid data being passed to `Interaction._guild` in certain cases.
([#2411](https://github.com/Pycord-Development/pycord/pull/2411))
- Fixed `BridgeCommand` duplication in default help commands.
([#2415](https://github.com/Pycord-Development/pycord/pull/2415))
- Fixed option typehints being ignored when using `parameter_name`.
([#2417](https://github.com/Pycord-Development/pycord/pull/2417))
- Fixed parameter `embed=None` causing `AttributeError` on `PartialMessage.edit`.
Expand Down
17 changes: 13 additions & 4 deletions discord/ext/commands/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,10 +995,19 @@ def add_indented_commands(self, commands, *, heading, max_size=None):
max_size = max_size or self.get_max_size(commands)

get_width = discord.utils._string_width
for command in commands:
name = command.name
width = max_size - (get_width(name) - len(name))
entry = f'{self.indent * " "}{name:<{width}} {command.short_doc}'
last_name = "" # check name duplicates
last_parent = "" # make sure those duplicates are under the same parent
for command_name, command_parent, command in [
(command.name, command.parent, command) for command in commands
]: # unpack parameters of command for each of the commands
if (
last_name == command_name and command_parent == last_parent
): # check if the last command is the same group and name
continue
last_name = command_name
last_parent = command_parent
width = max_size - (get_width(command_name) - len(command_name))
entry = f'{self.indent * " "}{command_name:<{width}} {command.short_doc}'
self.paginator.add_line(self.shorten_text(entry))

async def send_pages(self):
Expand Down