Skip to content
Open
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
16 changes: 16 additions & 0 deletions discord/ext/commands/hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@ def replace_parameters(
) -> List[inspect.Parameter]:
# Need to convert commands.Parameter back to inspect.Parameter so this will be a bit ugly
params = signature.parameters.copy()

pending_rename: Dict[str, str] = {}
pending_description: Dict[str, str] = {}
for name, parameter in parameters.items():

converter = parameter.converter
# Parameter.converter properly infers from the default and has a str default
# This allows the actual signature to inherit this property
Expand All @@ -282,6 +286,12 @@ def replace_parameters(
default = _CallableDefault(parameter.default) if callable(parameter.default) else parameter.default
param = param.replace(default=default)

if parameter.description:
pending_description[name] = parameter.description

if parameter.displayed_name:
pending_rename[name] = parameter.displayed_name

if isinstance(param.default, Parameter):
# If we're here, then then it hasn't been handled yet so it should be removed completely
param = param.replace(default=parameter.empty)
Expand All @@ -293,6 +303,12 @@ def replace_parameters(

params[name] = param

if pending_description:
app_commands.describe(**pending_description)(callback)

if pending_rename:
app_commands.rename(**pending_rename)(callback)

return list(params.values())


Expand Down