Skip to content

Commit

Permalink
Add Message#call
Browse files Browse the repository at this point in the history
  • Loading branch information
DonovanDMC committed Jun 10, 2024
1 parent f73241e commit 83c46e0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/structures/Member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ export default class Member extends Base {
}
}

/** If the member associated with the user is a bot. */
/** If the user associated with this member is a bot. */
get bot(): boolean {
return this.user.bot;
}

/** The Discord-tag of the user associated with this member. */
get discriminator(): string {
return this.user.discriminator;
Expand Down
11 changes: 10 additions & 1 deletion lib/structures/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ import type {
AnyThreadChannel,
RoleSubscriptionData,
MessageInteractionMetadata,
GetPollAnswerUsersOptions
GetPollAnswerUsersOptions,
Call
} from "../types/channels";
import type { RawMember } from "../types/guilds";
import type { DeleteWebhookMessageOptions, EditWebhookMessageOptions } from "../types/webhooks";
Expand Down Expand Up @@ -66,6 +67,8 @@ export default class Message<T extends AnyTextableChannel | Uncached = AnyTextab
attachments: TypedCollection<RawAttachment, Attachment>;
/** The author of this message. */
author: User;
/** The call associated with this message. */
call?: Call;
/** The ID of the channel this message was created in. */
channelID: string;
/** The components on this message. */
Expand Down Expand Up @@ -210,6 +213,12 @@ export default class Message<T extends AnyTextableChannel | Uncached = AnyTextab
this.attachments.update(attachment);
}
}
if (data.call !== undefined) {
this.call = {
endedTimestamp: data.call.ended_timestamp ? new Date(data.call.ended_timestamp) : null,
participants: data.call.participants
};
}
if (data.components !== undefined) {
this.components = this.client.util.componentsToParsed(data.components);
}
Expand Down
11 changes: 11 additions & 0 deletions lib/types/channels.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ export interface RawMessage {
application_id?: string;
attachments: Array<RawAttachment>;
author: RawUser; // this can be an invalid user if `webhook_id` is set
call?: RawCall;
channel_id: string;
components?: Array<RawMessageActionRow>;
content: string;
Expand Down Expand Up @@ -708,6 +709,16 @@ export interface RawMessage {
webhook_id?: string;
}

export interface RawCall {
ended_timestamp?: string | null;
participants: Array<string>;
}

export interface Call {
endedTimestamp: Date | null;
participants: Array<string>;
}

export interface ChannelMention {
guild_id: string;
id: string;
Expand Down

0 comments on commit 83c46e0

Please sign in to comment.