Commands won't be registered

I've currently only one slash command and one listener (for the ready event) but the listener won't be executed as well as the application command which also won't get registered. After I added some breakpoints to debug the bot I noticed that no breakpoint is hit in the listener and the application command file. src/index.ts
import {LogLevel, SapphireClient} from "@sapphire/framework";
import {Intents} from "discord.js";
import "@sapphire/plugin-logger/register";

require("dotenv").config()
const client = new SapphireClient({
intents: [Intents.FLAGS.GUILDS],
logger: {
level: (process.env.DEBUG === "true" ? LogLevel.Debug : LogLevel.Info)
}
})

client.login(process.env.TOKEN)

process.on("SIGINT", () => {
client.logger.info("Good bye")
client.destroy()
})
import {LogLevel, SapphireClient} from "@sapphire/framework";
import {Intents} from "discord.js";
import "@sapphire/plugin-logger/register";

require("dotenv").config()
const client = new SapphireClient({
intents: [Intents.FLAGS.GUILDS],
logger: {
level: (process.env.DEBUG === "true" ? LogLevel.Debug : LogLevel.Info)
}
})

client.login(process.env.TOKEN)

process.on("SIGINT", () => {
client.logger.info("Good bye")
client.destroy()
})
src/commands/create-embed.ts
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';

@ApplyOptions<Command.Options>({
name: "create-embed",
description: 'Sendet ein Embed in diesen Channel oder einen anderen Channel'
})
export class CreateEmbedCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder //
.setName(this.name)
.setDescription(this.description)
.addStringOption(opt => opt
.setName("author-name")
.setDescription("Name des Autors")
)
.addStringOption(opt => opt
.setName("author-icon-url")
.setDescription("Icon URL des Autors")
)
.addStringOption(opt => opt
.setName("author-url")
.setDescription("URL des Autors")
)
.addStringOption(opt => opt
.setName("titel")
.setDescription("Titel")
)
.addStringOption(opt => opt
.setName("description")
.setDescription("Beschreibung")
)
.addStringOption(opt => opt
.setName("url")
.setDescription("URL")
)
.addStringOption(opt => opt
.setName("timestamp")
.setDescription("Timestamp (im Footer)")
)
.addStringOption(opt => opt
.setName("color")
.setDescription("Farbe (in HEX Code)")
)
.addStringOption(opt => opt
.setName("footer-text")
.setDescription("Text des Footers")
)
.addStringOption(opt => opt
.setName("footer-url")
.setDescription("URL des Footers")
)
.addStringOption(opt => opt
.setName("footer-proxy-url")
.setDescription("Proxy URL des Footers")
)
.addStringOption(opt => opt
.setName("fields")
.setDescription("Fields im Format {name: \"Field Name\", value: \"Field Value\", inline: true | false}")
)
.addChannelOption(opt => opt
.setName("channel")
.setDescription("Der Channel in den das Embed gesendet werden soll (ansonsten in den gleichen Channel)")
)
);
}

public override async chatInputRun(interaction: Command.ChatInputInteraction) {
const options = interaction.options.data
await interaction.reply(String(options))
}
}
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';

@ApplyOptions<Command.Options>({
name: "create-embed",
description: 'Sendet ein Embed in diesen Channel oder einen anderen Channel'
})
export class CreateEmbedCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder //
.setName(this.name)
.setDescription(this.description)
.addStringOption(opt => opt
.setName("author-name")
.setDescription("Name des Autors")
)
.addStringOption(opt => opt
.setName("author-icon-url")
.setDescription("Icon URL des Autors")
)
.addStringOption(opt => opt
.setName("author-url")
.setDescription("URL des Autors")
)
.addStringOption(opt => opt
.setName("titel")
.setDescription("Titel")
)
.addStringOption(opt => opt
.setName("description")
.setDescription("Beschreibung")
)
.addStringOption(opt => opt
.setName("url")
.setDescription("URL")
)
.addStringOption(opt => opt
.setName("timestamp")
.setDescription("Timestamp (im Footer)")
)
.addStringOption(opt => opt
.setName("color")
.setDescription("Farbe (in HEX Code)")
)
.addStringOption(opt => opt
.setName("footer-text")
.setDescription("Text des Footers")
)
.addStringOption(opt => opt
.setName("footer-url")
.setDescription("URL des Footers")
)
.addStringOption(opt => opt
.setName("footer-proxy-url")
.setDescription("Proxy URL des Footers")
)
.addStringOption(opt => opt
.setName("fields")
.setDescription("Fields im Format {name: \"Field Name\", value: \"Field Value\", inline: true | false}")
)
.addChannelOption(opt => opt
.setName("channel")
.setDescription("Der Channel in den das Embed gesendet werden soll (ansonsten in den gleichen Channel)")
)
);
}

public override async chatInputRun(interaction: Command.ChatInputInteraction) {
const options = interaction.options.data
await interaction.reply(String(options))
}
}
Solution:
oh, thanks for the hint. I've set the wrong main property. After changing it to the correct one (dist/index.js) everything works!
Jump to solution
8 Replies
Professor Varox
.sapphirerc.json
{
"projectLanguage": "ts",
"locations": {
"base": "src",
"arguments": "arguments",
"commands": "commands",
"listeners": "listeners",
"preconditions": "preconditions"
},
"customFileTemplates": {
"enabled": false,
"location": ""
}
}
{
"projectLanguage": "ts",
"locations": {
"base": "src",
"arguments": "arguments",
"commands": "commands",
"listeners": "listeners",
"preconditions": "preconditions"
},
"customFileTemplates": {
"enabled": false,
"location": ""
}
}
Log:
2022-12-05 15:30:32 - INFO - ApplicationCommandRegistries: Initializing...
2022-12-05 15:30:32 - INFO - ApplicationCommandRegistries: Took 275ms to initialize.
2022-12-05 15:30:32 - INFO - ApplicationCommandRegistries: Initializing...
2022-12-05 15:30:32 - INFO - ApplicationCommandRegistries: Took 275ms to initialize.
Spinel
Spinel2y ago
- Did you use a folder of the examples repository or did you use the CLI to generate your bot? - What's your file/folder structure? - What's your "main" property in package.json - Are you using TypeScript? And if so, how are you compiling and running your code? - Are you using the version 2 or version 3 of @sapphire/framework? - In case you are using version 3 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.
Favna
Favna2y ago
specifically the 2nd and 3rd points
Solution
Professor Varox
oh, thanks for the hint. I've set the wrong main property. After changing it to the correct one (dist/index.js) everything works!
Krish
Krish2y ago
This must send the link to the message instead of the ID
Favna
Favna2y ago
@Rhys
Rhys
Rhys2y ago
Good suggestion thank you, I think I can make it reply to the solution message as well Going to probably keep the question / solution ids in there as it's a way of preserving them incase it needs to be rebuilt in the future
Krish
Krish2y ago
or you can additionally add a section for message link along with the ID in the same embed
Want results from more Discord servers?
Add your server