From 28341bd71d03188cfbf6bfc0ac3dd1bd15d1851d Mon Sep 17 00:00:00 2001 From: Declan Chidlow Date: Fri, 6 Mar 2026 11:53:28 +0800 Subject: [PATCH] Improve the ping command --- .../bot/commands/configuration/allowlist.ts | 4 ++-- .../src/bot/commands/miscellaneous/ping.ts | 21 ++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/bot/src/bot/commands/configuration/allowlist.ts b/packages/bot/src/bot/commands/configuration/allowlist.ts index c1853d9..2d88cb2 100644 --- a/packages/bot/src/bot/commands/configuration/allowlist.ts +++ b/packages/bot/src/bot/commands/configuration/allowlist.ts @@ -28,7 +28,7 @@ export default { if (config.whitelist.users?.length) { config.whitelist.users.forEach((u, index) => { - if (index < 15) str += `* <@${u}>\n`; + if (index < 15) str += `- <@${u}>\n`; if (index === 15) str += `**${config!.whitelist!.users!.length - 15} more user${config!.whitelist!.users!.length === 16 ? "" : "s"}**\n`; }); } else str += `**No users in the allowlist**\n`; @@ -37,7 +37,7 @@ export default { if (config.whitelist.roles?.length) { config.whitelist.roles.forEach((r, index) => { - if (index < 15) str += `* <%${r}>\n`; + if (index < 15) str += `- <%${r}>\n`; if (index === 15) str += `**${config!.whitelist!.roles!.length - 15} more role${config!.whitelist!.roles!.length === 16 ? "" : "s"}**\n`; }); } else str += `**No roles in the allowlist**\n`; diff --git a/packages/bot/src/bot/commands/miscellaneous/ping.ts b/packages/bot/src/bot/commands/miscellaneous/ping.ts index b2b9ee7..331e437 100644 --- a/packages/bot/src/bot/commands/miscellaneous/ping.ts +++ b/packages/bot/src/bot/commands/miscellaneous/ping.ts @@ -11,11 +11,30 @@ export default { category: CommandCategory.Miscellaneous, run: async (message: MessageCommandContext) => { const now = Date.now(); + const wsPing = client.events.ping(); + const wsDisplay = wsPing === null || wsPing < 0 ? "\`Reconnecting/Syncing…\`" : `\`${wsPing}ms\``; + + const uptime = process.uptime(); + const d = Math.floor(uptime / 86400); + const h = Math.floor((uptime % 86400) / 3600); + const m = Math.floor((uptime % 3600) / 60); + const s = Math.floor(uptime % 60); + + let uptimeStr = ""; + if (d > 0) uptimeStr += `${d}d `; + if (h > 0) uptimeStr += `${h}h `; + if (m > 0) uptimeStr += `${m}m `; + if (uptime < 300) uptimeStr += `${s}s`; + message .reply(`⌛ Measuring...`) ?.catch(console.error) .then((msg) => { - if (msg) msg.edit({ content: ["## Ping Pong!", `WebSocket: \`${client.events.ping() ?? "--"}ms\``, `Message: \`${Math.round(Date.now() - now)}ms\``].join("\n") }); + if (msg) { + msg.edit({ + content: ["## Ping Pong!", `WebSocket: ${wsDisplay}`, `Message: \`${Math.round(Date.now() - now)}ms\``, `Uptime: \`${uptimeStr.trim() || "0s"}\``].join("\n"), + }); + } }); }, } as SimpleCommand; -- 2.51.2