refactor(APIComponents): simplify action row types (#325)

This commit is contained in:
Suneet Tipirneni
2022-02-12 21:12:55 -05:00
committed by GitHub
parent 5056da523a
commit ed1f717679
20 changed files with 84 additions and 86 deletions

View File

@@ -1,4 +1,4 @@
import type { APIActionRowComponent, APIModalComponent } from '../channel.ts';
import type { APIActionRowComponent, APIModalActionRowComponent } from '../channel.ts';
import type {
APIBaseInteraction,
InteractionType,
@@ -13,7 +13,8 @@ export interface ModalSubmitComponent {
value: string;
}
export interface ModalSubmitActionRowComponent extends Omit<APIActionRowComponent<APIModalComponent>, 'components'> {
export interface ModalSubmitActionRowComponent
extends Omit<APIActionRowComponent<APIModalActionRowComponent>, 'components'> {
components: ModalSubmitComponent[];
}

View File

@@ -1,7 +1,7 @@
import type { MessageFlags } from '../mod.ts';
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v8.ts';
import type { APIApplicationCommandOptionChoice } from './applicationCommands.ts';
import type { APIActionRowComponent, APIModalComponent } from '../channel.ts';
import type { APIActionRowComponent, APIModalActionRowComponent } from '../channel.ts';
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type
@@ -119,5 +119,5 @@ export interface APIModalInteractionResponseCallbackData {
/**
* Between 1 and 5 (inclusive) components that make up the modal
*/
components: APIActionRowComponent<APIModalComponent>[];
components: APIActionRowComponent<APIModalActionRowComponent>[];
}

View File

@@ -406,7 +406,7 @@ export interface APIMessage {
/**
* Sent if the message contains components like buttons, action rows, or other interactive components
*/
components?: APIActionRowComponent<APIMessageComponent>[];
components?: APIActionRowComponent<APIMessageActionRowComponent>[];
/**
* Sent if the message contains stickers
*
@@ -1013,7 +1013,7 @@ export interface APIActionRowComponent<T extends APIActionRowComponentTypes>
/**
* The components in the ActionRow
*/
components: Exclude<T, APIActionRowComponent<T>>[];
components: T[];
}
/**
@@ -1191,19 +1191,18 @@ export interface APITextInputComponent extends APIBaseComponent<ComponentType.Te
required?: boolean;
}
export type APIActionRowComponentTypes = APIMessageComponent | APIModalComponent;
/**
* https://discord.com/developers/docs/interactions/message-components#message-components
*/
export type APIMessageComponent = APIMessageActionRowComponent | APIActionRowComponent<APIMessageActionRowComponent>;
export type APIModalComponent = APIModalActionRowComponent | APIActionRowComponent<APIModalActionRowComponent>;
export type APIActionRowComponentTypes = APIMessageActionRowComponent | APIModalActionRowComponent;
/**
* https://discord.com/developers/docs/interactions/message-components#message-components
*/
export type APIMessageComponent =
| APIActionRowComponent<APIMessageComponent>
| APIButtonComponent
| APISelectMenuComponent;
export type APIMessageActionRowComponent = APIActionRowComponent<APIMessageComponent>;
export type APIMessageActionRowComponent = APIButtonComponent | APISelectMenuComponent;
// Modal components
export type APIModalComponent = APIActionRowComponent<APIModalComponent> | APITextInputComponent;
export type APIModalActionRowComponent = APIActionRowComponent<APIModalComponent>;
export type APIModalActionRowComponent = APITextInputComponent;

View File

@@ -1,4 +1,4 @@
import type { APIActionRowComponent, APIModalComponent } from '../channel.ts';
import type { APIActionRowComponent, APIModalActionRowComponent } from '../channel.ts';
import type {
APIBaseInteraction,
InteractionType,
@@ -13,7 +13,8 @@ export interface ModalSubmitComponent {
value: string;
}
export interface ModalSubmitActionRowComponent extends Omit<APIActionRowComponent<APIModalComponent>, 'components'> {
export interface ModalSubmitActionRowComponent
extends Omit<APIActionRowComponent<APIModalActionRowComponent>, 'components'> {
components: ModalSubmitComponent[];
}

View File

@@ -1,7 +1,7 @@
import type { MessageFlags } from '../mod.ts';
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9.ts';
import type { APIApplicationCommandOptionChoice } from './applicationCommands.ts';
import type { APIActionRowComponent, APIModalComponent } from '../channel.ts';
import type { APIActionRowComponent, APIModalActionRowComponent } from '../channel.ts';
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type
@@ -119,5 +119,5 @@ export interface APIModalInteractionResponseCallbackData {
/**
* Between 1 and 5 (inclusive) components that make up the modal
*/
components: APIActionRowComponent<APIModalComponent>[];
components: APIActionRowComponent<APIModalActionRowComponent>[];
}

View File

@@ -483,7 +483,7 @@ export interface APIMessage {
/**
* Sent if the message contains components like buttons, action rows, or other interactive components
*/
components?: APIActionRowComponent<APIMessageComponent>[];
components?: APIActionRowComponent<APIMessageActionRowComponent>[];
/**
* Sent if the message contains stickers
*
@@ -1182,7 +1182,7 @@ export interface APIActionRowComponent<T extends APIActionRowComponentTypes>
/**
* The components in the ActionRow
*/
components: Exclude<T, APIActionRowComponent<T>>[];
components: T[];
}
/**
@@ -1360,19 +1360,18 @@ export interface APITextInputComponent extends APIBaseComponent<ComponentType.Te
required?: boolean;
}
export type APIActionRowComponentTypes = APIMessageComponent | APIModalComponent;
/**
* https://discord.com/developers/docs/interactions/message-components#message-components
*/
export type APIMessageComponent = APIMessageActionRowComponent | APIActionRowComponent<APIMessageActionRowComponent>;
export type APIModalComponent = APIModalActionRowComponent | APIActionRowComponent<APIModalActionRowComponent>;
export type APIActionRowComponentTypes = APIMessageActionRowComponent | APIModalActionRowComponent;
/**
* https://discord.com/developers/docs/interactions/message-components#message-components
*/
export type APIMessageComponent =
| APIActionRowComponent<APIMessageComponent>
| APIButtonComponent
| APISelectMenuComponent;
export type APIMessageActionRowComponent = APIActionRowComponent<APIMessageComponent>;
export type APIMessageActionRowComponent = APIButtonComponent | APISelectMenuComponent;
// Modal components
export type APIModalComponent = APIActionRowComponent<APIModalComponent> | APITextInputComponent;
export type APIModalActionRowComponent = APIActionRowComponent<APIModalComponent>;
export type APIModalActionRowComponent = APITextInputComponent;

View File

@@ -1,7 +1,6 @@
import type { Permissions, Snowflake } from '../../globals.ts';
import type {
APIActionRowComponent,
APIMessageComponent,
APIAllowedMentions,
APIAttachment,
APIChannel,
@@ -16,6 +15,7 @@ import type {
MessageFlags,
OverwriteType,
VideoQualityMode,
APIMessageActionRowComponent,
} from '../../payloads/v8/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals.ts';
@@ -214,7 +214,7 @@ export type RESTPostAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefinedP
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent<APIMessageComponent>[];
components?: APIActionRowComponent<APIMessageActionRowComponent>[];
/**
* IDs of up to 3 stickers in the server to send in the message
*
@@ -348,7 +348,7 @@ export type RESTPatchAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefined
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent<APIMessageComponent>[] | null;
components?: APIActionRowComponent<APIMessageActionRowComponent>[] | null;
}>;
/**

View File

@@ -7,7 +7,7 @@ import type {
APIWebhook,
APIAttachment,
MessageFlags,
APIMessageComponent,
APIMessageActionRowComponent,
} from '../../payloads/v8/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, Nullable } from '../../utils/internals.ts';
@@ -136,7 +136,7 @@ export type RESTPostAPIWebhookWithTokenJSONBody = AddUndefinedToPossiblyUndefine
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent<APIMessageComponent>[];
components?: APIActionRowComponent<APIMessageActionRowComponent>[];
/**
* Attachment objects with filename and description
*/

View File

@@ -1,6 +1,5 @@
import type { Permissions, Snowflake } from '../../globals.ts';
import type {
APIMessageComponent,
APIActionRowComponent,
APIAllowedMentions,
APIAttachment,
@@ -19,6 +18,7 @@ import type {
OverwriteType,
ThreadAutoArchiveDuration,
VideoQualityMode,
APIMessageActionRowComponent,
} from '../../payloads/v9/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals.ts';
@@ -247,7 +247,7 @@ export type RESTPostAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefinedP
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent<APIMessageComponent>[];
components?: APIActionRowComponent<APIMessageActionRowComponent>[];
/**
* IDs of up to 3 stickers in the server to send in the message
*
@@ -381,7 +381,7 @@ export type RESTPatchAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefined
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent<APIMessageComponent>[] | null;
components?: APIActionRowComponent<APIMessageActionRowComponent>[] | null;
}>;
/**

View File

@@ -7,10 +7,9 @@ import type {
APIWebhook,
APIAttachment,
MessageFlags,
APIMessageComponent,
APIMessageActionRowComponent,
} from '../../payloads/v9/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, Nullable } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook
*/
@@ -136,7 +135,7 @@ export type RESTPostAPIWebhookWithTokenJSONBody = AddUndefinedToPossiblyUndefine
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent<APIMessageComponent>[];
components?: APIActionRowComponent<APIMessageActionRowComponent>[];
/**
* Attachment objects with filename and description
*/

View File

@@ -1,4 +1,4 @@
import type { APIActionRowComponent, APIModalComponent } from '../channel';
import type { APIActionRowComponent, APIModalActionRowComponent } from '../channel';
import type {
APIBaseInteraction,
InteractionType,
@@ -13,7 +13,8 @@ export interface ModalSubmitComponent {
value: string;
}
export interface ModalSubmitActionRowComponent extends Omit<APIActionRowComponent<APIModalComponent>, 'components'> {
export interface ModalSubmitActionRowComponent
extends Omit<APIActionRowComponent<APIModalActionRowComponent>, 'components'> {
components: ModalSubmitComponent[];
}

View File

@@ -1,7 +1,7 @@
import type { MessageFlags } from '../index';
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v8';
import type { APIApplicationCommandOptionChoice } from './applicationCommands';
import type { APIActionRowComponent, APIModalComponent } from '../channel';
import type { APIActionRowComponent, APIModalActionRowComponent } from '../channel';
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type
@@ -119,5 +119,5 @@ export interface APIModalInteractionResponseCallbackData {
/**
* Between 1 and 5 (inclusive) components that make up the modal
*/
components: APIActionRowComponent<APIModalComponent>[];
components: APIActionRowComponent<APIModalActionRowComponent>[];
}

View File

@@ -406,7 +406,7 @@ export interface APIMessage {
/**
* Sent if the message contains components like buttons, action rows, or other interactive components
*/
components?: APIActionRowComponent<APIMessageComponent>[];
components?: APIActionRowComponent<APIMessageActionRowComponent>[];
/**
* Sent if the message contains stickers
*
@@ -1013,7 +1013,7 @@ export interface APIActionRowComponent<T extends APIActionRowComponentTypes>
/**
* The components in the ActionRow
*/
components: Exclude<T, APIActionRowComponent<T>>[];
components: T[];
}
/**
@@ -1191,19 +1191,18 @@ export interface APITextInputComponent extends APIBaseComponent<ComponentType.Te
required?: boolean;
}
export type APIActionRowComponentTypes = APIMessageComponent | APIModalComponent;
/**
* https://discord.com/developers/docs/interactions/message-components#message-components
*/
export type APIMessageComponent = APIMessageActionRowComponent | APIActionRowComponent<APIMessageActionRowComponent>;
export type APIModalComponent = APIModalActionRowComponent | APIActionRowComponent<APIModalActionRowComponent>;
export type APIActionRowComponentTypes = APIMessageActionRowComponent | APIModalActionRowComponent;
/**
* https://discord.com/developers/docs/interactions/message-components#message-components
*/
export type APIMessageComponent =
| APIActionRowComponent<APIMessageComponent>
| APIButtonComponent
| APISelectMenuComponent;
export type APIMessageActionRowComponent = APIActionRowComponent<APIMessageComponent>;
export type APIMessageActionRowComponent = APIButtonComponent | APISelectMenuComponent;
// Modal components
export type APIModalComponent = APIActionRowComponent<APIModalComponent> | APITextInputComponent;
export type APIModalActionRowComponent = APIActionRowComponent<APIModalComponent>;
export type APIModalActionRowComponent = APITextInputComponent;

View File

@@ -1,4 +1,4 @@
import type { APIActionRowComponent, APIModalComponent } from '../channel';
import type { APIActionRowComponent, APIModalActionRowComponent } from '../channel';
import type {
APIBaseInteraction,
InteractionType,
@@ -13,7 +13,8 @@ export interface ModalSubmitComponent {
value: string;
}
export interface ModalSubmitActionRowComponent extends Omit<APIActionRowComponent<APIModalComponent>, 'components'> {
export interface ModalSubmitActionRowComponent
extends Omit<APIActionRowComponent<APIModalActionRowComponent>, 'components'> {
components: ModalSubmitComponent[];
}

View File

@@ -1,7 +1,7 @@
import type { MessageFlags } from '../index';
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9';
import type { APIApplicationCommandOptionChoice } from './applicationCommands';
import type { APIActionRowComponent, APIModalComponent } from '../channel';
import type { APIActionRowComponent, APIModalActionRowComponent } from '../channel';
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type
@@ -119,5 +119,5 @@ export interface APIModalInteractionResponseCallbackData {
/**
* Between 1 and 5 (inclusive) components that make up the modal
*/
components: APIActionRowComponent<APIModalComponent>[];
components: APIActionRowComponent<APIModalActionRowComponent>[];
}

View File

@@ -483,7 +483,7 @@ export interface APIMessage {
/**
* Sent if the message contains components like buttons, action rows, or other interactive components
*/
components?: APIActionRowComponent<APIMessageComponent>[];
components?: APIActionRowComponent<APIMessageActionRowComponent>[];
/**
* Sent if the message contains stickers
*
@@ -1182,7 +1182,7 @@ export interface APIActionRowComponent<T extends APIActionRowComponentTypes>
/**
* The components in the ActionRow
*/
components: Exclude<T, APIActionRowComponent<T>>[];
components: T[];
}
/**
@@ -1360,19 +1360,18 @@ export interface APITextInputComponent extends APIBaseComponent<ComponentType.Te
required?: boolean;
}
export type APIActionRowComponentTypes = APIMessageComponent | APIModalComponent;
/**
* https://discord.com/developers/docs/interactions/message-components#message-components
*/
export type APIMessageComponent = APIMessageActionRowComponent | APIActionRowComponent<APIMessageActionRowComponent>;
export type APIModalComponent = APIModalActionRowComponent | APIActionRowComponent<APIModalActionRowComponent>;
export type APIActionRowComponentTypes = APIMessageActionRowComponent | APIModalActionRowComponent;
/**
* https://discord.com/developers/docs/interactions/message-components#message-components
*/
export type APIMessageComponent =
| APIActionRowComponent<APIMessageComponent>
| APIButtonComponent
| APISelectMenuComponent;
export type APIMessageActionRowComponent = APIActionRowComponent<APIMessageComponent>;
export type APIMessageActionRowComponent = APIButtonComponent | APISelectMenuComponent;
// Modal components
export type APIModalComponent = APIActionRowComponent<APIModalComponent> | APITextInputComponent;
export type APIModalActionRowComponent = APIActionRowComponent<APIModalComponent>;
export type APIModalActionRowComponent = APITextInputComponent;

View File

@@ -1,7 +1,6 @@
import type { Permissions, Snowflake } from '../../globals';
import type {
APIActionRowComponent,
APIMessageComponent,
APIAllowedMentions,
APIAttachment,
APIChannel,
@@ -16,6 +15,7 @@ import type {
MessageFlags,
OverwriteType,
VideoQualityMode,
APIMessageActionRowComponent,
} from '../../payloads/v8/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals';
@@ -214,7 +214,7 @@ export type RESTPostAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefinedP
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent<APIMessageComponent>[];
components?: APIActionRowComponent<APIMessageActionRowComponent>[];
/**
* IDs of up to 3 stickers in the server to send in the message
*
@@ -348,7 +348,7 @@ export type RESTPatchAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefined
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent<APIMessageComponent>[] | null;
components?: APIActionRowComponent<APIMessageActionRowComponent>[] | null;
}>;
/**

View File

@@ -7,7 +7,7 @@ import type {
APIWebhook,
APIAttachment,
MessageFlags,
APIMessageComponent,
APIMessageActionRowComponent,
} from '../../payloads/v8/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, Nullable } from '../../utils/internals';
@@ -136,7 +136,7 @@ export type RESTPostAPIWebhookWithTokenJSONBody = AddUndefinedToPossiblyUndefine
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent<APIMessageComponent>[];
components?: APIActionRowComponent<APIMessageActionRowComponent>[];
/**
* Attachment objects with filename and description
*/

View File

@@ -1,6 +1,5 @@
import type { Permissions, Snowflake } from '../../globals';
import type {
APIMessageComponent,
APIActionRowComponent,
APIAllowedMentions,
APIAttachment,
@@ -19,6 +18,7 @@ import type {
OverwriteType,
ThreadAutoArchiveDuration,
VideoQualityMode,
APIMessageActionRowComponent,
} from '../../payloads/v9/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals';
@@ -247,7 +247,7 @@ export type RESTPostAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefinedP
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent<APIMessageComponent>[];
components?: APIActionRowComponent<APIMessageActionRowComponent>[];
/**
* IDs of up to 3 stickers in the server to send in the message
*
@@ -381,7 +381,7 @@ export type RESTPatchAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefined
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent<APIMessageComponent>[] | null;
components?: APIActionRowComponent<APIMessageActionRowComponent>[] | null;
}>;
/**

View File

@@ -7,10 +7,9 @@ import type {
APIWebhook,
APIAttachment,
MessageFlags,
APIMessageComponent,
APIMessageActionRowComponent,
} from '../../payloads/v9/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, Nullable } from '../../utils/internals';
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook
*/
@@ -136,7 +135,7 @@ export type RESTPostAPIWebhookWithTokenJSONBody = AddUndefinedToPossiblyUndefine
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent<APIMessageComponent>[];
components?: APIActionRowComponent<APIMessageActionRowComponent>[];
/**
* Attachment objects with filename and description
*/