Skip to content

Instantly share code, notes, and snippets.

@KOULIKS94
Last active March 10, 2025 06:24
Show Gist options
  • Select an option

  • Save KOULIKS94/27344d2f58899e4ca196d45c7208e72b to your computer and use it in GitHub Desktop.

Select an option

Save KOULIKS94/27344d2f58899e4ca196d45c7208e72b to your computer and use it in GitHub Desktop.
module.exports = {
name: "ping",
description: "Check bot response time",
execute: async (client, message) => {
try {
const start = Date.now(); // Get timestamp before sending reply
const sentMessage = await client.sendMessage(message.key.remoteJid, { text: "Pinging..." });
const end = Date.now(); // Get timestamp after sending reply
const ping = end - start; // Calculate latency
await client.sendMessage(message.key.remoteJid, { text: `Pong! 🏓 Response time: ${ping}ms` });
} catch (error) {
console.error("Ping command error:", error);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment