Custom scripts don't work with commands I register


PhantomBot Version: 2.4.1
OS Version: Linux (various)
Java Version: 1.8.0_172
Browser and Version (for Panel Support):
Stock PhantomBot: No (see below)

I have recently started tinkering with PhantomBot for use with a small (for now mainly discord) community, and first of all I want to thank you for this awesome piece of software!

For a couple days however I have had an issue, that I don’t know how to deal with. Maybe it’s something really stupid, but I couldn’t figure it out for multiple days, so I ask for your help.

I have written a couple simple scripts, some of which have worked for quite a while. The other day I noticed that a new script doesn’t work. So I decided to try a clean install. Since I have been unable to get any of the scrips working …

Log I'll be refering to

[08-14-2018 17:46:08.074 GMT] The working directory is: /home/philipp/Projects/Hades9/Bot/Dev/PhantomBot/dist/PhantomBot-2.4.1
[08-14-2018 17:46:08.076 GMT] Detected Java 1.8.0_172 running on Linux 4.17.12-1.1-MANJARO (amd64)
[08-14-2018 17:46:08.078 GMT] Debug Mode Enabled
[08-14-2018 17:46:08.079 GMT]
[08-14-2018 17:46:08.080 GMT] PhantomBot Version: 2.4.1
[08-14-2018 17:46:08.080 GMT] Build Revision: 9412ad98
[08-14-2018 17:46:08.080 GMT] Creator: mast3rplan
[08-14-2018 17:46:08.080 GMT] Developers: PhantomIndex, Kojitsari, ScaniaTV, Zackery (Zelakto) & IllusionaryOne
[08-14-2018 17:46:08.080 GMT]
[08-14-2018 17:46:08.080 GMT]
[08-14-2018 17:46:08.144 GMT] [DEBUG] [()] Checking database indexes, please wait…
[08-14-2018 17:46:08.244 GMT] YouTubeSocketServer accepting connections on port: 25003
[08-14-2018 17:46:08.247 GMT] PanelSocketServer accepting connections on port: 25004
[08-14-2018 17:46:08.254 GMT] HTTP server accepting connection on port: 25000
[08-14-2018 17:46:09.048 GMT]
["Loaded Module"s removed]
[08-14-2018 17:46:10.443 GMT] Successfully authenticated with Discord.
["Loaded Module"s removed]
[08-14-2018 17:46:10.668 GMT] Loaded module: discord/custom/test.js (Enabled)
["Loaded Module"s removed]
[08-14-2018 17:46:10.795 GMT] [EVENT] [init.js:371] Bot modules loaded. Initializing main functions…
[08-14-2018 17:46:10.800 GMT]
[08-14-2018 17:46:10.800 GMT] For support please visit:
[08-14-2018 17:46:10.800 GMT]
[08-14-2018 17:46:11.442 GMT] Bot Verification Status: NOT Verified.
[08-14-2018 17:46:11.453 GMT] Connecting to Twitch WS-IRC Server (SSL) []
[08-14-2018 17:46:11.464 GMT] [DEBUG] [backupSQLite3()] Backed up SQLite3 DB to ./dbbackup/
[08-14-2018 17:46:11.768 GMT] [DEBUG] [onOpen()] PanelSocketServer: Connection from localhost.localdomain:60548
[08-14-2018 17:46:12.437 GMT] Connected to [email protected] (SSL)
[08-14-2018 17:46:12.444 GMT] [DEBUG] [onEvent()] Dispatched event IrcConnectCompleteEvent
[08-14-2018 17:46:12.654 GMT] Channel Joined [#hades9bot]
[08-14-2018 17:46:12.656 GMT] [DEBUG] [onEvent()] Dispatched event IrcJoinCompleteEvent
[08-14-2018 17:46:12.657 GMT] [DEBUG] [ircJoinComplete()] ircJoinComplete::hades9bot
[08-14-2018 17:46:12.664 GMT] [DEBUG] [updateCache()] TwitchCache::updateCache
[08-14-2018 17:46:12.669 GMT] [DEBUG] [updateCache()] ViewerListCache::updateCache
[08-14-2018 17:46:12.884 GMT] [DEBUG] [onJoin()] User Joined Channel [hades9bot -> hades9bot]
[08-14-2018 17:46:12.894 GMT] [DEBUG] [onEvent()] Dispatched event IrcChannelJoinEvent
[08-14-2018 17:46:12.899 GMT] hades9bot ready!
[08-14-2018 17:46:12.935 GMT] [EVENT] [logging.js:195] Starting Log Rotation
[08-14-2018 17:46:12.949 GMT] [EVENT] [logging.js:208] Finished Log Rotation
[08-14-2018 17:46:13.217 GMT] [DEBUG] [onEvent()] Dispatched event IrcChannelUserModeEvent
[08-14-2018 17:46:13.601 GMT] [DEBUG] [onEvent()] Dispatched event IrcChannelUsersUpdateEvent
[08-14-2018 17:46:14.303 GMT] [DEBUG] [onEvent()] Dispatched event DiscordChannelMessageEvent
[08-14-2018 17:46:15.450 GMT] [DEBUG] [updateCache()] TwitchCache::setTwitchCacheReady(true)
[08-14-2018 17:46:22.441 GMT] [DEBUG] [lambda$onOpen$0()] Sending a PING to Twitch.
[08-14-2018 17:46:32.667 GMT] [DEBUG] [updateCache()] FollowersCache::updateCache
[08-14-2018 17:46:32.946 GMT] [DEBUG] [onEvent()] Dispatched event TwitchFollowsInitializedEvent
[08-14-2018 17:46:33.871 GMT] [DISCORD] [#Tyrius] tyrius: !account
[08-14-2018 17:46:33.879 GMT] [DEBUG] [onEvent()] Dispatched event DiscordChannelMessageEvent
[08-14-2018 17:46:33.888 GMT] [ERROR] [lambda$sendMessage$0()] Failed to send a message: [DiscordException] Failed to send message due to the channel object being null.
[08-14-2018 17:46:33.892 GMT] [EVENT] [test.js:4] account
[08-14-2018 17:46:33.893 GMT] [DEBUG] [onEvent()] Dispatched event DiscordChannelCommandEvent
[08-14-2018 17:46:45.451 GMT] [DEBUG] [updateCache()] TwitchCache::updateCache
[08-14-2018 17:46:51.137 GMT] [DISCORD] [#Tyrius] tyrius: !testcom
[08-14-2018 17:46:51.139 GMT] [DEBUG] [onEvent()] Dispatched event DiscordChannelCommandEvent
[08-14-2018 17:46:51.141 GMT] [DEBUG] [onEvent()] Dispatched event DiscordChannelMessageEvent
[08-14-2018 17:47:02.947 GMT] [DEBUG] [updateCache()] FollowersCache::updateCache
[08-14-2018 17:47:15.356 GMT] [DEBUG] [onJoin()] User Joined Channel [lordtyrius -> hades9bot]

(shortened for readability as indicated, removed @ because else discourse doesn’t let me post, as it thinks I’m mentioning a bunch of people)

I wrote a minimal script to try and debug my issue:

    $.bind('discordChannelCommand', function(event){

    $.bind('initReady', function(){
        $.discord.registerCommand('./discord/custom/test.js', 'testcom', 1);

What I want this to do: Whenever a command-event happens, it logs what event it was.
It also registers a custom command.

As you can see in the log: when I send a command like !account, it triggers both message and command events, and my test.js logs that. When I type !testcom, the same events trigger, but nothing else happens. As a result none of my scripts get any reaction.

I’m pretty much clueless at this point, I hope you can help me (or point me into the right direction).

Regarding modifications I made to the bot: Only minor stuff. You can see the “null” error in response to !account? that happens because I’m using private messaging. I’ve modified the bot to handle DMs for me (which comes down to using event.getDiscordChannel() and using the IChannel object to “say” the reply instead of calling say with the channel name as a string). I used my modified local version to take the logs, however I am experiencing the same behaviour with a clean v2.4.1 build from official github.

Best Regards,


I managed to resolve the issues, mostly.

It was a combination of setting wrong permissions and having faulty data in the “discordPermcom” database.

Is there any more documentation available than I’ve been able to find on these forums so far? I mean I’m learning about the inner workings of the bot every time I look at the code, but it would have helped to know what a certain parameter does e.g. that the registerCommand() of discord gets 0 (not admin) and 1 (admin) as permission.

Topics like (How to make your own Script) have been super helpful to me, because they teach about how you designed and implemented things. What are other must read resources for someone who tries to mod the bot (core and scripts)?


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