crv2/discord/commands/Ping.ts

22 lines
843 B
TypeScript

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
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\``,
});
}
}