mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix: Allow mixing subcommands with subcommand groups (#11303)
fix: allow subcommand with groups Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -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', () => {
|
describe('ChatInput command localizations', () => {
|
||||||
const expectedSingleLocale = { [Locale.EnglishUS]: 'foobar' };
|
const expectedSingleLocale = { [Locale.EnglishUS]: 'foobar' };
|
||||||
const expectedMultipleLocales = {
|
const expectedMultipleLocales = {
|
||||||
|
|||||||
@@ -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
|
// Because you can only add options via builders, there's no need to validate whole objects here otherwise
|
||||||
const chatInputCommandOptionsPredicate = z.union([
|
const chatInputCommandOptionsPredicate = z.union([
|
||||||
z.object({ type: basicOptionTypesPredicate }).array(),
|
z.object({ type: basicOptionTypesPredicate }).array(),
|
||||||
z.object({ type: z.literal(ApplicationCommandOptionType.Subcommand) }).array(),
|
z
|
||||||
z.object({ type: z.literal(ApplicationCommandOptionType.SubcommandGroup) }).array(),
|
.object({
|
||||||
|
type: z.union([
|
||||||
|
z.literal(ApplicationCommandOptionType.Subcommand),
|
||||||
|
z.literal(ApplicationCommandOptionType.SubcommandGroup),
|
||||||
|
]),
|
||||||
|
})
|
||||||
|
.array(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const chatInputCommandPredicate = baseChatInputCommandPredicate.extend({
|
export const chatInputCommandPredicate = baseChatInputCommandPredicate.extend({
|
||||||
|
|||||||
Reference in New Issue
Block a user