Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Components): new select menus #602

Merged
merged 9 commits into from
Oct 20, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,8 @@ import type {
APIApplicationCommandUserOption,
} from './_chatInput/user.ts';
import type { APIBaseApplicationCommandInteractionData } from './internals.ts';
import type { Snowflake } from '../../../../globals.ts';
import type { APIAttachment, APIRole, APIUser } from '../../mod.ts';
import type {
APIApplicationCommandInteractionWrapper,
APIInteractionDataResolvedChannel,
APIInteractionDataResolvedGuildMember,
ApplicationCommandType,
} from '../applicationCommands.ts';
import type { APIInteractionDataResolved } from '../../mod.ts';
import type { APIApplicationCommandInteractionWrapper, ApplicationCommandType } from '../applicationCommands.ts';
import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base.ts';

export * from './_chatInput/attachment.ts';
Expand Down Expand Up @@ -114,18 +108,7 @@ export type APIApplicationCommandInteractionDataBasicOption =
export interface APIChatInputApplicationCommandInteractionData
extends APIBaseApplicationCommandInteractionData<ApplicationCommandType.ChatInput> {
options?: APIApplicationCommandInteractionDataOption[];
resolved?: APIChatInputApplicationCommandInteractionDataResolved;
}

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure
*/
export interface APIChatInputApplicationCommandInteractionDataResolved {
users?: Record<Snowflake, APIUser>;
roles?: Record<Snowflake, APIRole>;
members?: Record<Snowflake, APIInteractionDataResolvedGuildMember>;
channels?: Record<Snowflake, APIInteractionDataResolvedChannel>;
attachments?: Record<Snowflake, APIAttachment>;
resolved?: APIInteractionDataResolved;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
import type { APIBaseApplicationCommandInteractionData } from './internals.ts';
import type { Snowflake } from '../../../../globals.ts';
import type { APIMessage } from '../../channel.ts';
import type { APIUser } from '../../user.ts';
import type {
APIApplicationCommandInteractionWrapper,
APIInteractionDataResolvedGuildMember,
ApplicationCommandType,
} from '../applicationCommands.ts';
import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base.ts';
import type { APIApplicationCommandInteractionWrapper, ApplicationCommandType } from '../applicationCommands.ts';
import type { APIDMInteractionWrapper, APIGuildInteractionWrapper, APIUserInteractionDataResolved } from '../base.ts';

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data
*/
export interface APIUserApplicationCommandInteractionData
extends APIBaseApplicationCommandInteractionData<ApplicationCommandType.User> {
target_id: Snowflake;
resolved: APIUserApplicationCommandInteractionDataResolved;
}

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure
*/
export interface APIUserApplicationCommandInteractionDataResolved {
users: Record<Snowflake, APIUser>;
members?: Record<Snowflake, APIInteractionDataResolvedGuildMember>;
resolved: APIUserInteractionDataResolved;
}

/**
Expand Down
18 changes: 0 additions & 18 deletions deno/payloads/v10/_interactions/applicationCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import type { APIBaseInteraction } from './base.ts';
import type { InteractionType } from './responses.ts';
import type { Permissions, Snowflake } from '../../../globals.ts';
import type { LocalizationMap } from '../../../v10.ts';
import type { APIPartialChannel, APIThreadMetadata } from '../channel.ts';
import type { APIGuildMember } from '../guild.ts';

export * from './_applicationCommands/chatInput.ts';
export * from './_applicationCommands/contextMenu.ts';
Expand Down Expand Up @@ -107,22 +105,6 @@ export type APIApplicationCommandInteractionData =
| APIChatInputApplicationCommandInteractionData
| APIContextMenuInteractionData;

/**
* https://discord.com/developers/docs/resources/channel#channel-object
*/
export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
thread_metadata?: APIThreadMetadata | null;
permissions: Permissions;
parent_id?: string | null;
}

/**
* https://discord.com/developers/docs/resources/guild#guild-member-object
*/
export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {
permissions: Permissions;
}

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
Expand Down
37 changes: 35 additions & 2 deletions deno/payloads/v10/_interactions/base.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { InteractionType } from './responses.ts';
import type { Permissions, Snowflake } from '../../../globals.ts';
import type { LocaleString } from '../../../v10.ts';
import type { APIMessage } from '../channel.ts';
import type { APIRole, LocaleString } from '../../../v10.ts';
import type { APIAttachment, APIMessage, APIPartialChannel, APIThreadMetadata } from '../channel.ts';
import type { APIGuildMember } from '../guild.ts';
import type { APIUser } from '../user.ts';

Expand Down Expand Up @@ -129,3 +129,36 @@ export type APIGuildInteractionWrapper<Original extends APIBaseInteraction<Inter
'user'
> &
Required<Pick<Original, 'member' | 'guild_id'>>;

