[TAG_FIELD_MISSING]: Field "type" is required to determine the model type.

I am creating a slash command group like so:
public override registerApplicationCommands(registry: Subcommand.Registry) {
registry.registerChatInputCommand(
new SlashCommandBuilder() //
.setName(CommandName.Admin) //
.setDescription('Administrative commands.')
.setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild)
.addSubcommandGroup(
new SlashCommandSubcommandGroupBuilder() //
.setName(CommandName.AdminMines)
.setDescription('Administrative commands related to the mines game.')
.addSubcommand(
new SlashCommandSubcommandBuilder() //
.setName(CommandName.AdminMinesStressTest)
.setDescription('Initializes a stress test in the specified channel.')
.addChannelOption(
new SlashCommandChannelOption() //
.setName(CommandParameterName.Channel)
.addChannelTypes(...this._minesGameStressTestChannelTypes)
.setDescription('The channel in which to run the stress test.')
.setRequired(true)
)
.addIntegerOption(
new SlashCommandIntegerOption() //
.setName(CommandParameterName.GameCount)
.setDescription('The amount of games to simulate.')
.setMinValue(1)
.setMaxValue(100)
.setRequired(true)
)
)
),
)
public override registerApplicationCommands(registry: Subcommand.Registry) {
registry.registerChatInputCommand(
new SlashCommandBuilder() //
.setName(CommandName.Admin) //
.setDescription('Administrative commands.')
.setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild)
.addSubcommandGroup(
new SlashCommandSubcommandGroupBuilder() //
.setName(CommandName.AdminMines)
.setDescription('Administrative commands related to the mines game.')
.addSubcommand(
new SlashCommandSubcommandBuilder() //
.setName(CommandName.AdminMinesStressTest)
.setDescription('Initializes a stress test in the specified channel.')
.addChannelOption(
new SlashCommandChannelOption() //
.setName(CommandParameterName.Channel)
.addChannelTypes(...this._minesGameStressTestChannelTypes)
.setDescription('The channel in which to run the stress test.')
.setRequired(true)
)
.addIntegerOption(
new SlashCommandIntegerOption() //
.setName(CommandParameterName.GameCount)
.setDescription('The amount of games to simulate.')
.setMinValue(1)
.setMaxValue(100)
.setRequired(true)
)
)
),
)
But I'm getting an error shown in this pastebin: https://pastebin.com/raw/DxR6KSGE
3 Replies
Favna
Favna7d ago
I cannot access the pastebin anymore? Also are you sure the error is from the register? Make sure to check your stacktrace. It saying model would suggest it's elsewhere
Teixeira
TeixeiraOP7d ago
Sorry about that, here's the pastebin: https://pastebin.com/raw/bBUZXYGq I do think it's registry related, although I'm not 100% sure @Favna I've noticed this happens whenever there's subcommands involved, doesn't need to be a subcommand group I've been digging through examples and Sapphire's documentation but I can't figure out what I'm doing wrong... I've worked with subcommands before and never ran into this particular issue I've fixed this by passing a callback to the registry (using builder => return builder (...)) . I'm not sure why this fixes it or why it doesn't work when I pass new instances of the builder classes though
Favna
Favna7d ago
Hm I thought we did support that but I guess there might be a bug with not calling the instance properly :Thonk:

Did you find this page helpful?