feat: ForumChannel

Backport https://github.com/discordjs/discord.js/pull/8786
This commit is contained in:
March 7th 2022-10-26 19:21:40 +07:00
parent db696d3e16
commit f8246be0aa
2 changed files with 32 additions and 20 deletions

View File

@ -55,8 +55,6 @@ class GuildForumThreadManager extends ThreadManager {
rateLimitPerUser,
appliedTags,
} = {}) {
let path = this.client.api.channels(this.channel.id);
if (!message) {
throw new TypeError('GUILD_FORUM_MESSAGE_REQUIRED');
}
@ -73,7 +71,7 @@ class GuildForumThreadManager extends ThreadManager {
if (autoArchiveDuration === 'MAX') autoArchiveDuration = resolveAutoArchiveMaxLimit(this.channel.guild);
const data = await path.threads.post({
const data = await this.client.api.channels(this.channel.id).threads.post({
data: {
name,
auto_archive_duration: autoArchiveDuration,

View File

@ -3,9 +3,9 @@
const { Channel } = require('./Channel');
const TextBasedChannel = require('./interfaces/TextBasedChannel');
const { RangeError } = require('../errors');
const InteractionManager = require('../managers/InteractionManager');
const MessageManager = require('../managers/MessageManager');
const ThreadMemberManager = require('../managers/ThreadMemberManager');
const ChannelFlags = require('../util/ChannelFlags');
const Permissions = require('../util/Permissions');
const { resolveAutoArchiveMaxLimit } = require('../util/Util');
@ -36,12 +36,6 @@ class ThreadChannel extends Channel {
*/
this.messages = new MessageManager(this);
/**
* A manager of the interactions sent to this channel
* @type {InteractionManager}
*/
this.interactions = new InteractionManager(this);
/**
* A manager of the members that are part of this thread
* @type {ThreadMemberManager}
@ -329,6 +323,7 @@ class ThreadChannel extends Channel {
* @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the thread in seconds
* @property {boolean} [locked] Whether the thread is locked
* @property {boolean} [invitable] Whether non-moderators can add other non-moderators to a thread
* @property {ChannelFlagsResolvable} [flags] The flags to set on the channel
* <info>Can only be edited on `GUILD_PRIVATE_THREAD`</info>
*/
@ -356,6 +351,7 @@ class ThreadChannel extends Channel {
locked: data.locked,
invitable: this.type === 'GUILD_PRIVATE_THREAD' ? data.invitable : undefined,
applied_tags: data.appliedTags,
flags: 'flags' in data ? ChannelFlags.resolve(data.flags) : undefined,
},
reason,
});
@ -363,16 +359,6 @@ class ThreadChannel extends Channel {
return this.client.actions.ChannelUpdate.handle(newData).updated;
}
/**
* Set the applied tags for this channel (only applicable to forum threads)
* @param {Snowflake[]} appliedTags The tags to set for this channel
* @param {string} [reason] Reason for changing the thread's applied tags
* @returns {Promise<GuildForumThreadChannel>}
*/
setAppliedTags(appliedTags, reason) {
return this.edit({ appliedTags, reason });
}
/**
* Sets whether the thread is archived.
* @param {boolean} [archived=true] Whether the thread is archived
@ -459,6 +445,34 @@ class ThreadChannel extends Channel {
return this.edit({ rateLimitPerUser }, 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.FLAGS.PINNED), reason });
}
/**
* 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.FLAGS.PINNED), reason });
}
/**
* Set the applied tags for this channel (only applicable to forum threads)
* @param {Snowflake[]} appliedTags The tags to set for this channel
* @param {string} [reason] Reason for changing the thread's applied tags
* @returns {Promise<GuildForumThreadChannel>}
*/
setAppliedTags(appliedTags, reason) {
return this.edit({ appliedTags, reason });
}
/**
* Whether the client user is a member of the thread.
* @type {boolean}