diff --git a/packages/discord.js/src/structures/ThreadChannel.js b/packages/discord.js/src/structures/ThreadChannel.js index ea10d1f8781c..dc135560f67c 100644 --- a/packages/discord.js/src/structures/ThreadChannel.js +++ b/packages/discord.js/src/structures/ThreadChannel.js @@ -1,6 +1,6 @@ 'use strict'; -const { ChannelType, PermissionFlagsBits, Routes } = require('discord-api-types/v10'); +const { ChannelType, PermissionFlagsBits, Routes, ChannelFlags } = require('discord-api-types/v10'); const { BaseChannel } = require('./BaseChannel'); const TextBasedChannel = require('./interfaces/TextBasedChannel'); const { DiscordjsRangeError, ErrorCodes } = require('../errors'); @@ -457,6 +457,24 @@ class ThreadChannel extends BaseChannel { return this.edit({ appliedTags, reason }); } + /** + * Pins this thread from the forum channel (only applicable to forum threads). + * @param {string} [reason] Reason for pinning + * @returns {Promise} + */ + pin(reason) { + return this.edit({ flags: this.flags.add(ChannelFlags.Pinned), reason }); + } + + /** + * Unpins this thread from the forum channel (only applicable to forum threads). + * @param {string} [reason] Reason for unpinning + * @returns {Promise} + */ + unpin(reason) { + return this.edit({ flags: this.flags.remove(ChannelFlags.Pinned), reason }); + } + /** * Whether the client user is a member of the thread. * @type {boolean} diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 437db959f4d5..542f29fc769a 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -2816,7 +2816,10 @@ export class ThreadChannel extends TextBasedCha public setInvitable(invitable?: boolean, reason?: string): Promise; public setLocked(locked?: boolean, reason?: string): Promise; public setName(name: string, reason?: string): Promise; + // The following 3 methods can only be run on forum threads. public setAppliedTags(appliedTags: Snowflake[], reason?: string): Promise>; + public pin(reason?: string): Promise>; + public unpin(reason?: string): Promise>; public toString(): ChannelMention; }