fix missing stuffs

This commit is contained in:
tungdo0602
2025-06-30 21:53:29 +07:00
parent bbd5f3cee5
commit 8b072d8b38
10 changed files with 40 additions and 8 deletions

View File

@@ -2,6 +2,6 @@
"singleQuote": true, "singleQuote": true,
"printWidth": 120, "printWidth": 120,
"trailingComma": "all", "trailingComma": "all",
"endOfLine": "lf", "endOfLine": "auto",
"arrowParens": "avoid" "arrowParens": "avoid"
} }

View File

@@ -12,7 +12,7 @@ class FileComponent extends BaseMessageComponent {
*/ */
/** /**
* @param {} [data={}] * @param {FileComponent | APIFileComponent} [data={}]
*/ */
constructor(data = {}) { constructor(data = {}) {
super({ type: 'FILE' }, data); super({ type: 'FILE' }, data);

View File

@@ -10,7 +10,7 @@ class MediaGalleryComponent extends BaseMessageComponent {
*/ */
/** /**
* @param {} [data={}] * @param {MediaGalleryComponent | APIMediaGalleryComponent} [data={}]
*/ */
constructor(data = {}) { constructor(data = {}) {
super({ type: 'MEDIA_GALLERY' }, data); super({ type: 'MEDIA_GALLERY' }, data);

View File

@@ -10,7 +10,7 @@ class MediaGalleryItem {
*/ */
/** /**
* @param {} [data={}] * @param {MediaGalleryItem | APIMediaGalleryItem} [data={}]
*/ */
constructor(data = {}) { constructor(data = {}) {
/** /**

View File

@@ -10,7 +10,7 @@ class SectionComponent extends BaseMessageComponent {
*/ */
/** /**
* @param {} [data={}] * @param {SectionComponent | APISectionComponent} [data={}]
*/ */
constructor(data = {}) { constructor(data = {}) {
super({ type: 'SECTION' }, data); super({ type: 'SECTION' }, data);

View File

@@ -10,7 +10,7 @@ class SeparatorComponent extends BaseMessageComponent {
*/ */
/** /**
* @param {} [data={}] * @param {SeparatorComponent | APISeparatorComponent} [data={}]
*/ */
constructor(data = {}) { constructor(data = {}) {
super({ type: 'SEPARATOR' }, data); super({ type: 'SEPARATOR' }, data);

View File

@@ -4,11 +4,26 @@ const BaseMessageComponent = require('./BaseMessageComponent');
const { MessageComponentTypes } = require('../util/Constants'); const { MessageComponentTypes } = require('../util/Constants');
class TextDisplayComponent extends BaseMessageComponent { class TextDisplayComponent extends BaseMessageComponent {
/**
* @property {String} [content] Text that will be displayed similar to a message
*/
/**
* @param {TextDisplayComponent | APITextDisplayComponent} [data={}]
*/
constructor(data = {}) { constructor(data = {}) {
super({ type: 'TEXT_DISPLAY' }, data); super({ type: 'TEXT_DISPLAY' }, data);
/**
* Text that will be displayed similar to a message
* @type {String}
*/
this.content = data.content ?? null; this.content = data.content ?? null;
} }
/**
* @returns {APITextDisplayComponent}
*/
toJSON() { toJSON() {
return { return {
type: MessageComponentTypes[this.type], type: MessageComponentTypes[this.type],

View File

@@ -16,8 +16,23 @@ class ThumbnailComponent extends BaseMessageComponent {
*/ */
constructor(data = {}) { constructor(data = {}) {
super({ type: 'THUMBNAIL' }, data); super({ type: 'THUMBNAIL' }, data);
/**
* A url or attachment
* @type {UnfurledMediaItem}
*/
this.media = new UnfurledMediaItem(data.media); this.media = new UnfurledMediaItem(data.media);
/**
* Alt text for the media, max 1024 characters
* @type {String}
*/
this.description = data.description ?? null; 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; this.spoiler = data.spoiler ?? false;
} }

View File

@@ -4,6 +4,9 @@ class UnfurledMediaItem {
/** /**
* @property {string} [url] Supports arbitrary urls and `attachment://<filename>` references * @property {string} [url] Supports arbitrary urls and `attachment://<filename>` references
*/ */
/**
* @param {UnfurledMediaItem | APIUnfurledMediaItem} [data={}]
*/
constructor(data = {}) { constructor(data = {}) {
/** /**
* @type {string} * @type {string}

View File

@@ -389,7 +389,6 @@ export interface APISectionComponent extends APIBaseComponent<MessageComponentTy
accessory: APIThumbnailComponent | APIMessageButtonInteractionData accessory: APIThumbnailComponent | APIMessageButtonInteractionData
} }
// APIActionRowComponent<APIActionRowComponentTypes> ???
export type APIContainerComponents = APIActionRowComponent<APIActionRowComponentTypes> | APITextDisplayComponent | APISectionComponent | APIMediaGalleryComponent | APISeparatorComponent | APIFileComponent; export type APIContainerComponents = APIActionRowComponent<APIActionRowComponentTypes> | APITextDisplayComponent | APISectionComponent | APIMediaGalleryComponent | APISeparatorComponent | APIFileComponent;
export interface APIContainerComponent extends APIBaseComponent<MessageComponentTypes.CONTAINER> { export interface APIContainerComponent extends APIBaseComponent<MessageComponentTypes.CONTAINER> {
components: APIContainerComponents[]; components: APIContainerComponents[];