mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
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:
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'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 { BaseChannel } = require('./BaseChannel');
|
||||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||||
const { DiscordjsRangeError, ErrorCodes } = require('../errors');
|
const { DiscordjsRangeError, ErrorCodes } = require('../errors');
|
||||||
@@ -457,6 +457,24 @@ class ThreadChannel extends BaseChannel {
|
|||||||
return this.edit({ appliedTags, reason });
|
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.
|
* Whether the client user is a member of the thread.
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
|
|||||||
3
packages/discord.js/typings/index.d.ts
vendored
3
packages/discord.js/typings/index.d.ts
vendored
@@ -2816,7 +2816,10 @@ export class ThreadChannel<Forum extends boolean = boolean> extends TextBasedCha
|
|||||||
public setInvitable(invitable?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
public setInvitable(invitable?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
||||||
public setLocked(locked?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
public setLocked(locked?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
||||||
public setName(name: string, 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 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;
|
public toString(): ChannelMention;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user