Ā© 2026 Hedgehog Software, LLC
isMessageInstance(msg)
import { isMessageInstance } from '@sapphire/discord.js-utilities'; import { ChatInputCommand, Command } from "@sapphire/framework"; export class PingCommand extends Command { public constructor(context: Command.Context, options: Command.Options) { super(context, { ...options }); } public override registerApplicationCommands(registry: ChatInputCommand.Registry) { registry.registerChatInputCommand((builder) => builder.setName('ping').setDescription('Ping bot to see if it is alive') ); } public async chatInputRun(interaction: Command.ChatInputInteraction) { const msg = await interaction.reply({ content: `Ping?`, ephemeral: false, fetchReply: true }); if (isMessageInstance(msg)) { const diff = msg.createdTimestamp - interaction.createdTimestamp; const ping = Math.round(this.container.client.ws.ping); return interaction.editReply(`Pong š! (Round trip took: ${diff}ms. Heartbeat: ${ping}ms.)`); } return interaction.editReply('Failed to retrieve ping :('); } }