From edab5afff9a4c79e5965c7c52b0a0d5ebb9ba35a Mon Sep 17 00:00:00 2001 From: DTrombett <73136330+DTrombett@users.noreply.github.com> Date: Tue, 29 Jun 2021 21:41:21 +0200 Subject: [PATCH] fix(Thread): make archive_timestamp not nullable (#5965) --- src/structures/ThreadChannel.js | 16 ++++++++-------- typings/index.d.ts | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/structures/ThreadChannel.js b/src/structures/ThreadChannel.js index 64d0da914861..5b893c09cf5d 100644 --- a/src/structures/ThreadChannel.js +++ b/src/structures/ThreadChannel.js @@ -99,12 +99,11 @@ class ThreadChannel extends Channel { this.rateLimitPerUser = data.rate_limit_per_user ?? 0; /** - * The timestamp the thread was last archived or unarchived at - * @type {?number} + * The timestamp when the thread's archive status was last changed + * If the thread was never archived or unarchived, this is set when it's created + * @type {number} */ - this.archiveTimestamp = data.thread_metadata.archive_timestamp - ? new Date(data.thread_metadata.archive_timestamp).getTime() - : null; + this.archiveTimestamp = new Date(data.thread_metadata.archive_timestamp).getTime(); /** * The approximate count of messages in this thread @@ -135,12 +134,13 @@ class ThreadChannel extends Channel { } /** - * The time the thread was last archived or unarchived at - * @type {?Date} + * The time when the thread's archive status was last changed + * If the thread was never archived or unarchived, this is set when it's created + * @type {Date} * @readonly */ get archivedAt() { - return this.archiveTimestamp ? new Date(this.archiveTimestamp) : null; + return new Date(this.archiveTimestamp); } /** diff --git a/typings/index.d.ts b/typings/index.d.ts index 0ea5497a7dbf..afd23e88e7cf 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1951,8 +1951,8 @@ declare module 'discord.js' { export class ThreadChannel extends TextBasedChannel(Channel) { constructor(guild: Guild, data?: object); public archived: boolean; - public readonly archivedAt: Date | null; - public archiveTimestamp: number | null; + public readonly archivedAt: Date; + public archiveTimestamp: number; public autoArchiveDuration: ThreadAutoArchiveDuration; public readonly editable: boolean; public guild: Guild;