Slash command not working

Idk whats wrong with it, theres no error in console or anything its just doesnt work. My code:
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 :(`
})
}
}
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 :(`
})
}
}
Solution:
nvm its problem with host, takes too long to update my files when i edit them
Jump to solution
5 Replies
Noxillio
Noxillio7mo ago
"Doesn't work" doesn't mean anything on its own. What exactly is happening?
Spinel
Spinel7mo ago
- Which version of @sapphire/framework are you using? - What's your file/folder structure? - Did you use the CLI to generate your bot? - What's your "main" property in package.json - Are you using TypeScript? And if so, how are you compiling and running your code? That is to say, what are your build and startup scripts? - In case you are using version 3.0.0 or higher of @sapphire/framework, and your problem related to message commands, did you add loadMessageCommandListeners to your SapphireClient options Remember that if you are new to @sapphire/framework it is important that you read the user guide.
Solution
KAS
KAS7mo ago
nvm its problem with host, takes too long to update my files when i edit them
Noxillio
Noxillio7mo ago
Oh okay, glad you were able to figure it out
UndiedGFX
UndiedGFX7mo ago
mark as solved.