Skip to content

Commit 6803121

Browse files
feat(Message): add call (#10283)
* feat(Message): add `call` * refactor: make `endedAt` a getter * types: fix `endedAt` return type * types(Message): add `call` property * docs: requested changes --------- Co-authored-by: Jiralite <[email protected]>
1 parent 3cdddbe commit 6803121

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

packages/discord.js/src/structures/Message.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,30 @@ class Message extends Base {
417417
} else {
418418
this.poll ??= null;
419419
}
420+
421+
/**
422+
* A call associated with a message
423+
* @typedef {Object} MessageCall
424+
* @property {Readonly<?Date>} endedAt The time the call ended
425+
* @property {?number} endedTimestamp The timestamp the call ended
426+
* @property {Snowflake[]} participants The ids of the users that participated in the call
427+
*/
428+
429+
if (data.call) {
430+
/**
431+
* The call associated with the message
432+
* @type {?MessageCall}
433+
*/
434+
this.call = {
435+
endedTimestamp: data.call.ended_timestamp ? Date.parse(data.call.ended_timestamp) : null,
436+
participants: data.call.participants,
437+
get endedAt() {
438+
return this.endedTimestamp && new Date(this.endedTimestamp);
439+
},
440+
};
441+
} else {
442+
this.call ??= null;
443+
}
420444
}
421445

422446
/**

packages/discord.js/typings/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,6 +2027,12 @@ export class LimitedCollection<Key, Value> extends Collection<Key, Value> {
20272027
public keepOverLimit: ((value: Value, key: Key, collection: this) => boolean) | null;
20282028
}
20292029

2030+
export interface MessageCall {
2031+
get endedAt(): Date | null;
2032+
endedTimestamp: number | null;
2033+
participants: readonly Snowflake[];
2034+
}
2035+
20302036
export type MessageComponentType = Exclude<ComponentType, ComponentType.TextInput | ComponentType.ActionRow>;
20312037

20322038
export interface MessageCollectorOptionsParams<
@@ -2118,6 +2124,7 @@ export class Message<InGuild extends boolean = boolean> extends Base {
21182124
public get thread(): AnyThreadChannel | null;
21192125
public tts: boolean;
21202126
public poll: Poll | null;
2127+
public call: MessageCall | null;
21212128
public type: MessageType;
21222129
public get url(): string;
21232130
public webhookId: Snowflake | null;

0 commit comments

Comments
 (0)