feat(ForumChannel): setDefaultForumLayout & fix bug
This commit is contained in:
@@ -30,21 +30,25 @@ class CategoryChannel extends GuildChannel {
|
||||
/**
|
||||
* Options for creating a channel using {@link CategoryChannel#createChannel}.
|
||||
* @typedef {Object} CategoryCreateChannelOptions
|
||||
* @property {string} [name] The name of the new channel
|
||||
* @property {ChannelType|number} [type='GUILD_TEXT'] The type of the new channel.
|
||||
* @property {number} [position] Position of the new channel
|
||||
* @property {string} [topic] The topic for the new channel
|
||||
* @property {boolean} [nsfw] Whether the new channel is NSFW
|
||||
* @property {number} [bitrate] Bitrate of the new channel in bits (only voice)
|
||||
* @property {number} [userLimit] Maximum amount of users allowed in the new channel (only voice)
|
||||
* @property {OverwriteResolvable[]|Collection<Snowflake, OverwriteResolvable>} [permissionOverwrites]
|
||||
* Permission overwrites of the new channel
|
||||
* @property {number} [position] Position of the new channel
|
||||
* @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the new channel in seconds
|
||||
* @property {string} [rtcRegion] The specific region of the new channel.
|
||||
* @property {VideoQualityMode} [videoQualityMode] The camera video quality mode of the voice channel
|
||||
* @property {GuildForumTagData[]} [availableTags] The tags that can be used in this channel (forum only).
|
||||
* @property {DefaultReactionEmoji} [defaultReactionEmoji]
|
||||
* The emoji to show in the add reaction button on a thread in a guild forum channel.
|
||||
* @property {SortOrderType} [defaultSortOrder] The default sort order mode used to order posts (forum only).
|
||||
* @property {ThreadAutoArchiveDuration} [defaultAutoArchiveDuration]
|
||||
* The default auto archive duration for all new threads in this channel
|
||||
* @property {?string} [rtcRegion] The specific region of the new channel
|
||||
* @property {?VideoQualityMode|number} [videoQualityMode] The camera video quality mode of the new channel
|
||||
* @property {ChannelFlagsResolvable} [flags] The flags to set on the new channel
|
||||
* @property {GuildForumTagData[]} [availableTags] The tags to set as available in a forum channel
|
||||
* @property {?DefaultReactionEmoji} [defaultReactionEmoji] The emoji to set as the default reaction emoji
|
||||
* @property {number} [defaultThreadRateLimitPerUser] The rate limit per user (slowmode) to set on forum posts
|
||||
* @property {?SortOrderType} [defaultSortOrder] The default sort order mode to set on the new channel
|
||||
* @property {string} [reason] Reason for creating the new channel
|
||||
*/
|
||||
|
||||
|
@@ -4,7 +4,7 @@ const GuildChannel = require('./GuildChannel');
|
||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||
const GuildForumThreadManager = require('../managers/GuildForumThreadManager');
|
||||
const InteractionManager = require('../managers/InteractionManager');
|
||||
const { SortOrderTypes } = require('../util/Constants');
|
||||
const { SortOrderTypes, ForumLayoutTypes } = require('../util/Constants');
|
||||
const { transformAPIGuildForumTag, transformAPIGuildDefaultReaction } = require('../util/Util');
|
||||
|
||||
/**
|
||||
@@ -46,18 +46,18 @@ class ForumChannel extends GuildChannel {
|
||||
constructor(guild, data, client) {
|
||||
super(guild, data, client, false);
|
||||
|
||||
/**
|
||||
* A manager of the threads belonging to this channel
|
||||
* @type {GuildForumThreadManager}
|
||||
*/
|
||||
this.threads = new GuildForumThreadManager(this);
|
||||
|
||||
/**
|
||||
* A manager of the interactions sent to this channel
|
||||
* @type {InteractionManager}
|
||||
*/
|
||||
this.interactions = new InteractionManager(this);
|
||||
|
||||
/**
|
||||
* A manager of the threads belonging to this channel
|
||||
* @type {GuildForumThreadManager}
|
||||
*/
|
||||
this.threads = new GuildForumThreadManager(this);
|
||||
|
||||
this._patch(data);
|
||||
}
|
||||
|
||||
@@ -78,9 +78,8 @@ class ForumChannel extends GuildChannel {
|
||||
* The emoji to show in the add reaction button on a thread in a guild forum channel
|
||||
* @type {?DefaultReactionEmoji}
|
||||
*/
|
||||
this.defaultReactionEmoji = data.default_reaction_emoji
|
||||
? transformAPIGuildDefaultReaction(data.default_reaction_emoji)
|
||||
: null;
|
||||
this.defaultReactionEmoji =
|
||||
data.default_reaction_emoji && transformAPIGuildDefaultReaction(data.default_reaction_emoji);
|
||||
} else {
|
||||
this.defaultReactionEmoji ??= null;
|
||||
}
|
||||
@@ -142,6 +141,12 @@ class ForumChannel extends GuildChannel {
|
||||
} else {
|
||||
this.defaultSortOrder ??= null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default layout type used to display posts
|
||||
* @type {ForumLayoutType}
|
||||
*/
|
||||
this.defaultForumLayout = ForumLayoutTypes[data.default_forum_layout];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,7 +156,7 @@ class ForumChannel extends GuildChannel {
|
||||
* @returns {Promise<ForumChannel>}
|
||||
*/
|
||||
setAvailableTags(availableTags, reason) {
|
||||
return this.edit({ availableTags, reason });
|
||||
return this.edit({ availableTags }, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +166,7 @@ class ForumChannel extends GuildChannel {
|
||||
* @returns {Promise<ForumChannel>}
|
||||
*/
|
||||
setDefaultReactionEmoji(defaultReactionEmoji, reason) {
|
||||
return this.edit({ defaultReactionEmoji, reason });
|
||||
return this.edit({ defaultReactionEmoji }, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,7 +176,7 @@ class ForumChannel extends GuildChannel {
|
||||
* @returns {Promise<ForumChannel>}
|
||||
*/
|
||||
setDefaultThreadRateLimitPerUser(defaultThreadRateLimitPerUser, reason) {
|
||||
return this.edit({ defaultThreadRateLimitPerUser, reason });
|
||||
return this.edit({ defaultThreadRateLimitPerUser }, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +186,17 @@ class ForumChannel extends GuildChannel {
|
||||
* @returns {Promise<ForumChannel>}
|
||||
*/
|
||||
setDefaultSortOrder(defaultSortOrder, reason) {
|
||||
return this.edit({ defaultSortOrder, reason });
|
||||
return this.edit({ defaultSortOrder }, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default forum layout type used to display posts
|
||||
* @param {ForumLayoutType} defaultForumLayout The default forum layout type to set on this channel
|
||||
* @param {string} [reason] Reason for changing the default forum layout
|
||||
* @returns {Promise<ForumChannel>}
|
||||
*/
|
||||
setDefaultForumLayout(defaultForumLayout, reason) {
|
||||
return this.edit({ defaultForumLayout }, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +230,7 @@ class ForumChannel extends GuildChannel {
|
||||
* @returns {Promise<ForumChannel>}
|
||||
*/
|
||||
setDefaultAutoArchiveDuration(defaultAutoArchiveDuration, reason) {
|
||||
return this.edit({ defaultAutoArchiveDuration, reason });
|
||||
return this.edit({ defaultAutoArchiveDuration }, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,7 +245,7 @@ class ForumChannel extends GuildChannel {
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setTopic(topic, reason) {
|
||||
return this.edit({ topic, reason });
|
||||
return this.edit({ topic }, reason);
|
||||
}
|
||||
|
||||
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
||||
|
Reference in New Issue
Block a user