Decorator Style for Register Subcommands

Is there a Short Style possible for that? Like That for normal Slash-Commands
@ApplyOptions<Command.Options>({
description: 'ping pong'
})

registry.registerChatInputCommand({
name: this.name,
description: this.description
});
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
const msg = await interaction.reply({ content: 'Ping?', fetchReply: true });

const content = `Pong! Bot Latency ${Math.round(this.container.client.ws.ping)}ms. API Latency ${
msg.createdTimestamp - interaction.createdTimestamp
}ms.`;

return await interaction.editReply({
content: content
});
}
@ApplyOptions<Command.Options>({
description: 'ping pong'
})

registry.registerChatInputCommand({
name: this.name,
description: this.description
});
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
const msg = await interaction.reply({ content: 'Ping?', fetchReply: true });

const content = `Pong! Bot Latency ${Math.round(this.container.client.ws.ping)}ms. API Latency ${
msg.createdTimestamp - interaction.createdTimestamp
}ms.`;

return await interaction.editReply({
content: content
});
}
Solution:
The official plugin doesn’t have decorators for subcommands so yes
Jump to solution
13 Replies
Favna
Favna8mo ago
GitHub
neko-plugins/packages/subcommands-advanced at main · sawa-ko/neko-p...
Plugins for @sapphire/framework. Contribute to sawa-ko/neko-plugins development by creating an account on GitHub.
SaysHQ
SaysHQ8mo ago
That Sounds kinda complicated. So if i dont want to use that i need to use it the Normal Way?
Solution
Favna
Favna8mo ago
The official plugin doesn’t have decorators for subcommands so yes
SaysHQ
SaysHQ8mo ago
Will it come in the future? 🥺
Favna
Favna8mo ago
The primary reason it doesn’t is because decorators are (for now) TS only and the sapphire design philosophy states that code has to work for both Js and Ts. Once Ecmascript decorators are shipped in an LTS version of Node we can look into adding them to the package but when that will be I cannot say. Once decorators are in Node we can also migrate @sapphire/decorators to be natively in the framework for example.
SaysHQ
SaysHQ8mo ago
Just to be sure i need this core, right? Or Anthing else?
registerApplicationCommands(registry: Subcommand.Registry) {
registry.registerChatInputCommand((builder) =>
builder
.setName('vip')
.setDescription('Vip command') // Needed even though base command isn't displayed to end user
.addSubcommand((command) => command.setName('list').setDescription('List vips'))
.addSubcommandGroup((group) =>
group
.setName('action')
.setDescription('action subcommand group') // Also needed even though the group isn't displayed to end user
.addSubcommand((command) =>
command
.setName('add')
.setDescription('Add a vip')
.addUserOption((option) =>
option.setName('user').setDescription('user to add to vip list').setRequired(true)
)
)
.addSubcommand((command) =>
command
.setName('remove')
.setDescription('Remove a vip')
.addUserOption((option) =>
option.setName('user').setDescription('user to remove from vip list').setRequired(true)
)
)
)
);
}
registerApplicationCommands(registry: Subcommand.Registry) {
registry.registerChatInputCommand((builder) =>
builder
.setName('vip')
.setDescription('Vip command') // Needed even though base command isn't displayed to end user
.addSubcommand((command) => command.setName('list').setDescription('List vips'))
.addSubcommandGroup((group) =>
group
.setName('action')
.setDescription('action subcommand group') // Also needed even though the group isn't displayed to end user
.addSubcommand((command) =>
command
.setName('add')
.setDescription('Add a vip')
.addUserOption((option) =>
option.setName('user').setDescription('user to add to vip list').setRequired(true)
)
)
.addSubcommand((command) =>
command
.setName('remove')
.setDescription('Remove a vip')
.addUserOption((option) =>
option.setName('user').setDescription('user to remove from vip list').setRequired(true)
)
)
)
);
}
NVM I`ll try it out sorry 🙈
Favna
Favna8mo ago
You cannot have both groups and non groups at the top level. command group… subcommand… command subcommand… Those are the 2 valid structures (wherein … denotes multiple)
SaysHQ
SaysHQ8mo ago
Wdym? I dont understand
Favna
Favna8mo ago
You cannot have both addSubcommand and addSubcommandGroup on the top level
SaysHQ
SaysHQ8mo ago
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
SaysHQ
SaysHQ8mo ago
Why? Its in the official Sapphire Docs too btw.
Favna
Favna8mo ago
Oh my bad apparently that is possible I guess
SaysHQ
SaysHQ8mo ago
Tysm for your help it works! You are really Awesome pikawow