Firebot
Firebot copied to clipboard
[Bug] $randomActiveViewer sometimes returns as string instead of doing it's job
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
Sometimes, $randomActiveViewer just appears in the message instead of returning a viewer name, at a time when there are active viewers.

My guess would be either an index out of bounds issue, or firebot sometimes forgets momentarily the active viewers list and it appears empty to the bot for an instant, although I can't access the logs to check more precisely (I'm not the streamer).
Expected Behavior
$randomActiveViewer should be replaced by a viewer name.
Steps To Reproduce
- Create a command using $randomActiveViewer.
- Have it used enough, by the looks of it
Version
5.52.0
What operating system are you using Firebot on?
Windows 10
Relevant log output
No response
Contact Details (Optional)
Alastor#8593
@Samuel38, do you have any logs that you can provide at the time that this happened?
Closing: Request for more information was not met
Hello,
With regards to the request for information, the details had been provided in the associates discord thread. I'm re-oppening this issue, because I have noticed it crop up again in the past few days.
Version : 5.53.2 other details remain unchanged.
The associated logs are :
15:33:45 GMT-0700 (Mountain Standard Time) - warn: [v5.53.2] Unable to parse variables for value: '$randomActiveViewer'
{
message: "Cannot read property 'toLowerCase' of undefined",
stack: "TypeError: Cannot read property 'toLowerCase' of undefined\n" +
' at Object.exports.getRandomActiveUser (C:\\Users\\jess\\AppData\\Local\\firebotv5\\app-5.53.2\\resources\\app.asar\\backend\\chat\\chat-listeners\\active-user-handler.js:58:34)\n' +
' at Object.evaluator (C:\\Users\\jess\\AppData\\Local\\firebotv5\\app-5.53.2\\resources\\app.asar\\backend\\variables\\builtin\\random-active-viewer.js:63:52)\n' +
' at VariableToken.evaluate (C:\\Users\\jess\\AppData\\Local\\firebotv5\\app-5.53.2\\resources\\app.asar\\node_modules\\expressionish\\src\\tokens\\variable.js:66:39)\n' +
' at evaluate (C:\\Users\\jess\\AppData\\Local\\firebotv5\\app-5.53.2\\resources\\app.asar\\node_modules\\expressionish\\src\\evaluate.js:50:39)\n' +
' at ReplaceVariableManager.evaluateText (C:\\Users\\jess\\AppData\\Local\\firebotv5\\app-5.53.2\\resources\\app.asar\\backend\\variables\\replace-variable-manager.js:51:16)\n' +
' at findAndReplaceVariables (C:\\Users\\jess\\AppData\\Local\\firebotv5\\app-5.53.2\\resources\\app.asar\\backend\\common\\effect-runner.js:30:66)\n' +
' at runEffects (C:\\Users\\jess\\AppData\\Local\\firebotv5\\app-5.53.2\\resources\\app.asar\\backend\\common\\effect-runner.js:124:15)\n' +
' at Object.processEffects (C:\\Users\\jess\\AppData\\Local\\firebotv5\\app-5.53.2\\resources\\app.asar\\backend\\common\\effect-runner.js:192:12)\n' +
' at C:\\Users\\jess\\AppData\\Local\\firebotv5\\app-5.53.2\\resources\\app.asar\\backend\\effects\\builtin\\conditional-effects\\conditional-effects.js:140:30'
}
It looks like the variable $randomActiveViewer returns Undefined for whatever reason. I can attest that there were active viewers at the time, so the list wasn't empty either. So my guess would be a timing issue where it fails if the database is in the process of being updated, and a possible solution might be to make use of semaphores.
Fixed in v5.55.0