Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 5076fe8

Browse files
committed
unfuck ping
1 parent a857bfe commit 5076fe8

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/commands/misc/ping.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChatInputCommandInteraction } from "discord.js";
1+
import { ChatInputCommandInteraction, EmbedBuilder, Colors } from "discord.js";
22
import { KOGBot } from "../../index.js"; // Adjust the path if necessary
33

44
class PingCommand implements SlashCommand {
@@ -14,16 +14,24 @@ class PingCommand implements SlashCommand {
1414
}
1515

1616
async execute(interaction: ChatInputCommandInteraction): Promise<void> {
17-
try {
18-
const sent = await interaction.reply({ content: "Ping!", fetchReply: true });
19-
const timeDiff = (sent.createdTimestamp - interaction.createdTimestamp);
20-
21-
22-
await interaction.editReply(`Pong! Latency is ${timeDiff}ms.`);
23-
} catch (error) {
24-
console.error(error);
25-
await interaction.reply("An error occurred while trying to check the latency.");
26-
}
17+
const ping = Math.floor(interaction.client.ws.ping);
18+
const message = await interaction.reply({
19+
embeds: [
20+
new EmbedBuilder()
21+
.setTitle("Pong!")
22+
.setDescription(`🏓**Client latency** \`${ping}\` ms\n🌐 **Round-trip** \`Calculating...\``)
23+
.setColor(Colors.Blue)
24+
]
25+
});
26+
const round = Math.floor(message.interaction.createdTimestamp - interaction.createdTimestamp);
27+
await interaction.editReply({
28+
embeds: [
29+
new EmbedBuilder()
30+
.setTitle("Pong!")
31+
.setDescription(`🏓**Client latency**: \`${ping}\` ms\n🌐 **Round-trip**: \`${round}\` ms`)
32+
.setColor(Colors.Green)
33+
]
34+
});
2735
}
2836
}
2937

0 commit comments

Comments
 (0)