diff --git a/packages/discord.js/src/structures/Message.js b/packages/discord.js/src/structures/Message.js index bbd550cc2..54c279591 100644 --- a/packages/discord.js/src/structures/Message.js +++ b/packages/discord.js/src/structures/Message.js @@ -417,6 +417,30 @@ class Message extends Base { } else { this.poll ??= null; } + + /** + * A call associated with a message + * @typedef {Object} MessageCall + * @property {Readonly} endedAt The time the call ended + * @property {?number} endedTimestamp The timestamp the call ended + * @property {Snowflake[]} participants The ids of the users that participated in the call + */ + + if (data.call) { + /** + * The call associated with the message + * @type {?MessageCall} + */ + this.call = { + endedTimestamp: data.call.ended_timestamp ? Date.parse(data.call.ended_timestamp) : null, + participants: data.call.participants, + get endedAt() { + return this.endedTimestamp && new Date(this.endedTimestamp); + }, + }; + } else { + this.call ??= null; + } } /** diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 8dd053843..ad28287fc 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -2027,6 +2027,12 @@ export class LimitedCollection extends Collection { public keepOverLimit: ((value: Value, key: Key, collection: this) => boolean) | null; } +export interface MessageCall { + get endedAt(): Date | null; + endedTimestamp: number | null; + participants: readonly Snowflake[]; +} + export type MessageComponentType = Exclude; export interface MessageCollectorOptionsParams< @@ -2118,6 +2124,7 @@ export class Message extends Base { public get thread(): AnyThreadChannel | null; public tts: boolean; public poll: Poll | null; + public call: MessageCall | null; public type: MessageType; public get url(): string; public webhookId: Snowflake | null;