mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +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;
|
||||
}
|
||||
|
||||
|
||||
11
yarn.lock
11
yarn.lock
@@ -8457,14 +8457,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"discord-api-types@npm:^0.37.20":
|
||||
version: 0.37.20
|
||||
resolution: "discord-api-types@npm:0.37.20"
|
||||
checksum: 88ebed85aada3483e83ac46a1b4574c0d59948060ac72f451d658fa646b20d62bd6f21792043621dcc5a9e9353d95c25de70646b8d2a93f0022154345800b26c
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"discord-api-types@npm:^0.37.23":
|
||||
"discord-api-types@npm:^0.37.20, discord-api-types@npm:^0.37.23":
|
||||
version: 0.37.23
|
||||
resolution: "discord-api-types@npm:0.37.23"
|
||||
checksum: 68c385366ccec523c35db4048f2c0d1fcd979fefb620ba57707dc648d0e647b817047a03682d9cac2e9e9a1642f2129ad343ac66a7a9b1e0d6bf53bc5eb11f37
|
||||
@@ -8484,7 +8477,7 @@ __metadata:
|
||||
"@sapphire/snowflake": ^3.2.2
|
||||
"@types/node": 16.18.4
|
||||
"@types/ws": ^8.5.3
|
||||
discord-api-types: ^0.37.20
|
||||
discord-api-types: ^0.37.23
|
||||
dtslint: ^4.2.1
|
||||
eslint: ^8.28.0
|
||||
eslint-formatter-pretty: ^4.1.0
|
||||
|
||||
Reference in New Issue
Block a user