Error message: onEvent()@ScriptEventManager.java:79, since latest bot update

training
commands
customscript

#1

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

$.mystuff(event);

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<>@ScriptEventManager.java:79] 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


#2

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


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

		//do not handle bot stuff
		if(sender.equalsIgnoreCase($.botName)){
			return;
		}

		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);}
		else{$.mystuff_command_unknown(event);}
    return;
}

Previouse post on what we are trying to do:


#4

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.


#5

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


#6

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.


#7

Hi @kojitsari,

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

thx

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


#8

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

it wont connect to my chat via web portal


#9


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()@ScriptEventManager.java:79] 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(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.undefReadError(ScriptRuntime.java:3993)
        at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1505)
        at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1240)
        at script.callHook(init.js:301)
        at script(init.js:491)
        at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:815)
        at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:109)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3282)
        at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:107)
        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.$Proxy2.handle(Unknown Source)
        at tv.phantombot.script.ScriptEventManager.onEvent(ScriptEventManager.java:75)
        at tv.phantombot.twitchwsirc.TwitchWSIRCParser.commandEvent(TwitchWSIRCParser.java:255)
        at tv.phantombot.twitchwsirc.TwitchWSIRCParser.privMsg(TwitchWSIRCParser.java:320)
        at tv.phantombot.twitchwsirc.TwitchWSIRCParser.access$100(TwitchWSIRCParser.java:55)
        at tv.phantombot.twitchwsirc.TwitchWSIRCParser$2.exec(TwitchWSIRCParser.java:92)
        at tv.phantombot.twitchwsirc.TwitchWSIRCParser.parseLine(TwitchWSIRCParser.java:220)
        at tv.phantombot.twitchwsirc.TwitchWSIRCParser.parseData(TwitchWSIRCParser.java:151)
        at tv.phantombot.twitchwsirc.TwitchWSIRC$MessageRunnable.run(TwitchWSIRC.java:284)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

#10

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.


#11

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


#12

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.


#13

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.


#14

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