Inaccurate ping measurement with client.ws.ping

Every time I pull from client.ws.ping, it outputs -1, regardless of the connection I'm on or the speed at which it's running. Is there a reason for this? This has been happening to me for as long as I've been familiar with discord.js (I think since v11)
8 Replies
d.js toolkit
d.js toolkit4w ago
Amgelo
Amgelo4w ago
that means the first heartbeat hasn't been received, it won't be -1 past the first minute
dallas
dallasOP4w ago
So the bot recieves a hearbeat every minute?
Amgelo
Amgelo4w ago
technically it's not known, since the heartbeat interval is part of the data received while connecting, it's not hardcoded but afaik it's usually somewhere around 40s
dallas
dallasOP4w ago
So there's no way to use an eventlistener for it then
Amgelo
Amgelo4w ago
for the heartbeat?
dallas
dallasOP4w ago
yeah I just found you can use
client.on(Events.Debug, (message) => {
if (message.includes('Heartbeat')) {
console.log(`Heartbeat: ${message}`)
}
})
client.on(Events.Debug, (message) => {
if (message.includes('Heartbeat')) {
console.log(`Heartbeat: ${message}`)
}
})
Showed Heartbeat: [WS => Shard 0] Heartbeat acknowledged, latency of 30ms.
d.js toolkit
d.js toolkit4w ago
The thread owner has marked this issue as solved.

Did you find this page helpful?