From 48e404db5547c8ce3f314724567ac445b0b5b682 Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sun, 23 Apr 2023 14:55:07 +0200 Subject: [PATCH 01/11] docs(BaseMessageOptions): Fix embeds and components (#9437) Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- src/structures/interfaces/TextBasedChannel.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/structures/interfaces/TextBasedChannel.js b/src/structures/interfaces/TextBasedChannel.js index a05a1281c118..3bafa43246c8 100644 --- a/src/structures/interfaces/TextBasedChannel.js +++ b/src/structures/interfaces/TextBasedChannel.js @@ -58,12 +58,12 @@ class TextBasedChannel { * @property {boolean} [tts=false] Whether or not the message should be spoken aloud * @property {string} [nonce=''] The nonce for the message * @property {string} [content=''] The content for the message - * @property {MessageEmbed[]|APIEmbed[]} [embeds] The embeds for the message + * @property {Array<(MessageEmbed|APIEmbed)>} [embeds] The embeds for the message * (see [here](https://discord.com/developers/docs/resources/channel#embed-object) for more details) * @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content * (see [here](https://discord.com/developers/docs/resources/channel#allowed-mentions-object) for more details) - * @property {FileOptions[]|BufferResolvable[]|MessageAttachment[]} [files] Files to send with the message - * @property {MessageActionRow[]|MessageActionRowOptions[]} [components] + * @property {Array<(FileOptions|BufferResolvable|MessageAttachment[])>} [files] Files to send with the message + * @property {Array<(MessageActionRow|MessageActionRowOptions)>} [components] * Action rows containing interactive components for the message (buttons, select menus) * @property {MessageAttachment[]} [attachments] Attachments to send in the message */ From 6513c418543f1dc39b596a80802d53f0b16c042e Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sun, 23 Apr 2023 15:03:25 +0200 Subject: [PATCH 02/11] docs(Options): fix links and invalid syntax (#9322) Co-authored-by: Almeida --- src/util/Options.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/Options.js b/src/util/Options.js index f2420dc21cd0..e77c1c87276f 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -251,7 +251,7 @@ class Options extends null { } /** - * The default settings passed to {@link Options.cacheWithLimits}. + * The default settings passed to {@link ClientOptions.makeCache}. * The caches that this changes are: * * `MessageManager` - Limit to 200 messages * * `ChannelManager` - Sweep archived threads @@ -281,11 +281,11 @@ class Options extends null { } /** - * The default settings passed to {@link Options.sweepers} (for v14). + * The default settings passed to {@link ClientOptions.sweepers}. * The sweepers that this changes are: * * `threads` - Sweep archived threads every hour, removing those archived more than 4 hours ago * If you want to keep default behavior and add on top of it you can use this object and add on to it, e.g. - * `sweepers: { ...Options.defaultSweeperSettings, messages: { interval: 300, lifetime: 600 } })` + * `sweepers: { ...Options.defaultSweeperSettings, messages: { interval: 300, lifetime: 600 } }` * @type {SweeperOptions} */ Options.defaultSweeperSettings = { From eb8cdd7864977e8783490db8791799dd2d974ab0 Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sun, 23 Apr 2023 15:08:10 +0200 Subject: [PATCH 03/11] feat: new website links --- README.md | 4 ++-- docs/README.md | 2 +- src/client/Client.js | 2 +- src/managers/ApplicationCommandManager.js | 4 ++-- src/util/LimitedCollection.js | 2 +- src/util/Sweepers.js | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0e639918f548..95b274d7d3d7 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ client.login('token'); ## Links - [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website)) -- [Documentation](https://discord.js.org/#/docs) +- [Documentation](https://discord.js.org/docs) - [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide)) See also the [Update Guide](https://discordjs.guide/additional-info/changes-in-v13.html), including updated and removed items in the library. - [discord.js Discord server](https://discord.gg/djs) @@ -116,7 +116,7 @@ client.login('token'); ## Contributing Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the -[documentation](https://discord.js.org/#/docs). +[documentation](https://discord.js.org/docs). See [the contribution guide](https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md) if you'd like to submit a PR. ## Help diff --git a/docs/README.md b/docs/README.md index b5ac7978f77d..f19a16b0494f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1 +1 @@ -## [View the documentation here.](https://discord.js.org/#/docs) +## [View the documentation here.](https://discord.js.org/docs) diff --git a/src/client/Client.js b/src/client/Client.js index d770e8f01dd3..06e9130a39e9 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -617,5 +617,5 @@ module.exports = Client; /** * @external Collection - * @see {@link https://discord.js.org/#/docs/collection/main/class/Collection} + * @see {@link https://discord.js.org/docs/packages/collection/main/Collection:Class} */ diff --git a/src/managers/ApplicationCommandManager.js b/src/managers/ApplicationCommandManager.js index 41870fbeb64c..0a3414ad8d91 100644 --- a/src/managers/ApplicationCommandManager.js +++ b/src/managers/ApplicationCommandManager.js @@ -255,10 +255,10 @@ module.exports = ApplicationCommandManager; /** * @external SlashCommandBuilder - * @see {@link https://discord.js.org/#/docs/builders/main/class/SlashCommandBuilder} + * @see {@link https://discord.js.org/docs/packages/builders/main/SlashCommandBuilder:Class} */ /** * @external ContextMenuCommandBuilder - * @see {@link https://discord.js.org/#/docs/builders/main/class/ContextMenuCommandBuilder} + * @see {@link https://discord.js.org/docs/packages/builders/main/ContextMenuCommandBuilder:Class} */ diff --git a/src/util/LimitedCollection.js b/src/util/LimitedCollection.js index 8ebda0e34bf8..7c793be16424 100644 --- a/src/util/LimitedCollection.js +++ b/src/util/LimitedCollection.js @@ -10,7 +10,7 @@ const { TypeError } = require('../errors/DJSError.js'); * @typedef {Function} SweepFilter * @param {LimitedCollection} collection The collection being swept * @returns {Function|null} Return `null` to skip sweeping, otherwise a function passed to `sweep()`, - * See {@link [Collection#sweep](https://discord.js.org/#/docs/collection/main/class/Collection?scrollTo=sweep)} + * See {@link [Collection#sweep](https://discord.js.org/docs/packages/collection/main/Collection:Class#sweep)} * for the definition of this function. */ diff --git a/src/util/Sweepers.js b/src/util/Sweepers.js index a104d3f4c0ed..d02f0d4db953 100644 --- a/src/util/Sweepers.js +++ b/src/util/Sweepers.js @@ -7,7 +7,7 @@ const { TypeError } = require('../errors/DJSError.js'); /** * @typedef {Function} GlobalSweepFilter * @returns {Function|null} Return `null` to skip sweeping, otherwise a function passed to `sweep()`, - * See {@link [Collection#sweep](https://discord.js.org/#/docs/collection/main/class/Collection?scrollTo=sweep)} + * See {@link [Collection#sweep](https://discord.js.org/docs/packages/collection/main/Collection:Class#sweep)} * for the definition of this function. */ From dffb60bd4f377ae565fb154130ca9bf1718cbc32 Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sun, 23 Apr 2023 15:10:35 +0200 Subject: [PATCH 04/11] type(GuildTextBasedChannel): remove exclusion of forum channels (#9326) Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- typings/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index cc7ca061e8d8..5dbdc0053a65 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -6387,7 +6387,7 @@ export type GuildBasedChannel = Extract; export type NonThreadGuildBasedChannel = Exclude; -export type GuildTextBasedChannel = Exclude, ForumChannel>; +export type GuildTextBasedChannel = Extract; export type TextChannelResolvable = Snowflake | TextChannel; From 2b0e627bd255aef1c1ec784212e619528fc4abb4 Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sun, 23 Apr 2023 15:13:02 +0200 Subject: [PATCH 05/11] refactor: Remove fromInteraction in internal channel creation (#9335) Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- src/managers/ChannelManager.js | 6 +++--- src/structures/Channel.js | 4 ++-- src/structures/ThreadChannel.js | 4 ++-- typings/index.d.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/managers/ChannelManager.js b/src/managers/ChannelManager.js index 06b25dc74825..785d6fff23a3 100644 --- a/src/managers/ChannelManager.js +++ b/src/managers/ChannelManager.js @@ -33,10 +33,10 @@ class ChannelManager extends CachedManager { * @name ChannelManager#cache */ - _add(data, guild, { cache = true, allowUnknownGuild = false, fromInteraction = false } = {}) { + _add(data, guild, { cache = true, allowUnknownGuild = false } = {}) { const existing = this.cache.get(data.id); if (existing) { - if (cache) existing._patch(data, fromInteraction); + if (cache) existing._patch(data); guild?.channels?._add(existing); if (ThreadChannelTypes.includes(existing.type)) { existing.parent?.threads?._add(existing); @@ -44,7 +44,7 @@ class ChannelManager extends CachedManager { return existing; } - const channel = Channel.create(this.client, data, guild, { allowUnknownGuild, fromInteraction }); + const channel = Channel.create(this.client, data, guild, { allowUnknownGuild }); if (!channel) { this.client.emit(Events.DEBUG, `Failed to find guild, or unknown type for channel ${data.id} ${data.type}`); diff --git a/src/structures/Channel.js b/src/structures/Channel.js index 50dfcefb55bf..cdffc3a2008a 100644 --- a/src/structures/Channel.js +++ b/src/structures/Channel.js @@ -186,7 +186,7 @@ class Channel extends Base { return this.type === 'GUILD_DIRECTORY'; } - static create(client, data, guild, { allowUnknownGuild, fromInteraction } = {}) { + static create(client, data, guild, { allowUnknownGuild } = {}) { CategoryChannel ??= require('./CategoryChannel'); DMChannel ??= require('./DMChannel'); NewsChannel ??= require('./NewsChannel'); @@ -238,7 +238,7 @@ class Channel extends Base { case ChannelTypes.GUILD_NEWS_THREAD: case ChannelTypes.GUILD_PUBLIC_THREAD: case ChannelTypes.GUILD_PRIVATE_THREAD: { - channel = new ThreadChannel(guild, data, client, fromInteraction); + channel = new ThreadChannel(guild, data, client); if (!allowUnknownGuild) channel.parent?.threads.cache.set(channel.id, channel); break; } diff --git a/src/structures/ThreadChannel.js b/src/structures/ThreadChannel.js index c635cb3888f9..0f3b7c6a89d4 100644 --- a/src/structures/ThreadChannel.js +++ b/src/structures/ThreadChannel.js @@ -15,7 +15,7 @@ const { resolveAutoArchiveMaxLimit } = require('../util/Util'); * @implements {TextBasedChannel} */ class ThreadChannel extends Channel { - constructor(guild, data, client, fromInteraction = false) { + constructor(guild, data, client) { super(guild?.client ?? client, data, false); /** @@ -41,7 +41,7 @@ class ThreadChannel extends Channel { * @type {ThreadMemberManager} */ this.members = new ThreadMemberManager(this); - if (data) this._patch(data, fromInteraction); + if (data) this._patch(data); } _patch(data, partial = false) { diff --git a/typings/index.d.ts b/typings/index.d.ts index 5dbdc0053a65..f51c237cc9a0 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2592,7 +2592,7 @@ export class TextInputComponent extends BaseMessageComponent { } export class ThreadChannel extends TextBasedChannelMixin(Channel, ['fetchWebhooks', 'createWebhook', 'setNSFW']) { - private constructor(guild: Guild, data?: RawThreadChannelData, client?: Client, fromInteraction?: boolean); + private constructor(guild: Guild, data?: RawThreadChannelData, client?: Client); public archived: boolean | null; public readonly archivedAt: Date | null; public archiveTimestamp: number | null; From bb7ce543f5fe953767f19b5f96b5d8b92c8c7223 Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sun, 23 Apr 2023 15:21:39 +0200 Subject: [PATCH 06/11] type(CategoryChannel): Ensure parent and parentId are null (#9327) Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- src/structures/CategoryChannel.js | 15 ++++++++++++++- typings/index.d.ts | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/structures/CategoryChannel.js b/src/structures/CategoryChannel.js index 831b787bc4b1..6a1574b3e794 100644 --- a/src/structures/CategoryChannel.js +++ b/src/structures/CategoryChannel.js @@ -7,6 +7,19 @@ const GuildChannel = require('./GuildChannel'); * @extends {GuildChannel} */ class CategoryChannel extends GuildChannel { + /** + * The id of the parent of this channel. + * @name CategoryChannel#parentId + * @type {null} + */ + + /** + * The parent of this channel. + * @name CategoryChannel#parent + * @type {null} + * @readonly + */ + /** * Channels that are a part of this category * @type {Collection} @@ -18,7 +31,7 @@ class CategoryChannel extends GuildChannel { /** * Sets the category parent of this channel. - * It is not currently possible to set the parent of a CategoryChannel. + * It is not possible to set the parent of a CategoryChannel. * @method setParent * @memberof CategoryChannel * @instance diff --git a/typings/index.d.ts b/typings/index.d.ts index f51c237cc9a0..0503ae83083f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -573,6 +573,8 @@ export type CategoryChannelTypes = ExcludeEnum< export class CategoryChannel extends GuildChannel { public readonly children: Collection>; + public static parent: null; + public parentId: null; public type: 'GUILD_CATEGORY'; public createChannel>( From f8806aedeed9e74bc08ae9a3e963f75d18c6163a Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sun, 23 Apr 2023 20:59:44 +0200 Subject: [PATCH 07/11] fix: requested changes Co-authored-by: kyranet --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 95b274d7d3d7..6c994e178b0d 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ client.login('token'); ## Links - [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website)) -- [Documentation](https://discord.js.org/docs) +- [Documentation](https://old.discordjs.dev/#/docs) - [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide)) See also the [Update Guide](https://discordjs.guide/additional-info/changes-in-v13.html), including updated and removed items in the library. - [discord.js Discord server](https://discord.gg/djs) From 4a15cc93ca4256a9a000ccc07f7e037cbec8d5c8 Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sun, 23 Apr 2023 21:04:57 +0200 Subject: [PATCH 08/11] perf(RoleManager): dont call Role#position getter twice per role (#9352) Co-authored-by: Almeida --- README.md | 2 +- docs/README.md | 2 +- src/managers/RoleManager.js | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6c994e178b0d..29b386423755 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ client.login('token'); ## Contributing Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the -[documentation](https://discord.js.org/docs). +[documentation](https://old.discord.js.org/#/docs). See [the contribution guide](https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md) if you'd like to submit a PR. ## Help diff --git a/docs/README.md b/docs/README.md index f19a16b0494f..b2ea7f6e6ba7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1 +1 @@ -## [View the documentation here.](https://discord.js.org/docs) +## [View the documentation here.](https://old.discord.js.org/#/docs) diff --git a/src/managers/RoleManager.js b/src/managers/RoleManager.js index f3041b84e5fa..a68fcf270375 100644 --- a/src/managers/RoleManager.js +++ b/src/managers/RoleManager.js @@ -299,11 +299,14 @@ class RoleManager extends CachedManager { const resolvedRole2 = this.resolve(role2); if (!resolvedRole1 || !resolvedRole2) throw new TypeError('INVALID_TYPE', 'role', 'Role nor a Snowflake'); - if (resolvedRole1.position === resolvedRole2.position) { + const role1Position = resolvedRole1.position; + const role2Position = resolvedRole2.position; + + if (role1Position === role2Position) { return Number(BigInt(resolvedRole2.id) - BigInt(resolvedRole1.id)); } - return resolvedRole1.position - resolvedRole2.position; + return role1Position - role2Position; } /** From cf72962a60e6336b5758af2f2b60d4abb80cd80e Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sun, 23 Apr 2023 21:11:42 +0200 Subject: [PATCH 09/11] fix: bad url --- README.md | 2 +- docs/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 29b386423755..f0b36cf2522d 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ client.login('token'); ## Contributing Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the -[documentation](https://old.discord.js.org/#/docs). +[documentation](https://old.discordjs.dev/#/docs). See [the contribution guide](https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md) if you'd like to submit a PR. ## Help diff --git a/docs/README.md b/docs/README.md index b2ea7f6e6ba7..5b2aa0c2a41d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1 +1 @@ -## [View the documentation here.](https://old.discord.js.org/#/docs) +## [View the documentation here.](https://old.discordjs.dev/#/docs) From 94933eae2f6d3970089428feabc52adafc830e62 Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sun, 23 Apr 2023 21:39:58 +0200 Subject: [PATCH 10/11] Update README.md Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f0b36cf2522d..957b10b40c5f 100644 --- a/README.md +++ b/README.md @@ -101,8 +101,8 @@ client.login('token'); - [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website)) - [Documentation](https://old.discordjs.dev/#/docs) -- [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide)) - See also the [Update Guide](https://discordjs.guide/additional-info/changes-in-v13.html), including updated and removed items in the library. +- [Guide](https://v13.discordjs.guide) ([source](https://github.com/discordjs/guide/tree/v13)) + See also the [Update Guide](https://v13.discordjs.guide/additional-info/changes-in-v13.html), including updated and removed items in the library. - [discord.js Discord server](https://discord.gg/djs) - [Discord API Discord server](https://discord.gg/discord-api) - [GitHub](https://github.com/discordjs/discord.js) From feffeab7d1bd33fee406bfb8c3f6e05b600c454f Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Mon, 1 May 2023 18:40:41 +0200 Subject: [PATCH 11/11] feat: use stable version --- src/client/Client.js | 2 +- src/managers/ApplicationCommandManager.js | 4 ++-- src/util/LimitedCollection.js | 2 +- src/util/Sweepers.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/Client.js b/src/client/Client.js index 06e9130a39e9..5fa052fb5f42 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -617,5 +617,5 @@ module.exports = Client; /** * @external Collection - * @see {@link https://discord.js.org/docs/packages/collection/main/Collection:Class} + * @see {@link https://discord.js.org/docs/packages/collection/stable/Collection:Class} */ diff --git a/src/managers/ApplicationCommandManager.js b/src/managers/ApplicationCommandManager.js index 0a3414ad8d91..57f6f4bfab70 100644 --- a/src/managers/ApplicationCommandManager.js +++ b/src/managers/ApplicationCommandManager.js @@ -255,10 +255,10 @@ module.exports = ApplicationCommandManager; /** * @external SlashCommandBuilder - * @see {@link https://discord.js.org/docs/packages/builders/main/SlashCommandBuilder:Class} + * @see {@link https://discord.js.org/docs/packages/builders/stable/SlashCommandBuilder:Class} */ /** * @external ContextMenuCommandBuilder - * @see {@link https://discord.js.org/docs/packages/builders/main/ContextMenuCommandBuilder:Class} + * @see {@link https://discord.js.org/docs/packages/builders/stable/ContextMenuCommandBuilder:Class} */ diff --git a/src/util/LimitedCollection.js b/src/util/LimitedCollection.js index 7c793be16424..956639d3f162 100644 --- a/src/util/LimitedCollection.js +++ b/src/util/LimitedCollection.js @@ -10,7 +10,7 @@ const { TypeError } = require('../errors/DJSError.js'); * @typedef {Function} SweepFilter * @param {LimitedCollection} collection The collection being swept * @returns {Function|null} Return `null` to skip sweeping, otherwise a function passed to `sweep()`, - * See {@link [Collection#sweep](https://discord.js.org/docs/packages/collection/main/Collection:Class#sweep)} + * See {@link [Collection#sweep](https://discord.js.org/docs/packages/collection/stable/Collection:Class#sweep)} * for the definition of this function. */ diff --git a/src/util/Sweepers.js b/src/util/Sweepers.js index d02f0d4db953..76848c52f7c7 100644 --- a/src/util/Sweepers.js +++ b/src/util/Sweepers.js @@ -7,7 +7,7 @@ const { TypeError } = require('../errors/DJSError.js'); /** * @typedef {Function} GlobalSweepFilter * @returns {Function|null} Return `null` to skip sweeping, otherwise a function passed to `sweep()`, - * See {@link [Collection#sweep](https://discord.js.org/docs/packages/collection/main/Collection:Class#sweep)} + * See {@link [Collection#sweep](https://discord.js.org/docs/packages/collection/stable/Collection:Class#sweep)} * for the definition of this function. */