Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ThreadChannel): add a helper for pin and unpin #8786

Merged
merged 12 commits into from Nov 19, 2022
20 changes: 19 additions & 1 deletion 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');
Expand Down Expand Up @@ -457,6 +457,24 @@ class ThreadChannel extends BaseChannel {
return this.edit({ appliedTags, reason });
}

/**
* Pins this thread from the forum channel.
* @param {string} [reason] Reason for pinning
* @returns {Promise<ThreadChannel>}
*/
pin(reason) {
return this.edit({ flags: this.flags.add(ChannelFlags.Pinned), reason });
Idris1401 marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Unpins this thread from the forum channel.
* @param {string} [reason] Reason for unpinning
* @returns {Promise<ThreadChannel>}
*/
unpin(reason) {
return this.edit({ flags: this.flags.remove(ChannelFlags.Pinned), reason });
Idris1401 marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Whether the client user is a member of the thread.
* @type {boolean}
Expand Down
2 changes: 2 additions & 0 deletions packages/discord.js/typings/index.d.ts
Expand Up @@ -2640,6 +2640,8 @@ export class ThreadChannel<Forum extends boolean = boolean> extends TextBasedCha
public setLocked(locked?: boolean, reason?: string): Promise<AnyThreadChannel>;
public setName(name: string, reason?: string): Promise<AnyThreadChannel>;
public setAppliedTags(appliedTags: Snowflake[], reason?: string): Promise<ThreadChannel<true>>;
public pin(reason?: string): Promise<AnyThreadChannel>;
public unpin(reason?: string): Promise<AnyThreadChannel>;
public toString(): ChannelMention;
}

Expand Down