How get bot latency?
bot.ws.ping
return -1
bot.ping
return NaN
Date.now() - message.createdTimestamp
not is latency8 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPdiscord.js - 14.13.0
Node.js - v21.1.0
Ping returns -1 initially because the first heartbeat hasn't been sent yet
That can take max 41s
The ping is sometimes real, but most often it is
-1
.
@wolvinny 🌈
Wait for the bot to send its first heartbeat, which is usually 41ms after the WS connected
41s
I'm waiting more than 41ms after starting the bot. Or need 41 seconds?