mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
feat(ForumChannel): add defaultForumLayout (#8895)
* feat(ForumChannel): add `defaultForumLayout` * fix: lockfile
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
"@discordjs/util": "workspace:^",
|
||||
"@sapphire/snowflake": "^3.2.2",
|
||||
"@types/ws": "^8.5.3",
|
||||
"discord-api-types": "^0.37.20",
|
||||
"discord-api-types": "^0.37.23",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"lodash.snakecase": "^4.1.1",
|
||||
"tslib": "^2.4.1",
|
||||
|
||||
@@ -56,6 +56,7 @@ class CategoryChannelChildManager extends DataManager {
|
||||
* @property {ThreadAutoArchiveDuration} [defaultAutoArchiveDuration]
|
||||
* The default auto archive duration for all new threads in this channel
|
||||
* @property {SortOrderType} [defaultSortOrder] The default sort order mode used to order posts (forum only).
|
||||
* @property {ForumLayoutType} [defaultForumLayout] The default layout used to display posts (forum only).
|
||||
* @property {string} [reason] Reason for creating the new channel
|
||||
*/
|
||||
|
||||
|
||||
@@ -161,6 +161,7 @@ class GuildChannelManager extends CachedManager {
|
||||
defaultReactionEmoji,
|
||||
defaultAutoArchiveDuration,
|
||||
defaultSortOrder,
|
||||
defaultForumLayout,
|
||||
reason,
|
||||
}) {
|
||||
parent &&= this.client.channels.resolveId(parent);
|
||||
@@ -184,6 +185,7 @@ class GuildChannelManager extends CachedManager {
|
||||
default_reaction_emoji: defaultReactionEmoji && transformGuildDefaultReaction(defaultReactionEmoji),
|
||||
default_auto_archive_duration: defaultAutoArchiveDuration,
|
||||
default_sort_order: defaultSortOrder,
|
||||
default_forum_layout: defaultForumLayout,
|
||||
},
|
||||
reason,
|
||||
});
|
||||
@@ -252,6 +254,7 @@ class GuildChannelManager extends CachedManager {
|
||||
* @property {number} [defaultThreadRateLimitPerUser] The rate limit per user (slowmode) to set on forum posts
|
||||
* @property {ChannelFlagsResolvable} [flags] The flags to set on the channel
|
||||
* @property {?SortOrderType} [defaultSortOrder] The default sort order mode to set on the channel
|
||||
* @property {ForumLayoutType} [defaultForumLayout] The default forum layout to set on the channel
|
||||
* @property {string} [reason] Reason for editing this channel
|
||||
*/
|
||||
|
||||
@@ -314,6 +317,7 @@ class GuildChannelManager extends CachedManager {
|
||||
default_thread_rate_limit_per_user: options.defaultThreadRateLimitPerUser,
|
||||
flags: 'flags' in options ? ChannelFlagsBitField.resolve(options.flags) : undefined,
|
||||
default_sort_order: options.defaultSortOrder,
|
||||
default_forum_layout: options.defaultForumLayout,
|
||||
},
|
||||
reason: options.reason,
|
||||
});
|
||||
|
||||
@@ -134,6 +134,12 @@ class ForumChannel extends GuildChannel {
|
||||
} else {
|
||||
this.defaultSortOrder ??= null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default layout type used to display posts
|
||||
* @type {ForumLayoutType}
|
||||
*/
|
||||
this.defaultForumLayout = data.default_forum_layout;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,6 +231,16 @@ class ForumChannel extends GuildChannel {
|
||||
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 });
|
||||
}
|
||||
|
||||
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
||||
/* eslint-disable no-empty-function */
|
||||
createWebhook() {}
|
||||
|
||||
@@ -218,6 +218,11 @@
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ComponentType}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external ForumLayoutType
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ForumLayoutType}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external GatewayCloseCodes
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/GatewayCloseCodes}
|
||||
|
||||
5
packages/discord.js/typings/index.d.ts
vendored
5
packages/discord.js/typings/index.d.ts
vendored
@@ -149,6 +149,7 @@ import {
|
||||
AuditLogRuleTriggerType,
|
||||
GatewayAutoModerationActionExecutionDispatchData,
|
||||
APIAutoModerationRule,
|
||||
ForumLayoutType,
|
||||
} from 'discord-api-types/v10';
|
||||
import { ChildProcess } from 'node:child_process';
|
||||
import { EventEmitter } from 'node:events';
|
||||
@@ -2253,6 +2254,7 @@ export class ForumChannel extends TextBasedChannelMixin(GuildChannel, true, [
|
||||
public nsfw: boolean;
|
||||
public topic: string | null;
|
||||
public defaultSortOrder: SortOrderType | null;
|
||||
public defaultForumLayout: ForumLayoutType;
|
||||
|
||||
public setAvailableTags(tags: GuildForumTagData[], reason?: string): Promise<this>;
|
||||
public setDefaultReactionEmoji(emojiId: DefaultReactionEmoji | null, reason?: string): Promise<this>;
|
||||
@@ -2265,6 +2267,7 @@ export class ForumChannel extends TextBasedChannelMixin(GuildChannel, true, [
|
||||
): Promise<this>;
|
||||
public setTopic(topic: string | null, reason?: string): Promise<this>;
|
||||
public setDefaultSortOrder(defaultSortOrder: SortOrderType | null, reason?: string): Promise<this>;
|
||||
public setDefaultForumLayout(defaultForumLayout: ForumLayoutType, reason?: string): Promise<this>;
|
||||
}
|
||||
|
||||
export class PermissionOverwrites extends Base {
|
||||
@@ -4584,6 +4587,7 @@ export interface CategoryCreateChannelOptions {
|
||||
defaultReactionEmoji?: DefaultReactionEmoji;
|
||||
defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;
|
||||
defaultSortOrder?: SortOrderType;
|
||||
defaultForumLayout?: ForumLayoutType;
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
@@ -5334,6 +5338,7 @@ export interface GuildChannelEditOptions {
|
||||
defaultThreadRateLimitPerUser?: number;
|
||||
flags?: ChannelFlagsResolvable;
|
||||
defaultSortOrder?: SortOrderType | null;
|
||||
defaultForumLayout?: ForumLayoutType;
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user