Skip to content

fix(commands): retrieve localization key for subcommand groups from docstring #1285

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/1285.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
|commands| Fix extracting localization key for :meth:`~ext.commands.InvokableSlashCommand.sub_command_group`\s from docstring, to be more consistent with top-level slash commands and sub commands.
7 changes: 6 additions & 1 deletion disnake/ext/commands/slash_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,13 @@ def __init__(
super().__init__(func, name=name_loc.string, **kwargs)
self.parent: InvokableSlashCommand = parent
self.children: Dict[str, SubCommand] = {}

# while subcommand groups don't have a description, parse the docstring regardless to
# retrieve the localization key, if any
docstring = utils.parse_docstring(func)

self.option = Option(
name=name_loc._upgrade(self.name),
name=name_loc._upgrade(self.name, key=docstring["localization_key_name"]),
description="-",
type=OptionType.sub_command_group,
options=[],
Expand Down
Loading