/**
* https://discord.com/developers/docs/resources/channel#channel-object
*/
export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
thread_metadata?: APIThreadMetadata | null;
permissions: Permissions;
parent_id?: string | null;
}

/**
* https://discord.com/developers/docs/resources/guild#guild-member-object
*/
export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {
permissions: Permissions;
}

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure
*/
export interface APIInteractionDataResolved {
users?: Record<Snowflake, APIUser>;
roles?: Record<Snowflake, APIRole>;
members?: Record<Snowflake, APIInteractionDataResolvedGuildMember>;
channels?: Record<Snowflake, APIInteractionDataResolvedChannel>;
attachments?: Record<Snowflake, APIAttachment>;
}

/**
* `users` and optional `members` from APIInteractionDataResolved, for user commands and user selects
*/
export type APIUserInteractionDataResolved = Required<Pick<APIInteractionDataResolved, 'users'>> &
advaith1 marked this conversation as resolved.
Show resolved Hide resolved
Pick<APIInteractionDataResolved, 'members'>;
43 changes: 40 additions & 3 deletions deno/payloads/v10/_interactions/messageComponents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts';
import type {
APIDMInteractionWrapper,
APIGuildInteractionWrapper,
APIInteractionDataResolved,
APIUserInteractionDataResolved,
} from './base.ts';
import type { Snowflake } from '../../../globals.ts';
import type { ComponentType } from '../channel.ts';
import type { APIBaseInteraction, InteractionType } from '../interactions.ts';

Expand Down Expand Up @@ -50,11 +56,42 @@ export interface APIMessageComponentBaseInteractionData<CType extends ComponentT

export type APIMessageButtonInteractionData = APIMessageComponentBaseInteractionData<ComponentType.Button>;

