add typings, fixed missing json
This commit is contained in:
@@ -12,7 +12,7 @@ class ContainerComponent extends BaseMessageComponent {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {} [data={}]
|
* @param {ContainerComponent | APIContainerComponent} [data={}]
|
||||||
*/
|
*/
|
||||||
constructor(data = {}) {
|
constructor(data = {}) {
|
||||||
super({ type: 'CONTAINER' }, 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
|
* Components of the type action row, text display, section, media gallery, separator, or file
|
||||||
* @type {ContainerComponents[]}
|
* @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
|
* Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class FileComponent extends BaseMessageComponent {
|
|||||||
* This unfurled media item is unique in that it only supports attachment references using the attachment://<filename> syntax
|
* This unfurled media item is unique in that it only supports attachment references using the attachment://<filename> syntax
|
||||||
* @type {UnfurledMediaItem}
|
* @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.
|
* Whether the container should be a spoiler (or blurred out). Defaults to false.
|
||||||
@@ -38,6 +38,7 @@ class FileComponent extends BaseMessageComponent {
|
|||||||
return {
|
return {
|
||||||
type: MessageComponentTypes[this.type],
|
type: MessageComponentTypes[this.type],
|
||||||
file: this.content,
|
file: this.content,
|
||||||
|
spoiler: this.spoiler,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,25 @@ const UnfurledMediaItem = require('./UnfurledMediaItem');
|
|||||||
const { MessageComponentTypes } = require('../util/Constants');
|
const { MessageComponentTypes } = require('../util/Constants');
|
||||||
|
|
||||||
class ThumbnailComponent extends BaseMessageComponent {
|
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 = {}) {
|
constructor(data = {}) {
|
||||||
super({ type: 'THUMBNAIL' }, data);
|
super({ type: 'THUMBNAIL' }, data);
|
||||||
this.media = new UnfurledMediaItem(data.media) ?? null;
|
this.media = new UnfurledMediaItem(data.media);
|
||||||
this.description = data.description ?? null;
|
this.description = data.description ?? null;
|
||||||
this.spoiler = data.spoiler ?? false;
|
this.spoiler = data.spoiler ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {APIThumbnailComponent}
|
||||||
|
*/
|
||||||
toJSON() {
|
toJSON() {
|
||||||
return {
|
return {
|
||||||
type: MessageComponentTypes[this.type],
|
type: MessageComponentTypes[this.type],
|
||||||
|
|||||||
2
typings/enums.d.ts
vendored
2
typings/enums.d.ts
vendored
@@ -333,7 +333,7 @@ export const enum RelationshipTypes {
|
|||||||
IMPLICIT = 5,
|
IMPLICIT = 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum SeparatorSpacingSize {
|
export const enum SeparatorSpacingSizes {
|
||||||
SMALL = 1,
|
SMALL = 1,
|
||||||
LARGE = 2,
|
LARGE = 2,
|
||||||
}
|
}
|
||||||
75
typings/index.d.ts
vendored
75
typings/index.d.ts
vendored
@@ -116,6 +116,7 @@ import {
|
|||||||
PollLayoutTypes,
|
PollLayoutTypes,
|
||||||
ReactionTypes,
|
ReactionTypes,
|
||||||
MessageReferenceTypes,
|
MessageReferenceTypes,
|
||||||
|
SeparatorSpacingSizes,
|
||||||
} from './enums';
|
} from './enums';
|
||||||
import {
|
import {
|
||||||
APIApplicationRoleConnectionMetadata,
|
APIApplicationRoleConnectionMetadata,
|
||||||
@@ -178,6 +179,15 @@ import {
|
|||||||
RawWelcomeScreenData,
|
RawWelcomeScreenData,
|
||||||
RawWidgetData,
|
RawWidgetData,
|
||||||
RawWidgetMemberData,
|
RawWidgetMemberData,
|
||||||
|
APIUnfurledMediaItem,
|
||||||
|
APIContainerComponent,
|
||||||
|
APIFileComponent,
|
||||||
|
APISectionComponent,
|
||||||
|
APISeparatorComponent,
|
||||||
|
APIThumbnailComponent,
|
||||||
|
APITextDisplayComponent,
|
||||||
|
APIMediaGalleryComponent,
|
||||||
|
APIMediaGalleryItem,
|
||||||
} from './rawDataTypes';
|
} from './rawDataTypes';
|
||||||
import { Socket } from 'node:dgram';
|
import { Socket } from 'node:dgram';
|
||||||
|
|
||||||
@@ -2299,6 +2309,71 @@ export class MessageButton extends BaseMessageComponent {
|
|||||||
private static resolveStyle(style: MessageButtonStyleResolvable): MessageButtonStyle;
|
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<T extends ThumbnailComponent | MessageButton> extends BaseMessageComponent {
|
||||||
|
public constructor(data?: SectionComponent<T> | APISectionComponent);
|
||||||
|
public components: TextDisplayComponent[];
|
||||||
|
public accessory: T[];
|
||||||
|
public toJSON(): APISectionComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ContainerComponent<
|
||||||
|
U extends ThumbnailComponent | MessageButton,
|
||||||
|
T extends MessageActionRow | TextDisplayComponent | SectionComponent<U> | MediaGalleryComponent | SeparatorComponent | FileComponent
|
||||||
|
> extends BaseMessageComponent {
|
||||||
|
public constructor(data?: ContainerComponent<U, T> | APIContainerComponent);
|
||||||
|
public components: T[];
|
||||||
|
public accent_color: number | null;
|
||||||
|
public spoiler: boolean;
|
||||||
|
public toJSON(): APIContainerComponent;
|
||||||
|
}
|
||||||
|
|
||||||
export class MessageCollector extends Collector<Snowflake, Message> {
|
export class MessageCollector extends Collector<Snowflake, Message> {
|
||||||
public constructor(channel: TextBasedChannel, options?: MessageCollectorOptions);
|
public constructor(channel: TextBasedChannel, options?: MessageCollectorOptions);
|
||||||
private _handleChannelDeletion(channel: NonThreadGuildBasedChannel): void;
|
private _handleChannelDeletion(channel: NonThreadGuildBasedChannel): void;
|
||||||
|
|||||||
51
typings/rawDataTypes.d.ts
vendored
51
typings/rawDataTypes.d.ts
vendored
@@ -87,8 +87,10 @@ import {
|
|||||||
GuildVerificationLevel,
|
GuildVerificationLevel,
|
||||||
GuildFeature,
|
GuildFeature,
|
||||||
LocalizationMap,
|
LocalizationMap,
|
||||||
|
APIActionRowComponent,
|
||||||
|
APIActionRowComponentTypes,
|
||||||
} from 'discord-api-types/v10';
|
} from 'discord-api-types/v10';
|
||||||
import { GuildChannel, Guild, PermissionOverwrites, MessageActionRow } from '.';
|
import { GuildChannel, Guild, PermissionOverwrites } from '.';
|
||||||
import type {
|
import type {
|
||||||
AutoModerationActionTypes,
|
AutoModerationActionTypes,
|
||||||
AutoModerationRuleEventTypes,
|
AutoModerationRuleEventTypes,
|
||||||
@@ -96,6 +98,7 @@ import type {
|
|||||||
AutoModerationRuleTriggerTypes,
|
AutoModerationRuleTriggerTypes,
|
||||||
ApplicationRoleConnectionMetadataTypes,
|
ApplicationRoleConnectionMetadataTypes,
|
||||||
MessageComponentTypes,
|
MessageComponentTypes,
|
||||||
|
SeparatorSpacingSizes,
|
||||||
} from './enums';
|
} from './enums';
|
||||||
|
|
||||||
export type RawActivityData = GatewayActivity;
|
export type RawActivityData = GatewayActivity;
|
||||||
@@ -344,13 +347,51 @@ export interface APIApplicationRoleConnectionMetadata {
|
|||||||
|
|
||||||
export interface APIBaseComponent<T extends MessageComponentTypes> {
|
export interface APIBaseComponent<T extends MessageComponentTypes> {
|
||||||
type: T;
|
type: T;
|
||||||
id?: Number;
|
id?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface APIUnfurledMediaItem {
|
export interface APIUnfurledMediaItem {
|
||||||
url: String;
|
url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface APIContainerComponent extends APIBaseComponent<MessageComponentTypes.CONTAINER> {
|
export interface APIMediaGalleryItem {
|
||||||
components: MessageActionRow
|
media: APIUnfurledMediaItem;
|
||||||
|
description: string;
|
||||||
|
spoiler: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface APISeparatorComponent extends APIBaseComponent<MessageComponentTypes.SEPARATOR> {
|
||||||
|
spacing: SeparatorSpacingSizes;
|
||||||
|
divider: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface APITextDisplayComponent extends APIBaseComponent<MessageComponentTypes.TEXT_DISPLAY> {
|
||||||
|
content: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface APIThumbnailComponent extends APIBaseComponent<MessageComponentTypes.THUMBNAIL> {
|
||||||
|
media: APIUnfurledMediaItem;
|
||||||
|
description: string;
|
||||||
|
spoiler: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface APIFileComponent extends APIBaseComponent<MessageComponentTypes.FILE> {
|
||||||
|
file: APIUnfurledMediaItem;
|
||||||
|
spoiler: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface APIMediaGalleryComponent extends APIBaseComponent<MessageComponentTypes.MEDIA_GALLERY> {
|
||||||
|
items: APIMediaGalleryItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface APISectionComponent extends APIBaseComponent<MessageComponentTypes.SECTION> {
|
||||||
|
components: APITextDisplayComponent[];
|
||||||
|
accessory: APIThumbnailComponent | APIMessageButtonInteractionData
|
||||||
|
}
|
||||||
|
|
||||||
|
type APIContainerComponents = APIActionRowComponent<APIActionRowComponentTypes> | APITextDisplayComponent | APISectionComponent | APIMediaGalleryComponent | APISeparatorComponent | APIFileComponent;
|
||||||
|
export interface APIContainerComponent extends APIBaseComponent<MessageComponentTypes.CONTAINER> {
|
||||||
|
components: APIContainerComponents[];
|
||||||
|
accent_color: number;
|
||||||
|
spoiler: boolean;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user