Bot not returning API latency
Hello, I'm trying to make my bot return API latency but it is responding with NaN.
In my code, API latency is defined as
const apiLatency = client.ws.ping;
. I also tried putting console.log(client.ws.ping)
but it still returned NaN. So I can't figure out whats the problem.4 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!Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Shows on the tag, 14.15.3
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessages] });
Ok yeah, that question made me realize the problem. I defined the client in the main.js of my "general plugin" instead of requiring the one from index.jsTry to log it 1 minute after the bot startup
During 1 minute, the ping equals -1 for any reason