New custom command doesn't work, JS error


#1

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.

onEvent()@ScriptEventManager.java:79


#2

Could we see the custom command?


#3

[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!


#4

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()@ScriptEventManager.java:77] Dispatched event ConsoleInputEvent
map
[09-28-2017 @ 01:16:16.657 MDT] [ERROR] [onEvent()@ScriptEventManager.java:79] 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(ScriptRuntime.java:3951)
	at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3929)
	at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3962)
	at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3981)
	at org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3998)
	at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2414)
	at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2407)
	at org.mozilla.javascript.gen.init_js_1._c_anonymous_28(init.js:447)
	at org.mozilla.javascript.gen.init_js_1.call(init.js)
	at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
	at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3282)
	at org.mozilla.javascript.gen.init_js_1.call(init.js)
	at org.mozilla.javascript.InterfaceAdapter.invokeImpl(InterfaceAdapter.java:137)
	at org.mozilla.javascript.InterfaceAdapter$1.run(InterfaceAdapter.java:83)
	at org.mozilla.javascript.Context.call(Context.java:501)
	at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:503)
	at org.mozilla.javascript.InterfaceAdapter.invoke(InterfaceAdapter.java:86)
	at org.mozilla.javascript.jdk13.VMBridge_jdk13$1.invoke(VMBridge_jdk13.java:132)
	at com.sun.proxy.$Proxy8.handle(Unknown Source)
	at tv.phantombot.script.ScriptEventManager.onEvent(ScriptEventManager.java:75)
	at tv.phantombot.PhantomBot.handleCommand(PhantomBot.java:1931)
	at tv.phantombot.PhantomBot.consoleInput(PhantomBot.java:1912)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
	at com.google.common.eventbus.EventBus.post(EventBus.java:275)
	at tv.phantombot.event.EventBus.post(EventBus.java:57)
	at tv.phantombot.console.ConsoleInputListener.run(ConsoleInputListener.java:32)

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.


#5

So, this is what Rhino is doing:

[09-28-2017 @ 01:36:50.843 MDT] test alias [map] [function map() { [native code for Array.map, 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.


#6

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

map
[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.


#7

Tested this morning.

https://github.com/PhantomBot/PhantomBot/pull/1690


#8

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


#9

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


#10

Ah, thanks


#11

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.


#12

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