Check for none instead of falsy in arg matching
This commit is contained in:
parent
03a1fdaaf5
commit
4e767a10e4
@ -129,7 +129,7 @@ class CommandHandler:
|
|||||||
try:
|
try:
|
||||||
remaining_val, call_args[arg.name] = arg.match(remaining_val.strip(), evt=evt,
|
remaining_val, call_args[arg.name] = arg.match(remaining_val.strip(), evt=evt,
|
||||||
instance=self.__bound_instance__)
|
instance=self.__bound_instance__)
|
||||||
if arg.required and not call_args[arg.name]:
|
if arg.required and call_args[arg.name] is None:
|
||||||
raise ValueError("Argument required")
|
raise ValueError("Argument required")
|
||||||
except ArgumentSyntaxError as e:
|
except ArgumentSyntaxError as e:
|
||||||
await evt.reply(e.message + (f"\n{self.__mb_usage__}" if e.show_usage else ""))
|
await evt.reply(e.message + (f"\n{self.__mb_usage__}" if e.show_usage else ""))
|
||||||
@ -303,7 +303,7 @@ class CustomArgument(Argument):
|
|||||||
orig_val = val
|
orig_val = val
|
||||||
val = re.split(r"\s", val, 1)[0]
|
val = re.split(r"\s", val, 1)[0]
|
||||||
res = self.matcher(val)
|
res = self.matcher(val)
|
||||||
if res:
|
if res is not None:
|
||||||
return orig_val[len(val):], res
|
return orig_val[len(val):], res
|
||||||
return orig_val, None
|
return orig_val, None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user