From 33193b249f934a5ab5076f11036035bd12a34193 Mon Sep 17 00:00:00 2001 From: Middledot Date: Sun, 5 Nov 2023 21:49:03 -0500 Subject: [PATCH] fix(ext.commands): command parsing bug #2089 --- discord/ext/commands/core.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index d3ce2e07db..6d7f198189 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -49,6 +49,7 @@ message_command, slash_command, user_command, + Option ) from ...enums import ChannelType from ...errors import * @@ -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 @@ -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: