From 2f371d00ed31b73942257f93ae7a81d07271c2c1 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Fri, 9 May 2025 04:03:32 +0200 Subject: [PATCH] Add message latency to ping command --- commands/misc/ping.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/commands/misc/ping.js b/commands/misc/ping.js index 6e23a0c..fe9fb09 100644 --- a/commands/misc/ping.js +++ b/commands/misc/ping.js @@ -1,7 +1,11 @@ module.exports = { name: 'ping', description: 'Just ping.', - execute({message, client}) { - message.channel.send(`Pong.\n${client.ws.ping}ms`) + async execute({message, client}) { + let apiLatency = client.ws.ping; + const time = process.hrtime.bigint(); + let initialMessage = await message.channel.send(`Pong.`) + const diff = Number(process.hrtime.bigint() - time) * 1e-6; + initialMessage.edit(`Pong.\nAPI latency: ${apiLatency} ms\nMessage latency: ${diff.toFixed(0)} ms.`); } }; \ No newline at end of file