Skip to content

Commit

Permalink
feat: add last_message_id & last_pin_timestamp prop
Browse files Browse the repository at this point in the history
  • Loading branch information
imnaiyar committed Sep 27, 2024
1 parent b2aa4aa commit fa796dd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/discord.js/src/structures/PartialGroupDMChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,35 @@ class PartialGroupDMChannel extends BaseChannel {
} else {
this.ownerId ??= null;
}

if ('last_message_id' in data) {
/**
* The channel's last message id, if one was sent
* @type {?Snowflake}
*/
this.lastMessageId = data.last_message_id;
} else {
this.lastMessageId ??= null;
}

if ('last_pin_timestamp' in data) {
/**
* The timestamp when the last pinned message was pinned, if there was one
* @type {?number}
*/
this.lastPinTimestamp = data.last_pin_timestamp;
} else {
this.lastPinTimestamp ??= null;
}
}

/**
* The date when the last pinned message was pinned, if there was one
* @type {?Date}
* @readonly
*/
get lastPinAt() {
return this.lastPinTimestamp && new Date(this.lastPinTimestamp);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2559,6 +2559,9 @@ export class PartialGroupDMChannel extends BaseChannel {
public recipients: PartialRecipient[];
public messages: PartialGroupDMMessageManager;
public ownerId: Snowflake | null;
public lastMessageId: Snowflake | null;
public lastPinTimestamp: number | null;
get lastPinAt(): Date | null;
public iconURL(options?: ImageURLOptions): string | null;
public fetchOwner(options?: BaseFetchOptions): Promise<User>;
public toString(): ChannelMention;
Expand Down

0 comments on commit fa796dd

Please sign in to comment.