ping.ts

1import { ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js'
2import { Command } from '@/types/bot'
3
4export default {
5	data: new SlashCommandBuilder()
6		.setName('ping')
7		.setDescription("Check the bot's latency"),
8
9	async execute(interaction: ChatInputCommandInteraction) {
10		const sent = await interaction.reply({
11			content: 'Pinging...',
12			fetchReply: true,
13		})
14		const latency = sent.createdTimestamp - interaction.createdTimestamp
15		await interaction.editReply(
16			`Pong! 🏓\nBot Latency: ${latency}ms\nAPI Latency: ${interaction.client.ws.ping}ms`,
17		)
18	},
19} as Command
20