fix(types)!: Sort & fix message.ts types (#4293)

This commit is contained in:
Fleny
2025-08-11 19:41:00 +02:00
committed by GitHub
parent 2f48861ebf
commit 946e22dc2f
+55 -29
View File
@@ -5,7 +5,12 @@ import type { DiscordChannel, DiscordThreadMember } from './channel.js'
import type { DiscordMessageComponents } from './components.js' import type { DiscordMessageComponents } from './components.js'
import type { DiscordEmoji } from './emoji.js' import type { DiscordEmoji } from './emoji.js'
import type { DiscordMessageCreateExtra } from './gateway.js' import type { DiscordMessageCreateExtra } from './gateway.js'
import type { DiscordAuthorizingIntegrationOwners, DiscordMessageInteraction, InteractionTypes } from './interactions.js' import type {
DiscordAuthorizingIntegrationOwners,
DiscordInteractionDataResolved,
DiscordMessageInteraction,
InteractionTypes,
} from './interactions.js'
import type { DiscordPoll } from './poll.js' import type { DiscordPoll } from './poll.js'
import type { DiscordSticker, DiscordStickerItem } from './sticker.js' import type { DiscordSticker, DiscordStickerItem } from './sticker.js'
import type { DiscordUser } from './user.js' import type { DiscordUser } from './user.js'
@@ -18,11 +23,13 @@ export interface DiscordMessage extends Partial<DiscordMessageCreateExtra> {
channel_id: string channel_id: string
/** /**
* The author of this message (not guaranteed to be a valid user) * The author of this message (not guaranteed to be a valid user)
* Note: The author object follows the structure of the user object, but is only a valid user in the case where the message is generated by a user or bot user. If the message is generated by a webhook, the author object corresponds to the webhook's id, username, and avatar. You can tell if a message is generated by a webhook by checking for the webhook_id on the message object. *
* @remarks
* The author object follows the structure of the user object, but is only a valid user in the case where the message is generated by a user or bot user. If the message is generated by a webhook, the author object corresponds to the webhook's id, username, and avatar. You can tell if a message is generated by a webhook by checking for the webhook_id on the message object.
*/ */
author: DiscordUser author: DiscordUser
/** Contents of the message */ /** Contents of the message */
content?: string content: string
/** When this message was sent */ /** When this message was sent */
timestamp: string timestamp: string
/** When this message was edited (or null if never) */ /** When this message was edited (or null if never) */
@@ -36,7 +43,7 @@ export interface DiscordMessage extends Partial<DiscordMessageCreateExtra> {
// /** Users specifically mentioned in the message */ // /** Users specifically mentioned in the message */
// mentions: DiscordUser[] // mentions: DiscordUser[]
/** Roles specifically mentioned in this message */ /** Roles specifically mentioned in this message */
mention_roles?: string[] mention_roles: string[]
/** /**
* Channels specifically mentioned in this message * Channels specifically mentioned in this message
* Note: Not all channel mentions in a message will appear in `mention_channels`. Only textual channels that are visible to everyone in a discoverable guild will ever be included. Only crossposted messages (via Channel Following) currently include `mention_channels` at all. If no mentions in the message meet these requirements, this field will not be sent. * Note: Not all channel mentions in a message will appear in `mention_channels`. Only textual channels that are visible to everyone in a discoverable guild will ever be included. Only crossposted messages (via Channel Following) currently include `mention_channels` at all. If no mentions in the message meet these requirements, this field will not be sent.
@@ -62,22 +69,19 @@ export interface DiscordMessage extends Partial<DiscordMessageCreateExtra> {
application?: Partial<DiscordApplication> application?: Partial<DiscordApplication>
/** if the message is an Interaction or application-owned webhook, this is the id of the application */ /** if the message is an Interaction or application-owned webhook, this is the id of the application */
application_id?: string application_id?: string
/** Data showing the source of a crosspost, channel follow add, pin, or reply message */
message_reference?: Omit<DiscordMessageReference, 'failIfNotExists'>
/** Message flags combined as a bitfield */ /** Message flags combined as a bitfield */
flags?: MessageFlags flags?: MessageFlags
/** /** Data showing the source of a crosspost, channel follow add, pin, or reply message */
* The stickers sent with the message (bots currently can only receive messages with stickers, not send) message_reference?: Omit<DiscordMessageReference, 'failIfNotExists'>
* @deprecated
*/
stickers?: DiscordSticker[]
/**
* The message associated with the 'message_reference'
* Note: This field is only returned for messages with a 'type' of '19', '21', or '23'. If the message is one of these but the 'referenced_message' field is not present, the backend did not attempt to fetch the message that was being replied to, so its state is unknown. If the field exists but is null, the referenced message was deleted.
*/
referenced_message?: DiscordMessage
/** The message associated with the `message_reference`. This is a minimal subset of fields in a message (e.g. `author` is excluded.) */ /** The message associated with the `message_reference`. This is a minimal subset of fields in a message (e.g. `author` is excluded.) */
message_snapshots?: DiscordMessageSnapshot[] message_snapshots?: DiscordMessageSnapshot[]
/**
* The message associated with the 'message_reference'
*
* @remarks
* This field is only returned for messages with a 'type' of '19', '21', or '23'. If the message is one of these but the 'referenced_message' field is not present, the backend did not attempt to fetch the message that was being replied to, so its state is unknown. If the field exists but is null, the referenced message was deleted.
*/
referenced_message?: DiscordMessage | null
/** sent if the message is sent as a result of an interaction */ /** sent if the message is sent as a result of an interaction */
interaction_metadata?: DiscordMessageInteractionMetadata interaction_metadata?: DiscordMessageInteractionMetadata
/** /**
@@ -92,8 +96,17 @@ export interface DiscordMessage extends Partial<DiscordMessageCreateExtra> {
components?: DiscordMessageComponents components?: DiscordMessageComponents
/** Sent if the message contains stickers */ /** Sent if the message contains stickers */
sticker_items?: DiscordStickerItem[] sticker_items?: DiscordStickerItem[]
/**
* The stickers sent with the message (bots currently can only receive messages with stickers, not send)
* @deprecated
*/
stickers?: DiscordSticker[]
/** A generally increasing integer (there may be gaps or duplicates) that represents the approximate position of the message in a thread, it can be used to estimate the relative position of the message in a thread in company with `total_message_sent` on parent thread */ /** A generally increasing integer (there may be gaps or duplicates) that represents the approximate position of the message in a thread, it can be used to estimate the relative position of the message in a thread in company with `total_message_sent` on parent thread */
position?: number position?: number
/** data of the role subscription purchase or renewal that prompted this ROLE_SUBSCRIPTION_PURCHASE message */
role_subscription_data?: DiscordRoleSubscriptionData
/** data for users, members, channels, and roles in the message's auto-populated select menus */
resolved?: DiscordInteractionDataResolved
/** The poll object */ /** The poll object */
poll?: DiscordPoll poll?: DiscordPoll
/** The call associated with the message */ /** The call associated with the message */
@@ -218,6 +231,7 @@ export interface DiscordApplicationCommandInteractionMetadata {
/** https://discord.com/developers/docs/resources/message#message-interaction-metadata-object-message-component-interaction-metadata-structure */ /** https://discord.com/developers/docs/resources/message#message-interaction-metadata-object-message-component-interaction-metadata-structure */
export interface DiscordMessageComponentInteractionMetadata { export interface DiscordMessageComponentInteractionMetadata {
/** Id of the interaction */
id: string id: string
/** The type of interaction */ /** The type of interaction */
type: InteractionTypes type: InteractionTypes
@@ -228,11 +242,12 @@ export interface DiscordMessageComponentInteractionMetadata {
/** ID of the original response message, present only on follow-up messages */ /** ID of the original response message, present only on follow-up messages */
original_response_message_id?: string original_response_message_id?: string
/** ID of the message that contained interactive component, present only on messages created from component interactions */ /** ID of the message that contained interactive component, present only on messages created from component interactions */
interacted_message_id?: string interacted_message_id: string
} }
/** https://discord.com/developers/docs/resources/message#message-interaction-metadata-object-modal-submit-interaction-metadata-structure */ /** https://discord.com/developers/docs/resources/message#message-interaction-metadata-object-modal-submit-interaction-metadata-structure */
export interface DiscordModalSubmitInteractionMetadata { export interface DiscordModalSubmitInteractionMetadata {
/** Id of the interaction */
id: string id: string
/** The type of interaction */ /** The type of interaction */
type: InteractionTypes type: InteractionTypes
@@ -243,7 +258,7 @@ export interface DiscordModalSubmitInteractionMetadata {
/** ID of the original response message, present only on follow-up messages */ /** ID of the original response message, present only on follow-up messages */
original_response_message_id?: string original_response_message_id?: string
/** Metadata for the interaction that was used to open the modal, present only on modal submit interactions */ /** Metadata for the interaction that was used to open the modal, present only on modal submit interactions */
triggering_interaction_metadata?: DiscordMessageInteractionMetadata triggering_interaction_metadata: DiscordApplicationCommandInteractionMetadata | DiscordMessageComponentInteractionMetadata
} }
/** https://discord.com/developers/docs/resources/message#message-call-object-message-call-object-structure */ /** https://discord.com/developers/docs/resources/message#message-call-object-message-call-object-structure */
@@ -251,7 +266,7 @@ export interface DiscordMessageCall {
/** Array of user object ids that participated in the call */ /** Array of user object ids that participated in the call */
participants: string[] participants: string[]
/** Time when call ended */ /** Time when call ended */
ended_timestamp: string ended_timestamp?: string | null
} }
/** https://discord.com/developers/docs/resources/message#message-reference-structure */ /** https://discord.com/developers/docs/resources/message#message-reference-structure */
@@ -268,7 +283,7 @@ export interface DiscordMessageReference {
/** id of the originating message's guild */ /** id of the originating message's guild */
guild_id?: string guild_id?: string
/** When sending, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, default true */ /** When sending, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, default true */
fail_if_not_exists: boolean fail_if_not_exists?: boolean
} }
/** https://discord.com/developers/docs/resources/message#message-reference-types */ /** https://discord.com/developers/docs/resources/message#message-reference-types */
@@ -347,10 +362,10 @@ export interface DiscordEmbed {
description?: string description?: string
/** Url of embed */ /** Url of embed */
url?: string url?: string
/** Color code of the embed */
color?: number
/** Timestamp of embed content */ /** Timestamp of embed content */
timestamp?: string timestamp?: string
/** Color code of the embed */
color?: number
/** Footer information */ /** Footer information */
footer?: DiscordEmbedFooter footer?: DiscordEmbedFooter
/** Image information */ /** Image information */
@@ -448,10 +463,14 @@ export interface DiscordEmbedField {
/** https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure */ /** https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure */
export interface DiscordAttachment { export interface DiscordAttachment {
/** Attachment id */
id: string
/** Name of file attached */ /** Name of file attached */
filename: string filename: string
/** The title of the file */ /** The title of the file */
title?: string title?: string
/** description for the file (max 1024 characters) */
description?: string
/** The attachment's [media type](https://en.wikipedia.org/wiki/Media_type) */ /** The attachment's [media type](https://en.wikipedia.org/wiki/Media_type) */
content_type?: string content_type?: string
/** Size of file in bytes */ /** Size of file in bytes */
@@ -460,10 +479,6 @@ export interface DiscordAttachment {
url: string url: string
/** A proxied url of file */ /** A proxied url of file */
proxy_url: string proxy_url: string
/** Attachment id */
id: string
/** description for the file (max 1024 characters) */
description?: string
/** Height of file (if image) */ /** Height of file (if image) */
height?: number | null height?: number | null
/** Width of file (if image) */ /** Width of file (if image) */
@@ -511,15 +526,25 @@ export enum AllowedMentionsTypes {
export interface DiscordAllowedMentions { export interface DiscordAllowedMentions {
/** An array of allowed mention types to parse from the content. */ /** An array of allowed mention types to parse from the content. */
parse?: AllowedMentionsTypes[] parse?: AllowedMentionsTypes[]
/** For replies, whether to mention the author of the message being replied to (default false) */
replied_user?: boolean
/** Array of role_ids to mention (Max size of 100) */ /** Array of role_ids to mention (Max size of 100) */
roles?: string[] roles?: string[]
/** Array of user_ids to mention (Max size of 100) */ /** Array of user_ids to mention (Max size of 100) */
users?: string[] users?: string[]
/** For replies, whether to mention the author of the message being replied to (default false) */
replied_user?: boolean
} }
// TODO: Implement RoleSubscriptionData https://discord.com/developers/docs/resources/message#role-subscription-data-object-role-subscription-data-object-structure /** https://discord.com/developers/docs/resources/message#role-subscription-data-object-role-subscription-data-object-structure */
export interface DiscordRoleSubscriptionData {
/** the id of the sku and listing that the user is subscribed to */
role_subscription_listing_id: string
/** the name of the tier that the user is subscribed to */
tier_name: string
/** the cumulative number of months that the user has been subscribed */
total_months_subscribed: number
/** whether this notification is for a renewal rather than a new purchase */
is_renewal: boolean
}
/** https://discord.com/developers/docs/resources/message#message-pin-object-message-pin-object-struture */ /** https://discord.com/developers/docs/resources/message#message-pin-object-message-pin-object-struture */
export interface DiscordMessagePin { export interface DiscordMessagePin {
@@ -529,6 +554,7 @@ export interface DiscordMessagePin {
message: DiscordMessage message: DiscordMessage
} }
// TODO: We usually don't have the create types, we should consider removing this.
/** https://discord.com/developers/docs/resources/message#create-message-jsonform-params */ /** https://discord.com/developers/docs/resources/message#create-message-jsonform-params */
export interface DiscordCreateMessage { export interface DiscordCreateMessage {
/** The message contents (up to 2000 characters) */ /** The message contents (up to 2000 characters) */