Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

feat: add lastPinTimestamp to DMChannel, update lastPinTimestamp #320

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions src/actions/channels/CHANNEL_PINS_UPDATE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export default class CoreAction extends Action {
const channel = guild ? guild.channels.get(data.d.channel_id) : this.client.dms.get(data.d.channel_id);
if (!channel || !isTextBasedChannel(channel)) return;

channel.lastPinTimestamp = data.d.last_pin_timestamp ?? null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can last_pin_timestamp ever be undefined? If so, you should guard the set with the isSet util from this library.


this.client.emit(this.clientEvent, channel, this.parseDate(data.d.last_pin_timestamp));
}

Expand Down
7 changes: 7 additions & 0 deletions src/lib/caching/structures/channels/DMChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export class DMChannel extends Channel {
*/
public lastMessageID!: string | null;

/**
* When the last pinned message was pinned.
* @since 0.0.3
*/
public lastPinTimestamp!: string | null;

/**
* The recipients of the DM.
* @since 0.0.1
Expand Down Expand Up @@ -151,6 +157,7 @@ export class DMChannel extends Channel {
// eslint-disable-next-line dot-notation
this.recipients = (data.recipients as APIUserData[]).map(user => this.client.users['_add'](user));
this.lastMessageID = data.last_message_id as string | null;
this.lastPinTimestamp = data.last_pin_timestamp ?? null;
return this;
}

Expand Down