Skip to content

Commit

Permalink
fix(ext.commands): command parsing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Middledot committed Nov 6, 2023
1 parent 9e4b3ff commit 33193b2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions discord/ext/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
message_command,
slash_command,
user_command,
Option
)
from ...enums import ChannelType
from ...errors import *
Expand Down Expand Up @@ -562,7 +563,13 @@ async def dispatch_error(self, ctx: Context, error: Exception) -> None:
ctx.bot.dispatch("command_error", ctx, error)

async def transform(self, ctx: Context, param: inspect.Parameter) -> Any:
required = param.default is param.empty
if isinstance(param.annotation, Option):
required = param.annotation.required or param.annotation.default is None
default = param.annotation.default
else:
required = (param.default is param.empty)
default = param.default

converter = get_converter(param)
consume_rest_is_special = (
param.kind == param.KEYWORD_ONLY and not self.rest_is_raw
Expand Down Expand Up @@ -599,7 +606,7 @@ async def transform(self, ctx: Context, param: inspect.Parameter) -> Any:
):
return await converter._construct_default(ctx)
raise MissingRequiredArgument(param)
return param.default
return default

previous = view.index
if consume_rest_is_special:
Expand Down

0 comments on commit 33193b2

Please sign in to comment.