#Decorator Style for Register Subcommands

1 messages · Page 1 of 1 (latest)

pine lily
#

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
        });
    }
hot bobcatBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

white maple
pine lily
white maple
#

The official plugin doesn’t have decorators for subcommands so yes

pine lily
hot bobcatBOT
white maple
# pine lily Will it come in the future? 🥺

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.

pine lily
#

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)
                )
            )
        )
    );
  }

NVM I`ll try it out sorry 🙈

white maple
#

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)

pine lily
#

Wdym? I dont understand

white maple
#

You cannot have both addSubcommand and addSubcommandGroup on the top level

pine lily
pine lily
white maple
#

Oh my bad apparently that is possible I guess