) : null}
{method.kind === ApiItemKind.Method && (method as ApiMethod).isStatic ? (
-
+
Static
) : null}
diff --git a/apps/website/src/hooks/useUnregisterServiceWorker.ts b/apps/website/src/hooks/useUnregisterServiceWorker.ts
index d56676f203ee..4fbdac7aa9c9 100644
--- a/apps/website/src/hooks/useUnregisterServiceWorker.ts
+++ b/apps/website/src/hooks/useUnregisterServiceWorker.ts
@@ -5,7 +5,7 @@ import { useEffect } from 'react';
export function useUnregisterServiceWorker() {
useEffect(() => {
// eslint-disable-next-line promise/prefer-await-to-then
- void navigator.serviceWorker?.getRegistrations().then((registrations) => {
+ void navigator.serviceWorker.getRegistrations().then((registrations) => {
for (const registration of registrations) {
void registration.unregister();
}
diff --git a/apps/website/src/middleware.ts b/apps/website/src/middleware.ts
index 33b758facb2c..a539db2a2d2a 100644
--- a/apps/website/src/middleware.ts
+++ b/apps/website/src/middleware.ts
@@ -3,7 +3,7 @@ import { NextResponse, type NextRequest } from 'next/server';
import { PACKAGES } from './util/constants';
async function fetchLatestVersion(packageName: string) {
- const res = await fetch(`https://docs.discordjs.dev/api/info?package=${packageName}`, { cache: 'no-store' });
+ const res = await fetch(`https://docs.discordjs.dev/api/info?package=${packageName}`);
const data: string[] = await res.json();
return data.at(-2);
diff --git a/apps/website/src/util/constants.ts b/apps/website/src/util/constants.ts
index 32cfa97e5fe8..cebf73752b9f 100644
--- a/apps/website/src/util/constants.ts
+++ b/apps/website/src/util/constants.ts
@@ -16,10 +16,8 @@ export const N_RECENT_VERSIONS = 2;
export const OVERLOAD_SEPARATOR = ':';
-export const METHOD_SEPARATOR = '#';
-
export const DESCRIPTION =
- "discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.";
+ "discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.";
export const CODE_EXAMPLE = `import { Client, GatewayIntentBits } from 'discord.js';
diff --git a/apps/website/src/util/fetchMember.ts b/apps/website/src/util/fetchMember.ts
deleted file mode 100644
index 324e5b7e9c42..000000000000
--- a/apps/website/src/util/fetchMember.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { addPackageToModel } from '@discordjs/scripts';
-import { ApiModel, ApiFunction } from '@microsoft/api-extractor-model';
-import { notFound } from 'next/navigation';
-import { OVERLOAD_SEPARATOR, PACKAGES } from './constants';
-import { findMember, findMemberByKey } from './model';
-import { fetchModelJSON } from '~/app/docAPI';
-
-export interface ItemRouteParams {
- item: string;
- package: string;
- version: string;
-}
-
-export async function fetchMember({ package: packageName, version: branchName = 'main', item }: ItemRouteParams) {
- if (!PACKAGES.includes(packageName)) {
- notFound();
- }
-
- const model = new ApiModel();
-
- if (branchName === 'main') {
- const modelJSONFiles = await Promise.all(PACKAGES.map(async (pkg) => fetchModelJSON(pkg, branchName)));
-
- for (const modelJSONFile of modelJSONFiles) {
- addPackageToModel(model, modelJSONFile);
- }
- } else {
- const modelJSON = await fetchModelJSON(packageName, branchName);
- addPackageToModel(model, modelJSON);
- }
-
- const [memberName, overloadIndex] = decodeURIComponent(item).split(OVERLOAD_SEPARATOR);
-
- // eslint-disable-next-line prefer-const
- let { containerKey, displayName: name } = findMember(model, packageName, memberName) ?? {};
- if (name && overloadIndex && !Number.isNaN(Number.parseInt(overloadIndex, 10))) {
- containerKey = ApiFunction.getContainerKey(name, Number.parseInt(overloadIndex, 10));
- }
-
- return memberName && containerKey ? findMemberByKey(model, packageName, containerKey) ?? null : null;
-}
diff --git a/apps/website/src/util/fetcher.ts b/apps/website/src/util/fetcher.ts
index 884d108a66f1..5071b32999b1 100644
--- a/apps/website/src/util/fetcher.ts
+++ b/apps/website/src/util/fetcher.ts
@@ -1,4 +1,4 @@
export const fetcher = async (url: string) => {
- const res = await fetch(url, { next: { revalidate: 3_600 } });
+ const res = await fetch(url);
return res.json();
};
diff --git a/apps/website/src/util/model.ts b/apps/website/src/util/model.server.ts
similarity index 91%
rename from apps/website/src/util/model.ts
rename to apps/website/src/util/model.server.ts
index 523dd0676f76..521c10113430 100644
--- a/apps/website/src/util/model.ts
+++ b/apps/website/src/util/model.server.ts
@@ -5,7 +5,7 @@ export function findMemberByKey(model: ApiModel, packageName: string, containerK
return (pkg.members[0] as ApiEntryPoint).tryGetMemberByKey(containerKey);
}
-export function findMember(model: ApiModel, packageName: string, memberName: string | undefined) {
+export function findMember(model: ApiModel, packageName: string, memberName: string | undefined): ApiItem | undefined {
if (!memberName) {
return undefined;
}
diff --git a/apps/website/src/util/summary.ts b/apps/website/src/util/summary.ts
new file mode 100644
index 000000000000..7b2d1cc80dea
--- /dev/null
+++ b/apps/website/src/util/summary.ts
@@ -0,0 +1,60 @@
+import type {
+ ApiItemJSON,
+ DocNodeJSON,
+ DocCodeSpanJSON,
+ DocPlainTextJSON,
+ DocNodeContainerJSON,
+ DocLinkTagJSON,
+} from '@discordjs/api-extractor-utils';
+
+export function tryResolveDescription(member: ApiItemJSON) {
+ const { summary } = member!;
+
+ if (!summary) {
+ return null;
+ }
+
+ let retVal = '';
+
+ function recurseNodes(node: DocNodeJSON, emitMarkdownLinks = false) {
+ switch (node.kind) {
+ case 'CodeSpan':
+ retVal += (node as DocCodeSpanJSON).code;
+ break;
+ case 'LinkTag': {
+ const { text, urlDestination } = node as DocLinkTagJSON;
+
+ if (text && urlDestination && emitMarkdownLinks) {
+ retVal += `[${text}](${urlDestination})`;
+ } else {
+ retVal += text ?? urlDestination ?? '';
+ }
+
+ break;
+ }
+
+ case 'PlainText':
+ retVal += (node as DocPlainTextJSON).text;
+ break;
+ case 'Section':
+ case 'Paragraph':
+ for (const currentNode of (node as DocNodeContainerJSON).nodes) {
+ recurseNodes(currentNode);
+ }
+
+ break;
+ default:
+ break;
+ }
+ }
+
+ for (const node of summary.nodes) {
+ recurseNodes(node);
+ }
+
+ if (retVal === '') {
+ return null;
+ }
+
+ return retVal;
+}
diff --git a/package.json b/package.json
index fb595fd834c4..b7e01d809d03 100644
--- a/package.json
+++ b/package.json
@@ -46,19 +46,19 @@
},
"homepage": "https://discord.js.org",
"devDependencies": {
- "@commitlint/cli": "^17.6.0",
- "@commitlint/config-angular": "^17.6.0",
+ "@commitlint/cli": "^17.5.1",
+ "@commitlint/config-angular": "^17.4.4",
"@favware/cliff-jumper": "^2.0.0",
"@favware/npm-deprecate": "^1.0.7",
"conventional-changelog-cli": "^2.2.2",
"husky": "^8.0.3",
"is-ci": "^3.0.1",
- "lint-staged": "^13.2.1",
+ "lint-staged": "^13.2.0",
"tsup": "^6.7.0",
- "turbo": "^1.9.1",
- "typescript": "^5.0.4",
- "unocss": "^0.51.4",
- "vercel": "^28.18.5",
+ "turbo": "^1.8.8",
+ "typescript": "^5.0.3",
+ "unocss": "^0.50.6",
+ "vercel": "^28.18.3",
"vitest": "^0.29.8"
},
"resolutions": {
diff --git a/packages/actions/package.json b/packages/actions/package.json
index d74fca2830a8..eb9211c304f9 100644
--- a/packages/actions/package.json
+++ b/packages/actions/package.json
@@ -41,20 +41,20 @@
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/glob": "^0.4.0",
- "@planetscale/database": "^1.7.0",
+ "@planetscale/database": "^1.6.0",
"tslib": "^2.5.0",
- "undici": "^5.21.2"
+ "undici": "^5.21.0"
},
"devDependencies": {
"@types/node": "16.18.23",
- "@vitest/coverage-c8": "^0.30.1",
+ "@vitest/coverage-c8": "^0.29.8",
"cross-env": "^7.0.3",
- "eslint": "^8.38.0",
- "eslint-config-neon": "^0.1.42",
+ "eslint": "^8.37.0",
+ "eslint-config-neon": "^0.1.41",
"eslint-formatter-pretty": "^5.0.0",
"prettier": "^2.8.7",
"tsup": "^6.7.0",
- "typescript": "^5.0.4",
+ "typescript": "^5.0.3",
"vitest": "^0.29.8"
},
"engines": {
diff --git a/packages/actions/src/uploadDocumentation/action.yml b/packages/actions/src/uploadDocumentation/action.yml
index 60e0ef272215..3ff169c80176 100644
--- a/packages/actions/src/uploadDocumentation/action.yml
+++ b/packages/actions/src/uploadDocumentation/action.yml
@@ -1,5 +1,5 @@
name: 'Upload documentation'
-description: 'Uploads the docs.api.json file to a planetscale database'
+description: 'Uploads the docs.json file to a planetscale database'
inputs:
package:
description: 'The package string'
diff --git a/packages/actions/src/uploadDocumentation/index.ts b/packages/actions/src/uploadDocumentation/index.ts
index 8cf82eb23a6e..8570c806b420 100644
--- a/packages/actions/src/uploadDocumentation/index.ts
+++ b/packages/actions/src/uploadDocumentation/index.ts
@@ -6,7 +6,7 @@ import { connect } from '@planetscale/database';
import { fetch } from 'undici';
if (!process.env.DATABASE_URL) {
- setFailed('DATABASE_URL is not set');
+ process.exit(0);
}
const pkg = getInput('package', { required: true });
@@ -14,14 +14,13 @@ const version = getInput('version') || 'main';
const sql = connect({
fetch,
- url: process.env.DATABASE_URL!,
+ url: process.env.DATABASE_URL,
});
-const globber = await create(`docs/${pkg}/docs/docs.api.json`);
+const globber = await create(`packages/${pkg}/docs/docs.api.json`);
for await (const file of globber.globGenerator()) {
const data = await readFile(file, 'utf8');
try {
- console.log(`Uploading ${file} with ${version}...`);
await sql.execute('replace into documentation (version, data) values (?, ?)', [version, data]);
} catch (error) {
const err = error as Error;
diff --git a/packages/api-extractor-utils/package.json b/packages/api-extractor-utils/package.json
index da053a250681..e2b1ea862aed 100644
--- a/packages/api-extractor-utils/package.json
+++ b/packages/api-extractor-utils/package.json
@@ -37,12 +37,12 @@
"devDependencies": {
"@types/node": "16.18.23",
"cross-env": "^7.0.3",
- "eslint": "^8.38.0",
- "eslint-config-neon": "^0.1.42",
+ "eslint": "^8.37.0",
+ "eslint-config-neon": "^0.1.41",
"eslint-formatter-pretty": "^5.0.0",
"prettier": "^2.8.7",
"tsup": "^6.7.0",
- "typescript": "^5.0.4"
+ "typescript": "^5.0.3"
},
"engines": {
"node": ">=16.9.0"
diff --git a/packages/brokers/docs/README.md b/packages/brokers/docs/README.md
index 29247c8cea21..88e2e10f72f2 100644
--- a/packages/brokers/docs/README.md
+++ b/packages/brokers/docs/README.md
@@ -1 +1 @@
-## [View the documentation here.](https://discord.js.org/docs/packages/brokers/main)
+## [View the documentation here.](https://discord.js.org/#/docs/brokers)
diff --git a/packages/brokers/package.json b/packages/brokers/package.json
index ebd4135ea942..b7773a36a161 100644
--- a/packages/brokers/package.json
+++ b/packages/brokers/package.json
@@ -58,21 +58,21 @@
"homepage": "https://discord.js.org",
"dependencies": {
"@msgpack/msgpack": "^3.0.0-beta2",
- "@vladfrangu/async_event_emitter": "^2.2.1",
+ "@vladfrangu/async_event_emitter": "^2.1.4",
"ioredis": "^5.3.1"
},
"devDependencies": {
"@favware/cliff-jumper": "^2.0.0",
"@microsoft/api-extractor": "^7.34.4",
"@types/node": "16.18.23",
- "@vitest/coverage-c8": "^0.30.1",
+ "@vitest/coverage-c8": "^0.29.8",
"cross-env": "^7.0.3",
- "eslint": "^8.38.0",
- "eslint-config-neon": "^0.1.42",
+ "eslint": "^8.37.0",
+ "eslint-config-neon": "^0.1.41",
"eslint-formatter-pretty": "^5.0.0",
"prettier": "^2.8.7",
"tsup": "^6.7.0",
- "typescript": "^5.0.4",
+ "typescript": "^5.0.3",
"vitest": "^0.29.8"
},
"engines": {
diff --git a/packages/brokers/src/brokers/Broker.ts b/packages/brokers/src/brokers/Broker.ts
index 7664051cd767..2ce6ceaeb4f7 100644
--- a/packages/brokers/src/brokers/Broker.ts
+++ b/packages/brokers/src/brokers/Broker.ts
@@ -26,9 +26,7 @@ export interface BaseBrokerOptions {
*/
maxChunk?: number;
/**
- * Unique consumer name.
- *
- * @see {@link https://redis.io/commands/xreadgroup/}
+ * Unique consumer name. See: https://redis.io/commands/xreadgroup/
*/
name?: string;
}
diff --git a/packages/brokers/src/brokers/redis/BaseRedis.ts b/packages/brokers/src/brokers/redis/BaseRedis.ts
index e13acdd57c2d..1e95913b4c05 100644
--- a/packages/brokers/src/brokers/redis/BaseRedis.ts
+++ b/packages/brokers/src/brokers/redis/BaseRedis.ts
@@ -32,7 +32,7 @@ export abstract class BaseRedisBroker
>
implements IBaseBroker
{
/**
- * Used for Redis queues, see the 3rd argument taken by {@link https://redis.io/commands/xadd | xadd}
+ * Used for Redis queues, see the 3rd argument taken by {@link https://redis.io/commands/xadd | xadd }
*/
public static readonly STREAM_DATA_KEY = 'data';
diff --git a/packages/builders/docs/README.md b/packages/builders/docs/README.md
index efed4aba3991..b5a4bb01b18c 100644
--- a/packages/builders/docs/README.md
+++ b/packages/builders/docs/README.md
@@ -1 +1 @@
-## [View the documentation here.](https://discord.js.org/docs/packages/builders/main)
+## [View the documentation here.](https://discord.js.org/#/docs/builders)
diff --git a/packages/builders/package.json b/packages/builders/package.json
index ae22083b8f06..95b60bc8a614 100644
--- a/packages/builders/package.json
+++ b/packages/builders/package.json
@@ -57,8 +57,8 @@
"dependencies": {
"@discordjs/formatters": "workspace:^",
"@discordjs/util": "workspace:^",
- "@sapphire/shapeshift": "^3.8.2",
- "discord-api-types": "^0.37.38",
+ "@sapphire/shapeshift": "^3.8.1",
+ "discord-api-types": "^0.37.37",
"fast-deep-equal": "^3.1.3",
"ts-mixer": "^6.0.3",
"tslib": "^2.5.0"
@@ -67,16 +67,16 @@
"@favware/cliff-jumper": "^2.0.0",
"@microsoft/api-extractor": "^7.34.4",
"@types/node": "16.18.23",
- "@vitest/coverage-c8": "^0.30.1",
+ "@vitest/coverage-c8": "^0.29.8",
"cross-env": "^7.0.3",
"downlevel-dts": "^0.11.0",
"esbuild-plugin-version-injector": "^1.1.0",
- "eslint": "^8.38.0",
- "eslint-config-neon": "^0.1.42",
+ "eslint": "^8.37.0",
+ "eslint-config-neon": "^0.1.41",
"eslint-formatter-pretty": "^5.0.0",
"prettier": "^2.8.7",
"tsup": "^6.7.0",
- "typescript": "^5.0.4",
+ "typescript": "^5.0.3",
"vitest": "^0.29.8"
},
"engines": {
diff --git a/packages/builders/src/components/ActionRow.ts b/packages/builders/src/components/ActionRow.ts
index 05ed65684fb5..90dda30cae9e 100644
--- a/packages/builders/src/components/ActionRow.ts
+++ b/packages/builders/src/components/ActionRow.ts
@@ -18,21 +18,10 @@ import type { StringSelectMenuBuilder } from './selectMenu/StringSelectMenu.js';
import type { UserSelectMenuBuilder } from './selectMenu/UserSelectMenu.js';
import type { TextInputBuilder } from './textInput/TextInput.js';
-/**
- * The builders that may be used for messages.
- */
export type MessageComponentBuilder =
| ActionRowBuilder
| MessageActionRowComponentBuilder;
-
-/**
- * The builders that may be used for modals.
- */
export type ModalComponentBuilder = ActionRowBuilder | ModalActionRowComponentBuilder;
-
-/**
- * The builders that may be used within an action row for messages.
- */
export type MessageActionRowComponentBuilder =
| ButtonBuilder
| ChannelSelectMenuBuilder
@@ -40,19 +29,11 @@ export type MessageActionRowComponentBuilder =
| RoleSelectMenuBuilder
| StringSelectMenuBuilder
| UserSelectMenuBuilder;
-
-/**
- * The builders that may be used within an action row for modals.
- */
export type ModalActionRowComponentBuilder = TextInputBuilder;
-
-/**
- * Any builder.
- */
export type AnyComponentBuilder = MessageActionRowComponentBuilder | ModalActionRowComponentBuilder;
/**
- * A builder that creates API-compatible JSON data for action rows.
+ * Represents an action row component
*
* @typeParam T - The types of components this action row holds
*/
@@ -60,16 +41,16 @@ export class ActionRowBuilder extends ComponentBu
APIActionRowComponent
> {
/**
- * The components within this action row.
+ * The components within this action row
*/
public readonly components: T[];
/**
- * Creates a new action row from API data.
+ * Creates a new action row from API data
*
* @param data - The API data to create this action row with
* @example
- * Creating an action row from an API data object:
+ * Creating an action row from an API data object
* ```ts
* const actionRow = new ActionRowBuilder({
* components: [
@@ -83,7 +64,7 @@ export class ActionRowBuilder extends ComponentBu
* });
* ```
* @example
- * Creating an action row using setters and API data:
+ * Creating an action row using setters and API data
* ```ts
* const actionRow = new ActionRowBuilder({
* components: [
@@ -106,7 +87,7 @@ export class ActionRowBuilder extends ComponentBu
/**
* Adds components to this action row.
*
- * @param components - The components to add
+ * @param components - The components to add to this action row.
*/
public addComponents(...components: RestOrArray) {
this.components.push(...normalizeArray(components));
@@ -114,9 +95,9 @@ export class ActionRowBuilder extends ComponentBu
}
/**
- * Sets components for this action row.
+ * Sets the components in this action row
*
- * @param components - The components to set
+ * @param components - The components to set this row to
*/
public setComponents(...components: RestOrArray) {
this.components.splice(0, this.components.length, ...normalizeArray(components));
diff --git a/packages/builders/src/components/Component.ts b/packages/builders/src/components/Component.ts
index e5e59638dfb9..9fe213355f37 100644
--- a/packages/builders/src/components/Component.ts
+++ b/packages/builders/src/components/Component.ts
@@ -6,13 +6,10 @@ import type {
ComponentType,
} from 'discord-api-types/v10';
-/**
- * Any action row component data represented as an object.
- */
export type AnyAPIActionRowComponent = APIActionRowComponent | APIActionRowComponentTypes;
/**
- * The base component builder that contains common symbols for all sorts of components.
+ * Represents a discord component
*
* @typeParam DataType - The type of internal API data that is stored within the component
*/
@@ -21,12 +18,12 @@ export abstract class ComponentBuilder<
> implements JSONEncodable
{
/**
- * The API data associated with this component.
+ * The API data associated with this component
*/
public readonly data: Partial;
/**
- * Serializes this builder to API-compatible JSON data.
+ * Serializes this component to an API-compatible JSON object
*
* @remarks
* This method runs validations on the data before serializing it.
@@ -34,11 +31,6 @@ export abstract class ComponentBuilder<
*/
public abstract toJSON(): AnyAPIActionRowComponent;
- /**
- * Constructs a new kind of component.
- *
- * @param data - The data to construct a component out of
- */
public constructor(data: Partial) {
this.data = data;
}
diff --git a/packages/builders/src/components/Components.ts b/packages/builders/src/components/Components.ts
index a8d287d05c56..d3e635ece957 100644
--- a/packages/builders/src/components/Components.ts
+++ b/packages/builders/src/components/Components.ts
@@ -14,63 +14,27 @@ import { StringSelectMenuBuilder } from './selectMenu/StringSelectMenu.js';
import { UserSelectMenuBuilder } from './selectMenu/UserSelectMenu.js';
import { TextInputBuilder } from './textInput/TextInput.js';
-/**
- * Components here are mapped to their respective builder.
- */
export interface MappedComponentTypes {
- /**
- * The action row component type is associated with an {@link ActionRowBuilder}.
- */
[ComponentType.ActionRow]: ActionRowBuilder;
- /**
- * The button component type is associated with an {@link ButtonBuilder}.
- */
[ComponentType.Button]: ButtonBuilder;
- /**
- * The string select component type is associated with an {@link StringSelectMenuBuilder}.
- */
[ComponentType.StringSelect]: StringSelectMenuBuilder;
- /**
- * The text inpiut component type is associated with an {@link TextInputBuilder}.
- */
[ComponentType.TextInput]: TextInputBuilder;
- /**
- * The user select component type is associated with an {@link UserSelectMenuBuilder}.
- */
[ComponentType.UserSelect]: UserSelectMenuBuilder;
- /**
- * The role select component type is associated with an {@link RoleSelectMenuBuilder}.
- */
[ComponentType.RoleSelect]: RoleSelectMenuBuilder;
- /**
- * The mentionable select component type is associated with an {@link MentionableSelectMenuBuilder}.
- */
[ComponentType.MentionableSelect]: MentionableSelectMenuBuilder;
- /**
- * The channel select component type is associated with an {@link ChannelSelectMenuBuilder}.
- */
[ComponentType.ChannelSelect]: ChannelSelectMenuBuilder;
}
/**
- * Factory for creating components from API data.
+ * Factory for creating components from API data
*
- * @typeParam T - The type of component to use
- * @param data - The API data to transform to a component class
+ * @param data - The api data to transform to a component class
*/
export function createComponentBuilder(
// eslint-disable-next-line @typescript-eslint/sort-type-union-intersection-members
data: (APIModalComponent | APIMessageComponent) & { type: T },
): MappedComponentTypes[T];
-
-/**
- * Factory for creating components from API data.
- *
- * @typeParam C - The type of component to use
- * @param data - The API data to transform to a component class
- */
export function createComponentBuilder(data: C): C;
-
export function createComponentBuilder(
data: APIMessageComponent | APIModalComponent | MessageComponentBuilder,
): ComponentBuilder {
@@ -96,7 +60,7 @@ export function createComponentBuilder(
case ComponentType.ChannelSelect:
return new ChannelSelectMenuBuilder(data);
default:
- // @ts-expect-error This case can still occur if we get a newer unsupported component type
+ // @ts-expect-error: This case can still occur if we get a newer unsupported component type
throw new Error(`Cannot properly serialize component type: ${data.type}`);
}
}
diff --git a/packages/builders/src/components/button/Button.ts b/packages/builders/src/components/button/Button.ts
index 30aad629b8a8..f6edbb863ed0 100644
--- a/packages/builders/src/components/button/Button.ts
+++ b/packages/builders/src/components/button/Button.ts
@@ -18,15 +18,15 @@ import {
import { ComponentBuilder } from '../Component.js';
/**
- * A builder that creates API-compatible JSON data for buttons.
+ * Represents a button component
*/
export class ButtonBuilder extends ComponentBuilder {
/**
- * Creates a new button from API data.
+ * Creates a new button from API data
*
* @param data - The API data to create this button with
* @example
- * Creating a button from an API data object:
+ * Creating a button from an API data object
* ```ts
* const button = new ButtonBuilder({
* custom_id: 'a cool button',
@@ -39,7 +39,7 @@ export class ButtonBuilder extends ComponentBuilder {
* });
* ```
* @example
- * Creating a button using setters and API data:
+ * Creating a button using setters and API data
* ```ts
* const button = new ButtonBuilder({
* style: ButtonStyle.Secondary,
@@ -54,9 +54,9 @@ export class ButtonBuilder extends ComponentBuilder {
}
/**
- * Sets the style of this button.
+ * Sets the style of this button
*
- * @param style - The style to use
+ * @param style - The style of the button
*/
public setStyle(style: ButtonStyle) {
this.data.style = buttonStyleValidator.parse(style);
@@ -64,12 +64,12 @@ export class ButtonBuilder extends ComponentBuilder {
}
/**
- * Sets the URL for this button.
+ * Sets the URL for this button
*
* @remarks
* This method is only available to buttons using the `Link` button style.
- * Only three types of URL schemes are currently supported: `https://`, `http://`, and `discord://`.
- * @param url - The URL to use
+ * Only three types of URL schemes are currently supported: `https://`, `http://` and `discord://`
+ * @param url - The URL to open when this button is clicked
*/
public setURL(url: string) {
(this.data as APIButtonComponentWithURL).url = urlValidator.parse(url);
@@ -77,11 +77,11 @@ export class ButtonBuilder extends ComponentBuilder {
}
/**
- * Sets the custom id for this button.
+ * Sets the custom id for this button
*
* @remarks
* This method is only applicable to buttons that are not using the `Link` button style.
- * @param customId - The custom id to use
+ * @param customId - The custom id to use for this button
*/
public setCustomId(customId: string) {
(this.data as APIButtonComponentWithCustomId).custom_id = customIdValidator.parse(customId);
@@ -89,9 +89,9 @@ export class ButtonBuilder extends ComponentBuilder {
}
/**
- * Sets the emoji to display on this button.
+ * Sets the emoji to display on this button
*
- * @param emoji - The emoji to use
+ * @param emoji - The emoji to display on this button
*/
public setEmoji(emoji: APIMessageComponentEmoji) {
this.data.emoji = emojiValidator.parse(emoji);
@@ -99,7 +99,7 @@ export class ButtonBuilder extends ComponentBuilder {
}
/**
- * Sets whether this button is disabled.
+ * Sets whether this button is disabled
*
* @param disabled - Whether to disable this button
*/
@@ -109,9 +109,9 @@ export class ButtonBuilder extends ComponentBuilder {
}
/**
- * Sets the label for this button.
+ * Sets the label for this button
*
- * @param label - The label to use
+ * @param label - The label to display on this button
*/
public setLabel(label: string) {
this.data.label = buttonLabelValidator.parse(label);
diff --git a/packages/builders/src/components/selectMenu/BaseSelectMenu.ts b/packages/builders/src/components/selectMenu/BaseSelectMenu.ts
index 458876e7fdc0..cd1a306ac8f8 100644
--- a/packages/builders/src/components/selectMenu/BaseSelectMenu.ts
+++ b/packages/builders/src/components/selectMenu/BaseSelectMenu.ts
@@ -2,18 +2,13 @@ import type { APISelectMenuComponent } from 'discord-api-types/v10';
import { customIdValidator, disabledValidator, minMaxValidator, placeholderValidator } from '../Assertions.js';
import { ComponentBuilder } from '../Component.js';
-/**
- * The base select menu builder that contains common symbols for select menu builders.
- *
- * @typeParam SelectMenuType - The type of select menu this would be instantiated for.
- */
export class BaseSelectMenuBuilder<
SelectMenuType extends APISelectMenuComponent,
> extends ComponentBuilder {
/**
- * Sets the placeholder for this select menu.
+ * Sets the placeholder for this select menu
*
- * @param placeholder - The placeholder to use
+ * @param placeholder - The placeholder to use for this select menu
*/
public setPlaceholder(placeholder: string) {
this.data.placeholder = placeholderValidator.parse(placeholder);
@@ -21,7 +16,7 @@ export class BaseSelectMenuBuilder<
}
/**
- * Sets the minimum values that must be selected in the select menu.
+ * Sets the minimum values that must be selected in the select menu
*
* @param minValues - The minimum values that must be selected
*/
@@ -31,7 +26,7 @@ export class BaseSelectMenuBuilder<
}
/**
- * Sets the maximum values that must be selected in the select menu.
+ * Sets the maximum values that must be selected in the select menu
*
* @param maxValues - The maximum values that must be selected
*/
@@ -41,9 +36,9 @@ export class BaseSelectMenuBuilder<
}
/**
- * Sets the custom id for this select menu.
+ * Sets the custom id for this select menu
*
- * @param customId - The custom id to use
+ * @param customId - The custom id to use for this select menu
*/
public setCustomId(customId: string) {
this.data.custom_id = customIdValidator.parse(customId);
@@ -51,7 +46,7 @@ export class BaseSelectMenuBuilder<
}
/**
- * Sets whether this select menu is disabled.
+ * Sets whether this select menu is disabled
*
* @param disabled - Whether this select menu is disabled
*/
@@ -60,9 +55,6 @@ export class BaseSelectMenuBuilder<
return this;
}
- /**
- * {@inheritDoc ComponentBuilder.toJSON}
- */
public toJSON(): SelectMenuType {
customIdValidator.parse(this.data.custom_id);
return {
diff --git a/packages/builders/src/components/selectMenu/ChannelSelectMenu.ts b/packages/builders/src/components/selectMenu/ChannelSelectMenu.ts
index fe5b27b83ae1..a2d46f35e65c 100644
--- a/packages/builders/src/components/selectMenu/ChannelSelectMenu.ts
+++ b/packages/builders/src/components/selectMenu/ChannelSelectMenu.ts
@@ -4,16 +4,13 @@ import { normalizeArray, type RestOrArray } from '../../util/normalizeArray.js';
import { channelTypesValidator, customIdValidator } from '../Assertions.js';
import { BaseSelectMenuBuilder } from './BaseSelectMenu.js';
-/**
- * A builder that creates API-compatible JSON data for channel select menus.
- */
export class ChannelSelectMenuBuilder extends BaseSelectMenuBuilder {
/**
- * Creates a new select menu from API data.
+ * Creates a new select menu from API data
*
* @param data - The API data to create this select menu with
* @example
- * Creating a select menu from an API data object:
+ * Creating a select menu from an API data object
* ```ts
* const selectMenu = new ChannelSelectMenuBuilder({
* custom_id: 'a cool select menu',
@@ -22,45 +19,39 @@ export class ChannelSelectMenuBuilder extends BaseSelectMenuBuilder) {
super({ ...data, type: ComponentType.ChannelSelect });
}
- /**
- * Adds channel types to this select menu.
- *
- * @param types - The channel types to use
- */
public addChannelTypes(...types: RestOrArray) {
- const normalizedTypes = normalizeArray(types);
+ // eslint-disable-next-line no-param-reassign
+ types = normalizeArray(types);
+
this.data.channel_types ??= [];
- this.data.channel_types.push(...channelTypesValidator.parse(normalizedTypes));
+ this.data.channel_types.push(...channelTypesValidator.parse(types));
return this;
}
- /**
- * Sets channel types for this select menu.
- *
- * @param types - The channel types to use
- */
public setChannelTypes(...types: RestOrArray) {
- const normalizedTypes = normalizeArray(types);
+ // eslint-disable-next-line no-param-reassign
+ types = normalizeArray(types);
+
this.data.channel_types ??= [];
- this.data.channel_types.splice(0, this.data.channel_types.length, ...channelTypesValidator.parse(normalizedTypes));
+ this.data.channel_types.splice(0, this.data.channel_types.length, ...channelTypesValidator.parse(types));
return this;
}
/**
- * {@inheritDoc BaseSelectMenuBuilder.toJSON}
+ * {@inheritDoc ComponentBuilder.toJSON}
*/
public override toJSON(): APIChannelSelectComponent {
customIdValidator.parse(this.data.custom_id);
diff --git a/packages/builders/src/components/selectMenu/MentionableSelectMenu.ts b/packages/builders/src/components/selectMenu/MentionableSelectMenu.ts
index a3a39a975fd8..c996e2b4776d 100644
--- a/packages/builders/src/components/selectMenu/MentionableSelectMenu.ts
+++ b/packages/builders/src/components/selectMenu/MentionableSelectMenu.ts
@@ -2,16 +2,13 @@ import type { APIMentionableSelectComponent } from 'discord-api-types/v10';
import { ComponentType } from 'discord-api-types/v10';
import { BaseSelectMenuBuilder } from './BaseSelectMenu.js';
-/**
- * A builder that creates API-compatible JSON data for mentionable select menus.
- */
export class MentionableSelectMenuBuilder extends BaseSelectMenuBuilder {
/**
- * Creates a new select menu from API data.
+ * Creates a new select menu from API data
*
* @param data - The API data to create this select menu with
* @example
- * Creating a select menu from an API data object:
+ * Creating a select menu from an API data object
* ```ts
* const selectMenu = new MentionableSelectMenuBuilder({
* custom_id: 'a cool select menu',
@@ -20,12 +17,12 @@ export class MentionableSelectMenuBuilder extends BaseSelectMenuBuilder) {
diff --git a/packages/builders/src/components/selectMenu/RoleSelectMenu.ts b/packages/builders/src/components/selectMenu/RoleSelectMenu.ts
index 2055b5f536cc..818ef5b7763f 100644
--- a/packages/builders/src/components/selectMenu/RoleSelectMenu.ts
+++ b/packages/builders/src/components/selectMenu/RoleSelectMenu.ts
@@ -2,16 +2,13 @@ import type { APIRoleSelectComponent } from 'discord-api-types/v10';
import { ComponentType } from 'discord-api-types/v10';
import { BaseSelectMenuBuilder } from './BaseSelectMenu.js';
-/**
- * A builder that creates API-compatible JSON data for role select menus.
- */
export class RoleSelectMenuBuilder extends BaseSelectMenuBuilder {
/**
- * Creates a new select menu from API data.
+ * Creates a new select menu from API data
*
* @param data - The API data to create this select menu with
* @example
- * Creating a select menu from an API data object:
+ * Creating a select menu from an API data object
* ```ts
* const selectMenu = new RoleSelectMenuBuilder({
* custom_id: 'a cool select menu',
@@ -20,12 +17,12 @@ export class RoleSelectMenuBuilder extends BaseSelectMenuBuilder) {
diff --git a/packages/builders/src/components/selectMenu/StringSelectMenu.ts b/packages/builders/src/components/selectMenu/StringSelectMenu.ts
index 9c6542387db0..e3f156be9dea 100644
--- a/packages/builders/src/components/selectMenu/StringSelectMenu.ts
+++ b/packages/builders/src/components/selectMenu/StringSelectMenu.ts
@@ -6,20 +6,20 @@ import { BaseSelectMenuBuilder } from './BaseSelectMenu.js';
import { StringSelectMenuOptionBuilder } from './StringSelectMenuOption.js';
/**
- * A builder that creates API-compatible JSON data for string select menus.
+ * Represents a string select menu component
*/
export class StringSelectMenuBuilder extends BaseSelectMenuBuilder {
/**
- * The options within this select menu.
+ * The options within this select menu
*/
public readonly options: StringSelectMenuOptionBuilder[];
/**
- * Creates a new select menu from API data.
+ * Creates a new select menu from API data
*
* @param data - The API data to create this select menu with
* @example
- * Creating a select menu from an API data object:
+ * Creating a select menu from an API data object
* ```ts
* const selectMenu = new StringSelectMenuBuilder({
* custom_id: 'a cool select menu',
@@ -33,7 +33,7 @@ export class StringSelectMenuBuilder extends BaseSelectMenuBuilder) {
- const normalizedOptions = normalizeArray(options);
- optionsLengthValidator.parse(this.options.length + normalizedOptions.length);
+ // eslint-disable-next-line no-param-reassign
+ options = normalizeArray(options);
+ optionsLengthValidator.parse(this.options.length + options.length);
this.options.push(
- ...normalizedOptions.map((normalizedOption) =>
- normalizedOption instanceof StringSelectMenuOptionBuilder
- ? normalizedOption
- : new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(normalizedOption)),
+ ...options.map((option) =>
+ option instanceof StringSelectMenuOptionBuilder
+ ? option
+ : new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(option)),
),
);
return this;
}
/**
- * Sets the options for this select menu.
+ * Sets the options on this select menu
*
- * @param options - The options to set
+ * @param options - The options to set on this select menu
*/
public setOptions(...options: RestOrArray) {
return this.spliceOptions(0, this.options.length, ...options);
}
/**
- * Removes, replaces, or inserts options for this select menu.
+ * Removes, replaces, or inserts options in the string select menu.
*
* @remarks
* This method behaves similarly
- * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice()}.
- * It's useful for modifying and adjusting the order of existing options.
+ * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice}.
+ *
+ * It's useful for modifying and adjusting order of the already-existing options of a string select menu.
* @example
- * Remove the first option:
+ * Remove the first option
* ```ts
* selectMenu.spliceOptions(0, 1);
* ```
* @example
- * Remove the first n option:
+ * Remove the first n option
* ```ts
- * const n = 4;
+ * const n = 4
* selectMenu.spliceOptions(0, n);
* ```
* @example
- * Remove the last option:
+ * Remove the last option
* ```ts
* selectMenu.spliceOptions(-1, 1);
* ```
@@ -110,27 +113,30 @@ export class StringSelectMenuBuilder extends BaseSelectMenuBuilder
) {
- const normalizedOptions = normalizeArray(options);
+ // eslint-disable-next-line no-param-reassign
+ options = normalizeArray(options);
const clone = [...this.options];
clone.splice(
index,
deleteCount,
- ...normalizedOptions.map((normalizedOption) =>
- normalizedOption instanceof StringSelectMenuOptionBuilder
- ? normalizedOption
- : new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(normalizedOption)),
+ ...options.map((option) =>
+ option instanceof StringSelectMenuOptionBuilder
+ ? option
+ : new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(option)),
),
);
optionsLengthValidator.parse(clone.length);
+
this.options.splice(0, this.options.length, ...clone);
+
return this;
}
/**
- * {@inheritDoc BaseSelectMenuBuilder.toJSON}
+ * {@inheritDoc ComponentBuilder.toJSON}
*/
public override toJSON(): APIStringSelectComponent {
validateRequiredSelectMenuParameters(this.options, this.data.custom_id);
diff --git a/packages/builders/src/components/selectMenu/StringSelectMenuOption.ts b/packages/builders/src/components/selectMenu/StringSelectMenuOption.ts
index 3e45970878e2..c43145463947 100644
--- a/packages/builders/src/components/selectMenu/StringSelectMenuOption.ts
+++ b/packages/builders/src/components/selectMenu/StringSelectMenuOption.ts
@@ -8,15 +8,15 @@ import {
} from '../Assertions.js';
/**
- * A builder that creates API-compatible JSON data for string select menu options.
+ * Represents an option within a string select menu component
*/
export class StringSelectMenuOptionBuilder implements JSONEncodable {
/**
- * Creates a new string select menu option from API data.
+ * Creates a new string select menu option from API data
*
* @param data - The API data to create this string select menu option with
* @example
- * Creating a string select menu option from an API data object:
+ * Creating a string select menu option from an API data object
* ```ts
* const selectMenuOption = new SelectMenuOptionBuilder({
* label: 'catchy label',
@@ -24,21 +24,21 @@ export class StringSelectMenuOptionBuilder implements JSONEncodable = {}) {}
/**
- * Sets the label for this option.
+ * Sets the label of this option
*
- * @param label - The label to use
+ * @param label - The label to show on this option
*/
public setLabel(label: string) {
this.data.label = labelValueDescriptionValidator.parse(label);
@@ -46,9 +46,9 @@ export class StringSelectMenuOptionBuilder implements JSONEncodable {
/**
- * Creates a new select menu from API data.
+ * Creates a new select menu from API data
*
* @param data - The API data to create this select menu with
* @example
- * Creating a select menu from an API data object:
+ * Creating a select menu from an API data object
* ```ts
* const selectMenu = new UserSelectMenuBuilder({
* custom_id: 'a cool select menu',
@@ -20,12 +17,12 @@ export class UserSelectMenuBuilder extends BaseSelectMenuBuilder) {
diff --git a/packages/builders/src/components/textInput/TextInput.ts b/packages/builders/src/components/textInput/TextInput.ts
index 42a4583726e1..02b97cb8620b 100644
--- a/packages/builders/src/components/textInput/TextInput.ts
+++ b/packages/builders/src/components/textInput/TextInput.ts
@@ -14,19 +14,16 @@ import {
textInputStyleValidator,
} from './Assertions.js';
-/**
- * A builder that creates API-compatible JSON data for text inputs.
- */
export class TextInputBuilder
extends ComponentBuilder
implements Equatable>
{
/**
- * Creates a new text input from API data.
+ * Creates a new text input from API data
*
* @param data - The API data to create this text input with
* @example
- * Creating a select menu option from an API data object:
+ * Creating a select menu option from an API data object
* ```ts
* const textInput = new TextInputBuilder({
* custom_id: 'a cool select menu',
@@ -35,7 +32,7 @@ export class TextInputBuilder
* });
* ```
* @example
- * Creating a select menu option using setters and API data:
+ * Creating a select menu option using setters and API data
* ```ts
* const textInput = new TextInputBuilder({
* label: 'Type something else',
@@ -49,9 +46,9 @@ export class TextInputBuilder
}
/**
- * Sets the custom id for this text input.
+ * Sets the custom id for this text input
*
- * @param customId - The custom id to use
+ * @param customId - The custom id of this text input
*/
public setCustomId(customId: string) {
this.data.custom_id = customIdValidator.parse(customId);
@@ -59,9 +56,9 @@ export class TextInputBuilder
}
/**
- * Sets the label for this text input.
+ * Sets the label for this text input
*
- * @param label - The label to use
+ * @param label - The label for this text input
*/
public setLabel(label: string) {
this.data.label = labelValidator.parse(label);
@@ -69,9 +66,9 @@ export class TextInputBuilder
}
/**
- * Sets the style for this text input.
+ * Sets the style for this text input
*
- * @param style - The style to use
+ * @param style - The style for this text input
*/
public setStyle(style: TextInputStyle) {
this.data.style = textInputStyleValidator.parse(style);
@@ -79,7 +76,7 @@ export class TextInputBuilder
}
/**
- * Sets the minimum length of text for this text input.
+ * Sets the minimum length of text for this text input
*
* @param minLength - The minimum length of text for this text input
*/
@@ -89,7 +86,7 @@ export class TextInputBuilder
}
/**
- * Sets the maximum length of text for this text input.
+ * Sets the maximum length of text for this text input
*
* @param maxLength - The maximum length of text for this text input
*/
@@ -99,9 +96,9 @@ export class TextInputBuilder
}
/**
- * Sets the placeholder for this text input.
+ * Sets the placeholder of this text input
*
- * @param placeholder - The placeholder to use
+ * @param placeholder - The placeholder of this text input
*/
public setPlaceholder(placeholder: string) {
this.data.placeholder = placeholderValidator.parse(placeholder);
@@ -109,9 +106,9 @@ export class TextInputBuilder
}
/**
- * Sets the value for this text input.
+ * Sets the value of this text input
*
- * @param value - The value to use
+ * @param value - The value for this text input
*/
public setValue(value: string) {
this.data.value = valueValidator.parse(value);
@@ -119,7 +116,7 @@ export class TextInputBuilder
}
/**
- * Sets whether this text input is required.
+ * Sets whether this text input is required
*
* @param required - Whether this text input is required
*/
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index 7023786cfedf..f021c022f602 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -62,9 +62,8 @@ export * from './util/validation.js';
export * from '@discordjs/util';
/**
- * The {@link https://github.com/discordjs/discord.js/blob/main/packages/builders#readme | @discordjs/builders} version
+ * The {@link https://github.com/discordjs/discord.js/blob/main/packages/builders/#readme | @discordjs/builders} version
* that you are currently using.
- *
- * @privateRemarks This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild.
*/
+// This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild
export const version = '[VI]{{inject}}[/VI]' as string;
diff --git a/packages/builders/src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts b/packages/builders/src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts
index a4cb2be1d1d4..ea94da034f4b 100644
--- a/packages/builders/src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts
+++ b/packages/builders/src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts
@@ -15,54 +15,45 @@ import {
validateDMPermission,
} from './Assertions.js';
-/**
- * The type a context menu command can be.
- */
-export type ContextMenuCommandType = ApplicationCommandType.Message | ApplicationCommandType.User;
-
-/**
- * A builder that creates API-compatible JSON data for context menu commands.
- */
export class ContextMenuCommandBuilder {
/**
- * The name of this command.
+ * The name of this context menu command
*/
public readonly name: string = undefined!;
/**
- * The name localizations of this command.
+ * The localized names for this command
*/
public readonly name_localizations?: LocalizationMap;
/**
- * The type of this command.
+ * The type of this context menu command
*/
public readonly type: ContextMenuCommandType = undefined!;
/**
- * Whether this command is enabled by default when the application is added to a guild.
+ * Whether the command is enabled by default when the app is added to a guild
*
- * @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
+ * @deprecated This property is deprecated and will be removed in the future.
+ * You should use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
*/
public readonly default_permission: boolean | undefined = undefined;
/**
- * The set of permissions represented as a bit set for the command.
+ * Set of permissions represented as a bit set for the command
*/
public readonly default_member_permissions: Permissions | null | undefined = undefined;
/**
- * Indicates whether the command is available in direct messages with the application.
- *
- * @remarks
- * By default, commands are visible. This property is only for global commands.
+ * Indicates whether the command is available in DMs with the application, only for globally-scoped commands.
+ * By default, commands are visible.
*/
public readonly dm_permission: boolean | undefined = undefined;
/**
- * Sets the name of this command.
+ * Sets the name
*
- * @param name - The name to use
+ * @param name - The name
*/
public setName(name: string) {
// Assert the name matches the conditions
@@ -74,9 +65,9 @@ export class ContextMenuCommandBuilder {
}
/**
- * Sets the type of this command.
+ * Sets the type
*
- * @param type - The type to use
+ * @param type - The type
*/
public setType(type: ContextMenuCommandType) {
// Assert the type is valid
@@ -92,8 +83,8 @@ export class ContextMenuCommandBuilder {
*
* @remarks
* If set to `false`, you will have to later `PUT` the permissions for this command.
- * @param value - Whether to enable this command by default
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
+ * @param value - Whether or not to enable this command by default
+ * @see https://discord.com/developers/docs/interactions/application-commands#permissions
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
*/
public setDefaultPermission(value: boolean) {
@@ -106,12 +97,12 @@ export class ContextMenuCommandBuilder {
}
/**
- * Sets the default permissions a member should have in order to run this command.
+ * Sets the default permissions a member should have in order to run the command.
*
* @remarks
* You can set this to `'0'` to disable the command by default.
* @param permissions - The permissions bit field to set
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
+ * @see https://discord.com/developers/docs/interactions/application-commands#permissions
*/
public setDefaultMemberPermissions(permissions: Permissions | bigint | number | null | undefined) {
// Assert the value and parse it
@@ -123,12 +114,11 @@ export class ContextMenuCommandBuilder {
}
/**
- * Sets if the command is available in direct messages with the application.
+ * Sets if the command is available in DMs with the application, only for globally-scoped commands.
+ * By default, commands are visible.
*
- * @remarks
- * By default, commands are visible. This method is only for global commands.
- * @param enabled - Whether the command should be enabled in direct messages
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
+ * @param enabled - If the command should be enabled in DMs
+ * @see https://discord.com/developers/docs/interactions/application-commands#permissions
*/
public setDMPermission(enabled: boolean | null | undefined) {
// Assert the value matches the conditions
@@ -140,10 +130,10 @@ export class ContextMenuCommandBuilder {
}
/**
- * Sets a name localization for this command.
+ * Sets a name localization
*
- * @param locale - The locale to set
- * @param localizedName - The localized name for the given `locale`
+ * @param locale - The locale to set a description for
+ * @param localizedName - The localized description for the given locale
*/
public setNameLocalization(locale: LocaleString, localizedName: string | null) {
if (!this.name_localizations) {
@@ -164,9 +154,9 @@ export class ContextMenuCommandBuilder {
}
/**
- * Sets the name localizations for this command.
+ * Sets the name localizations
*
- * @param localizedNames - The object of localized names to set
+ * @param localizedNames - The dictionary of localized descriptions to set
*/
public setNameLocalizations(localizedNames: LocalizationMap | null) {
if (localizedNames === null) {
@@ -182,7 +172,7 @@ export class ContextMenuCommandBuilder {
}
/**
- * Serializes this builder to API-compatible JSON data.
+ * Returns the final data that should be sent to Discord.
*
* @remarks
* This method runs validations on the data before serializing it.
@@ -196,3 +186,5 @@ export class ContextMenuCommandBuilder {
return { ...this };
}
}
+
+export type ContextMenuCommandType = ApplicationCommandType.Message | ApplicationCommandType.User;
diff --git a/packages/builders/src/interactions/modals/Modal.ts b/packages/builders/src/interactions/modals/Modal.ts
index 948d774df203..46cd4b3fc133 100644
--- a/packages/builders/src/interactions/modals/Modal.ts
+++ b/packages/builders/src/interactions/modals/Modal.ts
@@ -1,5 +1,3 @@
-/* eslint-disable jsdoc/check-param-names */
-
import type { JSONEncodable } from '@discordjs/util';
import type {
APIActionRowComponent,
@@ -12,25 +10,11 @@ import { createComponentBuilder } from '../../components/Components.js';
import { normalizeArray, type RestOrArray } from '../../util/normalizeArray.js';
import { titleValidator, validateRequiredParameters } from './Assertions.js';
-/**
- * A builder that creates API-compatible JSON data for modals.
- */
export class ModalBuilder implements JSONEncodable {
- /**
- * The API data associated with this modal.
- */
public readonly data: Partial;
- /**
- * The components within this modal.
- */
public readonly components: ActionRowBuilder[] = [];
- /**
- * Creates a new modal from API data.
- *
- * @param data - The API data to create this modal with
- */
public constructor({ components, ...data }: Partial = {}) {
this.data = { ...data };
this.components = (components?.map((component) => createComponentBuilder(component)) ??
@@ -38,9 +22,9 @@ export class ModalBuilder implements JSONEncodable>) {
this.components.splice(0, this.components.length, ...normalizeArray(components));
diff --git a/packages/builders/src/interactions/slashCommands/SlashCommandBuilder.ts b/packages/builders/src/interactions/slashCommands/SlashCommandBuilder.ts
index d10ba093ed52..56e207f47a33 100644
--- a/packages/builders/src/interactions/slashCommands/SlashCommandBuilder.ts
+++ b/packages/builders/src/interactions/slashCommands/SlashCommandBuilder.ts
@@ -19,69 +19,84 @@ import { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } fro
import { SharedNameAndDescription } from './mixins/NameAndDescription.js';
import { SharedSlashCommandOptions } from './mixins/SharedSlashCommandOptions.js';
-/**
- * A builder that creates API-compatible JSON data for slash commands.
- */
@mix(SharedSlashCommandOptions, SharedNameAndDescription)
export class SlashCommandBuilder {
/**
- * The name of this command.
+ * The name of this slash command
*/
public readonly name: string = undefined!;
/**
- * The name localizations of this command.
+ * The localized names for this command
*/
public readonly name_localizations?: LocalizationMap;
/**
- * The description of this command.
+ * The description of this slash command
*/
public readonly description: string = undefined!;
/**
- * The description localizations of this command.
+ * The localized descriptions for this command
*/
public readonly description_localizations?: LocalizationMap;
/**
- * The options of this command.
+ * The options of this slash command
*/
public readonly options: ToAPIApplicationCommandOptions[] = [];
/**
- * Whether this command is enabled by default when the application is added to a guild.
+ * Whether the command is enabled by default when the app is added to a guild
*
- * @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
+ * @deprecated This property is deprecated and will be removed in the future.
+ * You should use {@link (SlashCommandBuilder:class).setDefaultMemberPermissions} or {@link (SlashCommandBuilder:class).setDMPermission} instead.
*/
public readonly default_permission: boolean | undefined = undefined;
/**
- * The set of permissions represented as a bit set for the command.
+ * Set of permissions represented as a bit set for the command
*/
public readonly default_member_permissions: Permissions | null | undefined = undefined;
/**
- * Indicates whether the command is available in direct messages with the application.
- *
- * @remarks
- * By default, commands are visible. This property is only for global commands.
+ * Indicates whether the command is available in DMs with the application, only for globally-scoped commands.
+ * By default, commands are visible.
*/
public readonly dm_permission: boolean | undefined = undefined;
/**
- * Whether this command is NSFW.
+ * Whether this command is NSFW
*/
public readonly nsfw: boolean | undefined = undefined;
+ /**
+ * Returns the final data that should be sent to Discord.
+ *
+ * @remarks
+ * This method runs validations on the data before serializing it.
+ * As such, it may throw an error if the data is invalid.
+ */
+ public toJSON(): RESTPostAPIChatInputApplicationCommandsJSONBody {
+ validateRequiredParameters(this.name, this.description, this.options);
+
+ validateLocalizationMap(this.name_localizations);
+ validateLocalizationMap(this.description_localizations);
+
+ return {
+ ...this,
+ options: this.options.map((option) => option.toJSON()),
+ };
+ }
+
/**
* Sets whether the command is enabled by default when the application is added to a guild.
*
* @remarks
* If set to `false`, you will have to later `PUT` the permissions for this command.
* @param value - Whether or not to enable this command by default
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
- * @deprecated Use {@link SlashCommandBuilder.setDefaultMemberPermissions} or {@link SlashCommandBuilder.setDMPermission} instead.
+ * @see https://discord.com/developers/docs/interactions/application-commands#permissions
+ * @deprecated Use {@link (SlashCommandBuilder:class).setDefaultMemberPermissions} or {@link (SlashCommandBuilder:class).setDMPermission} instead.
*/
public setDefaultPermission(value: boolean) {
// Assert the value matches the conditions
@@ -98,7 +113,7 @@ export class SlashCommandBuilder {
* @remarks
* You can set this to `'0'` to disable the command by default.
* @param permissions - The permissions bit field to set
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
+ * @see https://discord.com/developers/docs/interactions/application-commands#permissions
*/
public setDefaultMemberPermissions(permissions: Permissions | bigint | number | null | undefined) {
// Assert the value and parse it
@@ -110,12 +125,11 @@ export class SlashCommandBuilder {
}
/**
- * Sets if the command is available in direct messages with the application.
+ * Sets if the command is available in DMs with the application, only for globally-scoped commands.
+ * By default, commands are visible.
*
- * @remarks
- * By default, commands are visible. This method is only for global commands.
- * @param enabled - Whether the command should be enabled in direct messages
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
+ * @param enabled - If the command should be enabled in DMs
+ * @see https://discord.com/developers/docs/interactions/application-commands#permissions
*/
public setDMPermission(enabled: boolean | null | undefined) {
// Assert the value matches the conditions
@@ -127,7 +141,7 @@ export class SlashCommandBuilder {
}
/**
- * Sets whether this command is NSFW.
+ * Sets whether this command is NSFW
*
* @param nsfw - Whether this command is NSFW
*/
@@ -139,9 +153,9 @@ export class SlashCommandBuilder {
}
/**
- * Adds a new subcommand group to this command.
+ * Adds a new subcommand group to this command
*
- * @param input - A function that returns a subcommand group builder or an already built builder
+ * @param input - A function that returns a subcommand group builder, or an already built builder
*/
public addSubcommandGroup(
input:
@@ -165,9 +179,9 @@ export class SlashCommandBuilder {
}
/**
- * Adds a new subcommand to this command.
+ * Adds a new subcommand to this command
*
- * @param input - A function that returns a subcommand builder or an already built builder
+ * @param input - A function that returns a subcommand builder, or an already built builder
*/
public addSubcommand(
input:
@@ -189,47 +203,18 @@ export class SlashCommandBuilder {
return this;
}
-
- /**
- * Serializes this builder to API-compatible JSON data.
- *
- * @remarks
- * This method runs validations on the data before serializing it.
- * As such, it may throw an error if the data is invalid.
- */
- public toJSON(): RESTPostAPIChatInputApplicationCommandsJSONBody {
- validateRequiredParameters(this.name, this.description, this.options);
-
- validateLocalizationMap(this.name_localizations);
- validateLocalizationMap(this.description_localizations);
-
- return {
- ...this,
- options: this.options.map((option) => option.toJSON()),
- };
- }
}
export interface SlashCommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions {}
-/**
- * An interface specifically for slash command subcommands.
- */
export interface SlashCommandSubcommandsOnlyBuilder
extends Omit> {}
-/**
- * An interface specifically for slash command options.
- */
export interface SlashCommandOptionsOnlyBuilder
extends SharedNameAndDescription,
SharedSlashCommandOptions,
Pick {}
-/**
- * An interface that ensures the `toJSON()` call will return something
- * that can be serialized into API-compatible data.
- */
export interface ToAPIApplicationCommandOptions {
toJSON(): APIApplicationCommandOption;
}
diff --git a/packages/builders/src/interactions/slashCommands/SlashCommandSubcommands.ts b/packages/builders/src/interactions/slashCommands/SlashCommandSubcommands.ts
index 38821537674f..e9b540448d65 100644
--- a/packages/builders/src/interactions/slashCommands/SlashCommandSubcommands.ts
+++ b/packages/builders/src/interactions/slashCommands/SlashCommandSubcommands.ts
@@ -11,31 +11,31 @@ import { SharedNameAndDescription } from './mixins/NameAndDescription.js';
import { SharedSlashCommandOptions } from './mixins/SharedSlashCommandOptions.js';
/**
- * Represents a folder for subcommands.
+ * Represents a folder for subcommands
*
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups}
+ * For more information, go to https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups
*/
@mix(SharedNameAndDescription)
export class SlashCommandSubcommandGroupBuilder implements ToAPIApplicationCommandOptions {
/**
- * The name of this subcommand group.
+ * The name of this subcommand group
*/
public readonly name: string = undefined!;
/**
- * The description of this subcommand group.
+ * The description of this subcommand group
*/
public readonly description: string = undefined!;
/**
- * The subcommands within this subcommand group.
+ * The subcommands part of this subcommand group
*/
public readonly options: SlashCommandSubcommandBuilder[] = [];
/**
- * Adds a new subcommand to this group.
+ * Adds a new subcommand to this group
*
- * @param input - A function that returns a subcommand builder or an already built builder
+ * @param input - A function that returns a subcommand builder, or an already built builder
*/
public addSubcommand(
input:
@@ -60,13 +60,6 @@ export class SlashCommandSubcommandGroupBuilder implements ToAPIApplicationComma
return this;
}
- /**
- * Serializes this builder to API-compatible JSON data.
- *
- * @remarks
- * This method runs validations on the data before serializing it.
- * As such, it may throw an error if the data is invalid.
- */
public toJSON(): APIApplicationCommandSubcommandGroupOption {
validateRequiredParameters(this.name, this.description, this.options);
@@ -84,34 +77,27 @@ export class SlashCommandSubcommandGroupBuilder implements ToAPIApplicationComma
export interface SlashCommandSubcommandGroupBuilder extends SharedNameAndDescription {}
/**
- * A builder that creates API-compatible JSON data for slash command subcommands.
+ * Represents a subcommand
*
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups}
+ * For more information, go to https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups
*/
@mix(SharedNameAndDescription, SharedSlashCommandOptions)
export class SlashCommandSubcommandBuilder implements ToAPIApplicationCommandOptions {
/**
- * The name of this subcommand.
+ * The name of this subcommand
*/
public readonly name: string = undefined!;
/**
- * The description of this subcommand.
+ * The description of this subcommand
*/
public readonly description: string = undefined!;
/**
- * The options within this subcommand.
+ * The options of this subcommand
*/
public readonly options: ApplicationCommandOptionBase[] = [];
- /**
- * Serializes this builder to API-compatible JSON data.
- *
- * @remarks
- * This method runs validations on the data before serializing it.
- * As such, it may throw an error if the data is invalid.
- */
public toJSON(): APIApplicationCommandSubcommandOption {
validateRequiredParameters(this.name, this.description, this.options);
diff --git a/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.ts b/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.ts
index 0cdbdbe6266f..5ac38d1f6a89 100644
--- a/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.ts
+++ b/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.ts
@@ -1,26 +1,17 @@
-/**
- * This mixin holds minimum and maximum symbols used for options.
- */
export abstract class ApplicationCommandNumericOptionMinMaxValueMixin {
- /**
- * The maximum value of this option.
- */
public readonly max_value?: number;
- /**
- * The minimum value of this option.
- */
public readonly min_value?: number;
/**
- * Sets the maximum number value of this option.
+ * Sets the maximum number value of this option
*
* @param max - The maximum value this option can be
*/
public abstract setMaxValue(max: number): this;
/**
- * Sets the minimum number value of this option.
+ * Sets the minimum number value of this option
*
* @param min - The minimum value this option can be
*/
diff --git a/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionBase.ts b/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionBase.ts
index 51f450e0f355..b40ce0c96934 100644
--- a/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionBase.ts
+++ b/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionBase.ts
@@ -2,26 +2,15 @@ import type { APIApplicationCommandBasicOption, ApplicationCommandOptionType } f
import { validateRequiredParameters, validateRequired, validateLocalizationMap } from '../Assertions.js';
import { SharedNameAndDescription } from './NameAndDescription.js';
-/**
- * The base application command option builder that contains common symbols for application command builders.
- */
export abstract class ApplicationCommandOptionBase extends SharedNameAndDescription {
- /**
- * The type of this option.
- */
public abstract readonly type: ApplicationCommandOptionType;
- /**
- * Whether this option is required.
- *
- * @defaultValue `false`
- */
public readonly required: boolean = false;
/**
- * Sets whether this option is required.
+ * Marks the option as required
*
- * @param required - Whether this option should be required
+ * @param required - If this option should be required
*/
public setRequired(required: boolean) {
// Assert that you actually passed a boolean
@@ -32,18 +21,8 @@ export abstract class ApplicationCommandOptionBase extends SharedNameAndDescript
return this;
}
- /**
- * Serializes this builder to API-compatible JSON data.
- *
- * @remarks
- * This method runs validations on the data before serializing it.
- * As such, it may throw an error if the data is invalid.
- */
public abstract toJSON(): APIApplicationCommandBasicOption;
- /**
- * This method runs required validators on this builder.
- */
protected runRequiredValidations() {
validateRequiredParameters(this.name, this.description, []);
diff --git a/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts b/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts
index c97d996e7fb4..a9125ac04e98 100644
--- a/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts
+++ b/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts
@@ -1,12 +1,7 @@
import { s } from '@sapphire/shapeshift';
import { ChannelType } from 'discord-api-types/v10';
-/**
- * The allowed channel types used for a channel option in a slash command builder.
- *
- * @privateRemarks This can't be dynamic because const enums are erased at runtime.
- * @internal
- */
+// Only allow valid channel types to be used. (This can't be dynamic because const enums are erased at runtime)
const allowedChannelTypes = [
ChannelType.GuildText,
ChannelType.GuildVoice,
@@ -19,26 +14,17 @@ const allowedChannelTypes = [
ChannelType.GuildForum,
] as const;
-/**
- * The type of allowed channel types used for a channel option.
- */
export type ApplicationCommandOptionAllowedChannelTypes = (typeof allowedChannelTypes)[number];
const channelTypesPredicate = s.array(s.union(...allowedChannelTypes.map((type) => s.literal(type))));
-/**
- * This mixin holds channel type symbols used for options.
- */
export class ApplicationCommandOptionChannelTypesMixin {
- /**
- * The channel types of this option.
- */
public readonly channel_types?: ApplicationCommandOptionAllowedChannelTypes[];
/**
- * Adds channel types to this option.
+ * Adds channel types to this option
*
- * @param channelTypes - The channel types
+ * @param channelTypes - The channel types to add
*/
public addChannelTypes(...channelTypes: ApplicationCommandOptionAllowedChannelTypes[]) {
if (this.channel_types === undefined) {
diff --git a/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts b/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts
index 29fdd1e3cabf..5ea7105f14c4 100644
--- a/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts
+++ b/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts
@@ -11,29 +11,16 @@ const choicesPredicate = s.object({
}).array;
const booleanPredicate = s.boolean;
-/**
- * This mixin holds choices and autocomplete symbols used for options.
- */
export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin {
- /**
- * The choices of this option.
- */
public readonly choices?: APIApplicationCommandOptionChoice[];
- /**
- * Whether this option utilizes autocomplete.
- */
public readonly autocomplete?: boolean;
- /**
- * The type of this option.
- *
- * @privateRemarks Since this is present and this is a mixin, this is needed.
- */
+ // Since this is present and this is a mixin, this is needed
public readonly type!: ApplicationCommandOptionType;
/**
- * Adds multiple choices to this option.
+ * Adds multiple choices for this option
*
* @param choices - The choices to add
*/
@@ -64,11 +51,6 @@ export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin[]>(...choices: Input): this {
if (choices.length > 0 && this.autocomplete) {
throw new RangeError('Autocomplete and choices are mutually exclusive to each other.');
@@ -83,9 +65,9 @@ export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin {
public readonly options!: ToAPIApplicationCommandOptions[];
/**
- * Adds a boolean option.
+ * Adds a boolean option
*
- * @param input - A function that returns an option builder or an already built builder
+ * @param input - A function that returns an option builder, or an already built builder
*/
public addBooleanOption(
input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption),
@@ -31,18 +26,18 @@ export class SharedSlashCommandOptions {
}
/**
- * Adds a user option.
+ * Adds a user option
*
- * @param input - A function that returns an option builder or an already built builder
+ * @param input - A function that returns an option builder, or an already built builder
*/
public addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)) {
return this._sharedAddOptionMethod(input, SlashCommandUserOption);
}
/**
- * Adds a channel option.
+ * Adds a channel option
*
- * @param input - A function that returns an option builder or an already built builder
+ * @param input - A function that returns an option builder, or an already built builder
*/
public addChannelOption(
input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption),
@@ -51,18 +46,18 @@ export class SharedSlashCommandOptions {
}
/**
- * Adds a role option.
+ * Adds a role option
*
- * @param input - A function that returns an option builder or an already built builder
+ * @param input - A function that returns an option builder, or an already built builder
*/
public addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)) {
return this._sharedAddOptionMethod(input, SlashCommandRoleOption);
}
/**
- * Adds an attachment option.
+ * Adds an attachment option
*
- * @param input - A function that returns an option builder or an already built builder
+ * @param input - A function that returns an option builder, or an already built builder
*/
public addAttachmentOption(
input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption),
@@ -71,9 +66,9 @@ export class SharedSlashCommandOptions {
}
/**
- * Adds a mentionable option.
+ * Adds a mentionable option
*
- * @param input - A function that returns an option builder or an already built builder
+ * @param input - A function that returns an option builder, or an already built builder
*/
public addMentionableOption(
input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption),
@@ -82,9 +77,9 @@ export class SharedSlashCommandOptions {
}
/**
- * Adds a string option.
+ * Adds a string option
*
- * @param input - A function that returns an option builder or an already built builder
+ * @param input - A function that returns an option builder, or an already built builder
*/
public addStringOption(
input:
@@ -102,9 +97,9 @@ export class SharedSlashCommandOptions {
}
/**
- * Adds an integer option.
+ * Adds an integer option
*
- * @param input - A function that returns an option builder or an already built builder
+ * @param input - A function that returns an option builder, or an already built builder
*/
public addIntegerOption(
input:
@@ -122,9 +117,9 @@ export class SharedSlashCommandOptions {
}
/**
- * Adds a number option.
+ * Adds a number option
*
- * @param input - A function that returns an option builder or an already built builder
+ * @param input - A function that returns an option builder, or an already built builder
*/
public addNumberOption(
input:
@@ -141,13 +136,6 @@ export class SharedSlashCommandOptions {
return this._sharedAddOptionMethod(input, SlashCommandNumberOption);
}
- /**
- * Where the actual adding magic happens. ✨
- *
- * @param input - The input. What else?
- * @param Instance - The instance of whatever is being added
- * @internal
- */
private _sharedAddOptionMethod(
input:
| Omit
diff --git a/packages/builders/src/interactions/slashCommands/options/attachment.ts b/packages/builders/src/interactions/slashCommands/options/attachment.ts
index cb31812f1c4a..006911033f78 100644
--- a/packages/builders/src/interactions/slashCommands/options/attachment.ts
+++ b/packages/builders/src/interactions/slashCommands/options/attachment.ts
@@ -1,18 +1,9 @@
import { ApplicationCommandOptionType, type APIApplicationCommandAttachmentOption } from 'discord-api-types/v10';
import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase.js';
-/**
- * A slash command attachment option.
- */
export class SlashCommandAttachmentOption extends ApplicationCommandOptionBase {
- /**
- * The type of this option.
- */
public override readonly type = ApplicationCommandOptionType.Attachment as const;
- /**
- * {@inheritDoc ApplicationCommandOptionBase.toJSON}
- */
public toJSON(): APIApplicationCommandAttachmentOption {
this.runRequiredValidations();
diff --git a/packages/builders/src/interactions/slashCommands/options/boolean.ts b/packages/builders/src/interactions/slashCommands/options/boolean.ts
index 5d82ea77c8ae..f2c9768bad6e 100644
--- a/packages/builders/src/interactions/slashCommands/options/boolean.ts
+++ b/packages/builders/src/interactions/slashCommands/options/boolean.ts
@@ -1,18 +1,9 @@
import { ApplicationCommandOptionType, type APIApplicationCommandBooleanOption } from 'discord-api-types/v10';
import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase.js';
-/**
- * A slash command boolean option.
- */
export class SlashCommandBooleanOption extends ApplicationCommandOptionBase {
- /**
- * The type of this option.
- */
public readonly type = ApplicationCommandOptionType.Boolean as const;
- /**
- * {@inheritDoc ApplicationCommandOptionBase.toJSON}
- */
public toJSON(): APIApplicationCommandBooleanOption {
this.runRequiredValidations();
diff --git a/packages/builders/src/interactions/slashCommands/options/channel.ts b/packages/builders/src/interactions/slashCommands/options/channel.ts
index 89400820c004..e3dac0aa6c15 100644
--- a/packages/builders/src/interactions/slashCommands/options/channel.ts
+++ b/packages/builders/src/interactions/slashCommands/options/channel.ts
@@ -3,19 +3,10 @@ import { mix } from 'ts-mixer';
import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase.js';
import { ApplicationCommandOptionChannelTypesMixin } from '../mixins/ApplicationCommandOptionChannelTypesMixin.js';
-/**
- * A slash command channel option.
- */
@mix(ApplicationCommandOptionChannelTypesMixin)
export class SlashCommandChannelOption extends ApplicationCommandOptionBase {
- /**
- * The type of this option.
- */
public override readonly type = ApplicationCommandOptionType.Channel as const;
- /**
- * {@inheritDoc ApplicationCommandOptionBase.toJSON}
- */
public toJSON(): APIApplicationCommandChannelOption {
this.runRequiredValidations();
diff --git a/packages/builders/src/interactions/slashCommands/options/integer.ts b/packages/builders/src/interactions/slashCommands/options/integer.ts
index c51542c705f7..e8a98f4c44d0 100644
--- a/packages/builders/src/interactions/slashCommands/options/integer.ts
+++ b/packages/builders/src/interactions/slashCommands/options/integer.ts
@@ -7,17 +7,11 @@ import { ApplicationCommandOptionWithChoicesAndAutocompleteMixin } from '../mixi
const numberValidator = s.number.int;
-/**
- * A slash command integer option.
- */
@mix(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)
export class SlashCommandIntegerOption
extends ApplicationCommandOptionBase
implements ApplicationCommandNumericOptionMinMaxValueMixin
{
- /**
- * The type of this option.
- */
public readonly type = ApplicationCommandOptionType.Integer as const;
/**
@@ -42,9 +36,6 @@ export class SlashCommandIntegerOption
return this;
}
- /**
- * {@inheritDoc ApplicationCommandOptionBase.toJSON}
- */
public toJSON(): APIApplicationCommandIntegerOption {
this.runRequiredValidations();
diff --git a/packages/builders/src/interactions/slashCommands/options/mentionable.ts b/packages/builders/src/interactions/slashCommands/options/mentionable.ts
index 56292f612675..91a0416dfd62 100644
--- a/packages/builders/src/interactions/slashCommands/options/mentionable.ts
+++ b/packages/builders/src/interactions/slashCommands/options/mentionable.ts
@@ -1,18 +1,9 @@
import { ApplicationCommandOptionType, type APIApplicationCommandMentionableOption } from 'discord-api-types/v10';
import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase.js';
-/**
- * A slash command mentionable option.
- */
export class SlashCommandMentionableOption extends ApplicationCommandOptionBase {
- /**
- * The type of this option.
- */
public readonly type = ApplicationCommandOptionType.Mentionable as const;
- /**
- * {@inheritDoc ApplicationCommandOptionBase.toJSON}
- */
public toJSON(): APIApplicationCommandMentionableOption {
this.runRequiredValidations();
diff --git a/packages/builders/src/interactions/slashCommands/options/number.ts b/packages/builders/src/interactions/slashCommands/options/number.ts
index 040ed97da593..80b5cd6e5593 100644
--- a/packages/builders/src/interactions/slashCommands/options/number.ts
+++ b/packages/builders/src/interactions/slashCommands/options/number.ts
@@ -7,17 +7,11 @@ import { ApplicationCommandOptionWithChoicesAndAutocompleteMixin } from '../mixi
const numberValidator = s.number;
-/**
- * A slash command number option.
- */
@mix(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)
export class SlashCommandNumberOption
extends ApplicationCommandOptionBase
implements ApplicationCommandNumericOptionMinMaxValueMixin
{
- /**
- * The type of this option.
- */
public readonly type = ApplicationCommandOptionType.Number as const;
/**
@@ -42,9 +36,6 @@ export class SlashCommandNumberOption
return this;
}
- /**
- * {@inheritDoc ApplicationCommandOptionBase.toJSON}
- */
public toJSON(): APIApplicationCommandNumberOption {
this.runRequiredValidations();
diff --git a/packages/builders/src/interactions/slashCommands/options/role.ts b/packages/builders/src/interactions/slashCommands/options/role.ts
index 8dca05d0adc6..4f5871d56069 100644
--- a/packages/builders/src/interactions/slashCommands/options/role.ts
+++ b/packages/builders/src/interactions/slashCommands/options/role.ts
@@ -1,18 +1,9 @@
import { ApplicationCommandOptionType, type APIApplicationCommandRoleOption } from 'discord-api-types/v10';
import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase.js';
-/**
- * A slash command role option.
- */
export class SlashCommandRoleOption extends ApplicationCommandOptionBase {
- /**
- * The type of this option.
- */
public override readonly type = ApplicationCommandOptionType.Role as const;
- /**
- * {@inheritDoc ApplicationCommandOptionBase.toJSON}
- */
public toJSON(): APIApplicationCommandRoleOption {
this.runRequiredValidations();
diff --git a/packages/builders/src/interactions/slashCommands/options/string.ts b/packages/builders/src/interactions/slashCommands/options/string.ts
index 2136d74bff2c..345b7934a12a 100644
--- a/packages/builders/src/interactions/slashCommands/options/string.ts
+++ b/packages/builders/src/interactions/slashCommands/options/string.ts
@@ -7,24 +7,12 @@ import { ApplicationCommandOptionWithChoicesAndAutocompleteMixin } from '../mixi
const minLengthValidator = s.number.greaterThanOrEqual(0).lessThanOrEqual(6_000);
const maxLengthValidator = s.number.greaterThanOrEqual(1).lessThanOrEqual(6_000);
-/**
- * A slash command string option.
- */
@mix(ApplicationCommandOptionWithChoicesAndAutocompleteMixin)
export class SlashCommandStringOption extends ApplicationCommandOptionBase {
- /**
- * The type of this option.
- */
public readonly type = ApplicationCommandOptionType.String as const;
- /**
- * The maximum length of this option.
- */
public readonly max_length?: number;
- /**
- * The minimum length of this option.
- */
public readonly min_length?: number;
/**
@@ -53,9 +41,6 @@ export class SlashCommandStringOption extends ApplicationCommandOptionBase {
return this;
}
- /**
- * {@inheritDoc ApplicationCommandOptionBase.toJSON}
- */
public toJSON(): APIApplicationCommandStringOption {
this.runRequiredValidations();
diff --git a/packages/builders/src/interactions/slashCommands/options/user.ts b/packages/builders/src/interactions/slashCommands/options/user.ts
index 471faf96ce44..609450fa5d11 100644
--- a/packages/builders/src/interactions/slashCommands/options/user.ts
+++ b/packages/builders/src/interactions/slashCommands/options/user.ts
@@ -1,18 +1,9 @@
import { ApplicationCommandOptionType, type APIApplicationCommandUserOption } from 'discord-api-types/v10';
import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase.js';
-/**
- * A slash command user option.
- */
export class SlashCommandUserOption extends ApplicationCommandOptionBase {
- /**
- * The type of this option.
- */
public readonly type = ApplicationCommandOptionType.User as const;
- /**
- * {@inheritDoc ApplicationCommandOptionBase.toJSON}
- */
public toJSON(): APIApplicationCommandUserOption {
this.runRequiredValidations();
diff --git a/packages/builders/src/messages/embed/Embed.ts b/packages/builders/src/messages/embed/Embed.ts
index ab3474b12184..5ced72817ba2 100644
--- a/packages/builders/src/messages/embed/Embed.ts
+++ b/packages/builders/src/messages/embed/Embed.ts
@@ -13,91 +13,59 @@ import {
validateFieldLength,
} from './Assertions.js';
-/**
- * A tuple satisfying the RGB color model.
- *
- * @see {@link https://developer.mozilla.org/docs/Glossary/RGB}
- */
export type RGBTuple = [red: number, green: number, blue: number];
-/**
- * The base icon data typically used in payloads.
- */
export interface IconData {
/**
- * The URL of the icon.
+ * The URL of the icon
*/
iconURL?: string;
/**
- * The proxy URL of the icon.
+ * The proxy URL of the icon
*/
proxyIconURL?: string;
}
-/**
- * Represents the author data of an embed.
- */
export type EmbedAuthorData = IconData & Omit;
-/**
- * Represents the author options of an embed.
- */
export type EmbedAuthorOptions = Omit;
-/**
- * Represents the footer data of an embed.
- */
export type EmbedFooterData = IconData & Omit;
-/**
- * Represents the footer options of an embed.
- */
export type EmbedFooterOptions = Omit;
-/**
- * Represents the image data of an embed.
- */
export interface EmbedImageData extends Omit {
/**
- * The proxy URL for the image.
+ * The proxy URL for the image
*/
proxyURL?: string;
}
-
/**
- * A builder that creates API-compatible JSON data for embeds.
+ * Represents a embed in a message (image/video preview, rich embed, etc.)
*/
export class EmbedBuilder {
- /**
- * The API data associated with this embed.
- */
public readonly data: APIEmbed;
- /**
- * Creates a new embed from API data.
- *
- * @param data - The API data to create this embed with
- */
public constructor(data: APIEmbed = {}) {
this.data = { ...data };
if (data.timestamp) this.data.timestamp = new Date(data.timestamp).toISOString();
}
/**
- * Appends fields to the embed.
+ * Appends fields to the embed
*
* @remarks
* This method accepts either an array of fields or a variable number of field parameters.
* The maximum amount of fields that can be added is 25.
* @example
- * Using an array:
+ * Using an array
* ```ts
* const fields: APIEmbedField[] = ...;
* const embed = new EmbedBuilder()
* .addFields(fields);
* ```
* @example
- * Using rest parameters (variadic):
+ * Using rest parameters (variadic)
* ```ts
* const embed = new EmbedBuilder()
* .addFields(
@@ -108,40 +76,41 @@ export class EmbedBuilder {
* @param fields - The fields to add
*/
public addFields(...fields: RestOrArray): this {
- const normalizedFields = normalizeArray(fields);
+ // eslint-disable-next-line no-param-reassign
+ fields = normalizeArray(fields);
// Ensure adding these fields won't exceed the 25 field limit
- validateFieldLength(normalizedFields.length, this.data.fields);
+ validateFieldLength(fields.length, this.data.fields);
// Data assertions
- embedFieldsArrayPredicate.parse(normalizedFields);
+ embedFieldsArrayPredicate.parse(fields);
- if (this.data.fields) this.data.fields.push(...normalizedFields);
- else this.data.fields = normalizedFields;
+ if (this.data.fields) this.data.fields.push(...fields);
+ else this.data.fields = fields;
return this;
}
/**
- * Removes, replaces, or inserts fields for this embed.
+ * Removes, replaces, or inserts fields in the embed.
*
* @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/en-US/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.
* @example
- * Remove the first field:
+ * Remove the first field
* ```ts
* embed.spliceFields(0, 1);
* ```
* @example
- * Remove the first n fields:
+ * Remove the first n fields
* ```ts
- * const n = 4;
+ * const n = 4
* embed.spliceFields(0, n);
* ```
* @example
- * Remove the last field:
+ * Remove the last field
* ```ts
* embed.spliceFields(-1, 1);
* ```
@@ -161,7 +130,7 @@ export class EmbedBuilder {
}
/**
- * Sets the fields for this embed.
+ * Sets the embed's fields
*
* @remarks
* This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,
@@ -176,9 +145,9 @@ export class EmbedBuilder {
}
/**
- * Sets the author of this embed.
+ * Sets the author of this embed
*
- * @param options - The options to use
+ * @param options - The options for the author
*/
public setAuthor(options: EmbedAuthorOptions | null): this {
@@ -195,9 +164,9 @@ export class EmbedBuilder {
}
/**
- * Sets the color of this embed.
+ * Sets the color of this embed
*
- * @param color - The color to use
+ * @param color - The color of the embed
*/
public setColor(color: RGBTuple | number | null): this {
// Data assertions
@@ -214,9 +183,9 @@ export class EmbedBuilder {
}
/**
- * Sets the description of this embed.
+ * Sets the description of this embed
*
- * @param description - The description to use
+ * @param description - The description
*/
public setDescription(description: string | null): this {
// Data assertions
@@ -227,9 +196,9 @@ export class EmbedBuilder {
}
/**
- * Sets the footer of this embed.
+ * Sets the footer of this embed
*
- * @param options - The footer to use
+ * @param options - The options for the footer
*/
public setFooter(options: EmbedFooterOptions | null): this {
if (options === null) {
@@ -245,9 +214,9 @@ export class EmbedBuilder {
}
/**
- * Sets the image of this embed.
+ * Sets the image of this embed
*
- * @param url - The image URL to use
+ * @param url - The URL of the image
*/
public setImage(url: string | null): this {
// Data assertions
@@ -258,9 +227,9 @@ export class EmbedBuilder {
}
/**
- * Sets the thumbnail of this embed.
+ * Sets the thumbnail of this embed
*
- * @param url - The thumbnail URL to use
+ * @param url - The URL of the thumbnail
*/
public setThumbnail(url: string | null): this {
// Data assertions
@@ -271,9 +240,9 @@ export class EmbedBuilder {
}
/**
- * Sets the timestamp of this embed.
+ * Sets the timestamp of this embed
*
- * @param timestamp - The timestamp or date to use
+ * @param timestamp - The timestamp or date
*/
public setTimestamp(timestamp: Date | number | null = Date.now()): this {
// Data assertions
@@ -284,9 +253,9 @@ export class EmbedBuilder {
}
/**
- * Sets the title for this embed.
+ * Sets the title of this embed
*
- * @param title - The title to use
+ * @param title - The title
*/
public setTitle(title: string | null): this {
// Data assertions
@@ -297,9 +266,9 @@ export class EmbedBuilder {
}
/**
- * Sets the URL of this embed.
+ * Sets the URL of this embed
*
- * @param url - The URL to use
+ * @param url - The URL
*/
public setURL(url: string | null): this {
// Data assertions
@@ -310,11 +279,7 @@ export class EmbedBuilder {
}
/**
- * Serializes this builder to API-compatible JSON data.
- *
- * @remarks
- * This method runs validations on the data before serializing it.
- * As such, it may throw an error if the data is invalid.
+ * Transforms the embed to a plain object
*/
public toJSON(): APIEmbed {
return { ...this.data };
diff --git a/packages/builders/src/util/componentUtil.ts b/packages/builders/src/util/componentUtil.ts
index f2439fb9925e..06ec6bf8c694 100644
--- a/packages/builders/src/util/componentUtil.ts
+++ b/packages/builders/src/util/componentUtil.ts
@@ -1,10 +1,5 @@
import type { APIEmbed } from 'discord-api-types/v10';
-/**
- * Calculates the length of the embed.
- *
- * @param data - The embed data to check
- */
export function embedLength(data: APIEmbed) {
return (
(data.title?.length ?? 0) +
diff --git a/packages/builders/src/util/normalizeArray.ts b/packages/builders/src/util/normalizeArray.ts
index bf31830a324b..2fda6fbdf33b 100644
--- a/packages/builders/src/util/normalizeArray.ts
+++ b/packages/builders/src/util/normalizeArray.ts
@@ -1,19 +1,6 @@
-/**
- * Normalizes data that is a rest parameter or an array into an array with a depth of 1.
- *
- * @typeParam T - The data that must satisfy {@link RestOrArray}.
- * @param arr - The (possibly variadic) data to normalize
- */
export function normalizeArray(arr: RestOrArray): T[] {
if (Array.isArray(arr[0])) return arr[0];
return arr as T[];
}
-/**
- * Represents data that may be an array or came from a rest parameter.
- *
- * @remarks
- * This type is used throughout builders to ensure both an array and variadic arguments
- * may be used. It is normalized with {@link normalizeArray}.
- */
export type RestOrArray = T[] | [T[]];
diff --git a/packages/builders/src/util/validation.ts b/packages/builders/src/util/validation.ts
index 37e5c224bc6e..c2830f99926f 100644
--- a/packages/builders/src/util/validation.ts
+++ b/packages/builders/src/util/validation.ts
@@ -1,26 +1,5 @@
let validate = true;
-/**
- * Enables validators.
- *
- * @returns Whether validation is occurring.
- */
-export function enableValidators() {
- return (validate = true);
-}
-
-/**
- * Disables validators.
- *
- * @returns Whether validation is occurring.
- */
-export function disableValidators() {
- return (validate = false);
-}
-
-/**
- * Checks whether validation is occurring.
- */
-export function isValidationEnabled() {
- return validate;
-}
+export const enableValidators = () => (validate = true);
+export const disableValidators = () => (validate = false);
+export const isValidationEnabled = () => validate;
diff --git a/packages/collection/docs/README.md b/packages/collection/docs/README.md
index 7a63106ac796..e729e721f591 100644
--- a/packages/collection/docs/README.md
+++ b/packages/collection/docs/README.md
@@ -1 +1 @@
-## [View the documentation here.](https://discord.js.org/docs/packages/collection/main)
+## [View the documentation here.](https://discord.js.org/#/docs/collection)
diff --git a/packages/collection/package.json b/packages/collection/package.json
index e729583fdf27..898441312be0 100644
--- a/packages/collection/package.json
+++ b/packages/collection/package.json
@@ -54,15 +54,15 @@
"@favware/cliff-jumper": "^2.0.0",
"@microsoft/api-extractor": "^7.34.4",
"@types/node": "16.18.23",
- "@vitest/coverage-c8": "^0.30.1",
+ "@vitest/coverage-c8": "^0.29.8",
"cross-env": "^7.0.3",
"esbuild-plugin-version-injector": "^1.1.0",
- "eslint": "^8.38.0",
- "eslint-config-neon": "^0.1.42",
+ "eslint": "^8.37.0",
+ "eslint-config-neon": "^0.1.41",
"eslint-formatter-pretty": "^5.0.0",
"prettier": "^2.8.7",
"tsup": "^6.7.0",
- "typescript": "^5.0.4",
+ "typescript": "^5.0.3",
"vitest": "^0.29.8"
},
"engines": {
diff --git a/packages/core/package.json b/packages/core/package.json
index 8f5a43679598..016d0be3a6b1 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -56,23 +56,23 @@
"@discordjs/rest": "workspace:^",
"@discordjs/util": "workspace:^",
"@discordjs/ws": "workspace:^",
- "@sapphire/snowflake": "^3.4.2",
- "@vladfrangu/async_event_emitter": "^2.2.1",
- "discord-api-types": "^0.37.38"
+ "@sapphire/snowflake": "^3.4.0",
+ "@vladfrangu/async_event_emitter": "^2.1.4",
+ "discord-api-types": "^0.37.37"
},
"devDependencies": {
"@favware/cliff-jumper": "^2.0.0",
"@microsoft/api-extractor": "^7.34.4",
"@types/node": "16.18.23",
- "@vitest/coverage-c8": "^0.30.1",
+ "@vitest/coverage-c8": "^0.29.8",
"cross-env": "^7.0.3",
"esbuild-plugin-version-injector": "^1.1.0",
- "eslint": "^8.38.0",
- "eslint-config-neon": "^0.1.42",
+ "eslint": "^8.37.0",
+ "eslint-config-neon": "^0.1.41",
"eslint-formatter-pretty": "^5.0.0",
"prettier": "^2.8.7",
"tsup": "^6.7.0",
- "typescript": "^5.0.4",
+ "typescript": "^5.0.3",
"vitest": "^0.29.8"
},
"engines": {
diff --git a/packages/core/src/api/channel.ts b/packages/core/src/api/channel.ts
index ae18a00dbc62..af4596845e96 100644
--- a/packages/core/src/api/channel.ts
+++ b/packages/core/src/api/channel.ts
@@ -61,7 +61,7 @@ export class ChannelsAPI {
channelId: Snowflake,
messageId: Snowflake,
{ files, ...body }: RESTPostAPIChannelMessageJSONBody & { files?: RawFile[] },
- { signal }: Pick = {},
+ { signal }: Pick,
) {
return this.rest.patch(Routes.channelMessage(channelId, messageId), {
files,
diff --git a/packages/core/src/api/guild.ts b/packages/core/src/api/guild.ts
index 5993dcc533e8..8b4161c67302 100644
--- a/packages/core/src/api/guild.ts
+++ b/packages/core/src/api/guild.ts
@@ -98,7 +98,7 @@ export class GuildsAPI {
* @param guildId - The id of the guild
* @param options - The options for fetching the guild
*/
- public async get(guildId: string, { signal }: Pick = {}) {
+ public async get(guildId: string, { signal }: Pick) {
return this.rest.get(Routes.guild(guildId), { signal }) as Promise;
}
@@ -109,7 +109,7 @@ export class GuildsAPI {
* @param guildId - The id of the guild to fetch the preview from
* @param options - The options for fetching the guild preview
*/
- public async getPreview(guildId: Snowflake, { signal }: Pick = {}) {
+ public async getPreview(guildId: Snowflake, { signal }: Pick) {
return this.rest.get(Routes.guildPreview(guildId), {
signal,
}) as Promise;
@@ -122,7 +122,7 @@ export class GuildsAPI {
* @param body - The guild to create
* @param options - The options for creating the guild
*/
- public async create(body: RESTPostAPIGuildsJSONBody, { signal }: Pick = {}) {
+ public async create(body: RESTPostAPIGuildsJSONBody, { signal }: Pick) {
return this.rest.post(Routes.guilds(), { body, signal }) as Promise;
}
@@ -361,7 +361,7 @@ export class GuildsAPI {
public async deleteRole(
guildId: Snowflake,
roleId: Snowflake,
- { reason, signal }: Pick = {},
+ { reason, signal }: Pick,
) {
await this.rest.delete(Routes.guildRole(guildId, roleId), { reason, signal });
}
@@ -1129,7 +1129,7 @@ export class GuildsAPI {
guildId: Snowflake,
userId: Snowflake,
roleId: Snowflake,
- { reason, signal }: Pick = {},
+ { reason, signal }: Pick,
) {
await this.rest.delete(Routes.guildMemberRole(guildId, userId, roleId), { reason, signal });
}
diff --git a/packages/core/src/api/interactions.ts b/packages/core/src/api/interactions.ts
index 06cfa55f2a14..885efdcddae1 100644
--- a/packages/core/src/api/interactions.ts
+++ b/packages/core/src/api/interactions.ts
@@ -51,7 +51,7 @@ export class InteractionsAPI {
public async defer(
interactionId: Snowflake,
interactionToken: string,
- data?: APIInteractionResponseDeferredChannelMessageWithSource['data'],
+ data: APIInteractionResponseDeferredChannelMessageWithSource['data'],
{ signal }: Pick = {},
) {
await this.rest.post(Routes.interactionCallback(interactionId, interactionToken), {
@@ -138,7 +138,7 @@ export class InteractionsAPI {
public async getOriginalReply(
applicationId: Snowflake,
interactionToken: string,
- { signal }: Pick = {},
+ { signal }: Pick,
) {
return this.webhooks.getMessage(
applicationId,
diff --git a/packages/core/src/api/webhook.ts b/packages/core/src/api/webhook.ts
index 12031a880b02..e307b3f4f863 100644
--- a/packages/core/src/api/webhook.ts
+++ b/packages/core/src/api/webhook.ts
@@ -1,6 +1,6 @@
import { makeURLSearchParams, type RequestData, type RawFile, type REST } from '@discordjs/rest';
+import { Routes } from 'discord-api-types/v10';
import {
- Routes,
type RESTGetAPIWebhookWithTokenMessageQuery,
type RESTGetAPIChannelMessageResult,
type RESTGetAPIWebhookResult,
@@ -103,7 +103,7 @@ export class WebhooksAPI {
id: Snowflake,
token: string,
body: RESTPostAPIWebhookWithTokenJSONBody & RESTPostAPIWebhookWithTokenQuery & { files?: RawFile[]; wait: true },
- options?: Pick,
+ { signal }: Pick,
): Promise;
/**
@@ -119,7 +119,7 @@ export class WebhooksAPI {
id: Snowflake,
token: string,
body: RESTPostAPIWebhookWithTokenJSONBody & RESTPostAPIWebhookWithTokenQuery & { files?: RawFile[]; wait?: false },
- options?: Pick,
+ { signal }: Pick,
): Promise;
/**
@@ -238,11 +238,7 @@ export class WebhooksAPI {
id: Snowflake,
token: string,
messageId: Snowflake,
- {
- thread_id,
- files,
- ...body
- }: RESTPatchAPIWebhookWithTokenMessageJSONBody & { files?: RawFile[]; thread_id?: string },
+ { thread_id, ...body }: RESTPatchAPIWebhookWithTokenMessageJSONBody & { thread_id?: string },
{ signal }: Pick = {},
) {
return this.rest.patch(Routes.webhookMessage(id, token, messageId), {
@@ -250,7 +246,6 @@ export class WebhooksAPI {
auth: false,
body,
signal,
- files,
}) as Promise;
}
diff --git a/packages/discord.js/docs/README.md b/packages/discord.js/docs/README.md
index 978bafce93ae..b5ac7978f77d 100644
--- a/packages/discord.js/docs/README.md
+++ b/packages/discord.js/docs/README.md
@@ -1 +1 @@
-## [View the documentation here.](https://discord.js.org/docs/packages/discord.js/main)
+## [View the documentation here.](https://discord.js.org/#/docs)
diff --git a/packages/discord.js/package.json b/packages/discord.js/package.json
index 70c1863fce33..343462dc80fb 100644
--- a/packages/discord.js/package.json
+++ b/packages/discord.js/package.json
@@ -54,13 +54,13 @@
"@discordjs/formatters": "workspace:^",
"@discordjs/rest": "workspace:^",
"@discordjs/util": "workspace:^",
- "@sapphire/snowflake": "^3.4.2",
+ "@sapphire/snowflake": "^3.4.0",
"@types/ws": "^8.5.4",
- "discord-api-types": "^0.37.38",
+ "discord-api-types": "^0.37.37",
"fast-deep-equal": "^3.1.3",
"lodash.snakecase": "^4.1.1",
"tslib": "^2.5.0",
- "undici": "^5.21.2",
+ "undici": "^5.21.0",
"ws": "^8.13.0"
},
"devDependencies": {
@@ -68,13 +68,13 @@
"@favware/cliff-jumper": "^2.0.0",
"@types/node": "16.18.23",
"dtslint": "^4.2.1",
- "eslint": "^8.38.0",
+ "eslint": "^8.37.0",
"eslint-formatter-pretty": "^5.0.0",
"jest": "^29.5.0",
"prettier": "^2.8.7",
"tsd": "^0.28.1",
"tslint": "^6.1.3",
- "typescript": "^5.0.4"
+ "typescript": "^5.0.3"
},
"engines": {
"node": ">=16.9.0"
diff --git a/packages/discord.js/src/client/BaseClient.js b/packages/discord.js/src/client/BaseClient.js
index 65e19c25309b..3020db823af3 100644
--- a/packages/discord.js/src/client/BaseClient.js
+++ b/packages/discord.js/src/client/BaseClient.js
@@ -77,5 +77,5 @@ module.exports = BaseClient;
/**
* @external REST
- * @see {@link https://discord.js.org/docs/packages/rest/stable/REST:Class}
+ * @see {@link https://discord.js.org/#/docs/rest/main/class/REST}
*/
diff --git a/packages/discord.js/src/client/Client.js b/packages/discord.js/src/client/Client.js
index 28f01a1a0dfb..9b0005b24d34 100644
--- a/packages/discord.js/src/client/Client.js
+++ b/packages/discord.js/src/client/Client.js
@@ -420,6 +420,9 @@ class Client extends BaseClient {
if (!scopes.some(scope => [OAuth2Scopes.Bot, OAuth2Scopes.ApplicationsCommands].includes(scope))) {
throw new DiscordjsTypeError(ErrorCodes.InvalidMissingScopes);
}
+ if (scopes.some(scope => ![OAuth2Scopes.Bot].includes(scope)) && options.permissions) {
+ throw new DiscordjsTypeError(ErrorCodes.InvalidScopeWithPermissions);
+ }
const validScopes = Object.values(OAuth2Scopes);
const invalidScope = scopes.find(scope => !validScopes.includes(scope));
if (invalidScope) {
@@ -512,22 +515,26 @@ class Client extends BaseClient {
if (typeof options.failIfNotExists !== 'boolean') {
throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'failIfNotExists', 'a boolean');
}
+ if (options.allowedMentions && typeof options.allowedMentions !== 'object') {
+ throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'allowedMentions', 'an object');
+ }
+ if (typeof options.presence !== 'object') {
+ throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'presence', 'an object');
+ }
+ if (typeof options.ws !== 'object') {
+ throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'ws', 'an object');
+ }
+ if (typeof options.rest !== 'object') {
+ throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'rest', 'an object');
+ }
+ if (typeof options.jsonTransformer !== 'function') {
+ throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'jsonTransformer', 'a function');
+ }
}
}
module.exports = Client;
-/**
- * @class SnowflakeUtil
- * @classdesc This class is an alias for {@link https://www.npmjs.com/package/@sapphire/snowflake @sapphire/snowflake}'s
- * `DiscordSnowflake` class.
- *
- * Check their documentation
- * {@link https://www.sapphirejs.dev/docs/Documentation/api-utilities/classes/snowflake_src.Snowflake here}
- * to see what you can do.
- * @hideconstructor
- */
-
/**
* A {@link https://developer.twitter.com/en/docs/twitter-ids Twitter snowflake},
* except the epoch is 2015-01-01T00:00:00.000Z.
@@ -555,15 +562,15 @@ module.exports = Client;
/**
* @external Collection
- * @see {@link https://discord.js.org/docs/packages/collection/stable/Collection:Class}
+ * @see {@link https://discord.js.org/#/docs/collection/main/class/Collection}
*/
/**
* @external ImageURLOptions
- * @see {@link https://discord.js.org/docs/packages/rest/stable/ImageURLOptions:Interface}
+ * @see {@link https://discord.js.org/#/docs/rest/main/typedef/ImageURLOptions}
*/
/**
* @external BaseImageURLOptions
- * @see {@link https://discord.js.org/docs/packages/rest/stable/BaseImageURLOptions:Interface}
+ * @see {@link https://discord.js.org/#/docs/rest/main/typedef/BaseImageURLOptions}
*/
diff --git a/packages/discord.js/src/errors/ErrorCodes.js b/packages/discord.js/src/errors/ErrorCodes.js
index 3f074a1dad06..87a051aba703 100644
--- a/packages/discord.js/src/errors/ErrorCodes.js
+++ b/packages/discord.js/src/errors/ErrorCodes.js
@@ -142,6 +142,7 @@
* @property {'ModalSubmitInteractionFieldType'} ModalSubmitInteractionFieldType
* @property {'InvalidMissingScopes'} InvalidMissingScopes
+ * @property {'InvalidScopeWithPermissions'} InvalidScopeWithPermissions
* @property {'NotImplemented'} NotImplemented
@@ -289,6 +290,7 @@ const keys = [
'ModalSubmitInteractionFieldType',
'InvalidMissingScopes',
+ 'InvalidScopeWithPermissions',
'NotImplemented',
diff --git a/packages/discord.js/src/errors/Messages.js b/packages/discord.js/src/errors/Messages.js
index 1b79ec030023..da955c161456 100644
--- a/packages/discord.js/src/errors/Messages.js
+++ b/packages/discord.js/src/errors/Messages.js
@@ -155,6 +155,7 @@ const Messages = {
`Field with custom id "${customId}" is of type: ${type}; expected ${expected}.`,
[DjsErrorCodes.InvalidMissingScopes]: 'At least one valid scope must be provided for the invite',
+ [DjsErrorCodes.InvalidScopeWithPermissions]: 'Permissions cannot be set without the bot scope',
[DjsErrorCodes.NotImplemented]: (what, name) => `Method ${what} not implemented on ${name}.`,
diff --git a/packages/discord.js/src/managers/ApplicationCommandManager.js b/packages/discord.js/src/managers/ApplicationCommandManager.js
index 388b7b408fe3..7d08dc916d07 100644
--- a/packages/discord.js/src/managers/ApplicationCommandManager.js
+++ b/packages/discord.js/src/managers/ApplicationCommandManager.js
@@ -66,10 +66,12 @@ class ApplicationCommandManager extends CachedManager {
* @typedef {ApplicationCommand|Snowflake} ApplicationCommandResolvable
*/
+ /* eslint-disable max-len */
/**
* Data that resolves to the data of an ApplicationCommand
- * @typedef {ApplicationCommandData|APIApplicationCommand} ApplicationCommandDataResolvable
+ * @typedef {ApplicationCommandData|APIApplicationCommand|JSONEncodable} ApplicationCommandDataResolvable
*/
+ /* eslint-enable max-len */
/**
* Options used to fetch data from Discord
diff --git a/packages/discord.js/src/managers/GuildStickerManager.js b/packages/discord.js/src/managers/GuildStickerManager.js
index a4974ecd7236..c32e85f31957 100644
--- a/packages/discord.js/src/managers/GuildStickerManager.js
+++ b/packages/discord.js/src/managers/GuildStickerManager.js
@@ -35,7 +35,7 @@ class GuildStickerManager extends CachedManager {
/**
* Options used to create a guild sticker.
* @typedef {Object} GuildStickerCreateOptions
- * @property {AttachmentPayload|BufferResolvable|Stream} file The file for the sticker
+ * @property {BufferResolvable|Stream|JSONEncodable} file The file for the sticker
* @property {string} name The name for the sticker
* @property {string} tags The Discord name of a unicode emoji representing the sticker's expression
* @property {?string} [description] The description for the sticker
diff --git a/packages/discord.js/src/managers/MessageManager.js b/packages/discord.js/src/managers/MessageManager.js
index 28d622d2c79f..f93a54361bbe 100644
--- a/packages/discord.js/src/managers/MessageManager.js
+++ b/packages/discord.js/src/managers/MessageManager.js
@@ -151,7 +151,7 @@ class MessageManager extends CachedManager {
/**
* Options that can be passed to edit a message.
* @typedef {BaseMessageOptions} MessageEditOptions
- * @property {AttachmentPayload[]} [attachments] An array of attachments to keep,
+ * @property {Array>} [attachments] An array of attachments to keep,
* all attachments will be kept if omitted
* @property {MessageFlags} [flags] Which flags to set for the message
* Only the {@link MessageFlags.SuppressEmbeds} flag can be modified.
diff --git a/packages/discord.js/src/managers/RoleManager.js b/packages/discord.js/src/managers/RoleManager.js
index e0c4ed7d97c7..87b9e5656935 100644
--- a/packages/discord.js/src/managers/RoleManager.js
+++ b/packages/discord.js/src/managers/RoleManager.js
@@ -307,14 +307,11 @@ class RoleManager extends CachedManager {
throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'role', 'Role nor a Snowflake');
}
- const role1Position = resolvedRole1.position;
- const role2Position = resolvedRole2.position;
-
- if (role1Position === role2Position) {
+ if (resolvedRole1.position === resolvedRole2.position) {
return Number(BigInt(resolvedRole2.id) - BigInt(resolvedRole1.id));
}
- return role1Position - role2Position;
+ return resolvedRole1.position - resolvedRole2.position;
}
/**
diff --git a/packages/discord.js/src/structures/ActionRow.js b/packages/discord.js/src/structures/ActionRow.js
index 3f858b7e3c0a..ffa2fe7ed314 100644
--- a/packages/discord.js/src/structures/ActionRow.js
+++ b/packages/discord.js/src/structures/ActionRow.js
@@ -25,7 +25,7 @@ class ActionRow extends Component {
* Creates a new action row builder from JSON data
* @method from
* @memberof ActionRow
- * @param {ActionRowBuilder|ActionRow|APIActionRowComponent} other The other data
+ * @param {JSONEncodable|APIActionRowComponent} other The other data
* @returns {ActionRowBuilder}
* @deprecated Use {@link ActionRowBuilder.from} instead.
*/
diff --git a/packages/discord.js/src/structures/ActionRowBuilder.js b/packages/discord.js/src/structures/ActionRowBuilder.js
index 1d1650a8e310..eb5f27630a61 100644
--- a/packages/discord.js/src/structures/ActionRowBuilder.js
+++ b/packages/discord.js/src/structures/ActionRowBuilder.js
@@ -18,11 +18,15 @@ class ActionRowBuilder extends BuildersActionRow {
/**
* Creates a new action row builder from JSON data
- * @param {ActionRow|ActionRowBuilder|APIActionRowComponent} other The other data
+ * @param {JSONEncodable>
+ * |APIActionRowComponent} other The other data
* @returns {ActionRowBuilder}
*/
static from(other) {
- return new this(isJSONEncodable(other) ? other.toJSON() : other);
+ if (isJSONEncodable(other)) {
+ return new this(other.toJSON());
+ }
+ return new this(other);
}
}
@@ -30,5 +34,5 @@ module.exports = ActionRowBuilder;
/**
* @external BuildersActionRow
- * @see {@link https://discord.js.org/docs/packages/builders/stable/ActionRowBuilder:Class}
+ * @see {@link https://discord.js.org/#/docs/builders/main/class/ActionRowBuilder}
*/
diff --git a/packages/discord.js/src/structures/ApplicationCommand.js b/packages/discord.js/src/structures/ApplicationCommand.js
index bd87281c11f5..949a08a68ce9 100644
--- a/packages/discord.js/src/structures/ApplicationCommand.js
+++ b/packages/discord.js/src/structures/ApplicationCommand.js
@@ -602,5 +602,5 @@ module.exports = ApplicationCommand;
/**
* @external ApplicationCommandOptionAllowedChannelTypes
- * @see {@link https://discord.js.org/docs/packages/builders/stable/ApplicationCommandOptionAllowedChannelTypes:TypeAlias}
+ * @see {@link https://discord.js.org/#/docs/builders/main/typedef/ApplicationCommandOptionAllowedChannelTypes}
*/
diff --git a/packages/discord.js/src/structures/AttachmentBuilder.js b/packages/discord.js/src/structures/AttachmentBuilder.js
index 6c638108d843..e2e7cf5179cd 100644
--- a/packages/discord.js/src/structures/AttachmentBuilder.js
+++ b/packages/discord.js/src/structures/AttachmentBuilder.js
@@ -91,7 +91,7 @@ class AttachmentBuilder {
/**
* Makes a new builder instance from a preexisting attachment structure.
- * @param {AttachmentBuilder|Attachment|AttachmentPayload} other The builder to construct a new instance from
+ * @param {JSONEncodable} other The builder to construct a new instance from
* @returns {AttachmentBuilder}
*/
static from(other) {
diff --git a/packages/discord.js/src/structures/ButtonBuilder.js b/packages/discord.js/src/structures/ButtonBuilder.js
index f841f3854238..a32bf0015347 100644
--- a/packages/discord.js/src/structures/ButtonBuilder.js
+++ b/packages/discord.js/src/structures/ButtonBuilder.js
@@ -27,11 +27,14 @@ class ButtonBuilder extends BuildersButton {
/**
* Creates a new button builder from JSON data
- * @param {ButtonBuilder|ButtonComponent|APIButtonComponent} other The other data
+ * @param {JSONEncodable|APIButtonComponent} other The other data
* @returns {ButtonBuilder}
*/
static from(other) {
- return new this(isJSONEncodable(other) ? other.toJSON() : other);
+ if (isJSONEncodable(other)) {
+ return new this(other.toJSON());
+ }
+ return new this(other);
}
}
@@ -39,5 +42,5 @@ module.exports = ButtonBuilder;
/**
* @external BuildersButton
- * @see {@link https://discord.js.org/docs/packages/builders/stable/ButtonBuilder:Class}
+ * @see {@link https://discord.js.org/#/docs/builders/main/class/ButtonBuilder}
*/
diff --git a/packages/discord.js/src/structures/CategoryChannel.js b/packages/discord.js/src/structures/CategoryChannel.js
index d03804466b2b..df3621f4e138 100644
--- a/packages/discord.js/src/structures/CategoryChannel.js
+++ b/packages/discord.js/src/structures/CategoryChannel.js
@@ -8,22 +8,9 @@ const CategoryChannelChildManager = require('../managers/CategoryChannelChildMan
* @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
- */
-
/**
* Sets the category parent of this channel.
- * It is not possible to set the parent of a CategoryChannel.
+ * It is not currently possible to set the parent of a CategoryChannel.
* @method setParent
* @memberof CategoryChannel
* @instance
diff --git a/packages/discord.js/src/structures/ChannelSelectMenuBuilder.js b/packages/discord.js/src/structures/ChannelSelectMenuBuilder.js
index 54cde0471b74..324f70b3e27f 100644
--- a/packages/discord.js/src/structures/ChannelSelectMenuBuilder.js
+++ b/packages/discord.js/src/structures/ChannelSelectMenuBuilder.js
@@ -13,12 +13,15 @@ class ChannelSelectMenuBuilder extends BuildersChannelSelectMenu {
}
/**
- * Creates a new select menu builder from JSON data
- * @param {ChannelSelectMenuBuilder|ChannelSelectMenuComponent|APIChannelSelectComponent} other The other data
+ * Creates a new select menu builder from json data
+ * @param {JSONEncodable | APISelectMenuComponent} other The other data
* @returns {ChannelSelectMenuBuilder}
*/
static from(other) {
- return new this(isJSONEncodable(other) ? other.toJSON() : other);
+ if (isJSONEncodable(other)) {
+ return new this(other.toJSON());
+ }
+ return new this(other);
}
}
@@ -26,5 +29,5 @@ module.exports = ChannelSelectMenuBuilder;
/**
* @external BuildersChannelSelectMenu
- * @see {@link https://discord.js.org/docs/packages/builders/stable/ChannelSelectMenuBuilder:Class}
+ * @see {@link https://discord.js.org/#/docs/builders/main/class/ChannelSelectMenuBuilder}
*/
diff --git a/packages/discord.js/src/structures/EmbedBuilder.js b/packages/discord.js/src/structures/EmbedBuilder.js
index 825d056e1ce2..58d5c210436c 100644
--- a/packages/discord.js/src/structures/EmbedBuilder.js
+++ b/packages/discord.js/src/structures/EmbedBuilder.js
@@ -24,11 +24,14 @@ class EmbedBuilder extends BuildersEmbed {
/**
* Creates a new embed builder from JSON data
- * @param {EmbedBuilder|Embed|APIEmbed} other The other data
+ * @param {JSONEncodable|APIEmbed} other The other data
* @returns {EmbedBuilder}
*/
static from(other) {
- return new this(isJSONEncodable(other) ? other.toJSON() : other);
+ if (isJSONEncodable(other)) {
+ return new this(other.toJSON());
+ }
+ return new this(other);
}
}
@@ -36,5 +39,5 @@ module.exports = EmbedBuilder;
/**
* @external BuildersEmbed
- * @see {@link https://discord.js.org/docs/packages/builders/stable/EmbedBuilder:Class}
+ * @see {@link https://discord.js.org/#/docs/builders/main/class/EmbedBuilder}
*/
diff --git a/packages/discord.js/src/structures/MentionableSelectMenuBuilder.js b/packages/discord.js/src/structures/MentionableSelectMenuBuilder.js
index f66616e8ab03..d5673db6865e 100644
--- a/packages/discord.js/src/structures/MentionableSelectMenuBuilder.js
+++ b/packages/discord.js/src/structures/MentionableSelectMenuBuilder.js
@@ -13,13 +13,15 @@ class MentionableSelectMenuBuilder extends BuildersMentionableSelectMenu {
}
/**
- * Creates a new select menu builder from JSON data
- * @param {MentionableSelectMenuBuilder|MentionableSelectMenuComponent|APIMentionableSelectComponent} other
- * The other data
+ * Creates a new select menu builder from json data
+ * @param {JSONEncodable | APISelectMenuComponent} other The other data
* @returns {MentionableSelectMenuBuilder}
*/
static from(other) {
- return new this(isJSONEncodable(other) ? other.toJSON() : other);
+ if (isJSONEncodable(other)) {
+ return new this(other.toJSON());
+ }
+ return new this(other);
}
}
@@ -27,5 +29,5 @@ module.exports = MentionableSelectMenuBuilder;
/**
* @external BuildersMentionableSelectMenu
- * @see {@link https://discord.js.org/docs/packages/builders/stable/MentionableSelectMenuBuilder:Class}
+ * @see {@link https://discord.js.org/#/docs/builders/main/class/MentionableSelectMenuBuilder}
*/
diff --git a/packages/discord.js/src/structures/MessagePayload.js b/packages/discord.js/src/structures/MessagePayload.js
index a2681afc8cfb..6bcac122a235 100644
--- a/packages/discord.js/src/structures/MessagePayload.js
+++ b/packages/discord.js/src/structures/MessagePayload.js
@@ -227,7 +227,8 @@ class MessagePayload {
/**
* Resolves a single file into an object sendable to the API.
- * @param {AttachmentPayload|BufferResolvable|Stream} fileLike Something that could be resolved to a file
+ * @param {BufferResolvable|Stream|JSONEncodable} fileLike Something that could
+ * be resolved to a file
* @returns {Promise}
*/
static async resolveFile(fileLike) {
@@ -296,5 +297,5 @@ module.exports = MessagePayload;
/**
* @external RawFile
- * @see {@link https://discord.js.org/docs/packages/rest/stable/RawFile:Interface}
+ * @see {@link https://discord.js.org/#/docs/rest/main/typedef/RawFile}
*/
diff --git a/packages/discord.js/src/structures/ModalBuilder.js b/packages/discord.js/src/structures/ModalBuilder.js
index 40cf5d970c1e..84ddfbea29c4 100644
--- a/packages/discord.js/src/structures/ModalBuilder.js
+++ b/packages/discord.js/src/structures/ModalBuilder.js
@@ -17,11 +17,14 @@ class ModalBuilder extends BuildersModal {
/**
* Creates a new modal builder from JSON data
- * @param {ModalBuilder|APIModalComponent} other The other data
+ * @param {JSONEncodable|APIModalComponent} other The other data
* @returns {ModalBuilder}
*/
static from(other) {
- return new this(isJSONEncodable(other) ? other.toJSON() : other);
+ if (isJSONEncodable(other)) {
+ return new this(other.toJSON());
+ }
+ return new this(other);
}
}
@@ -29,5 +32,5 @@ module.exports = ModalBuilder;
/**
* @external BuildersModal
- * @see {@link https://discord.js.org/docs/packages/builders/stable/ModalBuilder:Class}
+ * @see {@link https://discord.js.org/#/docs/builders/main/class/ModalBuilder}
*/
diff --git a/packages/discord.js/src/structures/RoleSelectMenuBuilder.js b/packages/discord.js/src/structures/RoleSelectMenuBuilder.js
index c9d98c6f503e..a42b436fa2c8 100644
--- a/packages/discord.js/src/structures/RoleSelectMenuBuilder.js
+++ b/packages/discord.js/src/structures/RoleSelectMenuBuilder.js
@@ -13,12 +13,15 @@ class RoleSelectMenuBuilder extends BuildersRoleSelectMenu {
}
/**
- * Creates a new select menu builder from JSON data
- * @param {RoleSelectMenuBuilder|RoleSelectMenuComponent|APIRoleSelectComponent} other The other data
+ * Creates a new select menu builder from json data
+ * @param {JSONEncodable | APISelectMenuComponent} other The other data
* @returns {RoleSelectMenuBuilder}
*/
static from(other) {
- return new this(isJSONEncodable(other) ? other.toJSON() : other);
+ if (isJSONEncodable(other)) {
+ return new this(other.toJSON());
+ }
+ return new this(other);
}
}
@@ -26,5 +29,5 @@ module.exports = RoleSelectMenuBuilder;
/**
* @external BuildersRoleSelectMenu
- * @see {@link https://discord.js.org/docs/packages/builders/stable/RoleSelectMenuBuilder:Class}
+ * @see {@link https://discord.js.org/#/docs/builders/main/class/RoleSelectMenuBuilder}
*/
diff --git a/packages/discord.js/src/structures/StringSelectMenuBuilder.js b/packages/discord.js/src/structures/StringSelectMenuBuilder.js
index f82dbbf9bb49..3dd645e3cb53 100644
--- a/packages/discord.js/src/structures/StringSelectMenuBuilder.js
+++ b/packages/discord.js/src/structures/StringSelectMenuBuilder.js
@@ -23,7 +23,7 @@ class StringSelectMenuBuilder extends BuildersSelectMenu {
/**
* Normalizes a select menu option emoji
- * @param {SelectMenuOptionData|APISelectMenuOption} selectMenuOption The option to normalize
+ * @param {SelectMenuOptionData|JSONEncodable} selectMenuOption The option to normalize
* @returns {SelectMenuOptionBuilder|APISelectMenuOption}
* @private
*/
@@ -59,7 +59,7 @@ class StringSelectMenuBuilder extends BuildersSelectMenu {
/**
* Creates a new select menu builder from json data
- * @param {StringSelectMenuBuilder|StringSelectMenuComponent|APIStringSelectComponent} other The other data
+ * @param {JSONEncodable | APISelectMenuComponent} other The other data
* @returns {StringSelectMenuBuilder}
*/
static from(other) {
@@ -74,5 +74,5 @@ module.exports = StringSelectMenuBuilder;
/**
* @external BuildersSelectMenu
- * @see {@link https://discord.js.org/docs/packages/builders/stable/StringSelectMenuBuilder:Class}
+ * @see {@link https://discord.js.org/#/docs/builders/main/class/SelectMenuBuilder}
*/
diff --git a/packages/discord.js/src/structures/StringSelectMenuOptionBuilder.js b/packages/discord.js/src/structures/StringSelectMenuOptionBuilder.js
index 4b8ee5c8ee7f..f5fa6d9e6884 100644
--- a/packages/discord.js/src/structures/StringSelectMenuOptionBuilder.js
+++ b/packages/discord.js/src/structures/StringSelectMenuOptionBuilder.js
@@ -32,11 +32,14 @@ class StringSelectMenuOptionBuilder extends BuildersSelectMenuOption {
/**
* Creates a new select menu option builder from JSON data
- * @param {StringSelectMenuOptionBuilder|APISelectMenuOption} other The other data
+ * @param {JSONEncodable|APISelectMenuOption} other The other data
* @returns {StringSelectMenuOptionBuilder}
*/
static from(other) {
- return new this(isJSONEncodable(other) ? other.toJSON() : other);
+ if (isJSONEncodable(other)) {
+ return new this(other.toJSON());
+ }
+ return new this(other);
}
}
@@ -44,5 +47,5 @@ module.exports = StringSelectMenuOptionBuilder;
/**
* @external BuildersSelectMenuOption
- * @see {@link https://discord.js.org/docs/packages/builders/stable/SelectMenuOptionBuilder:Class}
+ * @see {@link https://discord.js.org/#/docs/builders/main/class/SelectMenuOptionBuilder}
*/
diff --git a/packages/discord.js/src/structures/TextInputBuilder.js b/packages/discord.js/src/structures/TextInputBuilder.js
index 2109d9c0fcd4..a30b3689b701 100644
--- a/packages/discord.js/src/structures/TextInputBuilder.js
+++ b/packages/discord.js/src/structures/TextInputBuilder.js
@@ -14,11 +14,14 @@ class TextInputBuilder extends BuildersTextInput {
/**
* Creates a new text input builder from JSON data
- * @param {TextInputBuilder|TextInputComponent|APITextInputComponent} other The other data
+ * @param {JSONEncodable|APITextInputComponent} other The other data
* @returns {TextInputBuilder}
*/
static from(other) {
- return new this(isJSONEncodable(other) ? other.toJSON() : other);
+ if (isJSONEncodable(other)) {
+ return new this(other.toJSON());
+ }
+ return new this(other);
}
}
@@ -26,5 +29,5 @@ module.exports = TextInputBuilder;
/**
* @external BuildersTextInput
- * @see {@link https://discord.js.org/docs/packages/builders/stable/TextInputBuilder:Class}
+ * @see {@link https://discord.js.org/#/docs/builders/main/class/TextInputBuilder}
*/
diff --git a/packages/discord.js/src/structures/UserSelectMenuBuilder.js b/packages/discord.js/src/structures/UserSelectMenuBuilder.js
index e0d6a543d94d..39db60fff326 100644
--- a/packages/discord.js/src/structures/UserSelectMenuBuilder.js
+++ b/packages/discord.js/src/structures/UserSelectMenuBuilder.js
@@ -13,12 +13,15 @@ class UserSelectMenuBuilder extends BuildersUserSelectMenu {
}
/**
- * Creates a new select menu builder from JSON data
- * @param {UserSelectMenuBuilder|UserSelectMenuComponent|APIUserSelectComponent} other The other data
+ * Creates a new select menu builder from json data
+ * @param {JSONEncodable | APISelectMenuComponent} other The other data
* @returns {UserSelectMenuBuilder}
*/
static from(other) {
- return new this(isJSONEncodable(other) ? other.toJSON() : other);
+ if (isJSONEncodable(other)) {
+ return new this(other.toJSON());
+ }
+ return new this(other);
}
}
@@ -26,5 +29,5 @@ module.exports = UserSelectMenuBuilder;
/**
* @external BuildersUserSelectMenu
- * @see {@link https://discord.js.org/docs/packages/rest/stable/UserSelectMenuBuilder:Class}
+ * @see {@link https://discord.js.org/#/docs/builders/main/class/UserSelectMenuBuilder}
*/
diff --git a/packages/discord.js/src/structures/interfaces/TextBasedChannel.js b/packages/discord.js/src/structures/interfaces/TextBasedChannel.js
index d5f9b27f2472..d8562f81a433 100644
--- a/packages/discord.js/src/structures/interfaces/TextBasedChannel.js
+++ b/packages/discord.js/src/structures/interfaces/TextBasedChannel.js
@@ -59,7 +59,7 @@ class TextBasedChannel {
* @property {Embed[]|APIEmbed[]} [embeds] The embeds for the message
* @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 {AttachmentBuilder[]|Attachment[]|AttachmentPayload[]|BufferResolvable[]} [files]
+ * @property {Array>|BufferResolvable[]|Attachment[]|AttachmentBuilder[]} [files]
* The files to send with the message.
* @property {ActionRow[]|ActionRowBuilder[]} [components]
* Action rows containing interactive components for the message (buttons, select menus)
diff --git a/packages/discord.js/src/util/APITypes.js b/packages/discord.js/src/util/APITypes.js
index 3a4878e2d4d9..79e48febcbe8 100644
--- a/packages/discord.js/src/util/APITypes.js
+++ b/packages/discord.js/src/util/APITypes.js
@@ -43,11 +43,6 @@
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIChannel}
*/
-/**
- * @external APIChannelSelectComponent
- * @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIChannelSelectComponent}
- */
-
/**
* @external APIEmbed
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIEmbed}
@@ -103,11 +98,6 @@
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIInteractionGuildMember}
*/
-/**
- * @external APIMentionableSelectComponent
- * @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIMentionableSelectComponent}
- */
-
/**
* @external APIMessage
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIMessage}
@@ -149,13 +139,13 @@
*/
/**
- * @external APISelectMenuOption
- * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APISelectMenuOption}
+ * @external APISelectMenuComponent
+ * @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APISelectMenuComponent}
*/
/**
- * @external APIStringSelectComponent
- * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIStringSelectComponent}
+ * @external APISelectMenuOption
+ * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APISelectMenuOption}
*/
/**
diff --git a/packages/discord.js/src/util/Components.js b/packages/discord.js/src/util/Components.js
index 1a2ccbcd24ad..42bee7f2afa0 100644
--- a/packages/discord.js/src/util/Components.js
+++ b/packages/discord.js/src/util/Components.js
@@ -150,3 +150,8 @@ const TextInputBuilder = require('../structures/TextInputBuilder');
const TextInputComponent = require('../structures/TextInputComponent');
const UserSelectMenuBuilder = require('../structures/UserSelectMenuBuilder');
const UserSelectMenuComponent = require('../structures/UserSelectMenuComponent');
+
+/**
+ * @external JSONEncodable
+ * @see {@link https://discord.js.org/#/docs/builders/main/typedef/JSONEncodable}
+ */
diff --git a/packages/discord.js/src/util/Options.js b/packages/discord.js/src/util/Options.js
index 77638259c2ce..52a756e9446c 100644
--- a/packages/discord.js/src/util/Options.js
+++ b/packages/discord.js/src/util/Options.js
@@ -198,5 +198,5 @@ module.exports = Options;
/**
* @external RESTOptions
- * @see {@link https://discord.js.org/docs/packages/rest/stable/RESTOptions:Interface}
+ * @see {@link https://discord.js.org/#/docs/rest/main/typedef/RESTOptions}
*/
diff --git a/packages/discord.js/src/util/Sweepers.js b/packages/discord.js/src/util/Sweepers.js
index 6eb2dc65d0e2..7796ddc99a96 100644
--- a/packages/discord.js/src/util/Sweepers.js
+++ b/packages/discord.js/src/util/Sweepers.js
@@ -8,7 +8,7 @@ const { DiscordjsTypeError, ErrorCodes } = require('../errors');
/**
* @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/stable/Collection:Class#sweep)}
+ * See {@link [Collection#sweep](https://discord.js.org/#/docs/collection/main/class/Collection?scrollTo=sweep)}
* for the definition of this function.
*/
diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts
index 5def0d151c20..fb06027cefd3 100644
--- a/packages/discord.js/typings/index.d.ts
+++ b/packages/discord.js/typings/index.d.ts
@@ -892,8 +892,6 @@ export type CategoryChannelType = Exclude<
export class CategoryChannel extends GuildChannel {
public get children(): CategoryChannelChildManager;
public type: ChannelType.GuildCategory;
- public get parent(): null;
- public parentId: null;
}
export type CategoryChannelResolvable = Snowflake | CategoryChannel;
@@ -6232,7 +6230,7 @@ export type CategoryChildChannel = Exclude;
-export type GuildTextBasedChannel = Extract;
+export type GuildTextBasedChannel = Exclude, ForumChannel>;
export type TextChannelResolvable = Snowflake | TextChannel;
diff --git a/packages/docgen/package.json b/packages/docgen/package.json
index 144af73796b3..8fd8735dc70a 100644
--- a/packages/docgen/package.json
+++ b/packages/docgen/package.json
@@ -43,19 +43,19 @@
"commander": "^10.0.0",
"jsdoc-to-markdown": "^8.0.0",
"tslib": "^2.5.0",
- "typedoc": "^0.24.1"
+ "typedoc": "^0.23.28"
},
"devDependencies": {
"@favware/cliff-jumper": "^2.0.0",
"@types/jsdoc-to-markdown": "^7.0.3",
"@types/node": "16.18.23",
"cross-env": "^7.0.3",
- "eslint": "^8.38.0",
- "eslint-config-neon": "^0.1.42",
+ "eslint": "^8.37.0",
+ "eslint-config-neon": "^0.1.41",
"eslint-formatter-pretty": "^5.0.0",
"prettier": "^2.8.7",
"tsup": "^6.7.0",
- "typescript": "^5.0.4"
+ "typescript": "^5.0.3"
},
"engines": {
"node": ">=16.9.0"
diff --git a/packages/formatters/__tests__/formatters.test.ts b/packages/formatters/__tests__/formatters.test.ts
index b6d3ea075fc4..beb136907f1f 100644
--- a/packages/formatters/__tests__/formatters.test.ts
+++ b/packages/formatters/__tests__/formatters.test.ts
@@ -240,19 +240,16 @@ describe('Message formatters', () => {
});
describe('Faces', () => {
- // prettier-ignore
- /* eslint-disable no-useless-escape */
- test('GIVEN Faces.Shrug THEN returns "¯\_(ツ)_/¯"', () => {
- expect<'¯\_(ツ)_/¯'>(Faces.Shrug).toEqual('¯\_(ツ)_/¯');
+ test('GIVEN Faces.Shrug THEN returns "¯\\_(ツ)\\_/¯"', () => {
+ expect<'¯\\_(ツ)\\_/¯'>(Faces.Shrug).toEqual('¯\\_(ツ)\\_/¯');
});
- /* eslint-enable no-useless-escape */
- test('GIVEN Faces.Tableflip THEN returns "(╯°□°)╯︵ ┻━┻"', () => {
- expect<'(╯°□°)╯︵ ┻━┻'>(Faces.Tableflip).toEqual('(╯°□°)╯︵ ┻━┻');
+ test('GIVEN Faces.Tableflip THEN returns "(╯°□°)╯︵ ┻━┻"', () => {
+ expect<'(╯°□°)╯︵ ┻━┻'>(Faces.Tableflip).toEqual('(╯°□°)╯︵ ┻━┻');
});
- test('GIVEN Faces.Unflip THEN returns "┬─┬ノ( º _ ºノ)"', () => {
- expect<'┬─┬ノ( º _ ºノ)'>(Faces.Unflip).toEqual('┬─┬ノ( º _ ºノ)');
+ test('GIVEN Faces.Unflip THEN returns "┬─┬ ノ( ゜-゜ノ)"', () => {
+ expect<'┬─┬ ノ( ゜-゜ノ)'>(Faces.Unflip).toEqual('┬─┬ ノ( ゜-゜ノ)');
});
});
});
diff --git a/packages/formatters/package.json b/packages/formatters/package.json
index f9b4940ee009..4bbe6bc4a80b 100644
--- a/packages/formatters/package.json
+++ b/packages/formatters/package.json
@@ -45,20 +45,20 @@
},
"homepage": "https://discord.js.org",
"dependencies": {
- "discord-api-types": "^0.37.38"
+ "discord-api-types": "^0.37.37"
},
"devDependencies": {
"@favware/cliff-jumper": "^2.0.0",
"@microsoft/api-extractor": "^7.34.4",
"@types/node": "16.18.23",
- "@vitest/coverage-c8": "^0.30.1",
+ "@vitest/coverage-c8": "^0.29.8",
"cross-env": "^7.0.3",
- "eslint": "^8.38.0",
- "eslint-config-neon": "^0.1.42",
+ "eslint": "^8.37.0",
+ "eslint-config-neon": "^0.1.41",
"eslint-formatter-pretty": "^5.0.0",
"prettier": "^2.8.7",
"tsup": "^6.7.0",
- "typescript": "^5.0.4",
+ "typescript": "^5.0.3",
"vitest": "^0.29.8"
},
"engines": {
diff --git a/packages/formatters/src/escapers.ts b/packages/formatters/src/escapers.ts
index 1c89ce193167..3575c0a3d661 100644
--- a/packages/formatters/src/escapers.ts
+++ b/packages/formatters/src/escapers.ts
@@ -1,109 +1,106 @@
/* eslint-disable prefer-named-capture-group */
-/**
- * The options that affect what will be escaped.
- */
export interface EscapeMarkdownOptions {
/**
- * Whether to escape bold text.
+ * Whether to escape bolds
*
- * @defaultValue `true`
+ * @defaultValue true
*/
bold?: boolean;
/**
- * Whether to escape bulleted lists.
+ * Whether to escape bulleted lists
*
- * @defaultValue `false`
+ * @defaultValue false
*/
bulletedList?: boolean;
/**
- * Whether to escape code blocks.
+ * Whether to escape code blocks
*
- * @defaultValue `true`
+ * @defaultValue true
*/
codeBlock?: boolean;
/**
- * Whether to escape text inside code blocks.
+ * Whether to escape text inside code blocks
*
- * @defaultValue `true`
+ * @defaultValue true
*/
codeBlockContent?: boolean;
/**
- * Whether to escape `\`.
+ * Whether to escape escape characters
*
- * @defaultValue `true`
+ * @defaultValue true
*/
escape?: boolean;
/**
- * Whether to escape headings.
+ * Whether to escape headings
*
- * @defaultValue `false`
+ * @defaultValue false
*/
heading?: boolean;
/**
- * Whether to escape inline code.
+ * Whether to escape inline code
*
- * @defaultValue `true`
+ * @defaultValue true
*/
inlineCode?: boolean;
/**
- * Whether to escape text inside inline code.
+ * Whether to escape text inside inline code
*
- * @defaultValue `true`
+ * @defaultValue true
*/
inlineCodeContent?: boolean;
/**
- * Whether to escape italics.
+ * Whether to escape italics
*
- * @defaultValue `true`
+ * @defaultValue true
*/
italic?: boolean;
/**
- * Whether to escape masked links.
+ * Whether to escape masked links
*
- * @defaultValue `false`
+ * @defaultValue false
*/
maskedLink?: boolean;
/**
- * Whether to escape numbered lists.
+ * Whether to escape numbered lists
*
- * @defaultValue `false`
+ * @defaultValue false
*/
numberedList?: boolean;
/**
- * Whether to escape spoilers.
+ * Whether to escape spoilers
*
- * @defaultValue `true`
+ * @defaultValue true
*/
spoiler?: boolean;
/**
- * Whether to escape strikethroughs.
+ * Whether to escape strikethroughs
*
- * @defaultValue `true`
+ * @defaultValue true
*/
strikethrough?: boolean;
/**
- * Whether to escape underlines.
+ * Whether to escape underlines
*
- * @defaultValue `true`
+ * @defaultValue true
*/
underline?: boolean;
}
/**
- * Escapes any Discord-flavored markdown in a string.
+ * Escapes any Discord-flavour markdown in a string.
*
* @param text - Content to escape
* @param options - Options for escaping the markdown
diff --git a/packages/formatters/src/formatters.ts b/packages/formatters/src/formatters.ts
index 1faeb0c4544a..8b253a977bc8 100644
--- a/packages/formatters/src/formatters.ts
+++ b/packages/formatters/src/formatters.ts
@@ -2,31 +2,26 @@ import type { URL } from 'node:url';
import type { Snowflake } from 'discord-api-types/globals';
/**
- * Wraps the content inside a code block with no language.
+ * Wraps the content inside a codeblock with no language
*
- * @typeParam C - This is inferred by the supplied content
* @param content - The content to wrap
*/
export function codeBlock(content: C): `\`\`\`\n${C}\n\`\`\``;
/**
- * Wraps the content inside a code block with the specified language.
+ * Wraps the content inside a codeblock with the specified language
*
- * @typeParam L - This is inferred by the supplied language
- * @typeParam C - This is inferred by the supplied content
- * @param language - The language for the code block
+ * @param language - The language for the codeblock
* @param content - The content to wrap
*/
export function codeBlock