Skip to content

Commit

Permalink
[commands] Fix displayed_default for callables and None values
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapptz committed Aug 10, 2023
1 parent c67a0c1 commit 3679b7c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion discord/ext/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ def signature(self) -> str:
if not param.required:
# We don't want None or '' to trigger the [name=value] case and instead it should
# do [name] since [name=None] or [name=] are not exactly useful for the user.
if param.default is not None and param.displayed_default:
if param.displayed_default:
result.append(
f'[{name}={param.displayed_default}]' if not greedy else f'[{name}={param.displayed_default}]...'
)
Expand Down
8 changes: 7 additions & 1 deletion discord/ext/commands/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,13 @@ def displayed_default(self) -> Optional[str]:
if self._displayed_default is not empty:
return self._displayed_default

return None if self.required else str(self.default)
if self.required:
return None

if callable(self.default) or self.default is None:
return None

return str(self.default)

@property
def displayed_name(self) -> Optional[str]:
Expand Down

0 comments on commit 3679b7c

Please sign in to comment.