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

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

* fix: remove erros

* Update packages/discord.js/src/structures/ThreadChannel.js

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

* Update packages/discord.js/src/structures/ThreadChannel.js

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

* Update packages/discord.js/src/structures/ThreadChannel.js

Co-authored-by: Almeida <almeidx@pm.me>

* Update packages/discord.js/src/structures/ThreadChannel.js

Co-authored-by: Almeida <almeidx@pm.me>

* Update packages/discord.js/typings/index.d.ts

Co-authored-by: Aura Román <kyradiscord@gmail.com>

* docs(ThreadChannel): improve description

* types(ThreadChannel): fix types

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: Almeida <almeidx@pm.me>
Co-authored-by: Aura Román <kyradiscord@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Idris
2022-11-19 21:54:43 +01:00
committed by GitHub
parent ff85481d3e
commit e74aa7f6b0
2 changed files with 22 additions and 1 deletions

View File

@@ -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<ThreadChannel>}
*/
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<ThreadChannel>}
*/
unpin(reason) {
return this.edit({ flags: this.flags.remove(ChannelFlags.Pinned), reason });
}
/**
* Whether the client user is a member of the thread.
* @type {boolean}

View File

@@ -2816,7 +2816,10 @@ export class ThreadChannel<Forum extends boolean = boolean> extends TextBasedCha
public setInvitable(invitable?: boolean, reason?: string): Promise<AnyThreadChannel>;
public setLocked(locked?: boolean, reason?: string): Promise<AnyThreadChannel>;
public setName(name: string, reason?: string): Promise<AnyThreadChannel>;
// The following 3 methods can only be run on forum threads.
public setAppliedTags(appliedTags: Snowflake[], reason?: string): Promise<ThreadChannel<true>>;
public pin(reason?: string): Promise<ThreadChannel<true>>;
public unpin(reason?: string): Promise<ThreadChannel<true>>;
public toString(): ChannelMention;
}