From c78407e751397be3eb30a5de36894ee8c9139084 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Fri, 7 Mar 2025 20:15:54 +0000 Subject: [PATCH 1/3] fix(GuildMemberManager): Ensure empty object for fetching many guild members (#10796) fix(GuildMemberManager): pass empty object for fetching many --- packages/discord.js/src/managers/GuildMemberManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/discord.js/src/managers/GuildMemberManager.js b/packages/discord.js/src/managers/GuildMemberManager.js index 383dda8a2cfc..cc7db3c20648 100644 --- a/packages/discord.js/src/managers/GuildMemberManager.js +++ b/packages/discord.js/src/managers/GuildMemberManager.js @@ -223,7 +223,7 @@ class GuildMemberManager extends CachedManager { query: initialQuery, time = 120e3, nonce = DiscordSnowflake.generate().toString(), - }) { + } = {}) { if (nonce.length > 32) throw new DiscordjsRangeError(ErrorCodes.MemberFetchNonceLength); const query = initialQuery || (!users ? '' : undefined); From 12638cd43cf57ce0ddb1aab517c9c14d1f238217 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Fri, 7 Mar 2025 20:19:14 +0000 Subject: [PATCH 2/3] fix(embed): Allow attachment protocols for thumbnails and images (#10795) fix(embed): allow attachment protocols for thumbnails and images Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../builders/__tests__/messages/embed.test.ts | 12 +++++++++++ .../builders/src/messages/embed/Assertions.ts | 20 +++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/packages/builders/__tests__/messages/embed.test.ts b/packages/builders/__tests__/messages/embed.test.ts index 65097ef23cb8..5b04b51dd30d 100644 --- a/packages/builders/__tests__/messages/embed.test.ts +++ b/packages/builders/__tests__/messages/embed.test.ts @@ -207,6 +207,12 @@ describe('Embed', () => { expect(embed.toJSON()).toStrictEqual({ ...base, thumbnail: { url: 'https://discord.js.org/static/logo.svg' } }); }); + test('GIVEN an embed using Embed#setThumbnail with attachment protocol THEN returns valid toJSON data', () => { + const embed = new EmbedBuilder(); + embed.setThumbnail('attachment://discordjs.webp'); + expect(embed.toJSON()).toStrictEqual({ ...base, thumbnail: { url: 'attachment://discordjs.webp' } }); + }); + test('GIVEN an embed with a pre-defined thumbnail THEN unset thumbnail THEN return valid toJSON data', () => { const embed = new EmbedBuilder({ thumbnail: { url: 'https://discord.js.org/static/logo.svg' }, ...dummy }); embed.clearThumbnail(); @@ -228,6 +234,12 @@ describe('Embed', () => { expect(embed.toJSON()).toStrictEqual({ ...base, image: { url: 'https://discord.js.org/static/logo.svg' } }); }); + test('GIVEN an embed using Embed#setImage with attachment protocol THEN returns valid toJSON data', () => { + const embed = new EmbedBuilder(); + embed.setImage('attachment://discordjs.webp'); + expect(embed.toJSON()).toStrictEqual({ ...base, image: { url: 'attachment://discordjs.webp' } }); + }); + test('GIVEN an embed using Embed#setImage THEN returns valid toJSON data', () => { const embed = new EmbedBuilder(); embed.setImage('https://discord.js.org/static/logo.svg'); diff --git a/packages/builders/src/messages/embed/Assertions.ts b/packages/builders/src/messages/embed/Assertions.ts index 9f7f06a47daa..aea6d805f396 100644 --- a/packages/builders/src/messages/embed/Assertions.ts +++ b/packages/builders/src/messages/embed/Assertions.ts @@ -4,17 +4,17 @@ import { embedLength } from '../../util/componentUtil.js'; const namePredicate = z.string().max(256); -const iconURLPredicate = z +const URLPredicate = z .string() .url() - .refine(refineURLPredicate(['http:', 'https:', 'attachment:']), { - message: 'Invalid protocol for icon URL. Must be http:, https:, or attachment:', - }); + .refine(refineURLPredicate(['http:', 'https:']), { message: 'Invalid protocol for URL. Must be http: or https:' }); -const URLPredicate = z +const URLWithAttachmentProtocolPredicate = z .string() .url() - .refine(refineURLPredicate(['http:', 'https:']), { message: 'Invalid protocol for URL. Must be http: or https:' }); + .refine(refineURLPredicate(['http:', 'https:', 'attachment:']), { + message: 'Invalid protocol for URL. Must be http:, https:, or attachment:', + }); export const embedFieldPredicate = z.object({ name: namePredicate, @@ -24,13 +24,13 @@ export const embedFieldPredicate = z.object({ export const embedAuthorPredicate = z.object({ name: namePredicate.min(1), - icon_url: iconURLPredicate.optional(), + icon_url: URLWithAttachmentProtocolPredicate.optional(), url: URLPredicate.optional(), }); export const embedFooterPredicate = z.object({ text: z.string().min(1).max(2_048), - icon_url: iconURLPredicate.optional(), + icon_url: URLWithAttachmentProtocolPredicate.optional(), }); export const embedPredicate = z @@ -41,8 +41,8 @@ export const embedPredicate = z timestamp: z.string().optional(), color: z.number().int().min(0).max(0xffffff).optional(), footer: embedFooterPredicate.optional(), - image: z.object({ url: URLPredicate }).optional(), - thumbnail: z.object({ url: URLPredicate }).optional(), + image: z.object({ url: URLWithAttachmentProtocolPredicate }).optional(), + thumbnail: z.object({ url: URLWithAttachmentProtocolPredicate }).optional(), author: embedAuthorPredicate.optional(), fields: z.array(embedFieldPredicate).max(25).optional(), }) From ab6a69401e7de81a7c619d82b9f00741dfae3af4 Mon Sep 17 00:00:00 2001 From: Almeida Date: Fri, 7 Mar 2025 21:23:42 +0000 Subject: [PATCH 3/3] docs: remove hardcoded locale from links (#10794) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .github/CODEOWNERS | 2 +- .github/workflows/cleanup-cache.yml | 2 +- packages/builders/src/components/ActionRow.ts | 2 +- .../components/selectMenu/StringSelectMenu.ts | 2 +- .../mixins/SharedChatInputCommandOptions.ts | 2 +- .../builders/src/interactions/modals/Modal.ts | 2 +- packages/builders/src/messages/embed/Embed.ts | 2 +- packages/builders/src/messages/poll/Poll.ts | 2 +- packages/collection/src/collection.ts | 42 +++++++++---------- packages/discord.js/src/client/Client.js | 4 +- .../src/structures/interfaces/Collector.js | 2 +- packages/rest/src/lib/REST.ts | 4 +- 12 files changed, 34 insertions(+), 34 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8ff450037ad0..f1d33f58a0b1 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,5 +1,5 @@ # Learn how to add code owners here: -# https://help.github.com/en/articles/about-code-owners +# https://help.github.com/articles/about-code-owners * @iCrawl diff --git a/.github/workflows/cleanup-cache.yml b/.github/workflows/cleanup-cache.yml index 93fedb93e90b..a7638de71f0e 100644 --- a/.github/workflows/cleanup-cache.yml +++ b/.github/workflows/cleanup-cache.yml @@ -1,4 +1,4 @@ -# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries +# https://docs.github.com/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries name: Cleanup caches on: pull_request: diff --git a/packages/builders/src/components/ActionRow.ts b/packages/builders/src/components/ActionRow.ts index 9d099356fd84..31ad306fbf44 100644 --- a/packages/builders/src/components/ActionRow.ts +++ b/packages/builders/src/components/ActionRow.ts @@ -297,7 +297,7 @@ export class ActionRowBuilder extends ComponentBuilder { * * @remarks * This method behaves similarly - * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}. + * to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}. * The maximum amount of fields that can be added is 25. * * It's useful for modifying and adjusting order of the already-existing fields of an embed. diff --git a/packages/builders/src/messages/poll/Poll.ts b/packages/builders/src/messages/poll/Poll.ts index 837c9e6fdb18..59ce2f015451 100644 --- a/packages/builders/src/messages/poll/Poll.ts +++ b/packages/builders/src/messages/poll/Poll.ts @@ -82,7 +82,7 @@ export class PollBuilder implements JSONEncodable { * * @remarks * This method behaves similarly - * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}. + * to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}. * The maximum amount of answers that can be added is 10. * * It's useful for modifying and adjusting order of the already-existing answers of a poll. diff --git a/packages/collection/src/collection.ts b/packages/collection/src/collection.ts index 9d0a7c7f4f6d..66fc07562b99 100644 --- a/packages/collection/src/collection.ts +++ b/packages/collection/src/collection.ts @@ -148,7 +148,7 @@ export class Collection extends Map { } /** - * Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}. + * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}. * Returns the item at a given index, allowing for positive and negative integers. * Negative integers count back from the last item in the collection. * @@ -172,7 +172,7 @@ export class Collection extends Map { } /** - * Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}. + * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}. * Returns the key at a given index, allowing for positive and negative integers. * Negative integers count back from the last item in the collection. * @@ -240,7 +240,7 @@ export class Collection extends Map { } /** - * Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()} + * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()} * but returns a Collection instead of an Array. */ public reverse() { @@ -252,10 +252,10 @@ export class Collection extends Map { /** * Searches for a single item where the given function returns a truthy value. This behaves like - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}. + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}. * All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you * should use the `get` method. See - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details. + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details. * * @param fn - The function to test with (should return a boolean) * @param thisArg - Value to use as `this` when executing the function @@ -288,7 +288,7 @@ export class Collection extends Map { /** * Searches for the key of a single item where the given function returns a truthy value. This behaves like - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()}, + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()}, * but returns the key rather than the positional index. * * @param fn - The function to test with (should return a boolean) @@ -322,7 +322,7 @@ export class Collection extends Map { /** * Searches for a last item where the given function returns a truthy value. This behaves like - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | Array.findLast()}. + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | Array.findLast()}. * * @param fn - The function to test with (should return a boolean) * @param thisArg - Value to use as `this` when executing the function @@ -354,7 +354,7 @@ export class Collection extends Map { /** * Searches for the key of a last item where the given function returns a truthy value. This behaves like - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex | Array.findLastIndex()}, + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex | Array.findLastIndex()}, * but returns the key rather than the positional index. * * @param fn - The function to test with (should return a boolean) @@ -407,7 +407,7 @@ export class Collection extends Map { /** * Identical to - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()}, + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()}, * but returns a Collection instead of an Array. * * @param fn - The function to test with (should return a boolean) @@ -502,7 +502,7 @@ export class Collection extends Map { /** * Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}. + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}. * * @param fn - Function that produces a new Collection * @param thisArg - Value to use as `this` when executing the function @@ -529,7 +529,7 @@ export class Collection extends Map { /** * Maps each item to another value into an array. Identical in behavior to - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}. + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}. * * @param fn - Function that produces an element of the new array, taking three arguments * @param thisArg - Value to use as `this` when executing the function @@ -559,7 +559,7 @@ export class Collection extends Map { /** * Maps each item to another value into a collection. Identical in behavior to - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}. + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}. * * @param fn - Function that produces an element of the new collection, taking three arguments * @param thisArg - Value to use as `this` when executing the function @@ -586,7 +586,7 @@ export class Collection extends Map { /** * Checks if there exists an item that passes a test. Identical in behavior to - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}. + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}. * * @param fn - Function used to test (should return a boolean) * @param thisArg - Value to use as `this` when executing the function @@ -609,7 +609,7 @@ export class Collection extends Map { /** * Checks if all items passes a test. Identical in behavior to - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}. + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}. * * @param fn - Function used to test (should return a boolean) * @param thisArg - Value to use as `this` when executing the function @@ -646,7 +646,7 @@ export class Collection extends Map { /** * Applies a function to produce a single value. Identical in behavior to - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}. + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}. * * @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`, * and `collection` @@ -688,7 +688,7 @@ export class Collection extends Map { /** * Applies a function to produce a single value. Identical in behavior to - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight | Array.reduceRight()}. + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight | Array.reduceRight()}. * * @param fn - Function used to reduce, taking four arguments; `accumulator`, `value`, `key`, and `collection` * @param initialValue - Starting value for the accumulator @@ -730,7 +730,7 @@ export class Collection extends Map { /** * Identical to - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()}, + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()}, * but returns the collection instead of undefined. * * @param fn - Function to execute for each element @@ -832,7 +832,7 @@ export class Collection extends Map { /** * The sort method sorts the items of a collection in place and returns it. * If a comparison function is not provided, the function sorts by element values, using the same stringwise comparison algorithm as - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | Array.sort()}. + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | Array.sort()}. * * @param compareFunction - Specifies a function that defines the sort order. The return value of this function should be negative if * `a` comes before `b`, positive if `b` comes before `a`, or zero if `a` and `b` are considered equal. @@ -1017,7 +1017,7 @@ export class Collection extends Map { } /** - * Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed | Array.toReversed()} + * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed | Array.toReversed()} * but returns a Collection instead of an Array. */ public toReversed() { @@ -1027,7 +1027,7 @@ export class Collection extends Map { /** * The toSorted method returns a shallow copy of the collection with the items sorted. * If a comparison function is not provided, the function sorts by element values, using the same stringwise comparison algorithm as - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | Array.sort()}. + * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | Array.sort()}. * * @param compareFunction - Specifies a function that defines the sort order. The return value of this function should be negative if * `a` comes before `b`, positive if `b` comes before `a`, or zero if `a` and `b` are considered equal. @@ -1089,7 +1089,7 @@ export class Collection extends Map { } /** - * Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/groupBy | Map.groupBy()} + * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/groupBy | Map.groupBy()} * but returns a Collection instead of a Map. */ public static override groupBy( diff --git a/packages/discord.js/src/client/Client.js b/packages/discord.js/src/client/Client.js index 0290c5daba74..8601cdf6b030 100644 --- a/packages/discord.js/src/client/Client.js +++ b/packages/discord.js/src/client/Client.js @@ -656,7 +656,7 @@ class Client extends BaseClient { } /** - * Calls {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval} on a script + * Calls {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/eval} on a script * with the client as `this`. * @param {string} script Script to eval * @returns {*} @@ -733,7 +733,7 @@ exports.Client = Client; */ /** - * A {@link https://developer.twitter.com/en/docs/twitter-ids Twitter snowflake}, + * A {@link https://docs.x.com/resources/fundamentals/x-ids Twitter snowflake}, * except the epoch is 2015-01-01T00:00:00.000Z. * * If we have a snowflake '266241948824764416' we can represent it as binary: diff --git a/packages/discord.js/src/structures/interfaces/Collector.js b/packages/discord.js/src/structures/interfaces/Collector.js index 9ae133e5f1d7..143e7104548b 100644 --- a/packages/discord.js/src/structures/interfaces/Collector.js +++ b/packages/discord.js/src/structures/interfaces/Collector.js @@ -267,7 +267,7 @@ class Collector extends AsyncEventEmitter { /** * Allows collectors to be consumed with for-await-of loops - * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of} + * @see {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/for-await...of} */ async *[Symbol.asyncIterator]() { const queue = []; diff --git a/packages/rest/src/lib/REST.ts b/packages/rest/src/lib/REST.ts index 205f4228cee5..86fab750e488 100644 --- a/packages/rest/src/lib/REST.ts +++ b/packages/rest/src/lib/REST.ts @@ -345,9 +345,9 @@ export class REST extends AsyncEventEmitter { for (const [index, file] of request.files.entries()) { const fileKey = file.key ?? `files[${index}]`; - // https://developer.mozilla.org/en-US/docs/Web/API/FormData/append#parameters + // https://developer.mozilla.org/docs/Web/API/FormData/append#parameters // FormData.append only accepts a string or Blob. - // https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob#parameters + // https://developer.mozilla.org/docs/Web/API/Blob/Blob#parameters // The Blob constructor accepts TypedArray/ArrayBuffer, strings, and Blobs. if (isBufferLike(file.data)) { // Try to infer the content type from the buffer if one isn't passed