Discord bot does sometimes only respond after two times

Java Version: 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11
OS Version: Linux 4.4.0-83-generic (amd64)
Panel Version: 1.1
PhantomBot Version: (Revision: 334e6502)
Stock Phantombot: Yes
Recent Changes To OS: No



We’re using phantombot mainly as a discord bot. We notice that the commands are getting slower and slower though. We have a pretty big list of commands (about 50) which are limited to 10 channels of the 40 of our server. A lot of times the bot only reacts after entering the command two times. After it reacted on posting the command the second time the bot seems to be faster. But after a while it doesn’t react to the first time posting the command.

An example of this can be seen over here: https://cdn.kayzr.com/sharex/fraise/11/11/2017-11-11_12-06-02.jpg

Also sometimes the bot doesn’t post that we’re live on twitch in discord. very odd. at times it does, other times it doesn’t

Any help appreciated.


do u have cooldowns set on discord commands? cus that could be 1 reason for the no reply every time


There’s no cooldown, all set on 0 seconds. And as I state, they work is you triggered a command just before but not if it has been a long time since a command has been called. So timer is not the case


Another screenshot, look at the timestamps, after about 5 minutes of inactivity it doesn’t react anymore.


There’s a cool down on live messages to prevent spam when the Twitch API decides to shit itself (happens oddly frequently). Believe the cool down is ~30 minutes, if you’re not hitting that then the odds are the API used to get the “going live” notification is hiccuping (not really anything we can do here).

As for the random command slowdowns unless you have logs for us, I would recommend updating to the nightly build pushed last night. Scania debugged and fixed an issue with some caches that was causing the Twitch side to slow down, and it may or may not be affecting Discord.


This could be your server not handling well, or losing connection to Discord. Keep and eye on the console times of when the bot reads the message and when it is sent. I’d also suggest trying the latest nightly build to see if that clears up any issues.


In what logfile should I be looking to see such behaviour?

EDIT: I’ve found the error logs in the ‘core-error’ folder, I get the following error:
[11-15-2017 @ 16:55:19.001 GMT] [lambda$sendMessage$0()@DiscordUtil.java:67] Failed to send a message: [DiscordException] Message was unable to be sent (Discord didn't return a response).

EDIT2: and then sometimes when it doesn’t react it shows in the logs it does…
The imgur album contains two images, what I see in discord and what I see in the server logs. Those are not the same


The message itself is not generated by PhantomBot, but the library that interfaces with Discord that we do not support, we just use.

In reading that code, what happens is the message is sent to Discord, but then null is returned. In glancing over the Discord4J code, it looks as if this is thrown when an IOException is caught while talking to the Discord servers.

Typically, in Java, IOException is thrown during a communication error in talking with the remote service (not always, but typically, I didn’t read all the code and see if any other calls would throw IOException). It could be as a simple as a network hiccup, machine not able to keep up with socket connections, or a blip at Discord.

Can you do the following from the shell on the server, I am curious:

cat /proc/cpuinfo | egrep "model name|cpu cores"

Also, based on your spelling of ‘behaviour’ may I assume that you are not based in the US? I wonder what your latency is to the Discord API servers.



I did run the command and got the following output:

model name	: Intel(R) Xeon(R) CPU E5-2673 v3 @ 2.40GHz
cpu cores	: 1

It’s running on an azure server in Amsterdam.


Azure is known for doing weird things with connections, you might be experiencing this, and I think all of Discord’s API servers are located in the US, so that could also be an issue. Can you run a quick traceroute gateway.discord.gg and see if you have any high pings or a long route.



My apologies for the late reply! I did a traceroute and that only returns stars, so no useful information. Doing a ping though gives me no loss and a 4ms average response time. So that seems to be correct, no spikes.

--- gateway.discord.gg ping statistics ---
76 packets transmitted, 76 received, 0% packet loss, time 75242ms
rtt min/avg/max/mdev = 3.513/3.772/4.115/0.137 ms


If Discord isn’t sending a response back, that means you probably lost connection with their web socket. That could just be Discord having issues or your connection isn’t stable at times with Discord. The only time I notice is a slowdown is when I have the bot in multiple servers, which you should never do because PhantomBot isn’t designed for it.


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