crra/discord/commands/Ping.ts

23 lines
989 B
TypeScript
Raw Normal View History

2024-03-19 17:41:20 -04:00
import DiscordInteractionCommand from "../../util/DiscordInteractionCommand";
import { ChatInputCommandInteraction } from "discord.js";
export default class Ping extends DiscordInteractionCommand {
constructor() {
super("ping", "Pings the bot");
}
public async execute(interaction: ChatInputCommandInteraction): Promise<void> {
const startTimestamp = Date.now(); // Mark the start of processing
// Assuming `interaction.reply` sends the initial response and records the timestamp right after
await interaction.reply({ content: "Pong!", ephemeral: false });
const repliedTimestamp = Date.now(); // Mark the timestamp after replying
const endTimestamp = Date.now(); // Mark the end of all processing (after editReply)
await interaction.editReply({
content: `🏓 Pong!\nClient: \`${repliedTimestamp - interaction.createdTimestamp}ms\`\nResponse: \`${endTimestamp - startTimestamp}ms\``
});
}
}