Professor Varox
Professor Varox
SIASapphire - Imagine a framework
Created by Professor Varox on 12/5/2022 in #sapphire-support
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))
}
}
12 replies