(random) tag return error



PhantomBot Version: 2.4.2
OS Version: Windows Server 2012 R2 6.3
Java Version: 1.8.0_191-b12
Browser and Version:
Stock PhantomBot: Yes

Sometimes custom commands whose responses contain a tag (random) or (1=random) return an error:

[ERROR] (init.js: 300) (hook.call, command, ./commands/customCommands.js) TypeError Cannot read property "0" from undefined

At the request of @IllusionaryOne


Thanks for opening the ticket!

The issue is due to the way that the $.users array is handled. For now, have put in a patch to customCommands.js when handling (random) and (randomrank) to always choose the bot as the random user if there is an error.

This was in last night’s Nightly and will be in the next stable release (unless the Permissions rewrite is done prior to that release, then this may be pulled).