Skip to content

Commit

Permalink
docs: create ThreadAutoArchiveDuration typedef
Browse files Browse the repository at this point in the history
  • Loading branch information
ckohen committed May 12, 2021
1 parent d570121 commit 6c85368
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
9 changes: 9 additions & 0 deletions src/managers/ThreadManager.js
Expand Up @@ -58,6 +58,15 @@ class ThreadManager extends BaseManager {
* @returns {?Snowflake}
*/

/**
* A number that is allowed to be the duration in minutes before a thread is automatically archived. This can be:
* * `60` (1 hour)
* * `1440` (1 day)
* * `4320` (3 days)
* * `10080` (7 days)
* @typedef {number} ThreadAutoArchiveDuration
*/

/**
* Creates a new thread in the channel.
* @param {string} name The name of the new Thread
Expand Down
2 changes: 1 addition & 1 deletion src/structures/Message.js
Expand Up @@ -629,7 +629,7 @@ class Message extends Base {
* Create a new public thread from this message
* @see ThreadManager#create
* @param {string} name The name ofthe new Thread
* @param {number} autoArchiveDuration How long in minutes before the thread is automatically archived
* @param {ThreadAutoArchiveDuration} autoArchiveDuration How long before the thread is automatically archived
* @param {string} [reason] Reason for creating the thread
* @returns {Promise<ThreadChannel>}
*/
Expand Down
3 changes: 1 addition & 2 deletions src/structures/ThreadChannel.js
Expand Up @@ -256,8 +256,7 @@ class ThreadChannel extends Channel {

/**
* Sets the duration before the channel is automatically archived.
* @param {number} autoArchiveDuration How long in minutes before the thread is automatically archived,
* one of `60`, `1440`, `4320`, or `10080`
* @param {ThreadAutoArchiveDuration} autoArchiveDuration How long before the thread is automatically archived
* @param {string} [reason] Reason for changing the archive time
* @returns {Promise<ThreadChannel>}
* @example
Expand Down
15 changes: 9 additions & 6 deletions typings/index.d.ts
Expand Up @@ -1192,7 +1192,7 @@ declare module 'discord.js' {
public reply(content: StringResolvable, options: ReplyMessageOptions): Promise<Message | Message[]>;
public startThread(
name: 'string',
autoArchiveDuration: AutoArchiveDuration,
autoArchiveDuration: ThreadAutoArchiveDuration,
reason?: string,
): Promise<ThreadChannel>;
public suppressEmbeds(suppress?: boolean): Promise<Message>;
Expand Down Expand Up @@ -1710,7 +1710,7 @@ declare module 'discord.js' {
public readonly archivedAt: Date;
public archiverID: Snowflake | null;
public archiveTimestamp: number | null;
public autoArchiveDuration: AutoArchiveDuration;
public autoArchiveDuration: ThreadAutoArchiveDuration;
public readonly deletable: boolean;
public readonly editable: boolean;
public guild: Guild;
Expand All @@ -1737,7 +1737,10 @@ declare module 'discord.js' {
public permissionsFor(memberOrRole: GuildMember | Role): Readonly<Permissions>;
public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly<Permissions> | null;
public setArchived(archived: boolean, reason?: string): Promise<ThreadChannel>;
public setAutoArchiveDuration(autoArchiveDuration: AutoArchiveDuration, reason?: string): Promise<ThreadChannel>;
public setAutoArchiveDuration(
autoArchiveDuration: ThreadAutoArchiveDuration,
reason?: string,
): Promise<ThreadChannel>;
public setLocked(locked: boolean, reason?: string): Promise<ThreadChannel>;
public setName(name: string, reason?: string): Promise<ThreadChannel>;
public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<ThreadChannel>;
Expand Down Expand Up @@ -2336,7 +2339,7 @@ declare module 'discord.js' {
public channel: TextChannel | NewsChannel;
public create(
name: string,
autoArchiveDuration: AutoArchiveDuration,
autoArchiveDuration: ThreadAutoArchiveDuration,
options?: { startMessage?: MessageResolvable; reason?: string },
): Promise<ThreadChannel>;
public fetch(options: ThreadChannelResolvable, cache?: boolean, force?: boolean): Promise<ThreadChannel | null>;
Expand Down Expand Up @@ -2618,7 +2621,7 @@ declare module 'discord.js' {
new?: any;
}

type AutoArchiveDuration = 60 | 1440 | 4320 | 10080;
type ThreadAutoArchiveDuration = 60 | 1440 | 4320 | 10080;

interface AwaitMessagesOptions extends MessageCollectorOptions {
errors?: string[];
Expand Down Expand Up @@ -3765,7 +3768,7 @@ declare module 'discord.js' {
interface ThreadEditData {
name?: string;
archived?: boolean;
autoArchiveDuration?: AutoArchiveDuration;
autoArchiveDuration?: ThreadAutoArchiveDuration;
rateLimitPeruser?: number;
locked?: boolean;
}
Expand Down

0 comments on commit 6c85368

Please sign in to comment.