feat(Message): add call

#10283 backport
This commit is contained in:
Elysia
2024-09-17 19:30:44 +07:00
parent 93b4118145
commit 4abb56e265
2 changed files with 31 additions and 0 deletions

View File

@@ -371,6 +371,30 @@ class Message extends Base {
} else { } else {
this.interaction ??= null; this.interaction ??= null;
} }
/**
* A call associated with a message
* @typedef {Object} MessageCall
* @property {Readonly<?Date>} 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;
}
} }
/** /**

7
typings/index.d.ts vendored
View File

@@ -2065,6 +2065,7 @@ export class Message<Cached extends boolean = boolean> extends Base {
public readonly url: string; public readonly url: string;
public webhookId: Snowflake | null; public webhookId: Snowflake | null;
public poll: MessagePoll | null; public poll: MessagePoll | null;
public call: MessageCall | null;
public flags: Readonly<MessageFlags>; public flags: Readonly<MessageFlags>;
public reference: MessageReference | null; public reference: MessageReference | null;
public position: number | null; public position: number | null;
@@ -2536,6 +2537,12 @@ export class MessagePoll {
public setDuration(duration: number): this; public setDuration(duration: number): this;
} }
export interface MessageCall {
readonly endedAt: Date | null;
endedTimestamp: number | null;
participants: readonly Snowflake[];
}
export class ModalSubmitFieldsResolver { export class ModalSubmitFieldsResolver {
constructor(components: PartialModalActionRow[]); constructor(components: PartialModalActionRow[]);
private readonly _fields: PartialTextInputData[]; private readonly _fields: PartialTextInputData[];