From 714f8bd5deddf945e106a3ea3a343a4121c65924 Mon Sep 17 00:00:00 2001 From: TotallyTung <117299275+TotallyTung@users.noreply.github.com> Date: Mon, 23 Jun 2025 19:16:41 +0700 Subject: [PATCH 01/18] component v2 1 --- src/structures/BaseMessageComponent.js | 1 + src/util/MessageFlags.js | 2 +- typings/enums.d.ts | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/structures/BaseMessageComponent.js b/src/structures/BaseMessageComponent.js index 8ae40df..f731c6b 100644 --- a/src/structures/BaseMessageComponent.js +++ b/src/structures/BaseMessageComponent.js @@ -49,6 +49,7 @@ class BaseMessageComponent { * The type of this component * @type {?MessageComponentType} */ + this.rawData = data; this.type = 'type' in data ? BaseMessageComponent.resolveType(data.type) : null; } diff --git a/src/util/MessageFlags.js b/src/util/MessageFlags.js index 2a461e8..73c67b7 100644 --- a/src/util/MessageFlags.js +++ b/src/util/MessageFlags.js @@ -57,7 +57,7 @@ MessageFlags.FLAGS = { SUPPRESS_NOTIFICATIONS: 1 << 12, IS_VOICE_MESSAGE: 1 << 13, HAS_SNAPSHOT: 1 << 14, - IS_UIKIT_COMPONENTS: 1 << 15, + IS_COMPONENTS_V2: 1 << 15, }; module.exports = MessageFlags; diff --git a/typings/enums.d.ts b/typings/enums.d.ts index 4c8ddc0..396bf65 100644 --- a/typings/enums.d.ts +++ b/typings/enums.d.ts @@ -226,6 +226,13 @@ export const enum MessageComponentTypes { ROLE_SELECT = 6, MENTIONABLE_SELECT = 7, CHANNEL_SELECT = 8, + SELECTION = 9, + TEXT_DISPLAY = 10, + THUMBNAIL = 11, + MEDIA_GALLERY = 12, + FILE = 13, + SEPARATOR = 14, + CONTAINER = 17, } export const enum SelectMenuComponentTypes { From 7a2a3d7a054e6b3c91fefcd4e352af3391fb2aee Mon Sep 17 00:00:00 2001 From: TotallyTung <117299275+TotallyTung@users.noreply.github.com> Date: Mon, 23 Jun 2025 22:04:53 +0700 Subject: [PATCH 02/18] component v2 --- src/structures/BaseMessageComponent.js | 35 +++++++++++++++++++++++++ src/structures/ContainerComponent.js | 24 +++++++++++++++++ src/structures/FileComponent.js | 22 ++++++++++++++++ src/structures/MediaGalleryComponent.js | 21 +++++++++++++++ src/structures/MediaGalleryItem.js | 21 +++++++++++++++ src/structures/SectionComponent.js | 23 ++++++++++++++++ src/structures/SeparatorComponent.js | 22 ++++++++++++++++ src/structures/TextDisplayComponent.js | 20 ++++++++++++++ src/structures/ThumbnailComponent.js | 25 ++++++++++++++++++ src/structures/UnfurledMediaItem.js | 15 +++++++++++ src/util/Constants.js | 16 +++++++++++ typings/enums.d.ts | 7 ++++- 12 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 src/structures/ContainerComponent.js create mode 100644 src/structures/FileComponent.js create mode 100644 src/structures/MediaGalleryComponent.js create mode 100644 src/structures/MediaGalleryItem.js create mode 100644 src/structures/SectionComponent.js create mode 100644 src/structures/SeparatorComponent.js create mode 100644 src/structures/TextDisplayComponent.js create mode 100644 src/structures/ThumbnailComponent.js create mode 100644 src/structures/UnfurledMediaItem.js diff --git a/src/structures/BaseMessageComponent.js b/src/structures/BaseMessageComponent.js index f731c6b..7e1d01d 100644 --- a/src/structures/BaseMessageComponent.js +++ b/src/structures/BaseMessageComponent.js @@ -91,6 +91,41 @@ class BaseMessageComponent { component = data instanceof TextInputComponent ? data : new TextInputComponent(data); break; } + case MessageComponentTypes.SECTION: { + const SectionComponent = require('./SectionComponent'); + component = data instanceof SectionComponent ? data : new SectionComponent(data); + break; + } + case MessageComponentTypes.TEXT_DISPLAY: { + const TextDisplayComponent = require('./TextDisplayComponent'); + component = data instanceof TextDisplayComponent ? data : new TextDisplayComponent(data); + break; + } + case MessageComponentTypes.THUMBNAIL: { + const ThumbnailComponent = require('./ThumbnailComponent'); + component = data instanceof ThumbnailComponent ? data : new ThumbnailComponent(data); + break; + } + case MessageComponentTypes.MEDIA_GALLERY: { + const MediaGalleryComponent = require('./MediaGalleryComponent'); + component = data instanceof MediaGalleryComponent ? data : new MediaGalleryComponent(data); + break; + } + case MessageComponentTypes.FILE: { + const FileComponent = require('./FileComponent'); + component = data instanceof FileComponent ? data : new FileComponent(data); + break; + } + case MessageComponentTypes.SEPARATOR: { + const SeparatorComponent = require('./SeparatorComponent'); + component = data instanceof SeparatorComponent ? data : new SeparatorComponent(data); + break; + } + case MessageComponentTypes.CONTAINER: { + const ContainerComponent = require('./ContainerComponent'); + component = data instanceof ContainerComponent ? data : new ContainerComponent(data); + break; + } default: if (client) { client.emit(Events.DEBUG, `[BaseMessageComponent] Received component with unknown type: ${data.type}`); diff --git a/src/structures/ContainerComponent.js b/src/structures/ContainerComponent.js new file mode 100644 index 00000000..8500fe5 --- /dev/null +++ b/src/structures/ContainerComponent.js @@ -0,0 +1,24 @@ +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const { MessageComponentTypes } = require('../util/Constants'); + +class ContainerComponent extends BaseMessageComponent { + constructor(data = {}) { + super({ type: 'CONTAINER' }); + this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? null; + this.accent_color = data.accent_color ?? null; + this.spoiler = data.spoiler ?? false; + } + + toJSON() { + return { + type: MessageComponentTypes[this.type], + components: this.components.map(c => c.toJSON()), + accent_color: this.accent_color, + spoiler: this.spoiler, + }; + } +} + +module.exports = ContainerComponent; \ No newline at end of file diff --git a/src/structures/FileComponent.js b/src/structures/FileComponent.js new file mode 100644 index 00000000..a2de1ea --- /dev/null +++ b/src/structures/FileComponent.js @@ -0,0 +1,22 @@ +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const { UnfurledMediaItem } = require('./UnfurledMediaItem'); +const { MessageComponentTypes } = require('../util/Constants'); + +class FileComponent extends BaseMessageComponent { + constructor(data = {}) { + super({ type: 'FILE' }); + this.file = new UnfurledMediaItem(data.file) ?? null; + this.spoiler = data.spoiler ?? false; + } + + toJSON() { + return { + type: MessageComponentTypes[this.type], + file: this.content, + }; + } +} + +module.exports = FileComponent; \ No newline at end of file diff --git a/src/structures/MediaGalleryComponent.js b/src/structures/MediaGalleryComponent.js new file mode 100644 index 00000000..e82ad76 --- /dev/null +++ b/src/structures/MediaGalleryComponent.js @@ -0,0 +1,21 @@ +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const { MediaGalleryItem } = require('./MediaGalleryItem'); +const { MessageComponentTypes } = require('../util/Constants'); + +class MediaGalleryComponent extends BaseMessageComponent { + constructor(data = {}) { + super({ type: 'MEDIA_GALLERY' }); + this.items = data.items?.map(item => new MediaGalleryItem(item)) ?? []; + } + + toJSON() { + return { + type: MessageComponentTypes[this.type], + items: this.items.map(c => c.toJSON()), + }; + } +} + +module.exports = MediaGalleryComponent; \ No newline at end of file diff --git a/src/structures/MediaGalleryItem.js b/src/structures/MediaGalleryItem.js new file mode 100644 index 00000000..1ceb2ca --- /dev/null +++ b/src/structures/MediaGalleryItem.js @@ -0,0 +1,21 @@ +'use strict'; + +const { UnfurledMediaItem } = require('./UnfurledMediaItem'); + +class MediaGalleryItem { + constructor(data = {}) { + this.media = new UnfurledMediaItem(data.media); + this.description = data.description ?? null; + this.spoiler = data.spoiler ?? false; + } + + toJSON() { + return { + media: this.media.toJSON(), + description: this.description, + spoiler: this.spoiler, + }; + } +} + +module.exports = MediaGalleryItem; \ No newline at end of file diff --git a/src/structures/SectionComponent.js b/src/structures/SectionComponent.js new file mode 100644 index 00000000..df4b030 --- /dev/null +++ b/src/structures/SectionComponent.js @@ -0,0 +1,23 @@ +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const { TextDisplayComponent } = require('./TextDisplayComponent'); +const { MessageComponentTypes } = require('../util/Constants'); + +class SectionComponent extends BaseMessageComponent { + constructor(data = {}) { + super({ type: 'SECTION' }); + this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? []; + this.accessory = BaseMessageComponent.create(c) ?? null; + } + + toJSON() { + return { + type: MessageComponentTypes[this.type], + components: this.components.map(c => c.toJSON()), + accessory: this.accessory.toJSON(), + }; + } +} + +module.exports = SectionComponent; diff --git a/src/structures/SeparatorComponent.js b/src/structures/SeparatorComponent.js new file mode 100644 index 00000000..8201aa5 --- /dev/null +++ b/src/structures/SeparatorComponent.js @@ -0,0 +1,22 @@ +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const { MessageComponentTypes, SeparatorSpacingSizes } = require('../util/Constants'); + +class SeparatorComponent extends BaseMessageComponent { + constructor(data = {}) { + super({ type: 'SEPARATOR' }); + this.spacing = data.spacing ?? SeparatorSpacingSizes.SMALL; + this.divider = data.divider ?? true; + } + + toJSON() { + return { + type: MessageComponentTypes[this.type], + spacing: this.spacing, + divider: this.divider, + }; + } +} + +module.exports = SeparatorComponent; \ No newline at end of file diff --git a/src/structures/TextDisplayComponent.js b/src/structures/TextDisplayComponent.js new file mode 100644 index 00000000..c7c5419 --- /dev/null +++ b/src/structures/TextDisplayComponent.js @@ -0,0 +1,20 @@ +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const { MessageComponentTypes } = require('../util/Constants'); + +class TextDisplayComponent extends BaseMessageComponent { + constructor(data = {}) { + super({ type: 'TEXT_DISPLAY' }); + this.content = data.content ?? null; + } + + toJSON() { + return { + type: MessageComponentTypes[this.type], + content: this.content, + }; + } +} + +module.exports = TextDisplayComponent; \ No newline at end of file diff --git a/src/structures/ThumbnailComponent.js b/src/structures/ThumbnailComponent.js new file mode 100644 index 00000000..7fc4fda --- /dev/null +++ b/src/structures/ThumbnailComponent.js @@ -0,0 +1,25 @@ +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const { UnfurledMediaItem } = require('./UnfurledMediaItem'); +const { MessageComponentTypes } = require('../util/Constants'); + +class ThumbnailComponent extends BaseMessageComponent { + constructor(data = {}) { + super({ type: 'THUMBNAIL' }); + this.media = new UnfurledMediaItem(data.media) ?? null; + this.description = data.description ?? null; + this.spoiler = data.spoiler ?? false; + } + + toJSON() { + return { + type: MessageComponentTypes[this.type], + media: this.media.toJSON(), + description: this.description, + spoiler: this.spoiler, + }; + } +} + +module.exports = ThumbnailComponent; \ No newline at end of file diff --git a/src/structures/UnfurledMediaItem.js b/src/structures/UnfurledMediaItem.js new file mode 100644 index 00000000..a21d16f --- /dev/null +++ b/src/structures/UnfurledMediaItem.js @@ -0,0 +1,15 @@ +'use strict'; + +class UnfurledMediaItem { + constructor(data = {}) { + this.url = data.url ?? null; + } + + toJSON() { + return { + url: this.url, + }; + } +} + +module.exports = UnfurledMediaItem; \ No newline at end of file diff --git a/src/util/Constants.js b/src/util/Constants.js index 02857a6..8f3b6e0 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -1615,6 +1615,15 @@ exports.MessageComponentTypes = createEnum([ 'ROLE_SELECT', 'MENTIONABLE_SELECT', 'CHANNEL_SELECT', + 'SECTION', + 'TEXT_DISPLAY', + 'THUMBNAIL', + 'MEDIA_GALLERY', + 'FILE', + 'SEPARATOR', + null, + null, + 'CONTAINER', ]); /** @@ -1796,6 +1805,12 @@ exports.RelationshipTypes = createEnum([ 'IMPLICIT', ]); +exports.SeparatorSpacingSizes = createEnum([ + null, + 'SMALL', + 'LARGE', +]); + exports._cleanupSymbol = Symbol('djsCleanup'); function keyMirror(arr) { @@ -1855,6 +1870,7 @@ function createEnum(keys) { * @property {Object} InteractionTypes The type of an {@link Interaction} object. * @property {InviteScope[]} InviteScopes The scopes of an invite. * @property {Object} RelationshipTypes Relationship Enums + * * @property {Object} SeparatorSpacingSize Relationship Enums * @property {Object} MembershipStates The value set for a team members membership state. * @property {Object} MessageButtonStyles The style of a message button. * @property {Object} MessageComponentTypes The type of a message component. diff --git a/typings/enums.d.ts b/typings/enums.d.ts index 396bf65..0578c65 100644 --- a/typings/enums.d.ts +++ b/typings/enums.d.ts @@ -226,7 +226,7 @@ export const enum MessageComponentTypes { ROLE_SELECT = 6, MENTIONABLE_SELECT = 7, CHANNEL_SELECT = 8, - SELECTION = 9, + SECTION = 9, TEXT_DISPLAY = 10, THUMBNAIL = 11, MEDIA_GALLERY = 12, @@ -332,3 +332,8 @@ export const enum RelationshipTypes { PENDING_OUTGOING = 4, IMPLICIT = 5, } + +export const enum SeparatorSpacingSize { + SMALL = 1, + LARGE = 2, +} \ No newline at end of file From 70cc08c2c6eec444398a7120f020853b4595b79a Mon Sep 17 00:00:00 2001 From: TotallyTung <117299275+TotallyTung@users.noreply.github.com> Date: Tue, 24 Jun 2025 11:31:41 +0700 Subject: [PATCH 03/18] fix --- src/structures/FileComponent.js | 2 +- src/structures/MediaGalleryComponent.js | 2 +- src/structures/MediaGalleryItem.js | 2 +- src/structures/SectionComponent.js | 4 ++-- src/structures/ThumbnailComponent.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/structures/FileComponent.js b/src/structures/FileComponent.js index a2de1ea..4327cda 100644 --- a/src/structures/FileComponent.js +++ b/src/structures/FileComponent.js @@ -1,7 +1,7 @@ 'use strict'; const BaseMessageComponent = require('./BaseMessageComponent'); -const { UnfurledMediaItem } = require('./UnfurledMediaItem'); +const UnfurledMediaItem = require('./UnfurledMediaItem'); const { MessageComponentTypes } = require('../util/Constants'); class FileComponent extends BaseMessageComponent { diff --git a/src/structures/MediaGalleryComponent.js b/src/structures/MediaGalleryComponent.js index e82ad76..ac416c2 100644 --- a/src/structures/MediaGalleryComponent.js +++ b/src/structures/MediaGalleryComponent.js @@ -1,7 +1,7 @@ 'use strict'; const BaseMessageComponent = require('./BaseMessageComponent'); -const { MediaGalleryItem } = require('./MediaGalleryItem'); +const MediaGalleryItem = require('./MediaGalleryItem'); const { MessageComponentTypes } = require('../util/Constants'); class MediaGalleryComponent extends BaseMessageComponent { diff --git a/src/structures/MediaGalleryItem.js b/src/structures/MediaGalleryItem.js index 1ceb2ca..9cba3e2 100644 --- a/src/structures/MediaGalleryItem.js +++ b/src/structures/MediaGalleryItem.js @@ -1,6 +1,6 @@ 'use strict'; -const { UnfurledMediaItem } = require('./UnfurledMediaItem'); +const UnfurledMediaItem = require('./UnfurledMediaItem'); class MediaGalleryItem { constructor(data = {}) { diff --git a/src/structures/SectionComponent.js b/src/structures/SectionComponent.js index df4b030..8bf8f09 100644 --- a/src/structures/SectionComponent.js +++ b/src/structures/SectionComponent.js @@ -8,7 +8,7 @@ class SectionComponent extends BaseMessageComponent { constructor(data = {}) { super({ type: 'SECTION' }); this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? []; - this.accessory = BaseMessageComponent.create(c) ?? null; + this.accessory = BaseMessageComponent.create(data.accessory) ?? null; } toJSON() { @@ -20,4 +20,4 @@ class SectionComponent extends BaseMessageComponent { } } -module.exports = SectionComponent; +module.exports = SectionComponent; \ No newline at end of file diff --git a/src/structures/ThumbnailComponent.js b/src/structures/ThumbnailComponent.js index 7fc4fda..cb981bd 100644 --- a/src/structures/ThumbnailComponent.js +++ b/src/structures/ThumbnailComponent.js @@ -1,7 +1,7 @@ 'use strict'; const BaseMessageComponent = require('./BaseMessageComponent'); -const { UnfurledMediaItem } = require('./UnfurledMediaItem'); +const UnfurledMediaItem = require('./UnfurledMediaItem'); const { MessageComponentTypes } = require('../util/Constants'); class ThumbnailComponent extends BaseMessageComponent { From df3d768087bb80841bcd504e793c61cc459ed652 Mon Sep 17 00:00:00 2001 From: TotallyTung <117299275+TotallyTung@users.noreply.github.com> Date: Tue, 24 Jun 2025 12:32:58 +0700 Subject: [PATCH 04/18] rawData --- src/structures/BaseMessageComponent.js | 4 ++-- src/structures/ContainerComponent.js | 2 +- src/structures/FileComponent.js | 2 +- src/structures/MediaGalleryComponent.js | 2 +- src/structures/MessageActionRow.js | 4 ++-- src/structures/MessageButton.js | 4 ++-- src/structures/MessageSelectMenu.js | 4 ++-- src/structures/SectionComponent.js | 2 +- src/structures/SeparatorComponent.js | 2 +- src/structures/TextDisplayComponent.js | 2 +- src/structures/TextInputComponent.js | 4 ++-- src/structures/ThumbnailComponent.js | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/structures/BaseMessageComponent.js b/src/structures/BaseMessageComponent.js index 7e1d01d..6bbf3df 100644 --- a/src/structures/BaseMessageComponent.js +++ b/src/structures/BaseMessageComponent.js @@ -44,12 +44,12 @@ class BaseMessageComponent { /** * @param {BaseMessageComponent|BaseMessageComponentOptions} [data={}] The options for this component */ - constructor(data) { + constructor(data, componentData = {}) { /** * The type of this component * @type {?MessageComponentType} */ - this.rawData = data; + this.rawData = componentData; this.type = 'type' in data ? BaseMessageComponent.resolveType(data.type) : null; } diff --git a/src/structures/ContainerComponent.js b/src/structures/ContainerComponent.js index 8500fe5..7af8ab6 100644 --- a/src/structures/ContainerComponent.js +++ b/src/structures/ContainerComponent.js @@ -5,7 +5,7 @@ const { MessageComponentTypes } = require('../util/Constants'); class ContainerComponent extends BaseMessageComponent { constructor(data = {}) { - super({ type: 'CONTAINER' }); + super({ type: 'CONTAINER' }, data); this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? null; this.accent_color = data.accent_color ?? null; this.spoiler = data.spoiler ?? false; diff --git a/src/structures/FileComponent.js b/src/structures/FileComponent.js index 4327cda..3ca2108 100644 --- a/src/structures/FileComponent.js +++ b/src/structures/FileComponent.js @@ -6,7 +6,7 @@ const { MessageComponentTypes } = require('../util/Constants'); class FileComponent extends BaseMessageComponent { constructor(data = {}) { - super({ type: 'FILE' }); + super({ type: 'FILE' }, data); this.file = new UnfurledMediaItem(data.file) ?? null; this.spoiler = data.spoiler ?? false; } diff --git a/src/structures/MediaGalleryComponent.js b/src/structures/MediaGalleryComponent.js index ac416c2..8c8dfc4 100644 --- a/src/structures/MediaGalleryComponent.js +++ b/src/structures/MediaGalleryComponent.js @@ -6,7 +6,7 @@ const { MessageComponentTypes } = require('../util/Constants'); class MediaGalleryComponent extends BaseMessageComponent { constructor(data = {}) { - super({ type: 'MEDIA_GALLERY' }); + super({ type: 'MEDIA_GALLERY' }, data); this.items = data.items?.map(item => new MediaGalleryItem(item)) ?? []; } diff --git a/src/structures/MessageActionRow.js b/src/structures/MessageActionRow.js index d2115d6..e9f719a 100644 --- a/src/structures/MessageActionRow.js +++ b/src/structures/MessageActionRow.js @@ -42,7 +42,7 @@ class MessageActionRow extends BaseMessageComponent { * @param {Client} [client] The client constructing this MessageActionRow, if provided */ constructor(data = {}, client = null) { - super({ type: 'ACTION_ROW' }); + super({ type: 'ACTION_ROW' }, data); /** * The components in this action row @@ -100,4 +100,4 @@ module.exports = MessageActionRow; /** * @external APIMessageComponent * @see {@link https://discord.com/developers/docs/interactions/message-components#component-object} - */ + */ \ No newline at end of file diff --git a/src/structures/MessageButton.js b/src/structures/MessageButton.js index a94c1ec..93674ad 100644 --- a/src/structures/MessageButton.js +++ b/src/structures/MessageButton.js @@ -24,7 +24,7 @@ class MessageButton extends BaseMessageComponent { * @param {MessageButton|MessageButtonOptions} [data={}] MessageButton to clone or raw data */ constructor(data = {}) { - super({ type: 'BUTTON' }); + super({ type: 'BUTTON' }, data); this.setup(data); } @@ -162,4 +162,4 @@ class MessageButton extends BaseMessageComponent { } } -module.exports = MessageButton; +module.exports = MessageButton; \ No newline at end of file diff --git a/src/structures/MessageSelectMenu.js b/src/structures/MessageSelectMenu.js index 3a118dd..f09df28 100644 --- a/src/structures/MessageSelectMenu.js +++ b/src/structures/MessageSelectMenu.js @@ -42,7 +42,7 @@ class MessageSelectMenu extends BaseMessageComponent { * @param {MessageSelectMenu|MessageSelectMenuOptions} [data={}] MessageSelectMenu to clone or raw data */ constructor(data = {}) { - super({ type: BaseMessageComponent.resolveType(data.type) ?? 'STRING_SELECT' }); + super({ type: BaseMessageComponent.resolveType(data.type) ?? 'STRING_SELECT' }, data); this.setup(data); } @@ -137,4 +137,4 @@ class MessageSelectMenu extends BaseMessageComponent { } } -module.exports = MessageSelectMenu; +module.exports = MessageSelectMenu; \ No newline at end of file diff --git a/src/structures/SectionComponent.js b/src/structures/SectionComponent.js index 8bf8f09..4b287e5 100644 --- a/src/structures/SectionComponent.js +++ b/src/structures/SectionComponent.js @@ -6,7 +6,7 @@ const { MessageComponentTypes } = require('../util/Constants'); class SectionComponent extends BaseMessageComponent { constructor(data = {}) { - super({ type: 'SECTION' }); + super({ type: 'SECTION' }, data); this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? []; this.accessory = BaseMessageComponent.create(data.accessory) ?? null; } diff --git a/src/structures/SeparatorComponent.js b/src/structures/SeparatorComponent.js index 8201aa5..b77ac5f 100644 --- a/src/structures/SeparatorComponent.js +++ b/src/structures/SeparatorComponent.js @@ -5,7 +5,7 @@ const { MessageComponentTypes, SeparatorSpacingSizes } = require('../util/Consta class SeparatorComponent extends BaseMessageComponent { constructor(data = {}) { - super({ type: 'SEPARATOR' }); + super({ type: 'SEPARATOR' }, data); this.spacing = data.spacing ?? SeparatorSpacingSizes.SMALL; this.divider = data.divider ?? true; } diff --git a/src/structures/TextDisplayComponent.js b/src/structures/TextDisplayComponent.js index c7c5419..4d4f8e0 100644 --- a/src/structures/TextDisplayComponent.js +++ b/src/structures/TextDisplayComponent.js @@ -5,7 +5,7 @@ const { MessageComponentTypes } = require('../util/Constants'); class TextDisplayComponent extends BaseMessageComponent { constructor(data = {}) { - super({ type: 'TEXT_DISPLAY' }); + super({ type: 'TEXT_DISPLAY' }, data); this.content = data.content ?? null; } diff --git a/src/structures/TextInputComponent.js b/src/structures/TextInputComponent.js index af60ac1..67f1ef6 100644 --- a/src/structures/TextInputComponent.js +++ b/src/structures/TextInputComponent.js @@ -27,7 +27,7 @@ class TextInputComponent extends BaseMessageComponent { * @param {TextInputComponent|TextInputComponentOptions} [data={}] TextInputComponent to clone or raw data */ constructor(data = {}) { - super({ type: 'TEXT_INPUT' }); + super({ type: 'TEXT_INPUT' }, data); this.setup(data); } @@ -128,4 +128,4 @@ class TextInputComponent extends BaseMessageComponent { } } -module.exports = TextInputComponent; +module.exports = TextInputComponent; \ No newline at end of file diff --git a/src/structures/ThumbnailComponent.js b/src/structures/ThumbnailComponent.js index cb981bd..9ccbc37 100644 --- a/src/structures/ThumbnailComponent.js +++ b/src/structures/ThumbnailComponent.js @@ -6,7 +6,7 @@ const { MessageComponentTypes } = require('../util/Constants'); class ThumbnailComponent extends BaseMessageComponent { constructor(data = {}) { - super({ type: 'THUMBNAIL' }); + super({ type: 'THUMBNAIL' }, data); this.media = new UnfurledMediaItem(data.media) ?? null; this.description = data.description ?? null; this.spoiler = data.spoiler ?? false; From 1aa4f523ad59873ff2a6f6fab91e37c212464835 Mon Sep 17 00:00:00 2001 From: TotallyTung <117299275+TotallyTung@users.noreply.github.com> Date: Sun, 29 Jun 2025 11:01:41 +0700 Subject: [PATCH 05/18] test --- src/structures/ContainerComponent.js | 4 ++++ src/structures/UnfurledMediaItem.js | 12 +++++++++++- typings/rawDataTypes.d.ts | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/structures/ContainerComponent.js b/src/structures/ContainerComponent.js index 7af8ab6..aa31042 100644 --- a/src/structures/ContainerComponent.js +++ b/src/structures/ContainerComponent.js @@ -4,6 +4,10 @@ const BaseMessageComponent = require('./BaseMessageComponent'); const { MessageComponentTypes } = require('../util/Constants'); class ContainerComponent extends BaseMessageComponent { + /** + * + * @param {*} data + */ constructor(data = {}) { super({ type: 'CONTAINER' }, data); this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? null; diff --git a/src/structures/UnfurledMediaItem.js b/src/structures/UnfurledMediaItem.js index a21d16f..6813ccc 100644 --- a/src/structures/UnfurledMediaItem.js +++ b/src/structures/UnfurledMediaItem.js @@ -1,10 +1,20 @@ 'use strict'; class UnfurledMediaItem { + /** + * + * @param {*} data + */ constructor(data = {}) { + /** + * @type {string} + */ this.url = data.url ?? null; } - + /** + * + * @returns {APIUnfurledMediaItem} + */ toJSON() { return { url: this.url, diff --git a/typings/rawDataTypes.d.ts b/typings/rawDataTypes.d.ts index f71348e..10f5eed 100644 --- a/typings/rawDataTypes.d.ts +++ b/typings/rawDataTypes.d.ts @@ -340,3 +340,7 @@ export interface APIApplicationRoleConnectionMetadata { description: string; description_localizations?: LocalizationMap; } + +export interface APIUnfurledMediaItem { + url: String; +} \ No newline at end of file From 767b72182e2f8de364061d458f5fc3e6147bb97d Mon Sep 17 00:00:00 2001 From: tungdo0602 Date: Sun, 29 Jun 2025 12:56:55 +0700 Subject: [PATCH 06/18] wtf --- src/structures/ContainerComponent.js | 27 +++++++++++++++++++++++-- src/structures/FileComponent.js | 23 +++++++++++++++++++++ src/structures/MediaGalleryComponent.js | 15 ++++++++++++++ src/structures/MediaGalleryItem.js | 26 ++++++++++++++++++++++++ src/structures/SectionComponent.js | 22 +++++++++++++++++++- src/structures/SeparatorComponent.js | 21 +++++++++++++++++++ src/structures/UnfurledMediaItem.js | 5 ++--- typings/rawDataTypes.d.ts | 12 ++++++++++- 8 files changed, 144 insertions(+), 7 deletions(-) diff --git a/src/structures/ContainerComponent.js b/src/structures/ContainerComponent.js index aa31042..e4c583c 100644 --- a/src/structures/ContainerComponent.js +++ b/src/structures/ContainerComponent.js @@ -5,16 +5,39 @@ const { MessageComponentTypes } = require('../util/Constants'); class ContainerComponent extends BaseMessageComponent { /** - * - * @param {*} data + * @typedef {MessageActionRow|TextDisplayComponent|SectionComponent|MediaGalleryComponent|SeparatorComponent|FileComponent} ContainerComponents + * @property {ContainerComponents[]} [components] Components of the type action row, text display, section, media gallery, separator, or file + * @property {Number} [accent_color] Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF + * @property {Boolean} [spoiler] Whether the container should be a spoiler (or blurred out). Defaults to false. + */ + + /** + * @param {} [data={}] */ constructor(data = {}) { super({ type: 'CONTAINER' }, data); + /** + * Components of the type action row, text display, section, media gallery, separator, or file + * @type {ContainerComponents[]} + */ this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? null; + + /** + * Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF + * @type {Number} + */ this.accent_color = data.accent_color ?? null; + + /** + * Whether the container should be a spoiler (or blurred out). Defaults to false. + * @type {Boolean} + */ this.spoiler = data.spoiler ?? false; } + /** + * @returns {APIContainerComponent} + */ toJSON() { return { type: MessageComponentTypes[this.type], diff --git a/src/structures/FileComponent.js b/src/structures/FileComponent.js index 3ca2108..53434ee 100644 --- a/src/structures/FileComponent.js +++ b/src/structures/FileComponent.js @@ -4,13 +4,36 @@ const BaseMessageComponent = require('./BaseMessageComponent'); const UnfurledMediaItem = require('./UnfurledMediaItem'); const { MessageComponentTypes } = require('../util/Constants'); + class FileComponent extends BaseMessageComponent { + /** + * @property {UnfurledMediaItem} [file] This unfurled media item is unique in that it only supports attachment references using the attachment:// syntax + * @property {Boolean} [spoiler] Whether the container should be a spoiler (or blurred out). Defaults to false. + */ + + /** + * @param {} [data={}] + */ constructor(data = {}) { super({ type: 'FILE' }, data); + + /** + * This unfurled media item is unique in that it only supports attachment references using the attachment:// syntax + * @type {UnfurledMediaItem} + */ this.file = new UnfurledMediaItem(data.file) ?? null; + + /** + * Whether the container should be a spoiler (or blurred out). Defaults to false. + * @type {Boolean} + */ this.spoiler = data.spoiler ?? false; } + + /** + * @returns {APIFileComponent} + */ toJSON() { return { type: MessageComponentTypes[this.type], diff --git a/src/structures/MediaGalleryComponent.js b/src/structures/MediaGalleryComponent.js index 8c8dfc4..5a68636 100644 --- a/src/structures/MediaGalleryComponent.js +++ b/src/structures/MediaGalleryComponent.js @@ -5,11 +5,26 @@ const MediaGalleryItem = require('./MediaGalleryItem'); const { MessageComponentTypes } = require('../util/Constants'); class MediaGalleryComponent extends BaseMessageComponent { + /** + * @property {MediaGalleryItem[]} [items] 1 to 10 media gallery items + */ + + /** + * @param {} [data={}] + */ constructor(data = {}) { super({ type: 'MEDIA_GALLERY' }, data); + + /** + * 1 to 10 media gallery items + * @type {MediaGalleryItem[]} + */ this.items = data.items?.map(item => new MediaGalleryItem(item)) ?? []; } + /** + * @returns {APIMediaGalleryComponent} + */ toJSON() { return { type: MessageComponentTypes[this.type], diff --git a/src/structures/MediaGalleryItem.js b/src/structures/MediaGalleryItem.js index 9cba3e2..9aa4e26 100644 --- a/src/structures/MediaGalleryItem.js +++ b/src/structures/MediaGalleryItem.js @@ -3,12 +3,38 @@ const UnfurledMediaItem = require('./UnfurledMediaItem'); class MediaGalleryItem { + /** + * @property {UnfurledMediaItem} [media] A url or attachment + * @property {String} [description] Alt text for the media, max 1024 characters + * @property {Boolean} [spoiler] Whether the media should be a spoiler (or blurred out). Defaults to false + */ + + /** + * @param {} [data={}] + */ constructor(data = {}) { + /** + * A url or attachment + * @type {UnfurledMediaItem} + */ this.media = new UnfurledMediaItem(data.media); + + /** + * Alt text for the media, max 1024 characters + * @type {String} + */ this.description = data.description ?? null; + + /** + * Whether the media should be a spoiler (or blurred out). Defaults to false + * @type {Boolean} + */ this.spoiler = data.spoiler ?? false; } + /** + * @returns {APIMediaGalleryItem} + */ toJSON() { return { media: this.media.toJSON(), diff --git a/src/structures/SectionComponent.js b/src/structures/SectionComponent.js index 4b287e5..c36233f 100644 --- a/src/structures/SectionComponent.js +++ b/src/structures/SectionComponent.js @@ -1,16 +1,36 @@ 'use strict'; const BaseMessageComponent = require('./BaseMessageComponent'); -const { TextDisplayComponent } = require('./TextDisplayComponent'); const { MessageComponentTypes } = require('../util/Constants'); class SectionComponent extends BaseMessageComponent { + /** + * @property {TextDisplayComponent[]} [components] One to three text components + * @property {ThumbnailComponent|MessageButton} [accessory] A thumbnail or a button component, with a future possibility of adding more compatible components + */ + + /** + * @param {} [data={}] + */ constructor(data = {}) { super({ type: 'SECTION' }, data); + + /** + * One to three text components + * @type {TextDisplayComponent[]} + */ this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? []; + + /** + * A thumbnail or a button component, with a future possibility of adding more compatible components + * @type {ThumbnailComponent|MessageButton} + */ this.accessory = BaseMessageComponent.create(data.accessory) ?? null; } + /** + * @returns {APISectionComponent} + */ toJSON() { return { type: MessageComponentTypes[this.type], diff --git a/src/structures/SeparatorComponent.js b/src/structures/SeparatorComponent.js index b77ac5f..aad39f4 100644 --- a/src/structures/SeparatorComponent.js +++ b/src/structures/SeparatorComponent.js @@ -4,12 +4,33 @@ const BaseMessageComponent = require('./BaseMessageComponent'); const { MessageComponentTypes, SeparatorSpacingSizes } = require('../util/Constants'); class SeparatorComponent extends BaseMessageComponent { + /** + * @property {SeparatorSpacingSizes} [spacing] Size of separator padding — SeparatorSpacingSizes.SMALL for small padding, SeparatorSpacingSizes.LARGE for large padding. Defaults to SeparatorSpacingSizes.SMALL + * @property {Boolean} [divider] Whether a visual divider should be displayed in the component. Defaults to true + */ + + /** + * @param {} [data={}] + */ constructor(data = {}) { super({ type: 'SEPARATOR' }, data); + + /** + * Size of separator padding — SeparatorSpacingSizes.SMALL for small padding, SeparatorSpacingSizes.LARGE for large padding. Defaults to SeparatorSpacingSizes.SMALL + * @type {SeparatorSpacingSizes} + */ this.spacing = data.spacing ?? SeparatorSpacingSizes.SMALL; + + /** + * Whether a visual divider should be displayed in the component. Defaults to true + * @type {Boolean} + */ this.divider = data.divider ?? true; } + /** + * @returns {APISeparatorComponent} + */ toJSON() { return { type: MessageComponentTypes[this.type], diff --git a/src/structures/UnfurledMediaItem.js b/src/structures/UnfurledMediaItem.js index 6813ccc..1bb2908 100644 --- a/src/structures/UnfurledMediaItem.js +++ b/src/structures/UnfurledMediaItem.js @@ -2,9 +2,8 @@ class UnfurledMediaItem { /** - * - * @param {*} data - */ + * @property {string} [url] Supports arbitrary urls and `attachment://` references + */ constructor(data = {}) { /** * @type {string} diff --git a/typings/rawDataTypes.d.ts b/typings/rawDataTypes.d.ts index 10f5eed..aee9c7b 100644 --- a/typings/rawDataTypes.d.ts +++ b/typings/rawDataTypes.d.ts @@ -88,13 +88,14 @@ import { GuildFeature, LocalizationMap, } from 'discord-api-types/v10'; -import { GuildChannel, Guild, PermissionOverwrites } from '.'; +import { GuildChannel, Guild, PermissionOverwrites, MessageActionRow } from '.'; import type { AutoModerationActionTypes, AutoModerationRuleEventTypes, AutoModerationRuleKeywordPresetTypes, AutoModerationRuleTriggerTypes, ApplicationRoleConnectionMetadataTypes, + MessageComponentTypes, } from './enums'; export type RawActivityData = GatewayActivity; @@ -341,6 +342,15 @@ export interface APIApplicationRoleConnectionMetadata { description_localizations?: LocalizationMap; } +export interface APIBaseComponent { + type: T; + id?: Number; +} + export interface APIUnfurledMediaItem { url: String; +} + +export interface APIContainerComponent extends APIBaseComponent { + components: MessageActionRow } \ No newline at end of file From 127ef86227256b891916ada964e31244cb2c48f1 Mon Sep 17 00:00:00 2001 From: tungdo0602 Date: Sun, 29 Jun 2025 14:33:00 +0700 Subject: [PATCH 07/18] add typings, fixed missing json --- src/structures/ContainerComponent.js | 4 +- src/structures/FileComponent.js | 3 +- src/structures/ThumbnailComponent.js | 14 +++++- typings/enums.d.ts | 2 +- typings/index.d.ts | 75 ++++++++++++++++++++++++++++ typings/rawDataTypes.d.ts | 49 ++++++++++++++++-- 6 files changed, 138 insertions(+), 9 deletions(-) diff --git a/src/structures/ContainerComponent.js b/src/structures/ContainerComponent.js index e4c583c..6fd612a 100644 --- a/src/structures/ContainerComponent.js +++ b/src/structures/ContainerComponent.js @@ -12,7 +12,7 @@ class ContainerComponent extends BaseMessageComponent { */ /** - * @param {} [data={}] + * @param {ContainerComponent | APIContainerComponent} [data={}] */ constructor(data = {}) { super({ type: 'CONTAINER' }, data); @@ -20,7 +20,7 @@ class ContainerComponent extends BaseMessageComponent { * Components of the type action row, text display, section, media gallery, separator, or file * @type {ContainerComponents[]} */ - this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? null; + this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? []; /** * Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF diff --git a/src/structures/FileComponent.js b/src/structures/FileComponent.js index 53434ee..afdb37f 100644 --- a/src/structures/FileComponent.js +++ b/src/structures/FileComponent.js @@ -21,7 +21,7 @@ class FileComponent extends BaseMessageComponent { * This unfurled media item is unique in that it only supports attachment references using the attachment:// syntax * @type {UnfurledMediaItem} */ - this.file = new UnfurledMediaItem(data.file) ?? null; + this.file = new UnfurledMediaItem(data.file); /** * Whether the container should be a spoiler (or blurred out). Defaults to false. @@ -38,6 +38,7 @@ class FileComponent extends BaseMessageComponent { return { type: MessageComponentTypes[this.type], file: this.content, + spoiler: this.spoiler, }; } } diff --git a/src/structures/ThumbnailComponent.js b/src/structures/ThumbnailComponent.js index 9ccbc37..9b7b90d 100644 --- a/src/structures/ThumbnailComponent.js +++ b/src/structures/ThumbnailComponent.js @@ -5,13 +5,25 @@ const UnfurledMediaItem = require('./UnfurledMediaItem'); const { MessageComponentTypes } = require('../util/Constants'); class ThumbnailComponent extends BaseMessageComponent { + /** + * @property {UnfurledMediaItem} [media] A url or attachment + * @property {String} [description] Alt text for the media, max 1024 characters + * @property {Boolean} [spoiler] Whether the thumbnail should be a spoiler (or blurred out). Defaults to false + */ + + /** + * @param {ThumbnailComponent | APIThumbnailComponent} [data={}] + */ constructor(data = {}) { super({ type: 'THUMBNAIL' }, data); - this.media = new UnfurledMediaItem(data.media) ?? null; + this.media = new UnfurledMediaItem(data.media); this.description = data.description ?? null; this.spoiler = data.spoiler ?? false; } + /** + * @returns {APIThumbnailComponent} + */ toJSON() { return { type: MessageComponentTypes[this.type], diff --git a/typings/enums.d.ts b/typings/enums.d.ts index 0578c65..cc8bff3 100644 --- a/typings/enums.d.ts +++ b/typings/enums.d.ts @@ -333,7 +333,7 @@ export const enum RelationshipTypes { IMPLICIT = 5, } -export const enum SeparatorSpacingSize { +export const enum SeparatorSpacingSizes { SMALL = 1, LARGE = 2, } \ No newline at end of file diff --git a/typings/index.d.ts b/typings/index.d.ts index 0457c56..f0a4272 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -116,6 +116,7 @@ import { PollLayoutTypes, ReactionTypes, MessageReferenceTypes, + SeparatorSpacingSizes, } from './enums'; import { APIApplicationRoleConnectionMetadata, @@ -178,6 +179,15 @@ import { RawWelcomeScreenData, RawWidgetData, RawWidgetMemberData, + APIUnfurledMediaItem, + APIContainerComponent, + APIFileComponent, + APISectionComponent, + APISeparatorComponent, + APIThumbnailComponent, + APITextDisplayComponent, + APIMediaGalleryComponent, + APIMediaGalleryItem, } from './rawDataTypes'; import { Socket } from 'node:dgram'; @@ -2299,6 +2309,71 @@ export class MessageButton extends BaseMessageComponent { private static resolveStyle(style: MessageButtonStyleResolvable): MessageButtonStyle; } +export class UnfurledMediaItem { + public constructor(data?: UnfurledMediaItem | APIUnfurledMediaItem); + public url: string | null; + public toJSON(): APIUnfurledMediaItem; +} + +export class MediaGalleryItem { + public constructor(data?: MediaGalleryItem | APIMediaGalleryItem); + public media: UnfurledMediaItem; + public description: string | null; + public spoiler: boolean; + public toJSON(): APIMediaGalleryItem; +} + +export class MediaGalleryComponent extends BaseMessageComponent { + public constructor(data?: MediaGalleryComponent | APIMediaGalleryComponent); + public items: MediaGalleryItem[]; + public toJSON(): APIMediaGalleryComponent; + } + +export class FileComponent extends BaseMessageComponent { + public constructor(data?: FileComponent | APIFileComponent); + public file: UnfurledMediaItem; + public spoiler: boolean; + public toJSON(): APIFileComponent; +} + +export class SeparatorComponent extends BaseMessageComponent { + public constructor(data?: SeparatorComponent | APISeparatorComponent); + public spacing: SeparatorSpacingSizes; + public divider: boolean; + public toJSON(): APISeparatorComponent; +} + +export class TextDisplayComponent extends BaseMessageComponent { + public constructor(data?: TextDisplayComponent | APITextDisplayComponent); + public content: string | null; + public toJSON(): APITextDisplayComponent; +} + +export class ThumbnailComponent extends BaseMessageComponent { + public constructor(data?: ThumbnailComponent | APIThumbnailComponent); + public media: UnfurledMediaItem; + public description: string | null; + public spoiler: boolean; +} + +export class SectionComponent extends BaseMessageComponent { + public constructor(data?: SectionComponent | APISectionComponent); + public components: TextDisplayComponent[]; + public accessory: T[]; + public toJSON(): APISectionComponent; +} + +export class ContainerComponent< + U extends ThumbnailComponent | MessageButton, + T extends MessageActionRow | TextDisplayComponent | SectionComponent | MediaGalleryComponent | SeparatorComponent | FileComponent +> extends BaseMessageComponent { + public constructor(data?: ContainerComponent | APIContainerComponent); + public components: T[]; + public accent_color: number | null; + public spoiler: boolean; + public toJSON(): APIContainerComponent; +} + export class MessageCollector extends Collector { public constructor(channel: TextBasedChannel, options?: MessageCollectorOptions); private _handleChannelDeletion(channel: NonThreadGuildBasedChannel): void; diff --git a/typings/rawDataTypes.d.ts b/typings/rawDataTypes.d.ts index aee9c7b..aa4934d 100644 --- a/typings/rawDataTypes.d.ts +++ b/typings/rawDataTypes.d.ts @@ -87,8 +87,10 @@ import { GuildVerificationLevel, GuildFeature, LocalizationMap, + APIActionRowComponent, + APIActionRowComponentTypes, } from 'discord-api-types/v10'; -import { GuildChannel, Guild, PermissionOverwrites, MessageActionRow } from '.'; +import { GuildChannel, Guild, PermissionOverwrites } from '.'; import type { AutoModerationActionTypes, AutoModerationRuleEventTypes, @@ -96,6 +98,7 @@ import type { AutoModerationRuleTriggerTypes, ApplicationRoleConnectionMetadataTypes, MessageComponentTypes, + SeparatorSpacingSizes, } from './enums'; export type RawActivityData = GatewayActivity; @@ -344,13 +347,51 @@ export interface APIApplicationRoleConnectionMetadata { export interface APIBaseComponent { type: T; - id?: Number; + id?: number; } export interface APIUnfurledMediaItem { - url: String; + url: string; } +export interface APIMediaGalleryItem { + media: APIUnfurledMediaItem; + description: string; + spoiler: boolean; +} + +export interface APISeparatorComponent extends APIBaseComponent { + spacing: SeparatorSpacingSizes; + divider: boolean; +} + +export interface APITextDisplayComponent extends APIBaseComponent { + content: string; +} + +export interface APIThumbnailComponent extends APIBaseComponent { + media: APIUnfurledMediaItem; + description: string; + spoiler: boolean; +} + +export interface APIFileComponent extends APIBaseComponent { + file: APIUnfurledMediaItem; + spoiler: boolean; +} + +export interface APIMediaGalleryComponent extends APIBaseComponent { + items: APIMediaGalleryItem; +} + +export interface APISectionComponent extends APIBaseComponent { + components: APITextDisplayComponent[]; + accessory: APIThumbnailComponent | APIMessageButtonInteractionData +} + +type APIContainerComponents = APIActionRowComponent | APITextDisplayComponent | APISectionComponent | APIMediaGalleryComponent | APISeparatorComponent | APIFileComponent; export interface APIContainerComponent extends APIBaseComponent { - components: MessageActionRow + components: APIContainerComponents[]; + accent_color: number; + spoiler: boolean; } \ No newline at end of file From e671401867f33ba07d401702060ca50e7f9d7749 Mon Sep 17 00:00:00 2001 From: tungdo0602 Date: Sun, 29 Jun 2025 14:34:15 +0700 Subject: [PATCH 08/18] a --- typings/rawDataTypes.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/rawDataTypes.d.ts b/typings/rawDataTypes.d.ts index aa4934d..ae606a2 100644 --- a/typings/rawDataTypes.d.ts +++ b/typings/rawDataTypes.d.ts @@ -389,7 +389,7 @@ export interface APISectionComponent extends APIBaseComponent | APITextDisplayComponent | APISectionComponent | APIMediaGalleryComponent | APISeparatorComponent | APIFileComponent; +export type APIContainerComponents = APIActionRowComponent | APITextDisplayComponent | APISectionComponent | APIMediaGalleryComponent | APISeparatorComponent | APIFileComponent; export interface APIContainerComponent extends APIBaseComponent { components: APIContainerComponents[]; accent_color: number; From bbd5f3cee5c2c02647322c60dfdfcb0fcf506262 Mon Sep 17 00:00:00 2001 From: tungdo0602 Date: Sun, 29 Jun 2025 14:41:53 +0700 Subject: [PATCH 09/18] considering --- typings/rawDataTypes.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/typings/rawDataTypes.d.ts b/typings/rawDataTypes.d.ts index ae606a2..48124d5 100644 --- a/typings/rawDataTypes.d.ts +++ b/typings/rawDataTypes.d.ts @@ -389,6 +389,7 @@ export interface APISectionComponent extends APIBaseComponent ??? export type APIContainerComponents = APIActionRowComponent | APITextDisplayComponent | APISectionComponent | APIMediaGalleryComponent | APISeparatorComponent | APIFileComponent; export interface APIContainerComponent extends APIBaseComponent { components: APIContainerComponents[]; From 8b072d8b38683fb95564c1c2fcfc327db6decc5b Mon Sep 17 00:00:00 2001 From: tungdo0602 Date: Mon, 30 Jun 2025 21:53:29 +0700 Subject: [PATCH 10/18] fix missing stuffs --- .prettierrc.json | 2 +- src/structures/FileComponent.js | 2 +- src/structures/MediaGalleryComponent.js | 2 +- src/structures/MediaGalleryItem.js | 2 +- src/structures/SectionComponent.js | 2 +- src/structures/SeparatorComponent.js | 2 +- src/structures/TextDisplayComponent.js | 15 +++++++++++++++ src/structures/ThumbnailComponent.js | 17 ++++++++++++++++- src/structures/UnfurledMediaItem.js | 3 +++ typings/rawDataTypes.d.ts | 1 - 10 files changed, 40 insertions(+), 8 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index 2a22378..a4a14c1 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -2,6 +2,6 @@ "singleQuote": true, "printWidth": 120, "trailingComma": "all", - "endOfLine": "lf", + "endOfLine": "auto", "arrowParens": "avoid" } diff --git a/src/structures/FileComponent.js b/src/structures/FileComponent.js index afdb37f..35d6acd 100644 --- a/src/structures/FileComponent.js +++ b/src/structures/FileComponent.js @@ -12,7 +12,7 @@ class FileComponent extends BaseMessageComponent { */ /** - * @param {} [data={}] + * @param {FileComponent | APIFileComponent} [data={}] */ constructor(data = {}) { super({ type: 'FILE' }, data); diff --git a/src/structures/MediaGalleryComponent.js b/src/structures/MediaGalleryComponent.js index 5a68636..25c1642 100644 --- a/src/structures/MediaGalleryComponent.js +++ b/src/structures/MediaGalleryComponent.js @@ -10,7 +10,7 @@ class MediaGalleryComponent extends BaseMessageComponent { */ /** - * @param {} [data={}] + * @param {MediaGalleryComponent | APIMediaGalleryComponent} [data={}] */ constructor(data = {}) { super({ type: 'MEDIA_GALLERY' }, data); diff --git a/src/structures/MediaGalleryItem.js b/src/structures/MediaGalleryItem.js index 9aa4e26..21dd9fc 100644 --- a/src/structures/MediaGalleryItem.js +++ b/src/structures/MediaGalleryItem.js @@ -10,7 +10,7 @@ class MediaGalleryItem { */ /** - * @param {} [data={}] + * @param {MediaGalleryItem | APIMediaGalleryItem} [data={}] */ constructor(data = {}) { /** diff --git a/src/structures/SectionComponent.js b/src/structures/SectionComponent.js index c36233f..9ac9e56 100644 --- a/src/structures/SectionComponent.js +++ b/src/structures/SectionComponent.js @@ -10,7 +10,7 @@ class SectionComponent extends BaseMessageComponent { */ /** - * @param {} [data={}] + * @param {SectionComponent | APISectionComponent} [data={}] */ constructor(data = {}) { super({ type: 'SECTION' }, data); diff --git a/src/structures/SeparatorComponent.js b/src/structures/SeparatorComponent.js index aad39f4..c2ef993 100644 --- a/src/structures/SeparatorComponent.js +++ b/src/structures/SeparatorComponent.js @@ -10,7 +10,7 @@ class SeparatorComponent extends BaseMessageComponent { */ /** - * @param {} [data={}] + * @param {SeparatorComponent | APISeparatorComponent} [data={}] */ constructor(data = {}) { super({ type: 'SEPARATOR' }, data); diff --git a/src/structures/TextDisplayComponent.js b/src/structures/TextDisplayComponent.js index 4d4f8e0..39ff22b 100644 --- a/src/structures/TextDisplayComponent.js +++ b/src/structures/TextDisplayComponent.js @@ -4,11 +4,26 @@ const BaseMessageComponent = require('./BaseMessageComponent'); const { MessageComponentTypes } = require('../util/Constants'); class TextDisplayComponent extends BaseMessageComponent { + /** + * @property {String} [content] Text that will be displayed similar to a message + */ + + /** + * @param {TextDisplayComponent | APITextDisplayComponent} [data={}] + */ constructor(data = {}) { super({ type: 'TEXT_DISPLAY' }, data); + + /** + * Text that will be displayed similar to a message + * @type {String} + */ this.content = data.content ?? null; } + /** + * @returns {APITextDisplayComponent} + */ toJSON() { return { type: MessageComponentTypes[this.type], diff --git a/src/structures/ThumbnailComponent.js b/src/structures/ThumbnailComponent.js index 9b7b90d..d3ba2e7 100644 --- a/src/structures/ThumbnailComponent.js +++ b/src/structures/ThumbnailComponent.js @@ -7,7 +7,7 @@ const { MessageComponentTypes } = require('../util/Constants'); class ThumbnailComponent extends BaseMessageComponent { /** * @property {UnfurledMediaItem} [media] A url or attachment - * @property {String} [description] Alt text for the media, max 1024 characters + * @property {String} [description] Alt text for the media, max 1024 characters * @property {Boolean} [spoiler] Whether the thumbnail should be a spoiler (or blurred out). Defaults to false */ @@ -16,8 +16,23 @@ class ThumbnailComponent extends BaseMessageComponent { */ constructor(data = {}) { super({ type: 'THUMBNAIL' }, data); + + /** + * A url or attachment + * @type {UnfurledMediaItem} + */ this.media = new UnfurledMediaItem(data.media); + + /** + * Alt text for the media, max 1024 characters + * @type {String} + */ this.description = data.description ?? null; + + /** + * Whether the thumbnail should be a spoiler (or blurred out). Defaults to false + * @type {Boolean} + */ this.spoiler = data.spoiler ?? false; } diff --git a/src/structures/UnfurledMediaItem.js b/src/structures/UnfurledMediaItem.js index 1bb2908..136d64a 100644 --- a/src/structures/UnfurledMediaItem.js +++ b/src/structures/UnfurledMediaItem.js @@ -4,6 +4,9 @@ class UnfurledMediaItem { /** * @property {string} [url] Supports arbitrary urls and `attachment://` references */ + /** + * @param {UnfurledMediaItem | APIUnfurledMediaItem} [data={}] + */ constructor(data = {}) { /** * @type {string} diff --git a/typings/rawDataTypes.d.ts b/typings/rawDataTypes.d.ts index 48124d5..ae606a2 100644 --- a/typings/rawDataTypes.d.ts +++ b/typings/rawDataTypes.d.ts @@ -389,7 +389,6 @@ export interface APISectionComponent extends APIBaseComponent ??? export type APIContainerComponents = APIActionRowComponent | APITextDisplayComponent | APISectionComponent | APIMediaGalleryComponent | APISeparatorComponent | APIFileComponent; export interface APIContainerComponent extends APIBaseComponent { components: APIContainerComponents[]; From 70cd1133f8b62d7c4e64e72fa523621f1fe8a92d Mon Sep 17 00:00:00 2001 From: tungdo0602 Date: Mon, 30 Jun 2025 21:57:54 +0700 Subject: [PATCH 11/18] fix 2 --- .eslintrc.json | 2 +- src/structures/ContainerComponent.js | 2 +- src/structures/FileComponent.js | 2 +- src/structures/MediaGalleryComponent.js | 2 +- src/structures/MediaGalleryItem.js | 2 +- src/structures/SectionComponent.js | 2 +- src/structures/SeparatorComponent.js | 2 +- src/structures/TextDisplayComponent.js | 2 +- src/structures/ThumbnailComponent.js | 2 +- src/structures/UnfurledMediaItem.js | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 283382f..11adec9 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -41,7 +41,7 @@ "singleQuote": true, "quoteProps": "as-needed", "trailingComma": "all", - "endOfLine": "lf", + "endOfLine": "auto", "arrowParens": "avoid" } ], diff --git a/src/structures/ContainerComponent.js b/src/structures/ContainerComponent.js index 6fd612a..fe9ee62 100644 --- a/src/structures/ContainerComponent.js +++ b/src/structures/ContainerComponent.js @@ -12,7 +12,7 @@ class ContainerComponent extends BaseMessageComponent { */ /** - * @param {ContainerComponent | APIContainerComponent} [data={}] + * @param {ContainerComponent | APIContainerComponent} [data={}] The data */ constructor(data = {}) { super({ type: 'CONTAINER' }, data); diff --git a/src/structures/FileComponent.js b/src/structures/FileComponent.js index 35d6acd..6c43139 100644 --- a/src/structures/FileComponent.js +++ b/src/structures/FileComponent.js @@ -12,7 +12,7 @@ class FileComponent extends BaseMessageComponent { */ /** - * @param {FileComponent | APIFileComponent} [data={}] + * @param {FileComponent | APIFileComponent} [data={}] The data */ constructor(data = {}) { super({ type: 'FILE' }, data); diff --git a/src/structures/MediaGalleryComponent.js b/src/structures/MediaGalleryComponent.js index 25c1642..aaf8ed3 100644 --- a/src/structures/MediaGalleryComponent.js +++ b/src/structures/MediaGalleryComponent.js @@ -10,7 +10,7 @@ class MediaGalleryComponent extends BaseMessageComponent { */ /** - * @param {MediaGalleryComponent | APIMediaGalleryComponent} [data={}] + * @param {MediaGalleryComponent | APIMediaGalleryComponent} [data={}] The data */ constructor(data = {}) { super({ type: 'MEDIA_GALLERY' }, data); diff --git a/src/structures/MediaGalleryItem.js b/src/structures/MediaGalleryItem.js index 21dd9fc..eb79ff8 100644 --- a/src/structures/MediaGalleryItem.js +++ b/src/structures/MediaGalleryItem.js @@ -10,7 +10,7 @@ class MediaGalleryItem { */ /** - * @param {MediaGalleryItem | APIMediaGalleryItem} [data={}] + * @param {MediaGalleryItem | APIMediaGalleryItem} [data={}] The data */ constructor(data = {}) { /** diff --git a/src/structures/SectionComponent.js b/src/structures/SectionComponent.js index 9ac9e56..2785af3 100644 --- a/src/structures/SectionComponent.js +++ b/src/structures/SectionComponent.js @@ -10,7 +10,7 @@ class SectionComponent extends BaseMessageComponent { */ /** - * @param {SectionComponent | APISectionComponent} [data={}] + * @param {SectionComponent | APISectionComponent} [data={}] The data */ constructor(data = {}) { super({ type: 'SECTION' }, data); diff --git a/src/structures/SeparatorComponent.js b/src/structures/SeparatorComponent.js index c2ef993..9342f57 100644 --- a/src/structures/SeparatorComponent.js +++ b/src/structures/SeparatorComponent.js @@ -10,7 +10,7 @@ class SeparatorComponent extends BaseMessageComponent { */ /** - * @param {SeparatorComponent | APISeparatorComponent} [data={}] + * @param {SeparatorComponent | APISeparatorComponent} [data={}] The data */ constructor(data = {}) { super({ type: 'SEPARATOR' }, data); diff --git a/src/structures/TextDisplayComponent.js b/src/structures/TextDisplayComponent.js index 39ff22b..273c657 100644 --- a/src/structures/TextDisplayComponent.js +++ b/src/structures/TextDisplayComponent.js @@ -9,7 +9,7 @@ class TextDisplayComponent extends BaseMessageComponent { */ /** - * @param {TextDisplayComponent | APITextDisplayComponent} [data={}] + * @param {TextDisplayComponent | APITextDisplayComponent} [data={}] The data */ constructor(data = {}) { super({ type: 'TEXT_DISPLAY' }, data); diff --git a/src/structures/ThumbnailComponent.js b/src/structures/ThumbnailComponent.js index d3ba2e7..3f10128 100644 --- a/src/structures/ThumbnailComponent.js +++ b/src/structures/ThumbnailComponent.js @@ -12,7 +12,7 @@ class ThumbnailComponent extends BaseMessageComponent { */ /** - * @param {ThumbnailComponent | APIThumbnailComponent} [data={}] + * @param {ThumbnailComponent | APIThumbnailComponent} [data={}] The data */ constructor(data = {}) { super({ type: 'THUMBNAIL' }, data); diff --git a/src/structures/UnfurledMediaItem.js b/src/structures/UnfurledMediaItem.js index 136d64a..c933ccc 100644 --- a/src/structures/UnfurledMediaItem.js +++ b/src/structures/UnfurledMediaItem.js @@ -5,7 +5,7 @@ class UnfurledMediaItem { * @property {string} [url] Supports arbitrary urls and `attachment://` references */ /** - * @param {UnfurledMediaItem | APIUnfurledMediaItem} [data={}] + * @param {UnfurledMediaItem | APIUnfurledMediaItem} [data={}] The data */ constructor(data = {}) { /** From da07ddabeee6e74265a326c826adc6b054c8fd1a Mon Sep 17 00:00:00 2001 From: tungdo0602 Date: Mon, 30 Jun 2025 22:05:20 +0700 Subject: [PATCH 12/18] fix 3 --- .eslintrc.json | 6 +++--- src/structures/BaseMessageComponent.js | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 11adec9..3bc3cd6 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -153,7 +153,7 @@ "error", "$this" ], - "eol-last": "error", + "eol-last": "warn", "func-names": "error", "func-name-matching": "error", "func-style": [ @@ -203,7 +203,7 @@ ], "no-new-object": "error", "no-spaced-func": "error", - "no-trailing-spaces": "error", + "no-trailing-spaces": "warn", "no-unneeded-ternary": "error", "no-whitespace-before-property": "error", "nonblock-statement-body-position": "error", @@ -285,6 +285,6 @@ "message": "Import setImmediate from `node:timers` instead" } ], - "linebreak-style": 0 + "linebreak-style": "off" } } \ No newline at end of file diff --git a/src/structures/BaseMessageComponent.js b/src/structures/BaseMessageComponent.js index 6bbf3df..f85bd65 100644 --- a/src/structures/BaseMessageComponent.js +++ b/src/structures/BaseMessageComponent.js @@ -43,6 +43,7 @@ class BaseMessageComponent { /** * @param {BaseMessageComponent|BaseMessageComponentOptions} [data={}] The options for this component + * * @param {MessageComponentOptions} [componentData={}] The raw data for component */ constructor(data, componentData = {}) { /** From 2e4542c0694967ff3baecf15592f5d6da13c3483 Mon Sep 17 00:00:00 2001 From: tungdo0602 Date: Mon, 30 Jun 2025 22:19:34 +0700 Subject: [PATCH 13/18] fix 4 --- .eslintrc.json | 6 +- .prettierrc.json | 2 +- src/structures/ContainerComponent.js | 102 ++++++++++++------------ src/structures/FileComponent.js | 90 ++++++++++----------- src/structures/MediaGalleryComponent.js | 72 ++++++++--------- src/structures/MediaGalleryItem.js | 94 +++++++++++----------- 6 files changed, 182 insertions(+), 184 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 3bc3cd6..80c6ae3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -41,7 +41,7 @@ "singleQuote": true, "quoteProps": "as-needed", "trailingComma": "all", - "endOfLine": "auto", + "endOfLine": "lf", "arrowParens": "avoid" } ], @@ -153,7 +153,7 @@ "error", "$this" ], - "eol-last": "warn", + "eol-last": "error", "func-names": "error", "func-name-matching": "error", "func-style": [ @@ -203,7 +203,7 @@ ], "no-new-object": "error", "no-spaced-func": "error", - "no-trailing-spaces": "warn", + "no-trailing-spaces": "error", "no-unneeded-ternary": "error", "no-whitespace-before-property": "error", "nonblock-statement-body-position": "error", diff --git a/.prettierrc.json b/.prettierrc.json index a4a14c1..2a22378 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -2,6 +2,6 @@ "singleQuote": true, "printWidth": 120, "trailingComma": "all", - "endOfLine": "auto", + "endOfLine": "lf", "arrowParens": "avoid" } diff --git a/src/structures/ContainerComponent.js b/src/structures/ContainerComponent.js index fe9ee62..3f44e9c 100644 --- a/src/structures/ContainerComponent.js +++ b/src/structures/ContainerComponent.js @@ -1,51 +1,51 @@ -'use strict'; - -const BaseMessageComponent = require('./BaseMessageComponent'); -const { MessageComponentTypes } = require('../util/Constants'); - -class ContainerComponent extends BaseMessageComponent { - /** - * @typedef {MessageActionRow|TextDisplayComponent|SectionComponent|MediaGalleryComponent|SeparatorComponent|FileComponent} ContainerComponents - * @property {ContainerComponents[]} [components] Components of the type action row, text display, section, media gallery, separator, or file - * @property {Number} [accent_color] Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF - * @property {Boolean} [spoiler] Whether the container should be a spoiler (or blurred out). Defaults to false. - */ - - /** - * @param {ContainerComponent | APIContainerComponent} [data={}] The data - */ - constructor(data = {}) { - super({ type: 'CONTAINER' }, data); - /** - * Components of the type action row, text display, section, media gallery, separator, or file - * @type {ContainerComponents[]} - */ - this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? []; - - /** - * Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF - * @type {Number} - */ - this.accent_color = data.accent_color ?? null; - - /** - * Whether the container should be a spoiler (or blurred out). Defaults to false. - * @type {Boolean} - */ - this.spoiler = data.spoiler ?? false; - } - - /** - * @returns {APIContainerComponent} - */ - toJSON() { - return { - type: MessageComponentTypes[this.type], - components: this.components.map(c => c.toJSON()), - accent_color: this.accent_color, - spoiler: this.spoiler, - }; - } -} - -module.exports = ContainerComponent; \ No newline at end of file +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const { MessageComponentTypes } = require('../util/Constants'); + +class ContainerComponent extends BaseMessageComponent { + /** + * @typedef {MessageActionRow|TextDisplayComponent|SectionComponent|MediaGalleryComponent|SeparatorComponent|FileComponent} ContainerComponents + * @property {ContainerComponents[]} [components] Components of the type action row, text display, section, media gallery, separator, or file + * @property {Number} [accent_color] Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF + * @property {Boolean} [spoiler] Whether the container should be a spoiler (or blurred out). Defaults to false. + */ + + /** + * @param {ContainerComponent | APIContainerComponent} [data={}] The data + */ + constructor(data = {}) { + super({ type: 'CONTAINER' }, data); + /** + * Components of the type action row, text display, section, media gallery, separator, or file + * @type {ContainerComponents[]} + */ + this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? []; + + /** + * Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF + * @type {Number} + */ + this.accent_color = data.accent_color ?? null; + + /** + * Whether the container should be a spoiler (or blurred out). Defaults to false. + * @type {Boolean} + */ + this.spoiler = data.spoiler ?? false; + } + + /** + * @returns {APIContainerComponent} + */ + toJSON() { + return { + type: MessageComponentTypes[this.type], + components: this.components.map(c => c.toJSON()), + accent_color: this.accent_color, + spoiler: this.spoiler, + }; + } +} + +module.exports = ContainerComponent; diff --git a/src/structures/FileComponent.js b/src/structures/FileComponent.js index 6c43139..0418a40 100644 --- a/src/structures/FileComponent.js +++ b/src/structures/FileComponent.js @@ -1,46 +1,44 @@ -'use strict'; - -const BaseMessageComponent = require('./BaseMessageComponent'); -const UnfurledMediaItem = require('./UnfurledMediaItem'); -const { MessageComponentTypes } = require('../util/Constants'); - - -class FileComponent extends BaseMessageComponent { - /** - * @property {UnfurledMediaItem} [file] This unfurled media item is unique in that it only supports attachment references using the attachment:// syntax - * @property {Boolean} [spoiler] Whether the container should be a spoiler (or blurred out). Defaults to false. - */ - - /** - * @param {FileComponent | APIFileComponent} [data={}] The data - */ - constructor(data = {}) { - super({ type: 'FILE' }, data); - - /** - * This unfurled media item is unique in that it only supports attachment references using the attachment:// syntax - * @type {UnfurledMediaItem} - */ - this.file = new UnfurledMediaItem(data.file); - - /** - * Whether the container should be a spoiler (or blurred out). Defaults to false. - * @type {Boolean} - */ - this.spoiler = data.spoiler ?? false; - } - - - /** - * @returns {APIFileComponent} - */ - toJSON() { - return { - type: MessageComponentTypes[this.type], - file: this.content, - spoiler: this.spoiler, - }; - } -} - -module.exports = FileComponent; \ No newline at end of file +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const UnfurledMediaItem = require('./UnfurledMediaItem'); +const { MessageComponentTypes } = require('../util/Constants'); + +class FileComponent extends BaseMessageComponent { + /** + * @property {UnfurledMediaItem} [file] This unfurled media item is unique in that it only supports attachment references using the attachment:// syntax + * @property {Boolean} [spoiler] Whether the container should be a spoiler (or blurred out). Defaults to false. + */ + + /** + * @param {FileComponent | APIFileComponent} [data={}] The data + */ + constructor(data = {}) { + super({ type: 'FILE' }, data); + + /** + * This unfurled media item is unique in that it only supports attachment references using the attachment:// syntax + * @type {UnfurledMediaItem} + */ + this.file = new UnfurledMediaItem(data.file); + + /** + * Whether the container should be a spoiler (or blurred out). Defaults to false. + * @type {Boolean} + */ + this.spoiler = data.spoiler ?? false; + } + + /** + * @returns {APIFileComponent} + */ + toJSON() { + return { + type: MessageComponentTypes[this.type], + file: this.content, + spoiler: this.spoiler, + }; + } +} + +module.exports = FileComponent; diff --git a/src/structures/MediaGalleryComponent.js b/src/structures/MediaGalleryComponent.js index aaf8ed3..b7ea099 100644 --- a/src/structures/MediaGalleryComponent.js +++ b/src/structures/MediaGalleryComponent.js @@ -1,36 +1,36 @@ -'use strict'; - -const BaseMessageComponent = require('./BaseMessageComponent'); -const MediaGalleryItem = require('./MediaGalleryItem'); -const { MessageComponentTypes } = require('../util/Constants'); - -class MediaGalleryComponent extends BaseMessageComponent { - /** - * @property {MediaGalleryItem[]} [items] 1 to 10 media gallery items - */ - - /** - * @param {MediaGalleryComponent | APIMediaGalleryComponent} [data={}] The data - */ - constructor(data = {}) { - super({ type: 'MEDIA_GALLERY' }, data); - - /** - * 1 to 10 media gallery items - * @type {MediaGalleryItem[]} - */ - this.items = data.items?.map(item => new MediaGalleryItem(item)) ?? []; - } - - /** - * @returns {APIMediaGalleryComponent} - */ - toJSON() { - return { - type: MessageComponentTypes[this.type], - items: this.items.map(c => c.toJSON()), - }; - } -} - -module.exports = MediaGalleryComponent; \ No newline at end of file +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const MediaGalleryItem = require('./MediaGalleryItem'); +const { MessageComponentTypes } = require('../util/Constants'); + +class MediaGalleryComponent extends BaseMessageComponent { + /** + * @property {MediaGalleryItem[]} [items] 1 to 10 media gallery items + */ + + /** + * @param {MediaGalleryComponent | APIMediaGalleryComponent} [data={}] The data + */ + constructor(data = {}) { + super({ type: 'MEDIA_GALLERY' }, data); + + /** + * 1 to 10 media gallery items + * @type {MediaGalleryItem[]} + */ + this.items = data.items?.map(item => new MediaGalleryItem(item)) ?? []; + } + + /** + * @returns {APIMediaGalleryComponent} + */ + toJSON() { + return { + type: MessageComponentTypes[this.type], + items: this.items.map(c => c.toJSON()), + }; + } +} + +module.exports = MediaGalleryComponent; diff --git a/src/structures/MediaGalleryItem.js b/src/structures/MediaGalleryItem.js index eb79ff8..4d145c8 100644 --- a/src/structures/MediaGalleryItem.js +++ b/src/structures/MediaGalleryItem.js @@ -1,47 +1,47 @@ -'use strict'; - -const UnfurledMediaItem = require('./UnfurledMediaItem'); - -class MediaGalleryItem { - /** - * @property {UnfurledMediaItem} [media] A url or attachment - * @property {String} [description] Alt text for the media, max 1024 characters - * @property {Boolean} [spoiler] Whether the media should be a spoiler (or blurred out). Defaults to false - */ - - /** - * @param {MediaGalleryItem | APIMediaGalleryItem} [data={}] The data - */ - constructor(data = {}) { - /** - * A url or attachment - * @type {UnfurledMediaItem} - */ - this.media = new UnfurledMediaItem(data.media); - - /** - * Alt text for the media, max 1024 characters - * @type {String} - */ - this.description = data.description ?? null; - - /** - * Whether the media should be a spoiler (or blurred out). Defaults to false - * @type {Boolean} - */ - this.spoiler = data.spoiler ?? false; - } - - /** - * @returns {APIMediaGalleryItem} - */ - toJSON() { - return { - media: this.media.toJSON(), - description: this.description, - spoiler: this.spoiler, - }; - } -} - -module.exports = MediaGalleryItem; \ No newline at end of file +'use strict'; + +const UnfurledMediaItem = require('./UnfurledMediaItem'); + +class MediaGalleryItem { + /** + * @property {UnfurledMediaItem} [media] A url or attachment + * @property {String} [description] Alt text for the media, max 1024 characters + * @property {Boolean} [spoiler] Whether the media should be a spoiler (or blurred out). Defaults to false + */ + + /** + * @param {MediaGalleryItem | APIMediaGalleryItem} [data={}] The data + */ + constructor(data = {}) { + /** + * A url or attachment + * @type {UnfurledMediaItem} + */ + this.media = new UnfurledMediaItem(data.media); + + /** + * Alt text for the media, max 1024 characters + * @type {String} + */ + this.description = data.description ?? null; + + /** + * Whether the media should be a spoiler (or blurred out). Defaults to false + * @type {Boolean} + */ + this.spoiler = data.spoiler ?? false; + } + + /** + * @returns {APIMediaGalleryItem} + */ + toJSON() { + return { + media: this.media.toJSON(), + description: this.description, + spoiler: this.spoiler, + }; + } +} + +module.exports = MediaGalleryItem; From fd9c0e0d0f70d0a40c017a18e9ca982d41d2a090 Mon Sep 17 00:00:00 2001 From: tungdo0602 Date: Mon, 30 Jun 2025 22:23:32 +0700 Subject: [PATCH 14/18] fix 5 --- src/structures/BaseMessageComponent.js | 2 +- src/structures/MessageActionRow.js | 2 +- src/structures/MessageButton.js | 2 +- src/structures/MessageSelectMenu.js | 2 +- src/structures/SectionComponent.js | 86 ++++++++++---------- src/structures/SeparatorComponent.js | 86 ++++++++++---------- src/structures/TextDisplayComponent.js | 70 ++++++++--------- src/structures/TextInputComponent.js | 2 +- src/structures/ThumbnailComponent.js | 104 ++++++++++++------------- src/structures/UnfurledMediaItem.js | 54 ++++++------- src/util/Constants.js | 6 +- 11 files changed, 206 insertions(+), 210 deletions(-) diff --git a/src/structures/BaseMessageComponent.js b/src/structures/BaseMessageComponent.js index f85bd65..026380b 100644 --- a/src/structures/BaseMessageComponent.js +++ b/src/structures/BaseMessageComponent.js @@ -43,7 +43,7 @@ class BaseMessageComponent { /** * @param {BaseMessageComponent|BaseMessageComponentOptions} [data={}] The options for this component - * * @param {MessageComponentOptions} [componentData={}] The raw data for component + * @param {MessageComponentOptions} [componentData={}] The raw data for component */ constructor(data, componentData = {}) { /** diff --git a/src/structures/MessageActionRow.js b/src/structures/MessageActionRow.js index e9f719a..1e9ca5b 100644 --- a/src/structures/MessageActionRow.js +++ b/src/structures/MessageActionRow.js @@ -100,4 +100,4 @@ module.exports = MessageActionRow; /** * @external APIMessageComponent * @see {@link https://discord.com/developers/docs/interactions/message-components#component-object} - */ \ No newline at end of file + */ diff --git a/src/structures/MessageButton.js b/src/structures/MessageButton.js index 93674ad..670e07b 100644 --- a/src/structures/MessageButton.js +++ b/src/structures/MessageButton.js @@ -162,4 +162,4 @@ class MessageButton extends BaseMessageComponent { } } -module.exports = MessageButton; \ No newline at end of file +module.exports = MessageButton; diff --git a/src/structures/MessageSelectMenu.js b/src/structures/MessageSelectMenu.js index f09df28..d2658ca 100644 --- a/src/structures/MessageSelectMenu.js +++ b/src/structures/MessageSelectMenu.js @@ -137,4 +137,4 @@ class MessageSelectMenu extends BaseMessageComponent { } } -module.exports = MessageSelectMenu; \ No newline at end of file +module.exports = MessageSelectMenu; diff --git a/src/structures/SectionComponent.js b/src/structures/SectionComponent.js index 2785af3..cfe6600 100644 --- a/src/structures/SectionComponent.js +++ b/src/structures/SectionComponent.js @@ -1,43 +1,43 @@ -'use strict'; - -const BaseMessageComponent = require('./BaseMessageComponent'); -const { MessageComponentTypes } = require('../util/Constants'); - -class SectionComponent extends BaseMessageComponent { - /** - * @property {TextDisplayComponent[]} [components] One to three text components - * @property {ThumbnailComponent|MessageButton} [accessory] A thumbnail or a button component, with a future possibility of adding more compatible components - */ - - /** - * @param {SectionComponent | APISectionComponent} [data={}] The data - */ - constructor(data = {}) { - super({ type: 'SECTION' }, data); - - /** - * One to three text components - * @type {TextDisplayComponent[]} - */ - this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? []; - - /** - * A thumbnail or a button component, with a future possibility of adding more compatible components - * @type {ThumbnailComponent|MessageButton} - */ - this.accessory = BaseMessageComponent.create(data.accessory) ?? null; - } - - /** - * @returns {APISectionComponent} - */ - toJSON() { - return { - type: MessageComponentTypes[this.type], - components: this.components.map(c => c.toJSON()), - accessory: this.accessory.toJSON(), - }; - } -} - -module.exports = SectionComponent; \ No newline at end of file +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const { MessageComponentTypes } = require('../util/Constants'); + +class SectionComponent extends BaseMessageComponent { + /** + * @property {TextDisplayComponent[]} [components] One to three text components + * @property {ThumbnailComponent|MessageButton} [accessory] A thumbnail or a button component, with a future possibility of adding more compatible components + */ + + /** + * @param {SectionComponent | APISectionComponent} [data={}] The data + */ + constructor(data = {}) { + super({ type: 'SECTION' }, data); + + /** + * One to three text components + * @type {TextDisplayComponent[]} + */ + this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? []; + + /** + * A thumbnail or a button component, with a future possibility of adding more compatible components + * @type {ThumbnailComponent|MessageButton} + */ + this.accessory = BaseMessageComponent.create(data.accessory) ?? null; + } + + /** + * @returns {APISectionComponent} + */ + toJSON() { + return { + type: MessageComponentTypes[this.type], + components: this.components.map(c => c.toJSON()), + accessory: this.accessory.toJSON(), + }; + } +} + +module.exports = SectionComponent; diff --git a/src/structures/SeparatorComponent.js b/src/structures/SeparatorComponent.js index 9342f57..78ab6f2 100644 --- a/src/structures/SeparatorComponent.js +++ b/src/structures/SeparatorComponent.js @@ -1,43 +1,43 @@ -'use strict'; - -const BaseMessageComponent = require('./BaseMessageComponent'); -const { MessageComponentTypes, SeparatorSpacingSizes } = require('../util/Constants'); - -class SeparatorComponent extends BaseMessageComponent { - /** - * @property {SeparatorSpacingSizes} [spacing] Size of separator padding — SeparatorSpacingSizes.SMALL for small padding, SeparatorSpacingSizes.LARGE for large padding. Defaults to SeparatorSpacingSizes.SMALL - * @property {Boolean} [divider] Whether a visual divider should be displayed in the component. Defaults to true - */ - - /** - * @param {SeparatorComponent | APISeparatorComponent} [data={}] The data - */ - constructor(data = {}) { - super({ type: 'SEPARATOR' }, data); - - /** - * Size of separator padding — SeparatorSpacingSizes.SMALL for small padding, SeparatorSpacingSizes.LARGE for large padding. Defaults to SeparatorSpacingSizes.SMALL - * @type {SeparatorSpacingSizes} - */ - this.spacing = data.spacing ?? SeparatorSpacingSizes.SMALL; - - /** - * Whether a visual divider should be displayed in the component. Defaults to true - * @type {Boolean} - */ - this.divider = data.divider ?? true; - } - - /** - * @returns {APISeparatorComponent} - */ - toJSON() { - return { - type: MessageComponentTypes[this.type], - spacing: this.spacing, - divider: this.divider, - }; - } -} - -module.exports = SeparatorComponent; \ No newline at end of file +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const { MessageComponentTypes, SeparatorSpacingSizes } = require('../util/Constants'); + +class SeparatorComponent extends BaseMessageComponent { + /** + * @property {SeparatorSpacingSizes} [spacing] Size of separator padding — SeparatorSpacingSizes.SMALL for small padding, SeparatorSpacingSizes.LARGE for large padding. Defaults to SeparatorSpacingSizes.SMALL + * @property {Boolean} [divider] Whether a visual divider should be displayed in the component. Defaults to true + */ + + /** + * @param {SeparatorComponent | APISeparatorComponent} [data={}] The data + */ + constructor(data = {}) { + super({ type: 'SEPARATOR' }, data); + + /** + * Size of separator padding — SeparatorSpacingSizes.SMALL for small padding, SeparatorSpacingSizes.LARGE for large padding. Defaults to SeparatorSpacingSizes.SMALL + * @type {SeparatorSpacingSizes} + */ + this.spacing = data.spacing ?? SeparatorSpacingSizes.SMALL; + + /** + * Whether a visual divider should be displayed in the component. Defaults to true + * @type {Boolean} + */ + this.divider = data.divider ?? true; + } + + /** + * @returns {APISeparatorComponent} + */ + toJSON() { + return { + type: MessageComponentTypes[this.type], + spacing: this.spacing, + divider: this.divider, + }; + } +} + +module.exports = SeparatorComponent; diff --git a/src/structures/TextDisplayComponent.js b/src/structures/TextDisplayComponent.js index 273c657..8fb96dc 100644 --- a/src/structures/TextDisplayComponent.js +++ b/src/structures/TextDisplayComponent.js @@ -1,35 +1,35 @@ -'use strict'; - -const BaseMessageComponent = require('./BaseMessageComponent'); -const { MessageComponentTypes } = require('../util/Constants'); - -class TextDisplayComponent extends BaseMessageComponent { - /** - * @property {String} [content] Text that will be displayed similar to a message - */ - - /** - * @param {TextDisplayComponent | APITextDisplayComponent} [data={}] The data - */ - constructor(data = {}) { - super({ type: 'TEXT_DISPLAY' }, data); - - /** - * Text that will be displayed similar to a message - * @type {String} - */ - this.content = data.content ?? null; - } - - /** - * @returns {APITextDisplayComponent} - */ - toJSON() { - return { - type: MessageComponentTypes[this.type], - content: this.content, - }; - } -} - -module.exports = TextDisplayComponent; \ No newline at end of file +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const { MessageComponentTypes } = require('../util/Constants'); + +class TextDisplayComponent extends BaseMessageComponent { + /** + * @property {String} [content] Text that will be displayed similar to a message + */ + + /** + * @param {TextDisplayComponent | APITextDisplayComponent} [data={}] The data + */ + constructor(data = {}) { + super({ type: 'TEXT_DISPLAY' }, data); + + /** + * Text that will be displayed similar to a message + * @type {String} + */ + this.content = data.content ?? null; + } + + /** + * @returns {APITextDisplayComponent} + */ + toJSON() { + return { + type: MessageComponentTypes[this.type], + content: this.content, + }; + } +} + +module.exports = TextDisplayComponent; diff --git a/src/structures/TextInputComponent.js b/src/structures/TextInputComponent.js index 67f1ef6..684f366 100644 --- a/src/structures/TextInputComponent.js +++ b/src/structures/TextInputComponent.js @@ -128,4 +128,4 @@ class TextInputComponent extends BaseMessageComponent { } } -module.exports = TextInputComponent; \ No newline at end of file +module.exports = TextInputComponent; diff --git a/src/structures/ThumbnailComponent.js b/src/structures/ThumbnailComponent.js index 3f10128..d8ab1de 100644 --- a/src/structures/ThumbnailComponent.js +++ b/src/structures/ThumbnailComponent.js @@ -1,52 +1,52 @@ -'use strict'; - -const BaseMessageComponent = require('./BaseMessageComponent'); -const UnfurledMediaItem = require('./UnfurledMediaItem'); -const { MessageComponentTypes } = require('../util/Constants'); - -class ThumbnailComponent extends BaseMessageComponent { - /** - * @property {UnfurledMediaItem} [media] A url or attachment - * @property {String} [description] Alt text for the media, max 1024 characters - * @property {Boolean} [spoiler] Whether the thumbnail should be a spoiler (or blurred out). Defaults to false - */ - - /** - * @param {ThumbnailComponent | APIThumbnailComponent} [data={}] The data - */ - constructor(data = {}) { - super({ type: 'THUMBNAIL' }, data); - - /** - * A url or attachment - * @type {UnfurledMediaItem} - */ - this.media = new UnfurledMediaItem(data.media); - - /** - * Alt text for the media, max 1024 characters - * @type {String} - */ - this.description = data.description ?? null; - - /** - * Whether the thumbnail should be a spoiler (or blurred out). Defaults to false - * @type {Boolean} - */ - this.spoiler = data.spoiler ?? false; - } - - /** - * @returns {APIThumbnailComponent} - */ - toJSON() { - return { - type: MessageComponentTypes[this.type], - media: this.media.toJSON(), - description: this.description, - spoiler: this.spoiler, - }; - } -} - -module.exports = ThumbnailComponent; \ No newline at end of file +'use strict'; + +const BaseMessageComponent = require('./BaseMessageComponent'); +const UnfurledMediaItem = require('./UnfurledMediaItem'); +const { MessageComponentTypes } = require('../util/Constants'); + +class ThumbnailComponent extends BaseMessageComponent { + /** + * @property {UnfurledMediaItem} [media] A url or attachment + * @property {String} [description] Alt text for the media, max 1024 characters + * @property {Boolean} [spoiler] Whether the thumbnail should be a spoiler (or blurred out). Defaults to false + */ + + /** + * @param {ThumbnailComponent | APIThumbnailComponent} [data={}] The data + */ + constructor(data = {}) { + super({ type: 'THUMBNAIL' }, data); + + /** + * A url or attachment + * @type {UnfurledMediaItem} + */ + this.media = new UnfurledMediaItem(data.media); + + /** + * Alt text for the media, max 1024 characters + * @type {String} + */ + this.description = data.description ?? null; + + /** + * Whether the thumbnail should be a spoiler (or blurred out). Defaults to false + * @type {Boolean} + */ + this.spoiler = data.spoiler ?? false; + } + + /** + * @returns {APIThumbnailComponent} + */ + toJSON() { + return { + type: MessageComponentTypes[this.type], + media: this.media.toJSON(), + description: this.description, + spoiler: this.spoiler, + }; + } +} + +module.exports = ThumbnailComponent; diff --git a/src/structures/UnfurledMediaItem.js b/src/structures/UnfurledMediaItem.js index c933ccc..ea988be 100644 --- a/src/structures/UnfurledMediaItem.js +++ b/src/structures/UnfurledMediaItem.js @@ -1,27 +1,27 @@ -'use strict'; - -class UnfurledMediaItem { - /** - * @property {string} [url] Supports arbitrary urls and `attachment://` references - */ - /** - * @param {UnfurledMediaItem | APIUnfurledMediaItem} [data={}] The data - */ - constructor(data = {}) { - /** - * @type {string} - */ - this.url = data.url ?? null; - } - /** - * - * @returns {APIUnfurledMediaItem} - */ - toJSON() { - return { - url: this.url, - }; - } -} - -module.exports = UnfurledMediaItem; \ No newline at end of file +'use strict'; + +class UnfurledMediaItem { + /** + * @property {string} [url] Supports arbitrary urls and `attachment://` references + */ + /** + * @param {UnfurledMediaItem | APIUnfurledMediaItem} [data={}] The data + */ + constructor(data = {}) { + /** + * @type {string} + */ + this.url = data.url ?? null; + } + /** + * + * @returns {APIUnfurledMediaItem} + */ + toJSON() { + return { + url: this.url, + }; + } +} + +module.exports = UnfurledMediaItem; diff --git a/src/util/Constants.js b/src/util/Constants.js index 8f3b6e0..bc1e28d 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -1805,11 +1805,7 @@ exports.RelationshipTypes = createEnum([ 'IMPLICIT', ]); -exports.SeparatorSpacingSizes = createEnum([ - null, - 'SMALL', - 'LARGE', -]); +exports.SeparatorSpacingSizes = createEnum([null, 'SMALL', 'LARGE']); exports._cleanupSymbol = Symbol('djsCleanup'); From d512d7ba5ba729b3da6992a4b321e31a8765bdf7 Mon Sep 17 00:00:00 2001 From: TotallyTung <117299275+TotallyTung@users.noreply.github.com> Date: Tue, 1 Jul 2025 10:15:53 +0700 Subject: [PATCH 15/18] Revert --- .eslintrc.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 80c6ae3..9850c65 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -285,6 +285,6 @@ "message": "Import setImmediate from `node:timers` instead" } ], - "linebreak-style": "off" + "linebreak-style": 0 } -} \ No newline at end of file +} From 1def6ef27d044674c7a149cb9b9f99284f792af0 Mon Sep 17 00:00:00 2001 From: tungdo0602 Date: Tue, 1 Jul 2025 20:17:13 +0700 Subject: [PATCH 16/18] test --- .eslintrc.json | 2 +- src/structures/Message.js | 5 ++-- typings/enums.d.ts | 13 ++++++++++- typings/index.d.ts | 49 ++++++++++++++++++++++----------------- 4 files changed, 44 insertions(+), 25 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 80c6ae3..283382f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -285,6 +285,6 @@ "message": "Import setImmediate from `node:timers` instead" } ], - "linebreak-style": "off" + "linebreak-style": 0 } } \ No newline at end of file diff --git a/src/structures/Message.js b/src/structures/Message.js index e5385bb..3c9b116 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -25,6 +25,7 @@ const MessageFlags = require('../util/MessageFlags'); const Permissions = require('../util/Permissions'); const SnowflakeUtil = require('../util/SnowflakeUtil'); const Util = require('../util/Util'); +const ContainerComponent = require('./ContainerComponent'); /** * @type {WeakSet} @@ -162,8 +163,8 @@ class Message extends Base { if ('components' in data) { /** - * A list of MessageActionRows in the message - * @type {MessageActionRow[]} + * A list of components in the message + * @type {MessageActionRow[] | ContainerComponent[]} */ this.components = data.components.map(c => BaseMessageComponent.create(c, this.client)); } else { diff --git a/typings/enums.d.ts b/typings/enums.d.ts index cc8bff3..d65c6c4 100644 --- a/typings/enums.d.ts +++ b/typings/enums.d.ts @@ -235,6 +235,17 @@ export const enum MessageComponentTypes { CONTAINER = 17, } +export const enum MessageComponentInteractables { + ACTION_ROW = 1, + BUTTON = 2, + STRING_SELECT = 3, + TEXT_INPUT = 4, + USER_SELECT = 5, + ROLE_SELECT = 6, + MENTIONABLE_SELECT = 7, + CHANNEL_SELECT = 8, +} + export const enum SelectMenuComponentTypes { STRING_SELECT = 3, USER_SELECT = 5, @@ -336,4 +347,4 @@ export const enum RelationshipTypes { export const enum SeparatorSpacingSizes { SMALL = 1, LARGE = 2, -} \ No newline at end of file +} diff --git a/typings/index.d.ts b/typings/index.d.ts index f0a4272..eb9aee9 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -92,6 +92,7 @@ import { MembershipStates, MessageButtonStyles, MessageComponentTypes, + MessageComponentInteractables, MessageTypes, MFALevels, NSFWLevels, @@ -1604,8 +1605,8 @@ export class GuildAuditLogsEntry< TAction = TActionRaw extends keyof GuildAuditLogsIds ? GuildAuditLogsIds[TActionRaw] : TActionRaw extends null - ? 'ALL' - : TActionRaw, + ? 'ALL' + : TActionRaw, TActionType extends GuildAuditLogsActionType = TAction extends keyof GuildAuditLogsTypes ? GuildAuditLogsTypes[TAction][1] : 'ALL', @@ -1952,10 +1953,10 @@ export type CacheTypeReducer< > = [State] extends ['cached'] ? CachedType : [State] extends ['raw'] - ? RawType - : [State] extends ['raw' | 'cached'] - ? PresentType - : Fallback; + ? RawType + : [State] extends ['raw' | 'cached'] + ? PresentType + : Fallback; export class Interaction extends Base { // This a technique used to brand different cached types. Or else we'll get `never` errors on typeguard checks. @@ -2132,7 +2133,7 @@ export interface StringMappedInteractionTypes = If; export type MappedInteractionTypes = EnumValueMapped< - typeof MessageComponentTypes, + typeof MessageComponentInteractables, { BUTTON: ButtonInteraction>; STRING_SELECT: StringSelectInteraction>; @@ -2327,7 +2328,7 @@ export class MediaGalleryComponent extends BaseMessageComponent { public constructor(data?: MediaGalleryComponent | APIMediaGalleryComponent); public items: MediaGalleryItem[]; public toJSON(): APIMediaGalleryComponent; - } +} export class FileComponent extends BaseMessageComponent { public constructor(data?: FileComponent | APIFileComponent); @@ -2365,7 +2366,13 @@ export class SectionComponent exte export class ContainerComponent< U extends ThumbnailComponent | MessageButton, - T extends MessageActionRow | TextDisplayComponent | SectionComponent | MediaGalleryComponent | SeparatorComponent | FileComponent + T extends + | MessageActionRow + | TextDisplayComponent + | SectionComponent + | MediaGalleryComponent + | SeparatorComponent + | FileComponent, > extends BaseMessageComponent { public constructor(data?: ContainerComponent | APIContainerComponent); public components: T[]; @@ -6908,8 +6915,8 @@ export type GuildScheduledEventResolvable = Snowflake | GuildScheduledEvent; export type GuildScheduledEventSetStatusArg = T extends 'SCHEDULED' ? 'ACTIVE' | 'CANCELED' : T extends 'ACTIVE' - ? 'COMPLETED' - : never; + ? 'COMPLETED' + : never; export type GuildScheduledEventStatus = keyof typeof GuildScheduledEventStatuses; @@ -7152,9 +7159,9 @@ export type MessageComponentOptions = | MessageButtonOptions | MessageSelectMenuOptions; -export type MessageComponentType = keyof typeof MessageComponentTypes; +export type MessageComponentType = keyof typeof MessageComponentInteractables; -export type MessageComponentTypeResolvable = MessageComponentType | MessageComponentTypes; +export type MessageComponentTypeResolvable = MessageComponentType | MessageComponentInteractables; export type GuildForumThreadMessageCreateOptions = Omit & Pick; @@ -8059,14 +8066,14 @@ export type WSEventType = export type Serialized = T extends symbol | bigint | (() => any) ? never : T extends number | string | boolean | undefined - ? T - : T extends { toJSON(): infer R } - ? R - : T extends ReadonlyArray - ? Serialized[] - : T extends ReadonlyMap | ReadonlySet - ? {} - : { [K in keyof T]: Serialized }; + ? T + : T extends { toJSON(): infer R } + ? R + : T extends ReadonlyArray + ? Serialized[] + : T extends ReadonlyMap | ReadonlySet + ? {} + : { [K in keyof T]: Serialized }; //#endregion From 5f8ddb43fb9807bb250002a6ced6eef9ee60befb Mon Sep 17 00:00:00 2001 From: tungdo0602 Date: Tue, 1 Jul 2025 20:19:20 +0700 Subject: [PATCH 17/18] revert --- .eslintrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 283382f..9850c65 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -287,4 +287,4 @@ ], "linebreak-style": 0 } -} \ No newline at end of file +} From 69ffeb4c8bccfd74f039766cd2fdd88a900c8440 Mon Sep 17 00:00:00 2001 From: tungdo0602 Date: Tue, 1 Jul 2025 20:21:38 +0700 Subject: [PATCH 18/18] fix --- src/structures/Message.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/structures/Message.js b/src/structures/Message.js index 3c9b116..cb2c202 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -25,7 +25,6 @@ const MessageFlags = require('../util/MessageFlags'); const Permissions = require('../util/Permissions'); const SnowflakeUtil = require('../util/SnowflakeUtil'); const Util = require('../util/Util'); -const ContainerComponent = require('./ContainerComponent'); /** * @type {WeakSet}