Skip to content

Commit

Permalink
Fix callable FlagConverter defaults on hybrid commands
Browse files Browse the repository at this point in the history
fix: Callable FlagConverter defaults being returned as-is on interaction based calls.
  • Loading branch information
DA-344 authored Jan 15, 2025
1 parent ed95f2f commit 7c8503f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion discord/ext/commands/hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ def replace_parameter(
descriptions[name] = flag.description
if flag.name != flag.attribute:
renames[name] = flag.name
if pseudo.default is not pseudo.empty:
# This ensures the default is wrapped around _CallableDefault if callable
# else leaves it as-is.
pseudo = pseudo.replace(
default=_CallableDefault(flag.default) if callable(flag.default) else flag.default
)

mapping[name] = pseudo

Expand Down Expand Up @@ -283,7 +289,7 @@ def replace_parameters(
param = param.replace(default=default)

if isinstance(param.default, Parameter):
# If we're here, then then it hasn't been handled yet so it should be removed completely
# If we're here, then it hasn't been handled yet so it should be removed completely
param = param.replace(default=parameter.empty)

# Flags are flattened out and thus don't get their parameter in the actual mapping
Expand Down

0 comments on commit 7c8503f

Please sign in to comment.