export interface APIMessageSelectMenuInteractionData
extends APIMessageComponentBaseInteractionData<ComponentType.SelectMenu> {
export interface APIMessageStringSelectInteractionData
extends APIMessageComponentBaseInteractionData<ComponentType.StringSelect> {
values: string[];
}

export interface APIMessageUserSelectInteractionData
extends APIMessageComponentBaseInteractionData<ComponentType.UserSelect> {
values: Snowflake[];
resolved: APIUserInteractionDataResolved;
}

export interface APIMessageRoleSelectInteractionData
extends APIMessageComponentBaseInteractionData<ComponentType.RoleSelect> {
values: Snowflake[];
resolved: Required<Pick<APIInteractionDataResolved, 'roles'>>;
}

export interface APIMessageMentionableSelectInteractionData
extends APIMessageComponentBaseInteractionData<ComponentType.MentionableSelect> {
values: Snowflake[];
resolved: Pick<APIInteractionDataResolved, 'users' | 'members' | 'roles'>;
}

export interface APIMessageChannelSelectInteractionData
extends APIMessageComponentBaseInteractionData<ComponentType.ChannelSelect> {
values: Snowflake[];
resolved: Required<Pick<APIInteractionDataResolved, 'channels'>>;
}

export type APIMessageSelectMenuInteractionData =
| APIMessageStringSelectInteractionData
| APIMessageUserSelectInteractionData
| APIMessageRoleSelectInteractionData
| APIMessageMentionableSelectInteractionData
| APIMessageChannelSelectInteractionData;

export type APIMessageComponentDMInteraction = APIDMInteractionWrapper<APIMessageComponentInteraction>;

export type APIMessageComponentGuildInteraction = APIGuildInteractionWrapper<APIMessageComponentInteraction>;
46 changes: 41 additions & 5 deletions deno/payloads/v10/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1306,13 +1306,38 @@ export enum ComponentType {
*/
Button,
/**
* Select Menu component
* Select menu for picking from defined text options
*/
SelectMenu,
advaith1 marked this conversation as resolved.
Show resolved Hide resolved
StringSelect,
advaith1 marked this conversation as resolved.
Show resolved Hide resolved
/**
* Text Input component
*/
TextInput,
/**
* Select menu for users
*/
UserSelect,
/**
* Select menu for roles
*/
RoleSelect,
/**
* Select menu for users and roles
*/
MentionableSelect,
/**
* Select menu for channels
*/
ChannelSelect,

// EVERYTHING BELOW THIS LINE SHOULD BE OLD NAMES FOR RENAMED ENUM MEMBERS //

/**
* Select menu for picking from defined text options
*
* @deprecated This is the old name for {@apilink ComponentType#StringSelect}
*/
SelectMenu = 3,
}

/**
Expand Down Expand Up @@ -1404,15 +1429,26 @@ export enum TextInputStyle {
/**
* https://discord.com/developers/docs/interactions/message-components#select-menus
*/
export interface APISelectMenuComponent extends APIBaseComponent<ComponentType.SelectMenu> {
export interface APISelectMenuComponent
extends APIBaseComponent<
| ComponentType.StringSelect
| ComponentType.UserSelect
| ComponentType.RoleSelect
| ComponentType.MentionableSelect
| ComponentType.ChannelSelect
> {
/**
* A developer-defined identifier for the select menu, max 100 characters
*/
custom_id: string;
/**
* The choices in the select, max 25
* Specified choices in a select menu (only required and available for StringSelect, max 25)
*/
options?: APISelectMenuOption[];
/**
* List of channel types to include in the ChannelSelect component
*/
options: APISelectMenuOption[];
channel_types?: ChannelType[];
advaith1 marked this conversation as resolved.
Show resolved Hide resolved
/**
* Custom placeholder text if nothing is selected, max 150 characters
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,8 @@ import type {
APIApplicationCommandUserOption,
} from './_chatInput/user.ts';
import type { APIBaseApplicationCommandInteractionData } from './internals.ts';
import type { Snowflake } from '../../../../globals.ts';
import type { APIAttachment, APIRole, APIUser } from '../../mod.ts';
import type {
APIApplicationCommandInteractionWrapper,
APIInteractionDataResolvedChannel,
APIInteractionDataResolvedGuildMember,
ApplicationCommandType,
} from '../applicationCommands.ts';
import type { APIInteractionDataResolved } from '../../mod.ts';
import type { APIApplicationCommandInteractionWrapper, ApplicationCommandType } from '../applicationCommands.ts';
import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base.ts';

export * from './_chatInput/attachment.ts';
Expand Down Expand Up @@ -114,18 +108,7 @@ export type APIApplicationCommandInteractionDataBasicOption =
export interface APIChatInputApplicationCommandInteractionData
extends APIBaseApplicationCommandInteractionData<ApplicationCommandType.ChatInput> {
options?: APIApplicationCommandInteractionDataOption[];
resolved?: APIChatInputApplicationCommandInteractionDataResolved;
}

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure
*/
export interface APIChatInputApplicationCommandInteractionDataResolved {
users?: Record<Snowflake, APIUser>;
roles?: Record<Snowflake, APIRole>;
members?: Record<Snowflake, APIInteractionDataResolvedGuildMember>;
channels?: Record<Snowflake, APIInteractionDataResolvedChannel>;
attachments?: Record<Snowflake, APIAttachment>;
resolved?: APIInteractionDataResolved;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
import type { APIBaseApplicationCommandInteractionData } from './internals.ts';
import type { Snowflake } from '../../../../globals.ts';
import type { APIMessage } from '../../channel.ts';
import type { APIUser } from '../../user.ts';
import type {
APIApplicationCommandInteractionWrapper,
APIInteractionDataResolvedGuildMember,
ApplicationCommandType,
} from '../applicationCommands.ts';
import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base.ts';
import type { APIApplicationCommandInteractionWrapper, ApplicationCommandType } from '../applicationCommands.ts';
import type { APIDMInteractionWrapper, APIGuildInteractionWrapper, APIUserInteractionDataResolved } from '../base.ts';

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data
*/
export interface APIUserApplicationCommandInteractionData
extends APIBaseApplicationCommandInteractionData<ApplicationCommandType.User> {
target_id: Snowflake;
resolved: APIUserApplicationCommandInteractionDataResolved;
}

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure
*/
export interface APIUserApplicationCommandInteractionDataResolved {
users: Record<Snowflake, APIUser>;
members?: Record<Snowflake, APIInteractionDataResolvedGuildMember>;
resolved: APIUserInteractionDataResolved;
}

/**
Expand Down
18 changes: 0 additions & 18 deletions deno/payloads/v9/_interactions/applicationCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import type { APIBaseInteraction } from './base.ts';
import type { InteractionType } from './responses.ts';
import type { Permissions, Snowflake } from '../../../globals.ts';
import type { LocalizationMap } from '../../../v9.ts';
import type { APIPartialChannel, APIThreadMetadata } from '../channel.ts';
import type { APIGuildMember } from '../guild.ts';

export * from './_applicationCommands/chatInput.ts';
export * from './_applicationCommands/contextMenu.ts';
Expand Down Expand Up @@ -107,22 +105,6 @@ export type APIApplicationCommandInteractionData =
| APIChatInputApplicationCommandInteractionData
| APIContextMenuInteractionData;

/**
* https://discord.com/developers/docs/resources/channel#channel-object
*/
export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
thread_metadata?: APIThreadMetadata | null;
permissions: Permissions;
parent_id?: string | null;
}

/**
* https://discord.com/developers/docs/resources/guild#guild-member-object
*/
export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {
permissions: Permissions;
}

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
Expand Down