Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Message): add call #10283

Merged
merged 7 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/discord.js/src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,30 @@ class Message extends Base {
} else {
this.poll ??= 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;
}
}

/**
Expand Down
7 changes: 7 additions & 0 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2027,6 +2027,12 @@ export class LimitedCollection<Key, Value> extends Collection<Key, Value> {
public keepOverLimit: ((value: Value, key: Key, collection: this) => boolean) | null;
}

export interface MessageCall {
sdanialraza marked this conversation as resolved.
Show resolved Hide resolved
get endedAt(): Date | null;
endedTimestamp: number | null;
participants: readonly Snowflake[];
}

export type MessageComponentType = Exclude<ComponentType, ComponentType.TextInput | ComponentType.ActionRow>;

export interface MessageCollectorOptionsParams<
Expand Down Expand Up @@ -2118,6 +2124,7 @@ export class Message<InGuild extends boolean = boolean> 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;
Expand Down
Loading