From 740d3f006ef637709e3026f90fe72f93b8397229 Mon Sep 17 00:00:00 2001 From: Rodry <38259440+ImRodry@users.noreply.github.com> Date: Wed, 27 Oct 2021 11:07:28 +0100 Subject: [PATCH] feat(StartThreadOptions): default autoArchiveDuration to channel's defaultAutoArchiveDuration (#6278) --- src/managers/ThreadManager.js | 20 ++++++++------------ src/structures/Message.js | 15 +++++++++++++-- typings/index.d.ts | 2 +- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/managers/ThreadManager.js b/src/managers/ThreadManager.js index f3935849c688..300041d0868e 100644 --- a/src/managers/ThreadManager.js +++ b/src/managers/ThreadManager.js @@ -59,17 +59,6 @@ class ThreadManager extends CachedManager { * @returns {?Snowflake} */ - /** - * A number that is allowed to be the duration (in minutes) of inactivity after which a thread is automatically - * archived. This can be: - * * `60` (1 hour) - * * `1440` (1 day) - * * `4320` (3 days) This is only available when the guild has the `THREE_DAY_THREAD_ARCHIVE` feature. - * * `10080` (7 days) This is only available when the guild has the `SEVEN_DAY_THREAD_ARCHIVE` feature. - * * `'MAX'` Based on the guild's features - * @typedef {number|string} ThreadAutoArchiveDuration - */ - /** * Options for creating a thread. Only one of `startMessage` or `type` can be defined. * @typedef {StartThreadOptions} ThreadCreateOptions @@ -108,7 +97,14 @@ class ThreadManager extends CachedManager { * .then(threadChannel => console.log(threadChannel)) * .catch(console.error); */ - async create({ name, autoArchiveDuration, startMessage, type, invitable, reason } = {}) { + async create({ + name, + autoArchiveDuration = this.channel.defaultAutoArchiveDuration, + startMessage, + type, + invitable, + reason, + } = {}) { let path = this.client.api.channels(this.channel.id); if (type && typeof type !== 'string' && typeof type !== 'number') { throw new TypeError('INVALID_TYPE', 'type', 'ThreadChannelType or Number'); diff --git a/src/structures/Message.js b/src/structures/Message.js index c2101f6b90a4..46036f65dad2 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -779,12 +779,23 @@ class Message extends Base { return this.channel.send(data); } + /** + * A number that is allowed to be the duration (in minutes) of inactivity after which a thread is automatically + * archived. This can be: + * * `60` (1 hour) + * * `1440` (1 day) + * * `4320` (3 days) This is only available when the guild has the `THREE_DAY_THREAD_ARCHIVE` feature. + * * `10080` (7 days) This is only available when the guild has the `SEVEN_DAY_THREAD_ARCHIVE` feature. + * * `'MAX'` Based on the guild's features + * @typedef {number|string} ThreadAutoArchiveDuration + */ + /** * Options for starting a thread on a message. * @typedef {Object} StartThreadOptions * @property {string} name The name of the new thread - * @property {ThreadAutoArchiveDuration} autoArchiveDuration The amount of time (in minutes) after which the thread - * should automatically archive in case of no recent activity + * @property {ThreadAutoArchiveDuration} [autoArchiveDuration=this.channel.defaultAutoArchiveDuration] The amount of + * time (in minutes) after which the thread should automatically archive in case of no recent activity * @property {string} [reason] Reason for creating the thread */ diff --git a/typings/index.d.ts b/typings/index.d.ts index 4e51b1c570c9..9f06685a8bff 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -4898,7 +4898,7 @@ export type StageInstanceResolvable = StageInstance | Snowflake; export interface StartThreadOptions { name: string; - autoArchiveDuration: ThreadAutoArchiveDuration; + autoArchiveDuration?: ThreadAutoArchiveDuration; reason?: string; }