© 2026 Hedgehog Software, LLC
const { Command } = require('@sapphire/framework'); const { EmbedBuilder } = require('discord.js'); const { isMessageInstance } = require('@sapphire/discord.js-utilities'); module.exports = class PingCommand extends Command { constructor(context, options) { super(context, { ...options, }); } registerApplicationCommands(registry) { registry.registerChatInputCommand((builder) => { builder .setName('ping') .setDescription(`Check the bot's response time with a quick ping command.`) }) } async chatInputRun(interaction) { const msg = await interaction.reply({ content: 'Pinging...', ephemeral: true, fetchReply: true }); if (isMessageInstance(msg)) { const restLatency = Math.floor(interaction.client.rest.ping) const gatewayLatency = Math.floor(interaction.client.ws.ping) const botLatency = Math.floor(msg.createdTimestamp - interaction.createdTimestamp) return interaction.editReply({ content: `:ping_pong: **| Pong! Bot Latency:** \`\`\`${botLatency}ms\`\`\`\n:stopwatch: **| Gateway Latency:** \`\`\`${gatewayLatency}ms\`\`\`\n:zap: **| Rest Latency: \`\`\`${restLatency}ms\`\`\`**` }) } return interaction.editReply({ content: `Failed to retrieve ping :(` }) } }
Join the Discord to ask follow-up questions and connect with the community
Sapphire is a next-gen object-oriented Discord.js bot framework.
2,286 Members