commands arent working

someone help me, the bot isnt working, it does go online, I dont get any error. ping.ts:
import { ApplicationCommandRegistry, Command } from "@sapphire/framework";
import { EmbedBuilder, type Message } from "discord.js";
import ms from "ms";

import os from "os";

export class UserCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "ping",
aliases: ["pong", "pingpong"],
description: "Replies with pong!",
fullCategory: ["General", "info"],
});
}

public override registerApplicationCommands(
registry: ApplicationCommandRegistry
) {
registry.registerChatInputCommand((builder) =>
builder.setName(this.name).setDescription(this.description)
);
}

public override async chatInputRun(
interaction: Command.ChatInputCommandInteraction
) {
const initialTime = Date.now();

const initialReply = await interaction.reply({
content: "🏓 Pinging...",
});

const latency =
initialReply.createdTimestamp - interaction.createdTimestamp;
const apiLatency = Math.round(this.container.client.ws.ping);
const memoryUsage = (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(
2
);
const totalMemory = (os.totalmem() / 1024 / 1024).toFixed(2);
const uptime = ms(this.container.client.uptime || 0);
const executionTime = `${Date.now() - initialTime}ms`;

const embed = new EmbedBuilder()
.setTitle("🏓 Pong!")
.setDescription(
`📡 Latency: \`${latency}ms\`. ⚡ API Latency: \`${apiLatency}ms\`.`
)
.addFields(
{ name: "⏲ Bot Uptime", value: uptime, inline: true },
{
name: "💾 Memory Usage",
value: `${memoryUsage} MB / ${totalMemory} MB`,
inline: true,
},
{
name: "⏱ Command Execution Time",
value: executionTime,
inline: true,
}
)
.setColor("#00FF00")
.setFooter({
text: `🔍 Requested by ${interaction.user.tag}`,
iconURL: interaction.user.displayAvatarURL(),
})
.setTimestamp();

return initialReply.edit({ embeds: [embed], content: "" });
}

public async messageRun(interaction: Message) {
console.log("message run")
const initialTime = Date.now();

const initialReply = await interaction.reply({
content: "🏓 Pinging...",
});

const latency =
initialReply.createdTimestamp - interaction.createdTimestamp;
const apiLatency = Math.round(this.container.client.ws.ping);
const memoryUsage = (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(
2
);
const totalMemory = (os.totalmem() / 1024 / 1024).toFixed(2);
const uptime = ms(this.container.client.uptime || 0);
const executionTime = `${Date.now() - initialTime}ms`;

const embed = new EmbedBuilder()
.setTitle("🏓 Pong!")
.setDescription(
`📡 Latency: \`${latency}ms\`. ⚡ API Latency: \`${apiLatency}ms\`.`
)
.addFields(
{ name: "⏲ Bot Uptime", value: uptime, inline: true },
{
name: "💾 Memory Usage",
value: `${memoryUsage} MB / ${totalMemory} MB`,
inline: true,
},
{
name: "⏱ Command Execution Time",
value: executionTime,
inline: true,
}
)
.setColor("#00FF00")
.setFooter({
text: `🔍 Requested by ${interaction.author.tag}`,
iconURL: interaction.author.displayAvatarURL(),
})
.setTimestamp();

return initialReply.edit({ embeds: [embed], content: "" });
}
}
import { ApplicationCommandRegistry, Command } from "@sapphire/framework";
import { EmbedBuilder, type Message } from "discord.js";
import ms from "ms";

import os from "os";

export class UserCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "ping",
aliases: ["pong", "pingpong"],
description: "Replies with pong!",
fullCategory: ["General", "info"],
});
}

public override registerApplicationCommands(
registry: ApplicationCommandRegistry
) {
registry.registerChatInputCommand((builder) =>
builder.setName(this.name).setDescription(this.description)
);
}

