Skip to content

Commit

Permalink
types: fix missing channel type in subcommand options (#6706)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckohen authored Sep 28, 2021
1 parent dfd7b40 commit da3ae48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3123,12 +3123,12 @@ export interface ApplicationCommandSubGroup extends BaseApplicationCommandOption

export interface ApplicationCommandSubCommandData extends BaseApplicationCommandOptionsData {
type: 'SUB_COMMAND' | ApplicationCommandOptionTypes.SUB_COMMAND;
options?: (ApplicationCommandChoicesData | ApplicationCommandNonOptionsData)[];
options?: (ApplicationCommandChoicesData | ApplicationCommandNonOptionsData | ApplicationCommandChannelOptionData)[];
}

export interface ApplicationCommandSubCommand extends BaseApplicationCommandOptionsData {
type: 'SUB_COMMAND';
options?: (ApplicationCommandChoicesOption | ApplicationCommandNonOptions)[];
options?: (ApplicationCommandChoicesOption | ApplicationCommandNonOptions | ApplicationCommandChannelOption)[];
}

export interface ApplicationCommandNonOptionsData extends BaseApplicationCommandOptionsData {
Expand Down
9 changes: 6 additions & 3 deletions typings/tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { APIInteractionGuildMember } from 'discord-api-types';
import {
ApplicationCommand,
ApplicationCommandChannelOption,
ApplicationCommandChannelOptionData,
ApplicationCommandChoicesData,
ApplicationCommandData,
ApplicationCommandManager,
Expand Down Expand Up @@ -752,9 +754,10 @@ declare const applicationSubCommandData: ApplicationCommandSubCommandData;
assertType<'SUB_COMMAND' | ApplicationCommandOptionTypes.SUB_COMMAND>(applicationSubCommandData.type);

// Check that only subcommands can have no subcommand or subcommand group sub-options.
assertType<(ApplicationCommandChoicesData | ApplicationCommandNonOptionsData)[] | undefined>(
applicationSubCommandData.options,
);
assertType<
| (ApplicationCommandChoicesData | ApplicationCommandNonOptionsData | ApplicationCommandChannelOptionData)[]
| undefined
>(applicationSubCommandData.options);
}

declare const guildApplicationCommandManager: GuildApplicationCommandManager;
Expand Down

0 comments on commit da3ae48

Please sign in to comment.