crv2/discord/commands/Ping.ts

22 lines
884 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
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\``
});
}
}