File tree Expand file tree Collapse file tree
__tests__/interactions/ChatInputCommands
src/interactions/commands/chatInput Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -376,6 +376,29 @@ describe('ChatInput Commands', () => {
376376 } ) ;
377377 } ) ;
378378
379+ describe ( 'Subcommand builder and subcommand group builder' , ( ) => {
380+ test ( 'GIVEN both types THEN does not throw error' , ( ) => {
381+ expect ( ( ) =>
382+ getBuilder ( )
383+ . setName ( 'test' )
384+ . setDescription ( 'Test command' )
385+ . addSubcommands ( ( subcommand ) =>
386+ subcommand . setName ( 'subcommand' ) . setDescription ( 'Description of subcommand' ) ,
387+ )
388+ . addSubcommandGroups ( ( subcommandGroup ) =>
389+ subcommandGroup
390+ . setName ( 'group' )
391+ . setDescription ( 'Description of group' )
392+
393+ . addSubcommands ( ( subcommand ) =>
394+ subcommand . setName ( 'subcommand' ) . setDescription ( 'Description of group subcommand' ) ,
395+ ) ,
396+ )
397+ . toJSON ( ) ,
398+ ) . not . toThrowError ( ) ;
399+ } ) ;
400+ } ) ;
401+
379402 describe ( 'ChatInput command localizations' , ( ) => {
380403 const expectedSingleLocale = { [ Locale . EnglishUS ] : 'foobar' } ;
381404 const expectedMultipleLocales = {
Original file line number Diff line number Diff line change @@ -127,8 +127,14 @@ const baseChatInputCommandPredicate = sharedNameAndDescriptionPredicate.extend({
127127// Because you can only add options via builders, there's no need to validate whole objects here otherwise
128128const chatInputCommandOptionsPredicate = z . union ( [
129129 z . object ( { type : basicOptionTypesPredicate } ) . array ( ) ,
130- z . object ( { type : z . literal ( ApplicationCommandOptionType . Subcommand ) } ) . array ( ) ,
131- z . object ( { type : z . literal ( ApplicationCommandOptionType . SubcommandGroup ) } ) . array ( ) ,
130+ z
131+ . object ( {
132+ type : z . union ( [
133+ z . literal ( ApplicationCommandOptionType . Subcommand ) ,
134+ z . literal ( ApplicationCommandOptionType . SubcommandGroup ) ,
135+ ] ) ,
136+ } )
137+ . array ( ) ,
132138] ) ;
133139
134140export const chatInputCommandPredicate = baseChatInputCommandPredicate . extend ( {
You can’t perform that action at this time.
0 commit comments