cmd.client.ping

Returns the bot's current WebSocket heartbeat latency in milliseconds.

JavaScript
const { cmd } = require("syntx.js");

cmd.client.ping(client);

Parameters

ParameterTypeRequiredDescription
clientERXClientYesThe syntx.js client instance.

Returns

number : The WebSocket ping in milliseconds.

Example

JavaScript
client.command({
  name: "ping",
  content: (message) => {
    const ms = cmd.client.ping(client);
    message.reply(`Pong! Latency: ${ms}ms`);
  },
});

Warning

This function must be called after the bot has logged in. Calling it before the WebSocket connection is established will throw a SyntxError because client.bot.ws is not yet available.

Note

The value returned is the WebSocket heartbeat latency, not the full round-trip time of an API call. For a more complete latency measurement, you can compare the difference between when a message was sent and when the reply was received.