From c8db766be427da39c9ae84cf8546223b8f11f85c Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 14 Aug 2022 05:36:35 -0400 Subject: [PATCH] Fix empty strings crashing Namespace for float options This feels like a Discord bug to me but it's causing issues --- discord/app_commands/namespace.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/discord/app_commands/namespace.py b/discord/app_commands/namespace.py index bd6b0f833..d7b6eb8c2 100644 --- a/discord/app_commands/namespace.py +++ b/discord/app_commands/namespace.py @@ -142,7 +142,8 @@ class Namespace: self.__dict__[name] = value elif opt_type == 10: # number value = option['value'] # type: ignore # Key is there - if value is None: + # This condition is written this way because 0 can be a valid float + if value is None or value == '': self.__dict__[name] = float('nan') else: self.__dict__[name] = float(value)