Could not pass a new instance of slash command builder to registry.registerApplicationCommands

I have found out that subcommand and subcommand group type is omitted when passing a newly instance of builder. When using the callback method it's not omitted 🤔 reproduction sample: https://github.com/yuanstuffs/registry-reproduction-sample
8 Replies
yuansheng
yuanshengOP•4d ago
No description
yuansheng
yuanshengOP•4d ago
import { ApplyOptions } from '@sapphire/decorators';
import { Command, type ApplicationCommandRegistry } from '@sapphire/framework';
import { ApplicationIntegrationType, InteractionContextType, SlashCommandBuilder } from 'discord.js';

@ApplyOptions<Command.Options>({
description: 'A command that will fail to register'
})
export class UserCommand extends Command {
public override chatInputRun() {}

public override registerApplicationCommands(registry: ApplicationCommandRegistry) {
const builder = new SlashCommandBuilder()
.setName(this.name)
.setDescription(this.description)
.setContexts(InteractionContextType.Guild)
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall)
.addSubcommandGroup((builder) =>
builder
.setName('g')
.setDescription('group')
.addSubcommand((builder) => builder.setName('sub').setDescription('sub'))
);

registry.registerChatInputCommand(builder);
}
}
import { ApplyOptions } from '@sapphire/decorators';
import { Command, type ApplicationCommandRegistry } from '@sapphire/framework';
import { ApplicationIntegrationType, InteractionContextType, SlashCommandBuilder } from 'discord.js';

@ApplyOptions<Command.Options>({
description: 'A command that will fail to register'
})
export class UserCommand extends Command {
public override chatInputRun() {}

public override registerApplicationCommands(registry: ApplicationCommandRegistry) {
const builder = new SlashCommandBuilder()
.setName(this.name)
.setDescription(this.description)
.setContexts(InteractionContextType.Guild)
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall)
.addSubcommandGroup((builder) =>
builder
.setName('g')
.setDescription('group')
.addSubcommand((builder) => builder.setName('sub').setDescription('sub'))
);

registry.registerChatInputCommand(builder);
}
}
doing builder.toJSON():
{
options: [
{
type: 2,
name: 'g',
name_localizations: undefined,
description: 'group',
description_localizations: undefined,
options: [Array]
}
],
name: 'fail-group',
name_localizations: undefined,
description: 'A command that will fail to register',
description_localizations: undefined,
contexts: [ 0 ],
default_permission: undefined,
default_member_permissions: undefined,
dm_permission: undefined,
integration_types: [ 0 ],
nsfw: undefined,
type: 1
}
{
options: [
{
type: 2,
name: 'g',
name_localizations: undefined,
description: 'group',
description_localizations: undefined,
options: [Array]
}
],
name: 'fail-group',
name_localizations: undefined,
description: 'A command that will fail to register',
description_localizations: undefined,
contexts: [ 0 ],
default_permission: undefined,
default_member_permissions: undefined,
dm_permission: undefined,
integration_types: [ 0 ],
nsfw: undefined,
type: 1
}
yuansheng
yuanshengOP•4d ago
Same as registering subcommands.
{
options: [
{
type: 1,
name: 'failure',
name_localizations: undefined,
description: 'Failure',
description_localizations: undefined,
options: []
}
],
name: 'fail',
name_localizations: undefined,
description: 'This will fail to register.',
description_localizations: undefined,
contexts: [ 0 ],
default_permission: undefined,
default_member_permissions: undefined,
dm_permission: undefined,
integration_types: [ 0 ],
nsfw: undefined,
type: 1
}
{
options: [
{
type: 1,
name: 'failure',
name_localizations: undefined,
description: 'Failure',
description_localizations: undefined,
options: []
}
],
name: 'fail',
name_localizations: undefined,
description: 'This will fail to register.',
description_localizations: undefined,
contexts: [ 0 ],
default_permission: undefined,
default_member_permissions: undefined,
dm_permission: undefined,
integration_types: [ 0 ],
nsfw: undefined,
type: 1
}
No description
yuansheng
yuanshengOP•17h ago
subcommands and sub groups are being omitted .
Favna
Favna•16h ago
I am running a bot with subcommands just fine so i have no idea what is going wrong here.
Favna
Favna•16h ago
yuansheng
yuanshengOP•15h ago
Using the callback method have no issues, how about try making a new instance of the slash command builder class with subcommands and pass it to the register chat input command function
Favna
Favna•15h ago
oh that's what you meant. hm yeah I think I reported before to @vladdy that passing an instance doesnt work properly

Did you find this page helpful?