Error with discord bot

I am using the stable 3.0 build. I had it set up on a vps and everything was working awesome, But my hosting went down and i lost my backup from hosting. So yesterday i looked up and found better windows vps hosting. I followed the same tut i used the first time it went so well. Everything currently is working and used same info and discord bot would never work. it joined the discord and would not post anything or respond to commands and i was getting this error every time. I searched for a fix but nothing was working. I even tried to make a new bot on discord incase it had to do with the discord bot token or anything and same result.

[10-29-2019 @ 06:35:10.981 GMT] [init.js:325] Error with Event Handler [twitchOnline] Script [./discord/handlers/streamHandler.js] Stacktrace [setStream()@misc.js:131
init.js:853] Exception [JavaException: java.lang.NullPointerException: null]
[10-29-2019 @ 06:35:44.952 GMT] [init.js:325] Error with Event Handler [twitchClip] Script [./discord/handlers/clipHandler.js] Stacktrace [clipHandler.js:67
init.js:622] Exception [JavaException: java.lang.NullPointerException: null]

1 Like

Thank you, i had the same problem since 5 days in the evening MEZ.
The modified File solved the Problem.
Would you kindly explain what caused the Problem and why it suddenly occurred in one of my bots and the other works perfectly well without the patch.

The old Discord4J (Version 2.x, the library we use to connect to Discord) was not programmed properly. When Discord added the Custom Status feature, it added a new potential value that could be used to represent the User’s Status, called presence. This value just represents the basic state like Playing or Watching and then additional values are used to get the info associated with this state.

Because D4J 2.x does not recognize the new presence value for Custom Status and has not been programmed to handle unknown values properly, it throws an Exception. Unfortunately for us, when the bot comes online, part of the setup that Discord’s API performs as we connect to the WebSocket is to send us the details of the servers (called Guilds) that the bot is apart of, including detailed information about each member, which includes presence.

Thus, when the bot connects, it gets that somebody had a custom status and the Exception prevents our logic from properly registering information about Discord (this occurs AFTER the authenticated with Discord message), which in turn causes all the other hooks to not setup correctly.

The patched jar is one that I recompiled with the custom status value being added in to D4J’s presence parsing. You can see the patch here. I honestly can’t remember where the offending line of code that actually throws the Exception is

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