New custom command doesn't work, JS error


Please fill out the following so that we might better serve your request. Please attach logs and console messages as well.

Stock PhantomBot: Yes
Any Recent Changes to Your System: No

Error when executing custom command.



Could we see the custom command?


[01:21:01 AM] @%z00z_ow: !addcom !map Vale enjoys King’s Row the most
[01:21:01 AM] @%^BotMainBTW: @z00z_ow, Command !map has been created!


My presumption is that map() is a JavaScript/Java function and that command is being interpreted as a JavaScript/Java function. I presume if you use a different command name it is fine?

[09-28-2017 @ 01:16:15.181 MDT] [CONSOLE] Executing debugon: Enable Debug Mode
[09-28-2017 @ 01:16:15.182 MDT] [DEBUG] [onEvent()] Dispatched event ConsoleInputEvent
[09-28-2017 @ 01:16:16.657 MDT] [ERROR] [onEvent()] Failed to dispatch event tv.phantombot.event.command.CommandEvent
org.mozilla.javascript.EcmaError: TypeError: Cannot call method "indexOf" of undefined (init.js#447)
	at org.mozilla.javascript.ScriptRuntime.constructError(
	at org.mozilla.javascript.ScriptRuntime.constructError(
	at org.mozilla.javascript.ScriptRuntime.typeError(
	at org.mozilla.javascript.ScriptRuntime.typeError2(
	at org.mozilla.javascript.ScriptRuntime.undefCallError(
	at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(
	at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(
	at org.mozilla.javascript.gen.init_js_1._c_anonymous_28(init.js:447)
	at org.mozilla.javascript.ContextFactory.doTopCall(
	at org.mozilla.javascript.ScriptRuntime.doTopCall(
	at org.mozilla.javascript.InterfaceAdapter.invokeImpl(
	at org.mozilla.javascript.InterfaceAdapter$
	at org.mozilla.javascript.InterfaceAdapter.invoke(
	at org.mozilla.javascript.jdk13.VMBridge_jdk13$1.invoke(
	at com.sun.proxy.$Proxy8.handle(Unknown Source)
	at tv.phantombot.script.ScriptEventManager.onEvent(
	at tv.phantombot.PhantomBot.handleCommand(
	at tv.phantombot.PhantomBot.consoleInput(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(

The entire error log is beneficial, like you see above. Will look into this a little more and see if it is, in fact, the name of the custom command that seems to be causing the problem.


So, this is what Rhino is doing:

[09-28-2017 @ 01:36:50.843 MDT] test alias [map] [function map() { [native code for, arity=1] }

It is literally treating ‘map’ as map() as I thought. Attempting to cast this as a String() is not making a difference either. This seems like an interesting Rhino bug. Our only course of action may be to not allow a JavaScript keyword to be used as a command, unfortunately, at this time.


I may have a fix, casting objects for aliases and cooldown differently:

[09-28-2017 @ 02:03:43.429 MDT] [CHAT] Vale enjoys King’s Row the most

However, I need to test cooldowns before pushing the fix, which will be sometime tomorrow. I am not keen to accidentally breaking cooldowns on accident since I changed that module as well.


Tested this morning.


I tested it with the very latest nightly (9/28) and I get the same exact error.


The update was 5 hours ago, you won’t see the fix until the next nightly build (or earlier if you build it yourself)


Ah, thanks


Yeah, sorry about that, I was testing in the morning since it was hovering around 2:00am my time and I host calls for work in the morning. The build is at 5:00am Mountain Time each time. Sometimes we run a manual build from the build server, but not always.


This topic was automatically closed after 30 days. New replies are no longer allowed.