Skip to content

Commit

Permalink
feat: ForumChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
aiko-chan-ai committed Oct 26, 2022
1 parent db696d3 commit f8246be
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
4 changes: 1 addition & 3 deletions src/managers/GuildForumThreadManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -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,
Expand Down
48 changes: 31 additions & 17 deletions src/structures/ThreadChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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>
*/

Expand Down Expand Up @@ -356,23 +351,14 @@ 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,
});

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
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit f8246be

Please sign in to comment.