[Bug] ensureNumber returning 0 when passed a NULL value
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
cc: Ysur via discord So, for over a year I was using a number of commands to increment various counters and using ensureNumber to set the increment to 1 if the command was given without an explicit number. (For instance "!command 2" would increment the counter by 2 while "!command" would increment it by 1)
I think it was an update about November of 2023 that this broke for me. Using the command without an explicitly declared number stopped incrementing my counters. The workaround was to switch to using the commands with a 1 by default. But given some time, I circled back to this and find that ensureNumber appears to be returning a value of 0 when given a null value.
Here are some examples (removed unneccessary info) where I added output to chat (using this message content: Arg0: $arg[0] / $ensureNumber[$arg[0],1]) in addition to the counter line in chat:
!win
Arg0: / 0
Wins: 0 / Losses: 0
!win a
Arg0: a / 1
Wins: 1 / Losses: 0
!win 3
Arg0: 3 / 3
Wins: 4 / Losses: 0
So, my questions are these. Am/was I doing something incorrectly (i.e. is this expected behavior)? Did the update possibly break something on my installation and how would I go about fixing it (assuming it isn't a general code issue if it hasn't been fixed by this time)? Any other explanation for what is going on that I haven't considered?
Thanks in advance!
Expected Behavior
treat null as nan and return default number
Steps To Reproduce
No response
Version
5.62.1
What operating system are you using Firebot on?
Windows 10
Relevant log output
No response
Contact Details (Optional)
No response