Compare commits

...

10 Commits

Author SHA1 Message Date
iCrawl
0cf29abcf0 chore(formatters): release @discordjs/formatters@0.1.0 2022-12-17 16:54:06 +01:00
Jiralite
dd62be077d docs(GuildForumThreadManager): Fix sticker type (#8940) 2022-12-16 18:20:11 +01:00
Jiralite
83eafb6146 chore: Add backport label (#8942) 2022-12-16 18:19:44 +01:00
Almeida
18b3a19810 fix: add @discordjs/formatters to dependency list (#8939) 2022-12-16 17:56:29 +01:00
Almeida
c76e170786 fix(resolveColor): invalid colors (#8933)
Fixes https://github.com/discordjs/discord.js/issues/8932
2022-12-16 14:28:18 +01:00
Almeida
cbafd479b3 feat(ForumChannel): add defaultForumLayout (#8895)
* feat(ForumChannel): add `defaultForumLayout`

* fix: lockfile
2022-12-16 13:27:11 +00:00
iCrawl
19519ec9fc chore(core): release @discordjs/core@0.3.0 2022-12-16 14:10:45 +01:00
iCrawl
166f742d02 fix(core): instantiate/export role connections 2022-12-16 14:09:51 +01:00
iCrawl
7a61004627 chore(core): release @discordjs/core@0.2.0 2022-12-16 03:59:25 +01:00
iCrawl
82f4827ee5 chore(ws): release @discordjs/ws@0.6.0 2022-12-16 03:55:39 +01:00
16 changed files with 96 additions and 15 deletions

2
.github/labels.yml vendored
View File

@@ -8,6 +8,8 @@
color: fbca04
- name: backlog
color: 7ef7ef
- name: backport
color: 88aabb
- name: blocked
color: fc1423
- name: bug

View File

@@ -0,0 +1,23 @@
# Changelog
All notable changes to this project will be documented in this file.
# [@discordjs/core@0.3.0](https://github.com/discordjs/discord.js/compare/@discordjs/core@0.2.0...@discordjs/core@0.3.0) - (2022-12-16)
## Bug Fixes
- **core:** Instantiate/export role connections ([166f742](https://github.com/discordjs/discord.js/commit/166f742d02d475a5044f935ee638ae1e25075b9c))
# [@discordjs/core@0.2.0](https://github.com/discordjs/discord.js/tree/@discordjs/core@0.2.0) - (2022-12-16)
## Bug Fixes
- **thread:** `get()` route (#8897) ([3dede75](https://github.com/discordjs/discord.js/commit/3dede75621993428216196c60658e0c482aa9f61))
- Remove casts when using `makeURLSearchParams()` (#8877) ([7430c8e](https://github.com/discordjs/discord.js/commit/7430c8e4c8e299acf750b46b6146c611b0c4941d))
## Features
- **core:** Add support for role connections (#8930) ([3d6fa24](https://github.com/discordjs/discord.js/commit/3d6fa248c07b2278504bbe8bafa17a3294971fd9))
- Add links to each routes documentation (#8898) ([73300c7](https://github.com/discordjs/discord.js/commit/73300c75fae7df9af293f7c03b179236679fb753))
- **interactions:** Add `messageId` parameter to `deleteReply()` (#8896) ([3f555d5](https://github.com/discordjs/discord.js/commit/3f555d5ddf53b778fc0e69e1ff77ec93d876dcdb))
- Add `@discordjs/core` (#8736) ([2127b32](https://github.com/discordjs/discord.js/commit/2127b32d26dedeb44ec43d16ec2e2046919f9bb0))

View File

@@ -1,6 +1,6 @@
{
"name": "@discordjs/core",
"version": "0.1.0",
"version": "0.3.0",
"description": "A thinly abstracted wrapper around the rest API, and gateway.",
"scripts": {
"test": "vitest run",

View File

@@ -4,6 +4,7 @@ import { ChannelsAPI } from './channel.js';
import { GuildsAPI } from './guild.js';
import { InteractionsAPI } from './interactions.js';
import { InvitesAPI } from './invite.js';
import { RoleConnectionsAPI } from './roleConnections.js';
import { StickersAPI } from './sticker.js';
import { ThreadsAPI } from './thread.js';
import { UsersAPI } from './user.js';
@@ -15,6 +16,7 @@ export * from './channel.js';
export * from './guild.js';
export * from './interactions.js';
export * from './invite.js';
export * from './roleConnections.js';
export * from './sticker.js';
export * from './thread.js';
export * from './user.js';
@@ -32,6 +34,8 @@ export class API {
public readonly invites: InvitesAPI;
public readonly roleConnections: RoleConnectionsAPI;
public readonly stickers: StickersAPI;
public readonly threads: ThreadsAPI;
@@ -47,6 +51,7 @@ export class API {
this.channels = new ChannelsAPI(rest);
this.guilds = new GuildsAPI(rest);
this.invites = new InvitesAPI(rest);
this.roleConnections = new RoleConnectionsAPI(rest);
this.stickers = new StickersAPI(rest);
this.threads = new ThreadsAPI(rest);
this.users = new UsersAPI(rest);

View File

@@ -51,11 +51,12 @@
"dependencies": {
"@discordjs/builders": "workspace:^",
"@discordjs/collection": "workspace:^",
"@discordjs/formatters": "workspace:^",
"@discordjs/rest": "workspace:^",
"@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",

View File

@@ -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
*/

View File

@@ -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,
});

View File

@@ -18,7 +18,7 @@ class GuildForumThreadManager extends ThreadManager {
/**
* @typedef {BaseMessageOptions} GuildForumThreadMessageCreateOptions
* @property {stickers} [stickers] The stickers to send with the message
* @property {StickerResolvable} [stickers] The stickers to send with the message
* @property {BitFieldResolvable} [flags] The flags to send with the message
*/

View File

@@ -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() {}

View File

@@ -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}

View File

@@ -477,13 +477,14 @@ function resolveColor(color) {
if (typeof color === 'string') {
if (color === 'Random') return Math.floor(Math.random() * (0xffffff + 1));
if (color === 'Default') return 0;
color = Colors[color] ?? parseInt(color.replace('#', ''), 16);
if (/^#?[\da-f]{6}$/i.test(color)) return parseInt(color.replace('#', ''), 16);
color = Colors[color];
} else if (Array.isArray(color)) {
color = (color[0] << 16) + (color[1] << 8) + color[2];
}
if (color < 0 || color > 0xffffff) throw new DiscordjsRangeError(ErrorCodes.ColorRange);
else if (Number.isNaN(color)) throw new DiscordjsTypeError(ErrorCodes.ColorConvert);
if (typeof color !== 'number' || Number.isNaN(color)) throw new DiscordjsTypeError(ErrorCodes.ColorConvert);
return color;
}

View File

@@ -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;
}

View File

@@ -0,0 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.
# [@discordjs/formatters@0.1.0](https://github.com/discordjs/discord.js/tree/@discordjs/formatters@0.1.0) - (2022-12-16)
## Features
- Add `@discordjs/formatters` (#8889) ([3fca638](https://github.com/discordjs/discord.js/commit/3fca638a8470dcea2f79ddb9f18526dbc0017c88))

View File

@@ -2,6 +2,20 @@
All notable changes to this project will be documented in this file.
# [@discordjs/ws@0.6.0](https://github.com/discordjs/discord.js/compare/@discordjs/ws@0.5.0...@discordjs/ws@0.6.0) - (2022-12-16)
## Bug Fixes
- **WebSocketShard:** Send ratelimit handling (#8887) ([40b504a](https://github.com/discordjs/discord.js/commit/40b504a2088effc6a467f40ac3cf2a6d736ab209))
## Features
- **core:** Add support for role connections (#8930) ([3d6fa24](https://github.com/discordjs/discord.js/commit/3d6fa248c07b2278504bbe8bafa17a3294971fd9))
## Refactor
- **WebSocketShard:** Identify throttling (#8888) ([8f552a0](https://github.com/discordjs/discord.js/commit/8f552a0e17c0eca71063e7a4353b9b351bcdf9fd))
# [@discordjs/ws@0.5.0](https://github.com/discordjs/discord.js/compare/@discordjs/ws@0.4.1...@discordjs/ws@0.5.0) - (2022-11-28)
## Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@discordjs/ws",
"version": "0.5.0",
"version": "0.6.0",
"description": "Wrapper around Discord's gateway",
"scripts": {
"test": "vitest run",

View File

@@ -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
@@ -8478,13 +8471,14 @@ __metadata:
"@discordjs/builders": "workspace:^"
"@discordjs/collection": "workspace:^"
"@discordjs/docgen": "workspace:^"
"@discordjs/formatters": "workspace:^"
"@discordjs/rest": "workspace:^"
"@discordjs/util": "workspace:^"
"@favware/cliff-jumper": ^1.9.0
"@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