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
63 changes: 61 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ declare namespace Eris {
type ActionRowComponents = Button | SelectMenu;
type Button = InteractionButton | URLButton;
type ButtonStyles = Constants["ButtonStyles"][keyof Constants["ButtonStyles"]];
type Component = ActionRow | ActionRowComponents;
type Component = ActionRow | ActionRowComponents | ComponentsV2;
type ComponentsV2 = Section | TextDisplay | Thumbnail | MediaGallery | File | Separator | Container;
type ImageFormat = Constants["ImageFormats"][number];
type MessageActivityTypes = Constants["MessageActivityTypes"][keyof Constants["MessageActivityTypes"]];
type MessageContent = string | AdvancedMessageContent;
Expand Down Expand Up @@ -1519,7 +1520,7 @@ declare namespace Eris {
interface AdvancedMessageContentEdit {
allowedMentions?: AllowedMentions;
attachments?: PartialAttachment[];
components?: ActionRow[];
components?: ActionRow[] | Component[];
content?: string;
/** @deprecated */
embed?: EmbedOptions;
Expand Down Expand Up @@ -1713,6 +1714,64 @@ declare namespace Eris {
id: string;
type: "user" | "role" | "channel";
}

interface Section {
accessory?: Thumbnail | Button;
components: TextDisplay[];
id?: number;
type: Constants["ComponentTypes"]["SECTION"];
}
interface TextDisplay {
content: string;
id?: number;
type: Constants["ComponentTypes"]["TEXT_DISPLAY"];
}
interface Thumbnail {
description?: string;
id?: number;
media: UnfurledMediaItem;
spoiler?: boolean;
type: Constants["ComponentTypes"]["THUMBNAIL"];
}
interface MediaGallery {
id?: number;
items: MediaGalleryItem[];
type: Constants["ComponentTypes"]["MEDIA_GALLERY"];
}
interface MediaGalleryItem {
description?: string;
media: UnfurledMediaItem;
spoiler?: boolean;
}
interface File {
file: UnfurledMediaItem;
id?: number;
name?: string;
size?: number;
spoiler?: boolean;
type: Constants["ComponentTypes"]["FILE"];
}
interface Separator {
divider?: boolean;
id?: number;
spacing?: 1 | 2;
type: Constants["ComponentTypes"]["SEPARATOR"];
}
interface Container {
accent_color?: number;
components: (ActionRow | TextDisplay | Section | MediaGallery | Separator | File)[];
id?: number;
spoiler?: boolean;
type: Constants["ComponentTypes"]["CONTAINER"];
}
interface UnfurledMediaItem {
attachment_id?: string;
content_type?: string;
height?: number;
proxy_url?: string;
url: string;
width?: number;
}
interface Sticker extends StickerItems {
available?: boolean;
description: string;
Expand Down
10 changes: 5 additions & 5 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ class Client extends EventEmitter {
* @arg {Number | String} content.components[].options[].value The value for this option
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 4, it is a text input; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select; if 9, it is a section; if 10, it is a text display; if 11, it is a thumbnail; if 12, it is a media gallery; if 13, it is a file; if 14, it is a separator; if 17, it is a container
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
* @arg {String} [content.content] A content string
* @arg {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
Expand Down Expand Up @@ -1110,7 +1110,7 @@ class Client extends EventEmitter {
* @arg {Number | String} options.message.components[].options[].value The value for this option
* @arg {String} [options.message.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
* @arg {Number} [options.message.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
* @arg {Number} options.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select
* @arg {Number} options.message.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 4, it is a text input; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select; if 9, it is a section; if 10, it is a text display; if 11, it is a thumbnail; if 12, it is a media gallery; if 13, it is a file; if 14, it is a separator; if 17, it is a container
* @arg {String} [options.message.components[].url] The URL that the component should open for users (type 2 style 5 only)
* @arg {String} [options.message.content] A string containing the message content
* @arg {Array<Object>} [options.message.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
Expand Down Expand Up @@ -2098,7 +2098,7 @@ class Client extends EventEmitter {
* @arg {Number | String} content.components[].options[].value The value for this option
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 4, it is a text input; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select; if 9, it is a section; if 10, it is a text display; if 11, it is a thumbnail; if 12, it is a media gallery; if 13, it is a file; if 14, it is a separator; if 17, it is a container
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
* @arg {String} [content.content] A content string
* @arg {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
Expand Down Expand Up @@ -2327,7 +2327,7 @@ class Client extends EventEmitter {
* @arg {Number | String} options.components[].options[].value The value for this option
* @arg {String} [options.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
* @arg {Number} [options.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
* @arg {Number} options.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select
* @arg {Number} options.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 4, it is a text input; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select; if 9, it is a section; if 10, it is a text display; if 11, it is a thumbnail; if 12, it is a media gallery; if 13, it is a file; if 14, it is a separator; if 17, it is a container
* @arg {String} [options.components[].url] The URL that the component should open for users (type 2 style 5 only)
* @arg {String} [options.content] A content string
* @arg {Object} [options.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
Expand Down Expand Up @@ -2424,7 +2424,7 @@ class Client extends EventEmitter {
* @arg {Number | String} options.components[].options[].value The value for this option
* @arg {String} [options.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
* @arg {Number} [options.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
* @arg {Number} options.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select
* @arg {Number} options.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 4, it is a text input; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select; if 9, it is a section; if 10, it is a text display; if 11, it is a thumbnail; if 12, it is a media gallery; if 13, it is a file; if 14, it is a separator; if 17, it is a container
* @arg {String} [options.components[].url] The URL that the component should open for users (type 2 style 5 only)
* @arg {String} [options.content] A content string
* @arg {Object} [options.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
Expand Down
9 changes: 9 additions & 0 deletions lib/Constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ export default interface Constants {
ROLE_SELECT: 6;
MENTIONABLE_SELECT: 7;
CHANNEL_SELECT: 8;
SECTION: 9;
TEXT_DISPLAY: 10;
THUMBNAIL: 11;
MEDIA_GALLERY: 12;
FILE: 13;
SEPARATOR: 14;
// Unknown 15-16
CONTAINER: 17;
};
ForumLayoutTypes: {
NOT_SET: 0;
Expand Down Expand Up @@ -430,6 +438,7 @@ export default interface Constants {
FAILED_TO_MENTION_SOME_ROLES_IN_THREAD: 256;
SUPPRESS_NOTIFICATIONS: 4096;
IS_VOICE_MESSAGE: 8192;
IS_COMPONENTS_V2: 32768;
};
MessageTypes: {
DEFAULT: 0;
Expand Down
10 changes: 10 additions & 0 deletions lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ module.exports.ComponentTypes = {
ROLE_SELECT: 6,
MENTIONABLE_SELECT: 7,
CHANNEL_SELECT: 8,
SECTION: 9,
TEXT_DISPLAY: 10,
THUMBNAIL: 11,
MEDIA_GALLERY: 12,
FILE: 13,
SEPARATOR: 14,
// Unknown 15-16
CONTAINER: 17,
};

module.exports.ConnectionVisibilityTypes = {
Expand Down Expand Up @@ -514,6 +522,8 @@ module.exports.MessageFlags = {
FAILED_TO_MENTION_SOME_ROLES_IN_THREAD: 1 << 8,
SUPPRESS_NOTIFICATIONS: 1 << 12,
IS_VOICE_MESSAGE: 1 << 13,
// Unknown 14
IS_COMPONENTS_V2: 1 << 15,
};

module.exports.MessageTypes = {
Expand Down
Loading