public override async chatInputRun(
interaction: Command.ChatInputCommandInteraction
) {
const initialTime = Date.now();

const initialReply = await interaction.reply({
content: "🏓 Pinging...",
});

const latency =
initialReply.createdTimestamp - interaction.createdTimestamp;
const apiLatency = Math.round(this.container.client.ws.ping);
const memoryUsage = (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(
2
);
const totalMemory = (os.totalmem() / 1024 / 1024).toFixed(2);
const uptime = ms(this.container.client.uptime || 0);
const executionTime = `${Date.now() - initialTime}ms`;

const embed = new EmbedBuilder()
.setTitle("🏓 Pong!")
.setDescription(
`📡 Latency: \`${latency}ms\`. ⚡ API Latency: \`${apiLatency}ms\`.`
)
.addFields(
{ name: "⏲ Bot Uptime", value: uptime, inline: true },
{
name: "💾 Memory Usage",
value: `${memoryUsage} MB / ${totalMemory} MB`,
inline: true,
},
{
name: "⏱ Command Execution Time",
value: executionTime,
inline: true,
}
)
.setColor("#00FF00")
.setFooter({
text: `🔍 Requested by ${interaction.user.tag}`,
iconURL: interaction.user.displayAvatarURL(),
})
.setTimestamp();

return initialReply.edit({ embeds: [embed], content: "" });
}

public async messageRun(interaction: Message) {
console.log("message run")
const initialTime = Date.now();

const initialReply = await interaction.reply({
content: "🏓 Pinging...",
});

const latency =
initialReply.createdTimestamp - interaction.createdTimestamp;
const apiLatency = Math.round(this.container.client.ws.ping);
const memoryUsage = (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(
2
);
const totalMemory = (os.totalmem() / 1024 / 1024).toFixed(2);
const uptime = ms(this.container.client.uptime || 0);
const executionTime = `${Date.now() - initialTime}ms`;

const embed = new EmbedBuilder()
.setTitle("🏓 Pong!")
.setDescription(
`📡 Latency: \`${latency}ms\`. ⚡ API Latency: \`${apiLatency}ms\`.`
)
.addFields(
{ name: "⏲ Bot Uptime", value: uptime, inline: true },
{
name: "💾 Memory Usage",
value: `${memoryUsage} MB / ${totalMemory} MB`,
inline: true,
},
{
name: "⏱ Command Execution Time",
value: executionTime,
inline: true,
}
)
.setColor("#00FF00")
.setFooter({
text: `🔍 Requested by ${interaction.author.tag}`,
iconURL: interaction.author.displayAvatarURL(),
})
.setTimestamp();

return initialReply.edit({ embeds: [embed], content: "" });
}
}
No description
Solution:
top of the guide:
No description
Jump to solution
7 Replies
Spinel
Spinel2mo ago
1. Which version of @sapphire/framework are you using? 2. What's your file/folder structure? 3. Did you use the CLI to generate your bot? 4. What's your main (CJS) or module (ESM) property in package.json 5. 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? - Did you remove your output folder and rebuild then try again? 6. Is 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.
Haft
HaftOP2mo ago
1. 5.2.1 2. first pic 3. no 4. ESNext 5. yes, with tsx for dev (watch) and tsc for compile. my scripts: "scripts": { "dev": "tsx watch src/index.ts", "build": "tsc", "start": "node ." }, 6. I ran without building 7. its also related to that, but slash commands too. It doesnt register the slash command either. And yes I did add that
No description
Favna
Favna2mo ago
4 asks what the property is, not what variant you're using
Solution
Favna
Favna2mo ago
top of the guide:
No description
Favna
Favna2mo ago
You should make sure it's identical between build and dev lest you end up changing it constantly. For example you can switch tsx with tsup and always run through node . (tsup --watch --on-success=\"pnpm run start\")
Favna
Favna2mo ago
or if you prefer tsc to compile for prod then use something like https://www.npmjs.com/package/tsc-watch
npm
tsc-watch
The TypeScript compiler with onSuccess command. Latest version: 6.2.0, last published: 6 months ago. Start using tsc-watch in your project by running npm i tsc-watch. There are 215 other projects in the npm registry using tsc-watch.
Haft
HaftOP2mo ago
1. thanks for the tips, I had many problems with the compiler missmatch. 2. It worked!! Can't believe I missed that 😅
Want results from more Discord servers?
Add your server