Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,29 @@ describe('ChatInput Commands', () => {
});
});

describe('Subcommand builder and subcommand group builder', () => {
test('GIVEN both types THEN does not throw error', () => {
expect(() =>
getBuilder()
.setName('test')
.setDescription('Test command')
.addSubcommands((subcommand) =>
subcommand.setName('subcommand').setDescription('Description of subcommand'),
)
.addSubcommandGroups((subcommandGroup) =>
subcommandGroup
.setName('group')
.setDescription('Description of group')

.addSubcommands((subcommand) =>
subcommand.setName('subcommand').setDescription('Description of group subcommand'),
),
)
.toJSON(),
).not.toThrowError();
});
});

describe('ChatInput command localizations', () => {
const expectedSingleLocale = { [Locale.EnglishUS]: 'foobar' };
const expectedMultipleLocales = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,14 @@ const baseChatInputCommandPredicate = sharedNameAndDescriptionPredicate.extend({
// Because you can only add options via builders, there's no need to validate whole objects here otherwise
const chatInputCommandOptionsPredicate = z.union([
z.object({ type: basicOptionTypesPredicate }).array(),
z.object({ type: z.literal(ApplicationCommandOptionType.Subcommand) }).array(),
z.object({ type: z.literal(ApplicationCommandOptionType.SubcommandGroup) }).array(),
z
.object({
type: z.union([
z.literal(ApplicationCommandOptionType.Subcommand),
z.literal(ApplicationCommandOptionType.SubcommandGroup),
]),
})
.array(),
]);

export const chatInputCommandPredicate = baseChatInputCommandPredicate.extend({
Expand Down