Error message: onEvent(), since latest bot update



I installed the latest stable build from the homepage and after i adding my own script-file to the init.js with the line:


I placed it in line 438 in the init.js from the script-folder right after:

         * @event command
        $api.on($script, 'command', function(event) {
            var sender = event.getSender(),
                command = event.getCommand(),
                args = event.getArgs(),
                subCommand = $.getSubCommandFromArguments(command, args),
                isMod = $.isModv3(sender, event.getTags());

Now, after calling of my functions, i got these error-message which gives me not really an information to fix this:

[ERROR] [onEvent<>] Failed to dispatch event tv.phantombot.event.command.CommandEvent

Is there anything I can do? Thx for the help.

PhantomBot Version: stable 2.3.9
OS Version: Win Server 2012 R2 64-bit
Java Version: 8 Update 144 (Build 1.8.0_144-b01)
Browser and Version (for Panel Support): latest version of Mozilla Firefox
Stock PhantomBot: No


Might be helpful to know what $.mystuff(event); does for someone to help you?

function mystuff_events(event)
		var command = event.getCommand(),
		sender = event.getSender();

		//do not handle bot stuff

		if(command.equalsIgnoreCase('addpl')){				$.mystuff_command_addpl(event);}
		else if(command.equalsIgnoreCase('beastmode')){		$.mystuff_command_beastmode(event);}
		else if(command.equalsIgnoreCase('budokaitenkaichi')){$.mystuff_command_budokaitenkaichi(event);}
		else if(command.equalsIgnoreCase('bet')){			$.mystuff_command_bet(event);}
		else if(command.equalsIgnoreCase('betnight')){		$.mystuff_command_betnight(event);}
		else if(command.equalsIgnoreCase('blue')){			$.mystuff_command_blue(event);}
		else if(command.equalsIgnoreCase('red')){			$.mystuff_command_red(event);}
		else if(command.equalsIgnoreCase('elite')){			$.mystuff_command_elite(event);}
		else if(command.equalsIgnoreCase('duell')){			$.mystuff_command_duel(event);}
		else if(command.equalsIgnoreCase('fightsuperman')){	$.mystuff_command_fightsuperman(event);}
		else if(command.equalsIgnoreCase('pos')){			$.mystuff_command_pos(event);}
		else if(command.equalsIgnoreCase('pvp')){			$.mystuff_command_pvp(event);}
		else if(command.equalsIgnoreCase('joinpvp')){		$.mystuff_command_joinpvp(event);}
		else if(command.equalsIgnoreCase('powerlevel')){	$.mystuff_command_powerlevel(event);}
		else if(command.equalsIgnoreCase('shenlong')){		$.mystuff_command_shenlong(event);}
		else if(command.equalsIgnoreCase('training')){		$.mystuff_command_training(event);}
		else if(command.equalsIgnoreCase('watchforce')){	$.mystuff_command_watchforce(event);}
		else if(command.equalsIgnoreCase('zeno')){			$.mystuff_command_zeno(event);}
		else if(command.equalsIgnoreCase('ahu')){			$.mystuff_command_ahu(event);}

Previouse post on what we are trying to do:


We have figured out what is causing this Issue with the new version.
We get that error when we register a specific command:
$.registerChatCommand('./chrissstrahl/basic.js', 'training', 0);

Renaming our command resolved the error message.
$.registerChatCommand('./chrissstrahl/basic.js', 'train', 0);

I have not found any indication towards this kind of issue in the changelog, maybe I missed something, if not some kind of a heads up would have been really nice.


I have to correct my self, the error is still not fixed.
I have no clues as to where to look now.


Using !debugon will catch more details along the line of what you need. That error indicates that your JS is failing, with debug on when it fails it should throw the stacktrace into the console (or the stacktrace.txt file, which you should be able to check without debug on) that will provide more information for you to go off of and if all else fails try {} catch {} is your friend.

If you’re doing anything in the bot that touches core/existing scripts you need to be checking the files you modify when we release updates, Github is definitely your friend for this. While we document the things that are the most impacting for users, we do not document every single bug fix and tweak directly to the change log.


Hi @kojitsari,

where should i type that “!debugon” into?
Since the update non of my functions is working anymore :frowning:


Is there a link to the stable version before that one? maybe i should stay with the old version, doe. :confused:


im having the same issue: here is the full error code [ERROR] [onEvent()] Failed to dispatch event tv.phantombot.event.command.CommandEvent

it wont connect to my chat via web portal


After this erro, I tried to follow the tutoruial:

But the init.js has changed so I can’t really figure out how to do it.

[ERROR] [onEvent()] Failed to dispatch event tv.phantombot.event.command.CommandEvent
org.mozilla.javascript.EcmaError: TypeError: Cannot read property "scriptName" from undefined (init.js#301)
        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.undefReadError(
        at org.mozilla.javascript.ScriptRuntime.getObjectProp(
        at org.mozilla.javascript.Interpreter.interpretLoop(
        at script.callHook(init.js:301)
        at script(init.js:491)
        at org.mozilla.javascript.Interpreter.interpret(
        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.$Proxy2.handle(Unknown Source)
        at tv.phantombot.script.ScriptEventManager.onEvent(
        at tv.phantombot.twitchwsirc.TwitchWSIRCParser.commandEvent(
        at tv.phantombot.twitchwsirc.TwitchWSIRCParser.privMsg(
        at tv.phantombot.twitchwsirc.TwitchWSIRCParser.access$100(
        at tv.phantombot.twitchwsirc.TwitchWSIRCParser$2.exec(
        at tv.phantombot.twitchwsirc.TwitchWSIRCParser.parseLine(
        at tv.phantombot.twitchwsirc.TwitchWSIRCParser.parseData(
        at tv.phantombot.twitchwsirc.TwitchWSIRC$
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$ Source)
        at Source)


From what I can tell by this, is that you have an error in your custom code, when the bot tries to write that error, it fails to do, so the error is sent back to Java. On my end, error logging is working fine, when updating do not replace files or overwrite them, that may be why you’re getting these errors. Also, you should never edit init.js, use our $.bind function from your script to make a custom module.


The funny thing is that with the old bot version it seams to run without any issues.


That’s normal, a lot of changes were made from version 2.3.8 to 2.3.9. The core script (init.js) was completely rewritten.


Thanks, I’ll give it a try(test runs) some time.
But for the time being I will work with the old version until everything is working as planned.
So the frustrating bug hunting will be the last ting that needs to be done by then.


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