This repository was archived by the owner on May 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-11
lines changed
Expand file tree Collapse file tree 1 file changed +19
-11
lines changed Original file line number Diff line number Diff line change 1- import { ChatInputCommandInteraction } from "discord.js" ;
1+ import { ChatInputCommandInteraction , EmbedBuilder , Colors } from "discord.js" ;
22import { KOGBot } from "../../index.js" ; // Adjust the path if necessary
33
44class 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
You can’t perform that action at this time.
0 commit comments