mirror of
https://github.com/discordjs/discord.js.git
synced 2026-05-23 12:00:09 +00:00
Compare commits
46 Commits
@discordjs
...
@discordjs
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
464ea2ab30 | ||
|
|
0d1d54a537 | ||
|
|
dd8bb397a8 | ||
|
|
61d3d6d4ae | ||
|
|
512b0c67b9 | ||
|
|
532c3842bc | ||
|
|
edace17a13 | ||
|
|
d3154cf8f1 | ||
|
|
45552faf02 | ||
|
|
ebfd52695e | ||
|
|
595bded8a5 | ||
|
|
c74c632cdb | ||
|
|
fc003050de | ||
|
|
8702978057 | ||
|
|
c2b18d6d8b | ||
|
|
519aa3abe8 | ||
|
|
89c076c89e | ||
|
|
f224a07381 | ||
|
|
8e1e1be0c2 | ||
|
|
193a5e9e20 | ||
|
|
73c6bc2c36 | ||
|
|
b7f1ebc334 | ||
|
|
92aea94411 | ||
|
|
41dee5177d | ||
|
|
bbde371324 | ||
|
|
66b971899a | ||
|
|
43235d43fe | ||
|
|
31df3d21cd | ||
|
|
2663d76709 | ||
|
|
44a1e85847 | ||
|
|
d2e1924fa6 | ||
|
|
68dd260dee | ||
|
|
5e66f85f55 | ||
|
|
46060419a9 | ||
|
|
7c1b73cc69 | ||
|
|
95db597fc8 | ||
|
|
0047a49b73 | ||
|
|
32dff01f29 | ||
|
|
efa50fc3fa | ||
|
|
aa61c20ffd | ||
|
|
d48136bee1 | ||
|
|
46bf8f0146 | ||
|
|
7280d4e82e | ||
|
|
bd2914cc98 | ||
|
|
77804cfd55 | ||
|
|
8fea3ed978 |
@@ -9,7 +9,9 @@
|
||||
<a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/v/discord.js.svg?maxAge=3600" alt="npm version" /></a>
|
||||
<a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/dt/discord.js.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Tests status" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2" alt="Code coverage" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/commits/main"><img src="https://img.shields.io/github/last-commit/discordjs/discord.js.svg?logo=github&logoColor=ffffff" alt="Last commit." /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/graphs/contributors"><img src="https://img.shields.io/github/contributors/discordjs/discord.js.svg?maxAge=3600&logo=github&logoColor=fff&color=00c7be" alt="contributors" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js"><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2" alt="Code coverage" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
|
||||
@@ -18,8 +18,9 @@ export async function Badges({ node }: { readonly node: any }) {
|
||||
const isAbstract = node.isAbstract;
|
||||
const isReadonly = node.isReadonly;
|
||||
const isOptional = node.isOptional;
|
||||
const isExternal = node.isExternal;
|
||||
|
||||
const isAny = isDeprecated || isProtected || isStatic || isAbstract || isReadonly || isOptional;
|
||||
const isAny = isDeprecated || isProtected || isStatic || isAbstract || isReadonly || isOptional || isExternal;
|
||||
|
||||
return isAny ? (
|
||||
<div className="mb-1 flex gap-3">
|
||||
@@ -33,6 +34,7 @@ export async function Badges({ node }: { readonly node: any }) {
|
||||
{isAbstract ? <Badge className="bg-cyan-500/20 text-cyan-500">abstract</Badge> : null}
|
||||
{isReadonly ? <Badge className="bg-purple-500/20 text-purple-500">readonly</Badge> : null}
|
||||
{isOptional ? <Badge className="bg-cyan-500/20 text-cyan-500">optional</Badge> : null}
|
||||
{isExternal ? <Badge className="bg-purple-500/20 text-purple-500">external</Badge> : null}
|
||||
</div>
|
||||
) : null;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ export async function ParameterNode({
|
||||
{description ? <Badges node={parameter} /> : null}
|
||||
{parameter.name}
|
||||
{parameter.isOptional ? '?' : ''}: <ExcerptNode node={parameter.typeExcerpt} version={version} />
|
||||
{parameter.defaultValue ? ` = ${parameter.defaultValue}` : ''}
|
||||
</span>
|
||||
{description && parameter.description?.length ? (
|
||||
<div className="mt-4 pl-4">
|
||||
|
||||
@@ -51,7 +51,13 @@ export async function PropertyNode({
|
||||
<LinkIcon aria-hidden size={16} />
|
||||
</Link>
|
||||
{property.displayName}
|
||||
{property.isOptional ? '?' : ''} : <ExcerptNode node={property.typeExcerpt} version={version} />
|
||||
{property.isOptional ? '?' : ''} : <ExcerptNode node={property.typeExcerpt} version={version} />{' '}
|
||||
{property.summary?.defaultValueBlock.length
|
||||
? `= ${property.summary.defaultValueBlock.reduce(
|
||||
(acc: string, def: { kind: string; text: string }) => `${acc}${def.text}`,
|
||||
'',
|
||||
)}`
|
||||
: ''}
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
|
||||
14
package.json
14
package.json
@@ -6,19 +6,19 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "turbo run build --concurrency=4",
|
||||
"build:affected": "turbo run build --filter=...[origin/main] --concurrency=4",
|
||||
"build:affected": "turbo run build --filter=...[origin/v14] --concurrency=4",
|
||||
"build:apps": "turbo run build:local --filter=...{apps/*} --concurrency=4",
|
||||
"build:apps:affected": "turbo run build:local --filter=...{apps/*}[origin/main] --concurrency=4",
|
||||
"build:apps:affected": "turbo run build:local --filter=...{apps/*}[origin/v14] --concurrency=4",
|
||||
"test": "turbo run test --concurrency=4",
|
||||
"test:affected": "turbo run test --filter=...[origin/main] --concurrency=4",
|
||||
"test:affected": "turbo run test --filter=...[origin/v14] --concurrency=4",
|
||||
"lint": "turbo run lint --concurrency=4",
|
||||
"lint:affected": "turbo run lint --filter=...[origin/main] --concurrency=4",
|
||||
"lint:affected": "turbo run lint --filter=...[origin/v14] --concurrency=4",
|
||||
"format": "turbo run format --concurrency=4",
|
||||
"format:affected": "turbo run format --filter=...[origin/main] --concurrency=4",
|
||||
"format:affected": "turbo run format --filter=...[origin/v14] --concurrency=4",
|
||||
"fmt": "turbo run format --concurrency=4",
|
||||
"fmt:affected": "turbo run format --filter=...[origin/main] --concurrency=4",
|
||||
"fmt:affected": "turbo run format --filter=...[origin/v14] --concurrency=4",
|
||||
"docs": "turbo run docs --concurrency=4",
|
||||
"docs:affected": "turbo run docs --filter=...[origin/main] --concurrency=4",
|
||||
"docs:affected": "turbo run docs --filter=...[origin/v14] --concurrency=4",
|
||||
"prepare": "is-ci || husky",
|
||||
"update": "pnpm --recursive update --interactive",
|
||||
"update:latest": "pnpm --recursive update --interactive --latest",
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
"meilisearch": "^0.38.0",
|
||||
"p-limit": "^6.1.0",
|
||||
"tslib": "^2.6.3",
|
||||
"undici": "6.19.8"
|
||||
"undici": "6.21.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.19.45",
|
||||
|
||||
@@ -14,6 +14,7 @@ import type { IExcerptTokenRange } from './Excerpt.js';
|
||||
* @public
|
||||
*/
|
||||
export interface IApiParameterOptions {
|
||||
defaultValue: string | undefined;
|
||||
isOptional: boolean;
|
||||
isRest: boolean;
|
||||
parameterName: string;
|
||||
@@ -124,6 +125,7 @@ export function ApiParameterListMixin<TBaseClass extends IApiItemConstructor>(
|
||||
isOptional: Boolean(parameterOptions.isOptional),
|
||||
isRest: Boolean(parameterOptions.isRest),
|
||||
parent: this,
|
||||
defaultValue: parameterOptions.defaultValue,
|
||||
});
|
||||
|
||||
this[_parameters].push(parameter);
|
||||
@@ -171,6 +173,7 @@ export function ApiParameterListMixin<TBaseClass extends IApiItemConstructor>(
|
||||
parameterTypeTokenRange: parameter.parameterTypeExcerpt.tokenRange,
|
||||
isOptional: parameter.isOptional,
|
||||
isRest: parameter.isRest,
|
||||
defaultValue: parameter.defaultValue,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ const MinifyJSONMapping = {
|
||||
constraintTokenRange: 'ctr',
|
||||
dependencies: 'dp',
|
||||
defaultTypeTokenRange: 'dtr',
|
||||
defaultValue: 'dv',
|
||||
docComment: 'd',
|
||||
endIndex: 'en',
|
||||
excerptTokens: 'ex',
|
||||
|
||||
@@ -262,6 +262,7 @@ function mapParam(
|
||||
startIndex: 1 + index + paramTokens.slice(0, index).reduce((akk, num) => akk + num, 0),
|
||||
endIndex: 1 + index + paramTokens.slice(0, index + 1).reduce((akk, num) => akk + num, 0),
|
||||
},
|
||||
defaultValue: param.default,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import type { Excerpt } from '../mixins/Excerpt.js';
|
||||
* @public
|
||||
*/
|
||||
export interface IParameterOptions {
|
||||
defaultValue: string | undefined;
|
||||
isOptional: boolean;
|
||||
isRest: boolean;
|
||||
name: string;
|
||||
@@ -56,6 +57,11 @@ export class Parameter {
|
||||
*/
|
||||
public isRest: boolean;
|
||||
|
||||
/**
|
||||
* The default value for this parameter if optional
|
||||
*/
|
||||
public defaultValue: string | undefined;
|
||||
|
||||
private readonly _parent: ApiParameterListMixin;
|
||||
|
||||
public constructor(options: IParameterOptions) {
|
||||
@@ -64,6 +70,7 @@ export class Parameter {
|
||||
this.isOptional = options.isOptional;
|
||||
this.isRest = options.isRest;
|
||||
this._parent = options.parent;
|
||||
this.defaultValue = options.defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -843,6 +843,7 @@ export class ApiModelGenerator {
|
||||
const parameters: IApiParameterOptions[] = this._captureParameters(
|
||||
nodesToCapture,
|
||||
functionDeclaration.parameters,
|
||||
jsDoc?.params,
|
||||
);
|
||||
|
||||
const excerptTokens: IExcerptToken[] = this._buildExcerptTokens(astDeclaration, nodesToCapture);
|
||||
@@ -1043,6 +1044,7 @@ export class ApiModelGenerator {
|
||||
const parameters: IApiParameterOptions[] = this._captureParameters(
|
||||
nodesToCapture,
|
||||
methodDeclaration.parameters,
|
||||
jsDoc?.params,
|
||||
);
|
||||
|
||||
const excerptTokens: IExcerptToken[] = this._buildExcerptTokens(astDeclaration, nodesToCapture);
|
||||
@@ -1137,7 +1139,11 @@ export class ApiModelGenerator {
|
||||
methodSignature.typeParameters,
|
||||
);
|
||||
|
||||
const parameters: IApiParameterOptions[] = this._captureParameters(nodesToCapture, methodSignature.parameters);
|
||||
const parameters: IApiParameterOptions[] = this._captureParameters(
|
||||
nodesToCapture,
|
||||
methodSignature.parameters,
|
||||
jsDoc?.params,
|
||||
);
|
||||
|
||||
const excerptTokens: IExcerptToken[] = this._buildExcerptTokens(astDeclaration, nodesToCapture);
|
||||
const apiItemMetadata: ApiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
|
||||
@@ -1342,7 +1348,7 @@ export class ApiModelGenerator {
|
||||
const apiItemMetadata: ApiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
|
||||
const docComment: tsdoc.DocComment | undefined = jsDoc
|
||||
? this._tsDocParser.parseString(
|
||||
`/**\n * ${this._fixLinkTags(jsDoc.description) ?? ''}${jsDoc.default ? ` (default: ${this._escapeSpecialChars(jsDoc.default)})` : ''}\n${
|
||||
`/**\n * ${this._fixLinkTags(jsDoc.description) ?? ''}${jsDoc.default ? `\n * @defaultValue ${this._escapeSpecialChars(jsDoc.default)}` : ''}\n${
|
||||
'see' in jsDoc ? jsDoc.see.map((see) => ` * @see ${see}\n`).join('') : ''
|
||||
}${'readonly' in jsDoc && jsDoc.readonly ? ' * @readonly\n' : ''}${
|
||||
'deprecated' in jsDoc && jsDoc.deprecated
|
||||
@@ -1529,6 +1535,7 @@ export class ApiModelGenerator {
|
||||
},
|
||||
isOptional: Boolean(parameter.optional),
|
||||
isRest: parameter.name.startsWith('...'),
|
||||
defaultValue: parameter.default?.toString(),
|
||||
});
|
||||
excerptTokens.push(...newTokens);
|
||||
excerptTokens.push({
|
||||
@@ -1548,6 +1555,7 @@ export class ApiModelGenerator {
|
||||
},
|
||||
isOptional: Boolean(parameter.optional),
|
||||
isRest: parameter.name.startsWith('...'),
|
||||
defaultValue: parameter.default?.toString(),
|
||||
});
|
||||
excerptTokens.push(...newTokens);
|
||||
excerptTokens.push({
|
||||
@@ -1640,6 +1648,7 @@ export class ApiModelGenerator {
|
||||
private _captureParameters(
|
||||
nodesToCapture: IExcerptBuilderNodeToCapture[],
|
||||
parameterNodes: ts.NodeArray<ts.ParameterDeclaration>,
|
||||
jsDoc?: DocgenParamJson[] | undefined,
|
||||
): IApiParameterOptions[] {
|
||||
const parameters: IApiParameterOptions[] = [];
|
||||
for (const parameter of parameterNodes) {
|
||||
@@ -1650,6 +1659,9 @@ export class ApiModelGenerator {
|
||||
parameterTypeTokenRange,
|
||||
isOptional: this._collector.typeChecker.isOptionalParameter(parameter),
|
||||
isRest: Boolean(parameter.dotDotDotToken),
|
||||
defaultValue:
|
||||
parameter.initializer?.getText() ??
|
||||
jsDoc?.find((param) => param.name === parameter.name.getText().trim())?.default?.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1753,7 +1765,7 @@ export class ApiModelGenerator {
|
||||
return input;
|
||||
}
|
||||
|
||||
return input.replaceAll(/(?<char>[{}])/g, '\\$<char>');
|
||||
return input.replaceAll(/(?<char>[@{}])/g, '\\$<char>');
|
||||
}
|
||||
|
||||
private _fixLinkTags(input?: string): string | undefined {
|
||||
@@ -1848,7 +1860,7 @@ export class ApiModelGenerator {
|
||||
isOptional: Boolean(prop.nullable),
|
||||
isReadonly: Boolean(prop.readonly),
|
||||
docComment: this._tsDocParser.parseString(
|
||||
`/**\n * ${this._fixLinkTags(prop.description) ?? ''}${prop.default ? ` (default: ${this._escapeSpecialChars(prop.default)})` : ''}\n${
|
||||
`/**\n * ${this._fixLinkTags(prop.description) ?? ''}\n${prop.default ? ` * @defaultValue ${this._escapeSpecialChars(prop.default)}\n` : ''}${
|
||||
prop.see?.map((see) => ` * @see ${see}\n`).join('') ?? ''
|
||||
}${prop.readonly ? ' * @readonly\n' : ''} */`,
|
||||
).docComment,
|
||||
@@ -1860,7 +1872,7 @@ export class ApiModelGenerator {
|
||||
}${prop.name} :`,
|
||||
},
|
||||
...mappedVarType,
|
||||
{ kind: ExcerptTokenKind.Content, text: ';' },
|
||||
{ kind: ExcerptTokenKind.Content, text: `${prop.default ? ` = ${prop.default}` : ''};` },
|
||||
],
|
||||
propertyTypeTokenRange: { startIndex: 1, endIndex: 1 + mappedVarType.length },
|
||||
releaseTag: prop.access === 'private' ? ReleaseTag.Internal : ReleaseTag.Public,
|
||||
@@ -1883,6 +1895,7 @@ export class ApiModelGenerator {
|
||||
startIndex: 1 + index + paramTokens.slice(0, index).reduce((akk, num) => akk + num, 0),
|
||||
endIndex: 1 + index + paramTokens.slice(0, index + 1).reduce((akk, num) => akk + num, 0),
|
||||
},
|
||||
defaultValue: param.default?.toString(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1907,7 +1920,7 @@ export class ApiModelGenerator {
|
||||
excerptTokens.push(...newTokens);
|
||||
excerptTokens.push({
|
||||
kind: ExcerptTokenKind.Content,
|
||||
text: `, ${method.params![index + 1]!.name}${
|
||||
text: `${method.params![index]!.default ? ` = ${method.params![index]!.default}` : ''}, ${method.params![index + 1]!.name}${
|
||||
method.params![index + 1]!.nullable || method.params![index + 1]!.optional ? '?' : ''
|
||||
}: `,
|
||||
});
|
||||
@@ -1917,7 +1930,10 @@ export class ApiModelGenerator {
|
||||
const newTokens = this._mapVarType(method.params[method.params.length - 1]!.type);
|
||||
paramTokens.push(newTokens.length);
|
||||
excerptTokens.push(...newTokens);
|
||||
excerptTokens.push({ kind: ExcerptTokenKind.Content, text: `): ` });
|
||||
excerptTokens.push({
|
||||
kind: ExcerptTokenKind.Content,
|
||||
text: `${method.params![method.params.length - 1]!.default ? ` = ${method.params![method.params.length - 1]!.default}` : ''}): `,
|
||||
});
|
||||
}
|
||||
|
||||
const returnTokens = this._mapVarType(method.returns?.[0] ?? []);
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
<a href="https://www.npmjs.com/package/@discordjs/brokers"><img src="https://img.shields.io/npm/v/@discordjs/brokers.svg?maxAge=3600" alt="npm version" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/brokers"><img src="https://img.shields.io/npm/dt/@discordjs/brokers.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=brokers" alt="Code coverage" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/commits/main/packages/brokers"><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Fbrokers"></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js"><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=brokers" alt="Code coverage" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
<a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/v/@discordjs/builders.svg?maxAge=3600" alt="npm version" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/dt/@discordjs/builders.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=builders" alt="Code coverage" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/commits/main/packages/builders"><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Fbuilders"></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js"><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=builders" alt="Code coverage" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
|
||||
@@ -565,7 +565,7 @@ describe('Slash Commands', () => {
|
||||
});
|
||||
|
||||
describe('integration types', () => {
|
||||
test('GIVEN a builder with valid integraton types THEN does not throw an error', () => {
|
||||
test('GIVEN a builder with valid integration types THEN does not throw an error', () => {
|
||||
expect(() =>
|
||||
getBuilder().setIntegrationTypes([
|
||||
ApplicationIntegrationType.GuildInstall,
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
"@discordjs/formatters": "workspace:^",
|
||||
"@discordjs/util": "workspace:^",
|
||||
"@sapphire/shapeshift": "^4.0.0",
|
||||
"discord-api-types": "^0.37.114",
|
||||
"discord-api-types": "^0.37.119",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"ts-mixer": "^6.0.4",
|
||||
"tslib": "^2.6.3"
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
<a href="https://www.npmjs.com/package/@discordjs/collection"><img src="https://img.shields.io/npm/v/@discordjs/collection.svg?maxAge=3600" alt="npm version" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/collection"><img src="https://img.shields.io/npm/dt/@discordjs/collection.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=collection" alt="Code coverage" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/commits/main/packages/collection"><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Fcollection"></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js"><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=collection" alt="Code coverage" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
# [@discordjs/core@2.1.0](https://github.com/discordjs/discord.js/compare/@discordjs/core@2.0.1...@discordjs/core@2.1.0) - (2025-04-25)
|
||||
|
||||
## Features
|
||||
|
||||
- **website:** Include reexported members in docs (#10518) ([aa61c20](https://github.com/discordjs/discord.js/commit/aa61c20ffdac3f3a0dca224f9e48e614309ecb2e))
|
||||
|
||||
# [@discordjs/core@2.0.0](https://github.com/discordjs/discord.js/compare/@discordjs/core@1.2.0...@discordjs/core@2.0.0) - (2024-09-01)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
<a href="https://www.npmjs.com/package/@discordjs/core"><img src="https://img.shields.io/npm/v/@discordjs/core.svg?maxAge=3600" alt="npm version" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/core"><img src="https://img.shields.io/npm/dt/@discordjs/core.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=core" alt="Code coverage" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/commits/main/packages/core"><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Fcore"></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js"><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=core" alt="Code coverage" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"extends": "../../api-extractor.json",
|
||||
"bundledPackages": ["discord-api-types"],
|
||||
"docModel": {
|
||||
"projectFolderUrl": "https://github.com/discordjs/discord.js/tree/main/packages/core"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@discordjs/core",
|
||||
"version": "2.0.1",
|
||||
"version": "2.1.0",
|
||||
"description": "A thinly abstracted wrapper around the rest API, and gateway.",
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
@@ -70,7 +70,7 @@
|
||||
"@discordjs/ws": "workspace:^",
|
||||
"@sapphire/snowflake": "^3.5.3",
|
||||
"@vladfrangu/async_event_emitter": "^2.4.6",
|
||||
"discord-api-types": "^0.37.114"
|
||||
"discord-api-types": "^0.38.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@discordjs/api-extractor": "workspace:^",
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<p>
|
||||
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/commits/main/packages/create-discord-bot"><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Fcreate-discord-bot"></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
"no-void": "error",
|
||||
"no-warning-comments": "warn",
|
||||
"prefer-promise-reject-errors": "error",
|
||||
"require-await": "warn",
|
||||
"require-await": "off",
|
||||
"wrap-iife": "error",
|
||||
"yoda": "error",
|
||||
|
||||
|
||||
@@ -2,6 +2,60 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
# [14.18.0](https://github.com/discordjs/discord.js/compare/14.17.3...14.18.0) - (2025-02-10)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- **Guild:** Type error with permissionOverwrites (#10527) ([8e1e1be](https://github.com/discordjs/discord.js/commit/8e1e1be0c23a0a063a6b530ac8cee30cf7629644))
|
||||
- Incorrect relative path (#10734) ([b7f1ebc](https://github.com/discordjs/discord.js/commit/b7f1ebc334e110be3208c476b61b82a69386fd84))
|
||||
- **PresenceUpdate:** Correctly add user regardless of their properties (#10672) ([7c1b73c](https://github.com/discordjs/discord.js/commit/7c1b73cc697fd3b85011bdb2c098ca3a3f863b1f))
|
||||
- **InteractionResponses:** Mark replied true for followUps (#10688) ([32dff01](https://github.com/discordjs/discord.js/commit/32dff01f291271bde3cfb354964ed140a6fa82d7))
|
||||
|
||||
## Documentation
|
||||
|
||||
- Use link tags to render links on the documentation (#10731) ([66b9718](https://github.com/discordjs/discord.js/commit/66b971899ab702240642e3ae2d189fd9e7efc701))
|
||||
- **Message:** Improve message snapshots description (#10709) ([31df3d2](https://github.com/discordjs/discord.js/commit/31df3d21cdc53400672924bc7c5dc7fd3053630b))
|
||||
|
||||
## Features
|
||||
|
||||
- Message forwards (#10733) ([89c076c](https://github.com/discordjs/discord.js/commit/89c076c89e90e8f5912786e8899ced9e8eea6003))
|
||||
- Incident Actions (#10727) ([41dee51](https://github.com/discordjs/discord.js/commit/41dee5177d9cb15f667e60a34619882222bf249c))
|
||||
- **website:** Type parameters links, builtin doc links, default values (#10515) ([43235d4](https://github.com/discordjs/discord.js/commit/43235d43fe76e26805c52dcff13519652bcb6a4a))
|
||||
- **PartialGroupDMChannel:** Add missing properties (#10502) ([5e66f85](https://github.com/discordjs/discord.js/commit/5e66f85f55724a583921252b035eb2097345fec8))
|
||||
- **Subscription:** Add `renewalSkuIds` (#10662) ([efa50fc](https://github.com/discordjs/discord.js/commit/efa50fc3fa463b09bde11c1640daa2abb8c22686))
|
||||
- **website:** Include reexported members in docs (#10518) ([aa61c20](https://github.com/discordjs/discord.js/commit/aa61c20ffdac3f3a0dca224f9e48e614309ecb2e))
|
||||
|
||||
## Refactor
|
||||
|
||||
- Use throw instead of Promise.reject (#10712) ([2663d76](https://github.com/discordjs/discord.js/commit/2663d767099f2e14a23f9cbfb868f279ffb253d1))
|
||||
- Remove data resolver exports (#10701) ([4606041](https://github.com/discordjs/discord.js/commit/46060419a9593dc5132ba6f13b58d0c18613679b))
|
||||
- **IntegrationApplication:** Move common properties to Application (#10627) ([95db597](https://github.com/discordjs/discord.js/commit/95db597fc844e7951b07cfb5741e27086ac7451a))
|
||||
|
||||
## Styling
|
||||
|
||||
- Prettier ([92aea94](https://github.com/discordjs/discord.js/commit/92aea944119638b12c03be0f627f20fe5fe5145e))
|
||||
|
||||
## Typings
|
||||
|
||||
- Fix recurrence rule types (#10694) ([193a5e9](https://github.com/discordjs/discord.js/commit/193a5e9e20fc4832592b2a3b6f142752121f43d5))
|
||||
- **ThreadOnlyChannel:** Remove incorrect `messages` property (#10708) ([44a1e85](https://github.com/discordjs/discord.js/commit/44a1e858473a51809cb1e6114d6a659fe28587f0))
|
||||
- Add `undefined` to `flags` for `exactOptionalPropertyTypes` (#10707) ([d2e1924](https://github.com/discordjs/discord.js/commit/d2e1924fa6a06120879a1158d501a899db3d6d96))
|
||||
- Allow only ephemeral for defer reply (#10696) ([68dd260](https://github.com/discordjs/discord.js/commit/68dd260dee1a7b0bbd4fcdff1b39283ea8dcedec))
|
||||
- Remove createComponent and createComponentBuilder (#10687) ([0047a49](https://github.com/discordjs/discord.js/commit/0047a49b7395acf0936702f233e7fb89e9f352fe))
|
||||
|
||||
# [14.17.3](https://github.com/discordjs/discord.js/compare/14.17.2...14.17.3) - (2025-01-08)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- **Message:** Ensure channel is defined for clean content (#10681) ([46bf8f0](https://github.com/discordjs/discord.js/commit/46bf8f0146b67d7c480a3512ade1edbfb16e7a26))
|
||||
- Use `resolve()` for `PermissionOverwrites` (#10686) ([7280d4e](https://github.com/discordjs/discord.js/commit/7280d4e82eb47ce7cb3964057d7d56a62179cf18))
|
||||
|
||||
# [14.17.2](https://github.com/discordjs/discord.js/compare/14.17.1...14.17.2) - (2025-01-02)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- **InteractionResponses:** Check correct property for deprecation ([77804cf](https://github.com/discordjs/discord.js/commit/77804cfd559691d9b8c85aec8c494cd6c14c4ea7))
|
||||
|
||||
# [14.17.0](https://github.com/discordjs/discord.js/compare/14.16.3...14.17.0) - (2025-01-01)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
<a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/v/discord.js.svg?maxAge=3600" alt="npm version" /></a>
|
||||
<a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/dt/discord.js.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Tests status" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2" alt="Code coverage" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/commits/main/packages/discord.js"><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Fdiscord.js"></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js"><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2" alt="Code coverage" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
{
|
||||
"extends": "../../api-extractor.json",
|
||||
"mainEntryPointFilePath": "<projectFolder>/typings/index.d.ts",
|
||||
"bundledPackages": [
|
||||
"discord-api-types",
|
||||
"@discordjs/builders",
|
||||
"@discordjs/formatters",
|
||||
"@discordjs/rest",
|
||||
"@discordjs/util",
|
||||
"@discordjs/ws"
|
||||
],
|
||||
"docModel": {
|
||||
"projectFolderUrl": "https://github.com/discordjs/discord.js/tree/main/packages/discord.js"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "discord.js",
|
||||
"version": "14.17.0",
|
||||
"version": "14.18.0",
|
||||
"description": "A powerful library for interacting with the Discord API",
|
||||
"scripts": {
|
||||
"test": "pnpm run docs:test && pnpm run test:typescript",
|
||||
@@ -65,18 +65,19 @@
|
||||
"homepage": "https://discord.js.org",
|
||||
"funding": "https://github.com/discordjs/discord.js?sponsor",
|
||||
"dependencies": {
|
||||
"@discordjs/builders": "^1.10.0",
|
||||
"@discordjs/builders": "^1.11.1",
|
||||
"@discordjs/collection": "1.5.3",
|
||||
"@discordjs/formatters": "^0.6.0",
|
||||
"@discordjs/formatters": "^0.6.1",
|
||||
"@discordjs/rest": "workspace:^",
|
||||
"@discordjs/util": "workspace:^",
|
||||
"@discordjs/ws": "^1.2.0",
|
||||
"@discordjs/ws": "^1.2.2",
|
||||
"@sapphire/snowflake": "3.5.3",
|
||||
"discord-api-types": "^0.37.114",
|
||||
"discord-api-types": "^0.38.1",
|
||||
"fast-deep-equal": "3.1.3",
|
||||
"lodash.snakecase": "4.1.1",
|
||||
"magic-bytes.js": "^1.10.0",
|
||||
"tslib": "^2.6.3",
|
||||
"undici": "6.19.8"
|
||||
"undici": "6.21.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@discordjs/api-extractor": "workspace:^",
|
||||
|
||||
@@ -18,6 +18,7 @@ const ClientPresence = require('../structures/ClientPresence');
|
||||
const GuildPreview = require('../structures/GuildPreview');
|
||||
const GuildTemplate = require('../structures/GuildTemplate');
|
||||
const Invite = require('../structures/Invite');
|
||||
const { SoundboardSound } = require('../structures/SoundboardSound');
|
||||
const { Sticker } = require('../structures/Sticker');
|
||||
const StickerPack = require('../structures/StickerPack');
|
||||
const VoiceRegion = require('../structures/VoiceRegion');
|
||||
@@ -390,6 +391,19 @@ class Client extends BaseClient {
|
||||
return this.fetchStickerPacks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the list of default soundboard sounds.
|
||||
* @returns {Promise<Collection<string, SoundboardSound>>}
|
||||
* @example
|
||||
* client.fetchDefaultSoundboardSounds()
|
||||
* .then(sounds => console.log(`Available soundboard sounds are: ${sounds.map(sound => sound.name).join(', ')}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async fetchDefaultSoundboardSounds() {
|
||||
const data = await this.rest.get(Routes.soundboardDefaultSounds());
|
||||
return new Collection(data.map(sound => [sound.sound_id, new SoundboardSound(this, sound)]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a guild preview from Discord, available for all guilds the bot is in and all Discoverable guilds.
|
||||
* @param {GuildResolvable} guild The guild to fetch the preview for
|
||||
|
||||
@@ -112,6 +112,10 @@ class GenericAction {
|
||||
return this.getPayload({ user_id: id }, manager, id, Partials.ThreadMember, false);
|
||||
}
|
||||
|
||||
getSoundboardSound(data, guild) {
|
||||
return this.getPayload(data, guild.soundboardSounds, data.sound_id, Partials.SoundboardSound);
|
||||
}
|
||||
|
||||
spreadInjectedData(data) {
|
||||
return Object.fromEntries(Object.getOwnPropertySymbols(data).map(symbol => [symbol, data[symbol]]));
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ class ActionsManager {
|
||||
this.register(require('./GuildScheduledEventUpdate'));
|
||||
this.register(require('./GuildScheduledEventUserAdd'));
|
||||
this.register(require('./GuildScheduledEventUserRemove'));
|
||||
this.register(require('./GuildSoundboardSoundDelete.js'));
|
||||
this.register(require('./GuildStickerCreate'));
|
||||
this.register(require('./GuildStickerDelete'));
|
||||
this.register(require('./GuildStickerUpdate'));
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
const Action = require('./Action.js');
|
||||
const Events = require('../../util/Events.js');
|
||||
|
||||
class GuildSoundboardSoundDeleteAction extends Action {
|
||||
handle(data) {
|
||||
const guild = this.client.guilds.cache.get(data.guild_id);
|
||||
|
||||
if (!guild) return {};
|
||||
|
||||
const soundboardSound = this.getSoundboardSound(data, guild);
|
||||
|
||||
if (soundboardSound) {
|
||||
guild.soundboardSounds.cache.delete(soundboardSound.soundId);
|
||||
|
||||
/**
|
||||
* Emitted whenever a soundboard sound is deleted in a guild.
|
||||
* @event Client#guildSoundboardSoundDelete
|
||||
* @param {SoundboardSound} soundboardSound The soundboard sound that was deleted
|
||||
*/
|
||||
this.client.emit(Events.GuildSoundboardSoundDelete, soundboardSound);
|
||||
}
|
||||
|
||||
return { soundboardSound };
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GuildSoundboardSoundDeleteAction;
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
const Action = require('./Action');
|
||||
const Events = require('../../util/Events');
|
||||
const Partials = require('../../util/Partials');
|
||||
|
||||
class PresenceUpdateAction extends Action {
|
||||
handle(data) {
|
||||
let user = this.client.users.cache.get(data.user.id);
|
||||
if (!user && data.user.username) user = this.client.users._add(data.user);
|
||||
if (!user && ('username' in data.user || this.client.options.partials.includes(Partials.User))) {
|
||||
user = this.client.users._add(data.user);
|
||||
}
|
||||
if (!user) return;
|
||||
|
||||
if (data.user.username) {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const Events = require('../../../util/Events.js');
|
||||
|
||||
module.exports = (client, { d: data }) => {
|
||||
const guild = client.guilds.cache.get(data.guild_id);
|
||||
|
||||
if (!guild) return;
|
||||
|
||||
const soundboardSounds = new Collection();
|
||||
|
||||
for (const soundboardSound of data.soundboard_sounds) {
|
||||
soundboardSounds.set(soundboardSound.sound_id, guild.soundboardSounds._add(soundboardSound));
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted whenever multiple guild soundboard sounds are updated.
|
||||
* @event Client#guildSoundboardSoundsUpdate
|
||||
* @param {Collection<Snowflake, SoundboardSound>} soundboardSounds The updated soundboard sounds
|
||||
* @param {Guild} guild The guild that the soundboard sounds are from
|
||||
*/
|
||||
client.emit(Events.GuildSoundboardSoundsUpdate, soundboardSounds, guild);
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
const Events = require('../../../util/Events.js');
|
||||
|
||||
module.exports = (client, { d: data }) => {
|
||||
const guild = client.guilds.cache.get(data.guild_id);
|
||||
|
||||
if (!guild) return;
|
||||
|
||||
const soundboardSound = guild.soundboardSounds._add(data);
|
||||
|
||||
/**
|
||||
* Emitted whenever a guild soundboard sound is created.
|
||||
* @event Client#guildSoundboardSoundCreate
|
||||
* @param {SoundboardSound} soundboardSound The created guild soundboard sound
|
||||
*/
|
||||
client.emit(Events.GuildSoundboardSoundCreate, soundboardSound);
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = (client, { d: data }) => {
|
||||
client.actions.GuildSoundboardSoundDelete.handle(data);
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
const Events = require('../../../util/Events.js');
|
||||
|
||||
module.exports = (client, { d: data }) => {
|
||||
const guild = client.guilds.cache.get(data.guild_id);
|
||||
|
||||
if (!guild) return;
|
||||
|
||||
const oldGuildSoundboardSound = guild.soundboardSounds.cache.get(data.sound_id)?._clone() ?? null;
|
||||
const newGuildSoundboardSound = guild.soundboardSounds._add(data);
|
||||
|
||||
/**
|
||||
* Emitted whenever a guild soundboard sound is updated.
|
||||
* @event Client#guildSoundboardSoundUpdate
|
||||
* @param {?SoundboardSound} oldGuildSoundboardSound The guild soundboard sound before the update
|
||||
* @param {SoundboardSound} newGuildSoundboardSound The guild soundboard sound after the update
|
||||
*/
|
||||
client.emit(Events.GuildSoundboardSoundUpdate, oldGuildSoundboardSound, newGuildSoundboardSound);
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const Events = require('../../../util/Events.js');
|
||||
|
||||
module.exports = (client, { d: data }) => {
|
||||
const guild = client.guilds.cache.get(data.guild_id);
|
||||
|
||||
if (!guild) return;
|
||||
|
||||
const soundboardSounds = new Collection();
|
||||
|
||||
for (const soundboardSound of data.soundboard_sounds) {
|
||||
soundboardSounds.set(soundboardSound.sound_id, guild.soundboardSounds._add(soundboardSound));
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted whenever soundboard sounds are received (all soundboard sounds come from the same guild).
|
||||
* @event Client#soundboardSounds
|
||||
* @param {Collection<Snowflake, SoundboardSound>} soundboardSounds The sounds received
|
||||
* @param {Guild} guild The guild that the soundboard sounds are from
|
||||
*/
|
||||
client.emit(Events.SoundboardSounds, soundboardSounds, guild);
|
||||
};
|
||||
@@ -32,6 +32,10 @@ const handlers = Object.fromEntries([
|
||||
['GUILD_SCHEDULED_EVENT_UPDATE', require('./GUILD_SCHEDULED_EVENT_UPDATE')],
|
||||
['GUILD_SCHEDULED_EVENT_USER_ADD', require('./GUILD_SCHEDULED_EVENT_USER_ADD')],
|
||||
['GUILD_SCHEDULED_EVENT_USER_REMOVE', require('./GUILD_SCHEDULED_EVENT_USER_REMOVE')],
|
||||
['GUILD_SOUNDBOARD_SOUNDS_UPDATE', require('./GUILD_SOUNDBOARD_SOUNDS_UPDATE.js')],
|
||||
['GUILD_SOUNDBOARD_SOUND_CREATE', require('./GUILD_SOUNDBOARD_SOUND_CREATE.js')],
|
||||
['GUILD_SOUNDBOARD_SOUND_DELETE', require('./GUILD_SOUNDBOARD_SOUND_DELETE.js')],
|
||||
['GUILD_SOUNDBOARD_SOUND_UPDATE', require('./GUILD_SOUNDBOARD_SOUND_UPDATE.js')],
|
||||
['GUILD_STICKERS_UPDATE', require('./GUILD_STICKERS_UPDATE')],
|
||||
['GUILD_UPDATE', require('./GUILD_UPDATE')],
|
||||
['INTERACTION_CREATE', require('./INTERACTION_CREATE')],
|
||||
@@ -50,6 +54,7 @@ const handlers = Object.fromEntries([
|
||||
['PRESENCE_UPDATE', require('./PRESENCE_UPDATE')],
|
||||
['READY', require('./READY')],
|
||||
['RESUMED', require('./RESUMED')],
|
||||
['SOUNDBOARD_SOUNDS', require('./SOUNDBOARD_SOUNDS.js')],
|
||||
['STAGE_INSTANCE_CREATE', require('./STAGE_INSTANCE_CREATE')],
|
||||
['STAGE_INSTANCE_DELETE', require('./STAGE_INSTANCE_DELETE')],
|
||||
['STAGE_INSTANCE_UPDATE', require('./STAGE_INSTANCE_UPDATE')],
|
||||
|
||||
@@ -106,6 +106,7 @@
|
||||
* @property {'GuildChannelUnowned'} GuildChannelUnowned
|
||||
* @property {'GuildOwned'} GuildOwned
|
||||
* @property {'GuildMembersTimeout'} GuildMembersTimeout
|
||||
* @property {'GuildSoundboardSoundsTimeout'} GuildSoundboardSoundsTimeout
|
||||
* @property {'GuildUncachedMe'} GuildUncachedMe
|
||||
* @property {'ChannelNotCached'} ChannelNotCached
|
||||
* @property {'StageChannelResolve'} StageChannelResolve
|
||||
@@ -131,6 +132,8 @@
|
||||
* @property {'MissingManageEmojisAndStickersPermission'} MissingManageEmojisAndStickersPermission
|
||||
* <warn>This property is deprecated. Use `MissingManageGuildExpressionsPermission` instead.</warn>
|
||||
*
|
||||
|
||||
* @property {'NotGuildSoundboardSound'} NotGuildSoundboardSound
|
||||
* @property {'NotGuildSticker'} NotGuildSticker
|
||||
|
||||
* @property {'ReactionResolveUser'} ReactionResolveUser
|
||||
@@ -266,6 +269,7 @@ const keys = [
|
||||
'GuildChannelUnowned',
|
||||
'GuildOwned',
|
||||
'GuildMembersTimeout',
|
||||
'GuildSoundboardSoundsTimeout',
|
||||
'GuildUncachedMe',
|
||||
'ChannelNotCached',
|
||||
'StageChannelResolve',
|
||||
@@ -290,6 +294,7 @@ const keys = [
|
||||
'MissingManageGuildExpressionsPermission',
|
||||
'MissingManageEmojisAndStickersPermission',
|
||||
|
||||
'NotGuildSoundboardSound',
|
||||
'NotGuildSticker',
|
||||
|
||||
'ReactionResolveUser',
|
||||
|
||||
@@ -91,11 +91,13 @@ const Messages = {
|
||||
[DjsErrorCodes.GuildChannelUnowned]: "The fetched channel does not belong to this manager's guild.",
|
||||
[DjsErrorCodes.GuildOwned]: 'Guild is owned by the client.',
|
||||
[DjsErrorCodes.GuildMembersTimeout]: "Members didn't arrive in time.",
|
||||
[DjsErrorCodes.GuildSoundboardSoundsTimeout]: "Soundboard sounds didn't arrive in time.",
|
||||
[DjsErrorCodes.GuildUncachedMe]: 'The client user as a member of this guild is uncached.',
|
||||
[DjsErrorCodes.ChannelNotCached]: 'Could not find the channel where this message came from in the cache!',
|
||||
[DjsErrorCodes.StageChannelResolve]: 'Could not resolve channel to a stage channel.',
|
||||
[DjsErrorCodes.GuildScheduledEventResolve]: 'Could not resolve the guild scheduled event.',
|
||||
[DjsErrorCodes.FetchOwnerId]: type => `Couldn't resolve the ${type} ownerId to fetch the ${type} member.`,
|
||||
[DjsErrorCodes.FetchOwnerId]: type =>
|
||||
`Couldn't resolve the ${type} ownerId to fetch the ${type} ${type === 'group DM' ? 'owner' : 'member'}.`,
|
||||
|
||||
[DjsErrorCodes.InvalidType]: (name, expected, an = false) => `Supplied ${name} is not a${an ? 'n' : ''} ${expected}.`,
|
||||
[DjsErrorCodes.InvalidElement]: (type, name, elem) => `Supplied ${type} ${name} includes an invalid element: ${elem}`,
|
||||
@@ -117,6 +119,8 @@ const Messages = {
|
||||
[DjsErrorCodes.MissingManageEmojisAndStickersPermission]: guild =>
|
||||
`Client must have Manage Emojis and Stickers permission in guild ${guild} to see emoji authors.`,
|
||||
|
||||
[DjsErrorCodes.NotGuildSoundboardSound]: action =>
|
||||
`Soundboard sound is a default (non-guild) soundboard sound and can't be ${action}.`,
|
||||
[DjsErrorCodes.NotGuildSticker]: 'Sticker is a standard (non-guild) sticker and has no author.',
|
||||
|
||||
[DjsErrorCodes.ReactionResolveUser]: "Couldn't resolve the user id to remove from the reaction.",
|
||||
|
||||
@@ -29,7 +29,6 @@ exports.ChannelFlagsBitField = require('./util/ChannelFlagsBitField');
|
||||
exports.Collection = require('@discordjs/collection').Collection;
|
||||
exports.Constants = require('./util/Constants');
|
||||
exports.Colors = require('./util/Colors');
|
||||
__exportStar(require('./util/DataResolver.js'), exports);
|
||||
exports.Events = require('./util/Events');
|
||||
exports.Formatters = require('./util/Formatters');
|
||||
exports.GuildMemberFlagsBitField = require('./util/GuildMemberFlagsBitField').GuildMemberFlagsBitField;
|
||||
@@ -76,6 +75,7 @@ exports.GuildMemberManager = require('./managers/GuildMemberManager');
|
||||
exports.GuildMemberRoleManager = require('./managers/GuildMemberRoleManager');
|
||||
exports.GuildMessageManager = require('./managers/GuildMessageManager');
|
||||
exports.GuildScheduledEventManager = require('./managers/GuildScheduledEventManager');
|
||||
exports.GuildSoundboardSoundManager = require('./managers/GuildSoundboardSoundManager.js').GuildSoundboardSoundManager;
|
||||
exports.GuildStickerManager = require('./managers/GuildStickerManager');
|
||||
exports.GuildTextThreadManager = require('./managers/GuildTextThreadManager');
|
||||
exports.MessageManager = require('./managers/MessageManager');
|
||||
@@ -124,12 +124,14 @@ exports.CommandInteraction = require('./structures/CommandInteraction');
|
||||
exports.Collector = require('./structures/interfaces/Collector');
|
||||
exports.CommandInteractionOptionResolver = require('./structures/CommandInteractionOptionResolver');
|
||||
exports.Component = require('./structures/Component');
|
||||
exports.ContainerComponent = require('./structures/ContainerComponent');
|
||||
exports.ContextMenuCommandInteraction = require('./structures/ContextMenuCommandInteraction');
|
||||
exports.DMChannel = require('./structures/DMChannel');
|
||||
exports.Embed = require('./structures/Embed');
|
||||
exports.EmbedBuilder = require('./structures/EmbedBuilder');
|
||||
exports.Emoji = require('./structures/Emoji').Emoji;
|
||||
exports.Entitlement = require('./structures/Entitlement').Entitlement;
|
||||
exports.FileComponent = require('./structures/FileComponent');
|
||||
exports.ForumChannel = require('./structures/ForumChannel');
|
||||
exports.Guild = require('./structures/Guild').Guild;
|
||||
exports.GuildAuditLogs = require('./structures/GuildAuditLogs');
|
||||
@@ -162,6 +164,8 @@ exports.Attachment = require('./structures/Attachment');
|
||||
exports.AttachmentBuilder = require('./structures/AttachmentBuilder');
|
||||
exports.ModalBuilder = require('./structures/ModalBuilder');
|
||||
exports.MediaChannel = require('./structures/MediaChannel');
|
||||
exports.MediaGalleryComponent = require('./structures/MediaGalleryComponent');
|
||||
exports.MediaGalleryItem = require('./structures/MediaGalleryItem');
|
||||
exports.MessageCollector = require('./structures/MessageCollector');
|
||||
exports.MessageComponentInteraction = require('./structures/MessageComponentInteraction');
|
||||
exports.MessageContextMenuCommandInteraction = require('./structures/MessageContextMenuCommandInteraction');
|
||||
@@ -181,6 +185,7 @@ exports.ReactionCollector = require('./structures/ReactionCollector');
|
||||
exports.ReactionEmoji = require('./structures/ReactionEmoji');
|
||||
exports.RichPresenceAssets = require('./structures/Presence').RichPresenceAssets;
|
||||
exports.Role = require('./structures/Role').Role;
|
||||
exports.SectionComponent = require('./structures/SectionComponent');
|
||||
exports.SelectMenuBuilder = require('./structures/SelectMenuBuilder');
|
||||
exports.ChannelSelectMenuBuilder = require('./structures/ChannelSelectMenuBuilder');
|
||||
exports.MentionableSelectMenuBuilder = require('./structures/MentionableSelectMenuBuilder');
|
||||
@@ -202,7 +207,9 @@ exports.RoleSelectMenuInteraction = require('./structures/RoleSelectMenuInteract
|
||||
exports.StringSelectMenuInteraction = require('./structures/StringSelectMenuInteraction');
|
||||
exports.UserSelectMenuInteraction = require('./structures/UserSelectMenuInteraction');
|
||||
exports.SelectMenuOptionBuilder = require('./structures/SelectMenuOptionBuilder');
|
||||
exports.SeparatorComponent = require('./structures/SeparatorComponent');
|
||||
exports.SKU = require('./structures/SKU').SKU;
|
||||
exports.SoundboardSound = require('./structures/SoundboardSound.js').SoundboardSound;
|
||||
exports.StringSelectMenuOptionBuilder = require('./structures/StringSelectMenuOptionBuilder');
|
||||
exports.StageChannel = require('./structures/StageChannel');
|
||||
exports.StageInstance = require('./structures/StageInstance').StageInstance;
|
||||
@@ -212,12 +219,15 @@ exports.StickerPack = require('./structures/StickerPack');
|
||||
exports.Team = require('./structures/Team');
|
||||
exports.TeamMember = require('./structures/TeamMember');
|
||||
exports.TextChannel = require('./structures/TextChannel');
|
||||
exports.TextDisplayComponent = require('./structures/TextDisplayComponent');
|
||||
exports.TextInputBuilder = require('./structures/TextInputBuilder');
|
||||
exports.TextInputComponent = require('./structures/TextInputComponent');
|
||||
exports.ThreadChannel = require('./structures/ThreadChannel');
|
||||
exports.ThreadMember = require('./structures/ThreadMember');
|
||||
exports.ThreadOnlyChannel = require('./structures/ThreadOnlyChannel');
|
||||
exports.ThumbnailComponent = require('./structures/ThumbnailComponent');
|
||||
exports.Typing = require('./structures/Typing');
|
||||
exports.UnfurledMediaItem = require('./structures/UnfurledMediaItem');
|
||||
exports.User = require('./structures/User');
|
||||
exports.UserContextMenuCommandInteraction = require('./structures/UserContextMenuCommandInteraction');
|
||||
exports.VoiceChannelEffect = require('./structures/VoiceChannelEffect');
|
||||
|
||||
@@ -36,8 +36,8 @@ class BaseGuildEmojiManager extends CachedManager {
|
||||
* @returns {?GuildEmoji}
|
||||
*/
|
||||
resolve(emoji) {
|
||||
if (emoji instanceof ReactionEmoji) return super.cache.get(emoji.id) ?? null;
|
||||
if (emoji instanceof ApplicationEmoji) return super.cache.get(emoji.id) ?? null;
|
||||
if (emoji instanceof ReactionEmoji) return this.cache.get(emoji.id) ?? null;
|
||||
if (emoji instanceof ApplicationEmoji) return this.cache.get(emoji.id) ?? null;
|
||||
return super.resolve(emoji);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,14 +97,14 @@ class GuildBanManager extends CachedManager {
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
*/
|
||||
fetch(options) {
|
||||
async fetch(options) {
|
||||
if (!options) return this._fetchMany();
|
||||
const { user, cache, force, limit, before, after } = options;
|
||||
const resolvedUser = this.client.users.resolveId(user ?? options);
|
||||
if (resolvedUser) return this._fetchSingle({ user: resolvedUser, cache, force });
|
||||
|
||||
if (!before && !after && !limit && cache === undefined) {
|
||||
return Promise.reject(new DiscordjsError(ErrorCodes.FetchBanResolveId));
|
||||
throw new DiscordjsError(ErrorCodes.FetchBanResolveId);
|
||||
}
|
||||
|
||||
return this._fetchMany(options);
|
||||
|
||||
@@ -84,7 +84,7 @@ class GuildChannelManager extends CachedManager {
|
||||
* @returns {?(GuildChannel|ThreadChannel)}
|
||||
*/
|
||||
resolve(channel) {
|
||||
if (channel instanceof ThreadChannel) return super.cache.get(channel.id) ?? null;
|
||||
if (channel instanceof ThreadChannel) return this.cache.get(channel.id) ?? null;
|
||||
return super.resolve(channel);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,14 +39,14 @@ class GuildEmojiRoleManager extends DataManager {
|
||||
* @param {RoleResolvable|RoleResolvable[]|Collection<Snowflake, Role>} roleOrRoles The role or roles to add
|
||||
* @returns {Promise<GuildEmoji>}
|
||||
*/
|
||||
add(roleOrRoles) {
|
||||
async add(roleOrRoles) {
|
||||
if (!Array.isArray(roleOrRoles) && !(roleOrRoles instanceof Collection)) roleOrRoles = [roleOrRoles];
|
||||
|
||||
const resolvedRoles = [];
|
||||
for (const role of roleOrRoles.values()) {
|
||||
const resolvedRole = this.guild.roles.resolveId(role);
|
||||
if (!resolvedRole) {
|
||||
return Promise.reject(new DiscordjsTypeError(ErrorCodes.InvalidElement, 'Array or Collection', 'roles', role));
|
||||
throw new DiscordjsTypeError(ErrorCodes.InvalidElement, 'Array or Collection', 'roles', role);
|
||||
}
|
||||
resolvedRoles.push(resolvedRole);
|
||||
}
|
||||
@@ -60,14 +60,14 @@ class GuildEmojiRoleManager extends DataManager {
|
||||
* @param {RoleResolvable|RoleResolvable[]|Collection<Snowflake, Role>} roleOrRoles The role or roles to remove
|
||||
* @returns {Promise<GuildEmoji>}
|
||||
*/
|
||||
remove(roleOrRoles) {
|
||||
async remove(roleOrRoles) {
|
||||
if (!Array.isArray(roleOrRoles) && !(roleOrRoles instanceof Collection)) roleOrRoles = [roleOrRoles];
|
||||
|
||||
const resolvedRoleIds = [];
|
||||
for (const role of roleOrRoles.values()) {
|
||||
const roleId = this.guild.roles.resolveId(role);
|
||||
if (!roleId) {
|
||||
return Promise.reject(new DiscordjsTypeError(ErrorCodes.InvalidElement, 'Array or Collection', 'roles', role));
|
||||
throw new DiscordjsTypeError(ErrorCodes.InvalidElement, 'Array or Collection', 'roles', role);
|
||||
}
|
||||
resolvedRoleIds.push(roleId);
|
||||
}
|
||||
|
||||
@@ -121,22 +121,22 @@ class GuildInviteManager extends CachedManager {
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
*/
|
||||
fetch(options) {
|
||||
async fetch(options) {
|
||||
if (!options) return this._fetchMany();
|
||||
if (typeof options === 'string') {
|
||||
const code = resolveInviteCode(options);
|
||||
if (!code) return Promise.reject(new DiscordjsError(ErrorCodes.InviteResolveCode));
|
||||
if (!code) throw new DiscordjsError(ErrorCodes.InviteResolveCode);
|
||||
return this._fetchSingle({ code, cache: true });
|
||||
}
|
||||
if (!options.code) {
|
||||
if (options.channelId) {
|
||||
const id = this.guild.channels.resolveId(options.channelId);
|
||||
if (!id) return Promise.reject(new DiscordjsError(ErrorCodes.GuildChannelResolve));
|
||||
if (!id) throw new DiscordjsError(ErrorCodes.GuildChannelResolve);
|
||||
return this._fetchChannelMany(id, options.cache);
|
||||
}
|
||||
|
||||
if ('cache' in options) return this._fetchMany(options.cache);
|
||||
return Promise.reject(new DiscordjsError(ErrorCodes.InviteResolveCode));
|
||||
throw new DiscordjsError(ErrorCodes.InviteResolveCode);
|
||||
}
|
||||
return this._fetchSingle({
|
||||
...options,
|
||||
|
||||
@@ -4,8 +4,9 @@ const process = require('node:process');
|
||||
const { setTimeout, clearTimeout } = require('node:timers');
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const { makeURLSearchParams } = require('@discordjs/rest');
|
||||
const { Routes, RouteBases } = require('discord-api-types/v10');
|
||||
const { GatewayOpcodes, Routes, RouteBases } = require('discord-api-types/v10');
|
||||
const CachedManager = require('./CachedManager');
|
||||
const { ErrorCodes, DiscordjsError } = require('../errors/index.js');
|
||||
const ShardClientUtil = require('../sharding/ShardClientUtil');
|
||||
const { Guild } = require('../structures/Guild');
|
||||
const GuildChannel = require('../structures/GuildChannel');
|
||||
@@ -18,6 +19,7 @@ const { resolveImage } = require('../util/DataResolver');
|
||||
const Events = require('../util/Events');
|
||||
const PermissionsBitField = require('../util/PermissionsBitField');
|
||||
const SystemChannelFlagsBitField = require('../util/SystemChannelFlagsBitField');
|
||||
const { _transformAPIIncidentsData } = require('../util/Transformers.js');
|
||||
const { resolveColor } = require('../util/Util');
|
||||
|
||||
let cacheWarningEmitted = false;
|
||||
@@ -281,6 +283,112 @@ class GuildManager extends CachedManager {
|
||||
return data.reduce((coll, guild) => coll.set(guild.id, new OAuth2Guild(this.client, guild)), new Collection());
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} FetchSoundboardSoundsOptions
|
||||
* @param {Snowflake[]} guildIds The ids of the guilds to fetch soundboard sounds for
|
||||
* @param {number} [time=10_000] The timeout for receipt of the soundboard sounds
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fetches soundboard sounds for the specified guilds.
|
||||
* @param {FetchSoundboardSoundsOptions} options The options for fetching soundboard sounds
|
||||
* @returns {Promise<Collection<Snowflake, Collection<Snowflake, SoundboardSound>>>}
|
||||
* @example
|
||||
* // Fetch soundboard sounds for multiple guilds
|
||||
* const soundboardSounds = await client.guilds.fetchSoundboardSounds({
|
||||
* guildIds: ['123456789012345678', '987654321098765432'],
|
||||
* })
|
||||
*
|
||||
* console.log(soundboardSounds.get('123456789012345678'));
|
||||
*/
|
||||
async fetchSoundboardSounds({ guildIds, time = 10_000 }) {
|
||||
const shardCount = this.client.options.shardCount;
|
||||
const shardIds = new Map();
|
||||
|
||||
for (const guildId of guildIds) {
|
||||
const shardId = ShardClientUtil.shardIdForGuildId(guildId, shardCount);
|
||||
const group = shardIds.get(shardId);
|
||||
|
||||
if (group) group.push(guildId);
|
||||
else shardIds.set(shardId, [guildId]);
|
||||
}
|
||||
|
||||
for (const [shardId, shardGuildIds] of shardIds) {
|
||||
this.client.ws.shards.get(shardId).send({
|
||||
op: GatewayOpcodes.RequestSoundboardSounds,
|
||||
d: {
|
||||
guild_ids: shardGuildIds,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const remainingGuildIds = new Set(guildIds);
|
||||
|
||||
const fetchedSoundboardSounds = new Collection();
|
||||
|
||||
const handler = (soundboardSounds, guild) => {
|
||||
timeout.refresh();
|
||||
|
||||
if (!remainingGuildIds.has(guild.id)) return;
|
||||
|
||||
fetchedSoundboardSounds.set(guild.id, soundboardSounds);
|
||||
|
||||
remainingGuildIds.delete(guild.id);
|
||||
|
||||
if (remainingGuildIds.size === 0) {
|
||||
clearTimeout(timeout);
|
||||
this.client.removeListener(Events.SoundboardSounds, handler);
|
||||
this.client.decrementMaxListeners();
|
||||
|
||||
resolve(fetchedSoundboardSounds);
|
||||
}
|
||||
};
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
this.client.removeListener(Events.SoundboardSounds, handler);
|
||||
this.client.decrementMaxListeners();
|
||||
reject(new DiscordjsError(ErrorCodes.GuildSoundboardSoundsTimeout));
|
||||
}, time).unref();
|
||||
|
||||
this.client.incrementMaxListeners();
|
||||
this.client.on(Events.SoundboardSounds, handler);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Options used to set incident actions. Supplying `null` to any option will disable the action.
|
||||
* @typedef {Object} IncidentActionsEditOptions
|
||||
* @property {?DateResolvable} [invitesDisabledUntil] When invites should be enabled again
|
||||
* @property {?DateResolvable} [dmsDisabledUntil] When direct messages should be enabled again
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sets the incident actions for a guild.
|
||||
* @param {GuildResolvable} guild The guild
|
||||
* @param {IncidentActionsEditOptions} incidentActions The incident actions to set
|
||||
* @returns {Promise<IncidentActions>}
|
||||
*/
|
||||
async setIncidentActions(guild, { invitesDisabledUntil, dmsDisabledUntil }) {
|
||||
const guildId = this.resolveId(guild);
|
||||
|
||||
const data = await this.client.rest.put(Routes.guildIncidentActions(guildId), {
|
||||
body: {
|
||||
invites_disabled_until: invitesDisabledUntil && new Date(invitesDisabledUntil).toISOString(),
|
||||
dms_disabled_until: dmsDisabledUntil && new Date(dmsDisabledUntil).toISOString(),
|
||||
},
|
||||
});
|
||||
|
||||
const parsedData = _transformAPIIncidentsData(data);
|
||||
const resolvedGuild = this.resolve(guild);
|
||||
|
||||
if (resolvedGuild) {
|
||||
resolvedGuild.incidentsData = parsedData;
|
||||
}
|
||||
|
||||
return parsedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URL for the PNG widget of a guild.
|
||||
* @param {GuildResolvable} guild The guild of the widget image
|
||||
|
||||
@@ -54,8 +54,8 @@ class GuildMemberManager extends CachedManager {
|
||||
resolve(member) {
|
||||
const memberResolvable = super.resolve(member);
|
||||
if (memberResolvable) return memberResolvable;
|
||||
const userResolvable = this.client.users.resolveId(member);
|
||||
if (userResolvable) return super.cache.get(userResolvable) ?? null;
|
||||
const userId = this.client.users.resolveId(member);
|
||||
if (userId) return this.cache.get(userId) ?? null;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ class GuildMemberManager extends CachedManager {
|
||||
resolveId(member) {
|
||||
const memberResolvable = super.resolveId(member);
|
||||
if (memberResolvable) return memberResolvable;
|
||||
const userResolvable = this.client.users.resolveId(member);
|
||||
return this.cache.has(userResolvable) ? userResolvable : null;
|
||||
const userId = this.client.users.resolveId(member);
|
||||
return this.cache.has(userId) ? userId : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +223,7 @@ class GuildMemberManager extends CachedManager {
|
||||
return this._add(data, cache);
|
||||
}
|
||||
|
||||
_fetchMany({
|
||||
async _fetchMany({
|
||||
limit = 0,
|
||||
withPresences: presences,
|
||||
users,
|
||||
@@ -231,7 +231,7 @@ class GuildMemberManager extends CachedManager {
|
||||
time = 120e3,
|
||||
nonce = DiscordSnowflake.generate().toString(),
|
||||
} = {}) {
|
||||
if (nonce.length > 32) return Promise.reject(new DiscordjsRangeError(ErrorCodes.MemberFetchNonceLength));
|
||||
if (nonce.length > 32) throw new DiscordjsRangeError(ErrorCodes.MemberFetchNonceLength);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!query && !users) query = '';
|
||||
@@ -461,7 +461,7 @@ class GuildMemberManager extends CachedManager {
|
||||
*/
|
||||
async kick(user, reason) {
|
||||
const id = this.client.users.resolveId(user);
|
||||
if (!id) return Promise.reject(new DiscordjsTypeError(ErrorCodes.InvalidType, 'user', 'UserResolvable'));
|
||||
if (!id) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'user', 'UserResolvable');
|
||||
|
||||
await this.client.rest.delete(Routes.guildMember(this.guild.id, id), { reason });
|
||||
|
||||
|
||||
@@ -41,15 +41,12 @@ class GuildScheduledEventManager extends CachedManager {
|
||||
* Options for setting a recurrence rule for a guild scheduled event.
|
||||
* @typedef {Object} GuildScheduledEventRecurrenceRuleOptions
|
||||
* @property {DateResolvable} startAt The time the recurrence rule interval starts at
|
||||
* @property {?DateResolvable} endAt The time the recurrence rule interval ends at
|
||||
* @property {GuildScheduledEventRecurrenceRuleFrequency} frequency How often the event occurs
|
||||
* @property {number} interval The spacing between the events
|
||||
* @property {?GuildScheduledEventRecurrenceRuleWeekday[]} byWeekday The days within a week to recur on
|
||||
* @property {?GuildScheduledEventRecurrenceRuleNWeekday[]} byNWeekday The days within a week to recur on
|
||||
* @property {?GuildScheduledEventRecurrenceRuleMonth[]} byMonth The months to recur on
|
||||
* @property {?number[]} byMonthDay The days within a month to recur on
|
||||
* @property {?number[]} byYearDay The days within a year to recur on
|
||||
* @property {?number} count The total amount of times the event is allowed to recur before stopping
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
192
packages/discord.js/src/managers/GuildSoundboardSoundManager.js
Normal file
192
packages/discord.js/src/managers/GuildSoundboardSoundManager.js
Normal file
@@ -0,0 +1,192 @@
|
||||
'use strict';
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const { lazy } = require('@discordjs/util');
|
||||
const { Routes } = require('discord-api-types/v10');
|
||||
const CachedManager = require('./CachedManager.js');
|
||||
const { DiscordjsTypeError, ErrorCodes } = require('../errors/index.js');
|
||||
const { SoundboardSound } = require('../structures/SoundboardSound.js');
|
||||
const { resolveBase64, resolveFile } = require('../util/DataResolver.js');
|
||||
|
||||
const fileTypeMime = lazy(() => require('magic-bytes.js').filetypemime);
|
||||
|
||||
/**
|
||||
* Manages API methods for Soundboard Sounds and stores their cache.
|
||||
* @extends {CachedManager}
|
||||
*/
|
||||
class GuildSoundboardSoundManager extends CachedManager {
|
||||
constructor(guild, iterable) {
|
||||
super(guild.client, SoundboardSound, iterable);
|
||||
|
||||
/**
|
||||
* The guild this manager belongs to
|
||||
* @type {Guild}
|
||||
*/
|
||||
this.guild = guild;
|
||||
}
|
||||
|
||||
/**
|
||||
* The cache of Soundboard Sounds
|
||||
* @type {Collection<Snowflake, SoundboardSound>}
|
||||
* @name GuildSoundboardSoundManager#cache
|
||||
*/
|
||||
|
||||
_add(data, cache) {
|
||||
return super._add(data, cache, { extras: [this.guild], id: data.sound_id });
|
||||
}
|
||||
|
||||
/**
|
||||
* Data that resolves to give a SoundboardSound object. This can be:
|
||||
* * A SoundboardSound object
|
||||
* * A Snowflake
|
||||
* @typedef {SoundboardSound|Snowflake} SoundboardSoundResolvable
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resolves a SoundboardSoundResolvable to a SoundboardSound object.
|
||||
* @method resolve
|
||||
* @memberof GuildSoundboardSoundManager
|
||||
* @instance
|
||||
* @param {SoundboardSoundResolvable} soundboardSound The SoundboardSound resolvable to identify
|
||||
* @returns {?SoundboardSound}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resolves a {@link SoundboardSoundResolvable} to a {@link SoundboardSound} id.
|
||||
* @param {SoundboardSoundResolvable} soundboardSound The soundboard sound resolvable to resolve
|
||||
* @returns {?Snowflake}
|
||||
*/
|
||||
resolveId(soundboardSound) {
|
||||
if (soundboardSound instanceof this.holds) return soundboardSound.soundId;
|
||||
if (typeof soundboardSound === 'string') return soundboardSound;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options used to create a soundboard sound in a guild.
|
||||
* @typedef {Object} GuildSoundboardSoundCreateOptions
|
||||
* @property {BufferResolvable|Stream} file The file for the soundboard sound
|
||||
* @property {string} name The name for the soundboard sound
|
||||
* @property {string} [contentType] The content type for the soundboard sound file
|
||||
* @property {number} [volume] The volume (a double) for the soundboard sound, from 0 (inclusive) to 1. Defaults to 1
|
||||
* @property {Snowflake} [emojiId] The emoji id for the soundboard sound
|
||||
* @property {string} [emojiName] The emoji name for the soundboard sound
|
||||
* @property {string} [reason] The reason for creating the soundboard sound
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new guild soundboard sound.
|
||||
* @param {GuildSoundboardSoundCreateOptions} options Options for creating a guild soundboard sound
|
||||
* @returns {Promise<SoundboardSound>} The created soundboard sound
|
||||
* @example
|
||||
* // Create a new soundboard sound from a file on your computer
|
||||
* guild.soundboardSounds.create({ file: './sound.mp3', name: 'sound' })
|
||||
* .then(sound => console.log(`Created new soundboard sound with name ${sound.name}!`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async create({ contentType, emojiId, emojiName, file, name, reason, volume }) {
|
||||
const resolvedFile = await resolveFile(file);
|
||||
|
||||
const resolvedContentType = contentType ?? resolvedFile.contentType ?? fileTypeMime()(resolvedFile.data)[0];
|
||||
|
||||
const sound = resolveBase64(resolvedFile.data, resolvedContentType);
|
||||
|
||||
const body = { emoji_id: emojiId, emoji_name: emojiName, name, sound, volume };
|
||||
|
||||
const soundboardSound = await this.client.rest.post(Routes.guildSoundboardSounds(this.guild.id), {
|
||||
body,
|
||||
reason,
|
||||
});
|
||||
|
||||
return this._add(soundboardSound);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data for editing a soundboard sound.
|
||||
* @typedef {Object} GuildSoundboardSoundEditOptions
|
||||
* @property {string} [name] The name of the soundboard sound
|
||||
* @property {?number} [volume] The volume of the soundboard sound, from 0 to 1
|
||||
* @property {?Snowflake} [emojiId] The emoji id of the soundboard sound
|
||||
* @property {?string} [emojiName] The emoji name of the soundboard sound
|
||||
* @property {string} [reason] The reason for editing the soundboard sound
|
||||
*/
|
||||
|
||||
/**
|
||||
* Edits a soundboard sound.
|
||||
* @param {SoundboardSoundResolvable} soundboardSound The soundboard sound to edit
|
||||
* @param {GuildSoundboardSoundEditOptions} [options={}] The new data for the soundboard sound
|
||||
* @returns {Promise<SoundboardSound>}
|
||||
*/
|
||||
async edit(soundboardSound, options = {}) {
|
||||
const soundId = this.resolveId(soundboardSound);
|
||||
|
||||
if (!soundId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'soundboardSound', 'SoundboardSoundResolvable');
|
||||
|
||||
const { emojiId, emojiName, name, reason, volume } = options;
|
||||
|
||||
const body = { emoji_id: emojiId, emoji_name: emojiName, name, volume };
|
||||
|
||||
const data = await this.client.rest.patch(Routes.guildSoundboardSound(this.guild.id, soundId), {
|
||||
body,
|
||||
reason,
|
||||
});
|
||||
|
||||
const existing = this.cache.get(soundId);
|
||||
|
||||
if (existing) {
|
||||
const clone = existing._clone();
|
||||
|
||||
clone._patch(data);
|
||||
return clone;
|
||||
}
|
||||
|
||||
return this._add(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a soundboard sound.
|
||||
* @param {SoundboardSoundResolvable} soundboardSound The soundboard sound to delete
|
||||
* @param {string} [reason] Reason for deleting this soundboard sound
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async delete(soundboardSound, reason) {
|
||||
const soundId = this.resolveId(soundboardSound);
|
||||
|
||||
if (!soundId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'soundboardSound', 'SoundboardSoundResolvable');
|
||||
|
||||
await this.client.rest.delete(Routes.guildSoundboardSound(this.guild.id, soundId), { reason });
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains one or more soundboard sounds from Discord, or the soundboard sound cache if they're already available.
|
||||
* @param {Snowflake} [id] The soundboard sound's id
|
||||
* @param {BaseFetchOptions} [options] Additional options for this fetch
|
||||
* @returns {Promise<SoundboardSound|Collection<Snowflake, SoundboardSound>>}
|
||||
* @example
|
||||
* // Fetch all soundboard sounds from the guild
|
||||
* guild.soundboardSounds.fetch()
|
||||
* .then(sounds => console.log(`There are ${sounds.size} soundboard sounds.`))
|
||||
* .catch(console.error);
|
||||
* @example
|
||||
* // Fetch a single soundboard sound
|
||||
* guild.soundboardSounds.fetch('222078108977594368')
|
||||
* .then(sound => console.log(`The soundboard sound name is: ${sound.name}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async fetch(id, { cache = true, force = false } = {}) {
|
||||
if (id) {
|
||||
if (!force) {
|
||||
const existing = this.cache.get(id);
|
||||
if (existing) return existing;
|
||||
}
|
||||
|
||||
const sound = await this.client.rest.get(Routes.guildSoundboardSound(this.guild.id, id));
|
||||
return this._add(sound, cache);
|
||||
}
|
||||
|
||||
const data = await this.client.rest.get(Routes.guildSoundboardSounds(this.guild.id));
|
||||
return new Collection(data.map(sound => [sound.sound_id, this._add(sound, cache)]));
|
||||
}
|
||||
}
|
||||
|
||||
exports.GuildSoundboardSoundManager = GuildSoundboardSoundManager;
|
||||
@@ -62,15 +62,13 @@ class PermissionOverwriteManager extends CachedManager {
|
||||
* },
|
||||
* ], 'Needed to change permissions');
|
||||
*/
|
||||
set(overwrites, reason) {
|
||||
async set(overwrites, reason) {
|
||||
if (!Array.isArray(overwrites) && !(overwrites instanceof Collection)) {
|
||||
return Promise.reject(
|
||||
new DiscordjsTypeError(
|
||||
ErrorCodes.InvalidType,
|
||||
'overwrites',
|
||||
'Array or Collection of Permission Overwrites',
|
||||
true,
|
||||
),
|
||||
throw new DiscordjsTypeError(
|
||||
ErrorCodes.InvalidType,
|
||||
'overwrites',
|
||||
'Array or Collection of Permission Overwrites',
|
||||
true,
|
||||
);
|
||||
}
|
||||
return this.channel.edit({ permissionOverwrites: overwrites, reason });
|
||||
|
||||
@@ -97,7 +97,7 @@ class ThreadManager extends CachedManager {
|
||||
* Data that can be resolved to a Date object. This can be:
|
||||
* * A Date object
|
||||
* * A number representing a timestamp
|
||||
* * An [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) string
|
||||
* * An {@link https://en.wikipedia.org/wiki/ISO_8601 ISO 8601} string
|
||||
* @typedef {Date|number|string} DateResolvable
|
||||
*/
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ class Shard extends EventEmitter {
|
||||
* before resolving (`-1` or `Infinity` for no wait)
|
||||
* @returns {Promise<ChildProcess>}
|
||||
*/
|
||||
spawn(timeout = 30_000) {
|
||||
async spawn(timeout = 30_000) {
|
||||
if (this.process) throw new DiscordjsError(ErrorCodes.ShardingProcessExists, this.id);
|
||||
if (this.worker) throw new DiscordjsError(ErrorCodes.ShardingWorkerExists, this.id);
|
||||
|
||||
@@ -161,7 +161,7 @@ class Shard extends EventEmitter {
|
||||
*/
|
||||
this.emit(ShardEvents.Spawn, child);
|
||||
|
||||
if (timeout === -1 || timeout === Infinity) return Promise.resolve(child);
|
||||
if (timeout === -1 || timeout === Infinity) return child;
|
||||
return new Promise((resolve, reject) => {
|
||||
const cleanup = () => {
|
||||
clearTimeout(spawnTimeoutTimer);
|
||||
@@ -260,10 +260,10 @@ class Shard extends EventEmitter {
|
||||
* .then(count => console.log(`${count} guilds in shard ${shard.id}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
fetchClientValue(prop) {
|
||||
async fetchClientValue(prop) {
|
||||
// Shard is dead (maybe respawning), don't cache anything and error immediately
|
||||
if (!this.process && !this.worker) {
|
||||
return Promise.reject(new DiscordjsError(ErrorCodes.ShardingNoChildExists, this.id));
|
||||
throw new DiscordjsError(ErrorCodes.ShardingNoChildExists, this.id);
|
||||
}
|
||||
|
||||
// Cached promise from previous call
|
||||
@@ -302,13 +302,13 @@ class Shard extends EventEmitter {
|
||||
* @param {*} [context] The context for the eval
|
||||
* @returns {Promise<*>} Result of the script execution
|
||||
*/
|
||||
eval(script, context) {
|
||||
async eval(script, context) {
|
||||
// Stringify the script if it's a Function
|
||||
const _eval = typeof script === 'function' ? `(${script})(this, ${JSON.stringify(context)})` : script;
|
||||
|
||||
// Shard is dead (maybe respawning), don't cache anything and error immediately
|
||||
if (!this.process && !this.worker) {
|
||||
return Promise.reject(new DiscordjsError(ErrorCodes.ShardingNoChildExists, this.id));
|
||||
throw new DiscordjsError(ErrorCodes.ShardingNoChildExists, this.id);
|
||||
}
|
||||
|
||||
// Cached promise from previous call
|
||||
|
||||
@@ -225,7 +225,8 @@ class ShardClientUtil {
|
||||
* Emitted when the client encounters an error.
|
||||
* <warn>Errors thrown within this event do not have a catch handler, it is
|
||||
* recommended to not use async functions as `error` event handlers. See the
|
||||
* [Node.js docs](https://nodejs.org/api/events.html#capture-rejections-of-promises) for details.</warn>
|
||||
* {@link https://nodejs.org/api/events.html#capture-rejections-of-promises Node.js documentation}
|
||||
* for details.)</warn>
|
||||
* @event Client#error
|
||||
* @param {Error} error The error encountered
|
||||
*/
|
||||
|
||||
@@ -256,9 +256,9 @@ class ShardingManager extends EventEmitter {
|
||||
* @param {BroadcastEvalOptions} [options={}] The options for the broadcast
|
||||
* @returns {Promise<*|Array<*>>} Results of the script execution
|
||||
*/
|
||||
broadcastEval(script, options = {}) {
|
||||
async broadcastEval(script, options = {}) {
|
||||
if (typeof script !== 'function') {
|
||||
return Promise.reject(new DiscordjsTypeError(ErrorCodes.ShardingInvalidEvalBroadcast));
|
||||
throw new DiscordjsTypeError(ErrorCodes.ShardingInvalidEvalBroadcast);
|
||||
}
|
||||
return this._performOnShards('eval', [`(${script})(this, ${JSON.stringify(options.context)})`], options.shard);
|
||||
}
|
||||
@@ -285,16 +285,16 @@ class ShardingManager extends EventEmitter {
|
||||
* @returns {Promise<*|Array<*>>} Results of the method execution
|
||||
* @private
|
||||
*/
|
||||
_performOnShards(method, args, shard) {
|
||||
if (this.shards.size === 0) return Promise.reject(new DiscordjsError(ErrorCodes.ShardingNoShards));
|
||||
async _performOnShards(method, args, shard) {
|
||||
if (this.shards.size === 0) throw new DiscordjsError(ErrorCodes.ShardingNoShards);
|
||||
|
||||
if (typeof shard === 'number') {
|
||||
if (this.shards.has(shard)) return this.shards.get(shard)[method](...args);
|
||||
return Promise.reject(new DiscordjsError(ErrorCodes.ShardingShardNotFound, shard));
|
||||
throw new DiscordjsError(ErrorCodes.ShardingShardNotFound, shard);
|
||||
}
|
||||
|
||||
if (this.shards.size !== this.shardList.length) {
|
||||
return Promise.reject(new DiscordjsError(ErrorCodes.ShardingInProcess));
|
||||
throw new DiscordjsError(ErrorCodes.ShardingInProcess);
|
||||
}
|
||||
|
||||
const promises = [];
|
||||
|
||||
@@ -173,26 +173,6 @@ class ClientApplication extends Application {
|
||||
this.guildId ??= null;
|
||||
}
|
||||
|
||||
if ('cover_image' in data) {
|
||||
/**
|
||||
* The hash of the application's cover image
|
||||
* @type {?string}
|
||||
*/
|
||||
this.cover = data.cover_image;
|
||||
} else {
|
||||
this.cover ??= null;
|
||||
}
|
||||
|
||||
if ('rpc_origins' in data) {
|
||||
/**
|
||||
* The application's RPC origins, if enabled
|
||||
* @type {string[]}
|
||||
*/
|
||||
this.rpcOrigins = data.rpc_origins;
|
||||
} else {
|
||||
this.rpcOrigins ??= [];
|
||||
}
|
||||
|
||||
if ('bot_require_code_grant' in data) {
|
||||
/**
|
||||
* If this application's bot requires a code grant when using the OAuth2 flow
|
||||
|
||||
@@ -14,6 +14,15 @@ class Component {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of this component
|
||||
* @type {number}
|
||||
* @readonly
|
||||
*/
|
||||
get id() {
|
||||
return this.data.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of the component
|
||||
* @type {ComponentType}
|
||||
|
||||
60
packages/discord.js/src/structures/ContainerComponent.js
Normal file
60
packages/discord.js/src/structures/ContainerComponent.js
Normal file
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
const Component = require('./Component');
|
||||
const { createComponent } = require('../util/Components');
|
||||
|
||||
/**
|
||||
* Represents a container component
|
||||
* @extends {Component}
|
||||
*/
|
||||
class ContainerComponent extends Component {
|
||||
constructor({ components, ...data }) {
|
||||
super(data);
|
||||
|
||||
/**
|
||||
* The components in this container
|
||||
* @type {Component[]}
|
||||
* @readonly
|
||||
*/
|
||||
this.components = components.map(component => createComponent(component));
|
||||
}
|
||||
|
||||
/**
|
||||
* The accent color of this container
|
||||
* @type {?number}
|
||||
* @readonly
|
||||
*/
|
||||
get accentColor() {
|
||||
return this.data.accent_color ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The hex accent color of this container
|
||||
* @type {?string}
|
||||
* @readonly
|
||||
*/
|
||||
get hexAccentColor() {
|
||||
return typeof this.data.accent_color === 'number'
|
||||
? `#${this.data.accent_color.toString(16).padStart(6, '0')}`
|
||||
: (this.data.accent_color ?? null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this container is spoilered
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get spoiler() {
|
||||
return this.data.spoiler ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the API-compatible JSON for this component
|
||||
* @returns {APIContainerComponent}
|
||||
*/
|
||||
toJSON() {
|
||||
return { ...this.data, components: this.components.map(component => component.toJSON()) };
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ContainerComponent;
|
||||
40
packages/discord.js/src/structures/FileComponent.js
Normal file
40
packages/discord.js/src/structures/FileComponent.js
Normal file
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
const Component = require('./Component');
|
||||
const UnfurledMediaItem = require('./UnfurledMediaItem');
|
||||
|
||||
/**
|
||||
* Represents a file component
|
||||
* @extends {Component}
|
||||
*/
|
||||
class FileComponent extends Component {
|
||||
constructor({ file, ...data }) {
|
||||
super(data);
|
||||
|
||||
/**
|
||||
* The media associated with this file
|
||||
* @type {UnfurledMediaItem}
|
||||
* @readonly
|
||||
*/
|
||||
this.file = new UnfurledMediaItem(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this thumbnail is spoilered
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get spoiler() {
|
||||
return this.data.spoiler ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the API-compatible JSON for this component
|
||||
* @returns {APIFileComponent}
|
||||
*/
|
||||
toJSON() {
|
||||
return { ...this.data, file: this.file.toJSON() };
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = FileComponent;
|
||||
@@ -21,6 +21,7 @@ const GuildEmojiManager = require('../managers/GuildEmojiManager');
|
||||
const GuildInviteManager = require('../managers/GuildInviteManager');
|
||||
const GuildMemberManager = require('../managers/GuildMemberManager');
|
||||
const GuildScheduledEventManager = require('../managers/GuildScheduledEventManager');
|
||||
const { GuildSoundboardSoundManager } = require('../managers/GuildSoundboardSoundManager');
|
||||
const GuildStickerManager = require('../managers/GuildStickerManager');
|
||||
const PresenceManager = require('../managers/PresenceManager');
|
||||
const RoleManager = require('../managers/RoleManager');
|
||||
@@ -29,6 +30,7 @@ const VoiceStateManager = require('../managers/VoiceStateManager');
|
||||
const { resolveImage } = require('../util/DataResolver');
|
||||
const Status = require('../util/Status');
|
||||
const SystemChannelFlagsBitField = require('../util/SystemChannelFlagsBitField');
|
||||
const { _transformAPIIncidentsData } = require('../util/Transformers.js');
|
||||
const { discordSort, getSortableGroupTypes, resolvePartialEmoji } = require('../util/Util');
|
||||
|
||||
/**
|
||||
@@ -107,6 +109,12 @@ class Guild extends AnonymousGuild {
|
||||
*/
|
||||
this.autoModerationRules = new AutoModerationRuleManager(this);
|
||||
|
||||
/**
|
||||
* A manager of the soundboard sounds of this guild.
|
||||
* @type {GuildSoundboardSoundManager}
|
||||
*/
|
||||
this.soundboardSounds = new GuildSoundboardSoundManager(this);
|
||||
|
||||
if (!data) return;
|
||||
if (data.unavailable) {
|
||||
/**
|
||||
@@ -470,6 +478,27 @@ class Guild extends AnonymousGuild {
|
||||
stickers: data.stickers,
|
||||
});
|
||||
}
|
||||
|
||||
if ('incidents_data' in data) {
|
||||
/**
|
||||
* Incident actions of a guild.
|
||||
* @typedef {Object} IncidentActions
|
||||
* @property {?Date} invitesDisabledUntil When invites would be enabled again
|
||||
* @property {?Date} dmsDisabledUntil When direct messages would be enabled again
|
||||
* @property {?Date} dmSpamDetectedAt When direct message spam was detected
|
||||
* @property {?Date} raidDetectedAt When a raid was detected
|
||||
*/
|
||||
|
||||
/**
|
||||
* The incidents data of this guild.
|
||||
* <info>You will need to fetch the guild using {@link BaseGuild#fetch} if you want to receive
|
||||
* this property.</info>
|
||||
* @type {?IncidentActions}
|
||||
*/
|
||||
this.incidentsData = data.incidents_data && _transformAPIIncidentsData(data.incidents_data);
|
||||
} else {
|
||||
this.incidentsData ??= null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1365,6 +1394,15 @@ class Guild extends AnonymousGuild {
|
||||
return this.edit({ features });
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the incident actions for a guild.
|
||||
* @param {IncidentActionsEditOptions} incidentActions The incident actions to set
|
||||
* @returns {Promise<IncidentActions>}
|
||||
*/
|
||||
async setIncidentActions(incidentActions) {
|
||||
return this.client.guilds.setIncidentActions(this.id, incidentActions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this guild equals another guild. It compares all properties, so for most operations
|
||||
* it is advisable to just compare `guild.id === guild2.id` as it is much faster and is often
|
||||
|
||||
@@ -53,10 +53,11 @@ const Targets = {
|
||||
* * An application command
|
||||
* * An auto moderation rule
|
||||
* * A guild onboarding prompt
|
||||
* * A soundboard sound
|
||||
* * An object with an id key if target was deleted or fake entity
|
||||
* * An object where the keys represent either the new value or the old value
|
||||
* @typedef {?(Object|Guild|BaseChannel|User|Role|Invite|Webhook|GuildEmoji|Message|Integration|StageInstance|Sticker|
|
||||
* GuildScheduledEvent|ApplicationCommand|AutoModerationRule|GuildOnboardingPrompt)} AuditLogEntryTarget
|
||||
* GuildScheduledEvent|ApplicationCommand|AutoModerationRule|GuildOnboardingPrompt|SoundboardSound)} AuditLogEntryTarget
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -367,6 +368,8 @@ class GuildAuditLogsEntry {
|
||||
: changesReduce(this.changes, { id: data.target_id });
|
||||
} else if (targetType === Targets.GuildOnboarding) {
|
||||
this.target = changesReduce(this.changes, { id: data.target_id });
|
||||
} else if (targetType === Targets.SoundboardSound) {
|
||||
this.target = guild.soundboardSounds.cache.get(data.target_id) ?? { id: data.target_id };
|
||||
} else if (data.target_id) {
|
||||
this.target = guild[`${targetType.toLowerCase()}s`]?.cache.get(data.target_id) ?? { id: data.target_id };
|
||||
}
|
||||
|
||||
@@ -265,8 +265,8 @@ class GuildChannel extends BaseChannel {
|
||||
* Locks in the permission overwrites from the parent channel.
|
||||
* @returns {Promise<GuildChannel>}
|
||||
*/
|
||||
lockPermissions() {
|
||||
if (!this.parent) return Promise.reject(new DiscordjsError(ErrorCodes.GuildChannelOrphan));
|
||||
async lockPermissions() {
|
||||
if (!this.parent) throw new DiscordjsError(ErrorCodes.GuildChannelOrphan);
|
||||
const permissionOverwrites = this.parent.permissionOverwrites.cache.map(overwrite => overwrite.toJSON());
|
||||
return this.edit({ permissionOverwrites });
|
||||
}
|
||||
|
||||
31
packages/discord.js/src/structures/MediaGalleryComponent.js
Normal file
31
packages/discord.js/src/structures/MediaGalleryComponent.js
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
const Component = require('./Component');
|
||||
const MediaGalleryItem = require('./MediaGalleryItem');
|
||||
|
||||
/**
|
||||
* Represents a media gallery component
|
||||
* @extends {Component}
|
||||
*/
|
||||
class MediaGalleryComponent extends Component {
|
||||
constructor({ items, ...data }) {
|
||||
super(data);
|
||||
|
||||
/**
|
||||
* The items in this media gallery
|
||||
* @type {MediaGalleryItem[]}
|
||||
* @readonly
|
||||
*/
|
||||
this.items = items.map(item => new MediaGalleryItem(item));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the API-compatible JSON for this component
|
||||
* @returns {APIMediaGalleryComponent}
|
||||
*/
|
||||
toJSON() {
|
||||
return { ...this.data, items: this.items.map(item => item.toJSON()) };
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MediaGalleryComponent;
|
||||
51
packages/discord.js/src/structures/MediaGalleryItem.js
Normal file
51
packages/discord.js/src/structures/MediaGalleryItem.js
Normal file
@@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
|
||||
const UnfurledMediaItem = require('./UnfurledMediaItem');
|
||||
|
||||
/**
|
||||
* Represents an item in a media gallery
|
||||
*/
|
||||
class MediaGalleryItem {
|
||||
constructor({ media, ...data }) {
|
||||
/**
|
||||
* The API data associated with this component
|
||||
* @type {APIMediaGalleryItem}
|
||||
*/
|
||||
this.data = data;
|
||||
|
||||
/**
|
||||
* The media associated with this media gallery item
|
||||
* @type {UnfurledMediaItem}
|
||||
* @readonly
|
||||
*/
|
||||
this.media = new UnfurledMediaItem(media);
|
||||
}
|
||||
|
||||
/**
|
||||
* The description of this media gallery item
|
||||
* @type {?string}
|
||||
* @readonly
|
||||
*/
|
||||
get description() {
|
||||
return this.data.description ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this media gallery item is spoilered
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get spoiler() {
|
||||
return this.data.spoiler ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the API-compatible JSON for this component
|
||||
* @returns {APIMediaGalleryItem}
|
||||
*/
|
||||
toJSON() {
|
||||
return { ...this.data, media: this.media.toJSON() };
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MediaGalleryItem;
|
||||
@@ -9,6 +9,7 @@ const {
|
||||
MessageType,
|
||||
MessageFlags,
|
||||
PermissionFlagsBits,
|
||||
MessageReferenceType,
|
||||
} = require('discord-api-types/v10');
|
||||
const Attachment = require('./Attachment');
|
||||
const Base = require('./Base');
|
||||
@@ -22,7 +23,7 @@ const ReactionCollector = require('./ReactionCollector');
|
||||
const { Sticker } = require('./Sticker');
|
||||
const { DiscordjsError, ErrorCodes } = require('../errors');
|
||||
const ReactionManager = require('../managers/ReactionManager');
|
||||
const { createComponent } = require('../util/Components');
|
||||
const { createComponent, findComponentByCustomId } = require('../util/Components');
|
||||
const { NonSystemMessageTypes, MaxBulkDeletableMessageAge, UndeletableMessageTypes } = require('../util/Constants');
|
||||
const MessageFlagsBitField = require('../util/MessageFlagsBitField');
|
||||
const PermissionsBitField = require('../util/PermissionsBitField');
|
||||
@@ -150,10 +151,10 @@ class Message extends Base {
|
||||
|
||||
if ('components' in data) {
|
||||
/**
|
||||
* An array of action rows in the message.
|
||||
* An array of components in the message.
|
||||
* <info>This property requires the {@link GatewayIntentBits.MessageContent} privileged intent
|
||||
* in a guild for messages that do not mention the client.</info>
|
||||
* @type {ActionRow[]}
|
||||
* @type {Component[]}
|
||||
*/
|
||||
this.components = data.components.map(component => createComponent(component));
|
||||
} else {
|
||||
@@ -452,7 +453,7 @@ class Message extends Base {
|
||||
|
||||
if (data.message_snapshots) {
|
||||
/**
|
||||
* The message associated with the message reference
|
||||
* The message snapshots associated with the message reference
|
||||
* @type {Collection<Snowflake, Message>}
|
||||
*/
|
||||
this.messageSnapshots = data.message_snapshots.reduce((coll, snapshot) => {
|
||||
@@ -590,7 +591,7 @@ class Message extends Base {
|
||||
*/
|
||||
get cleanContent() {
|
||||
// eslint-disable-next-line eqeqeq
|
||||
return this.content != null ? cleanContent(this.content, this.channel) : null;
|
||||
return this.content != null && this.channel ? cleanContent(this.content, this.channel) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -704,7 +705,11 @@ class Message extends Base {
|
||||
* @readonly
|
||||
*/
|
||||
get editable() {
|
||||
const precheck = Boolean(this.author.id === this.client.user.id && (!this.guild || this.channel?.viewable));
|
||||
const precheck = Boolean(
|
||||
this.author.id === this.client.user.id &&
|
||||
(!this.guild || this.channel?.viewable) &&
|
||||
this.reference?.type !== MessageReferenceType.Forward,
|
||||
);
|
||||
|
||||
// Regardless of permissions thread messages cannot be edited if
|
||||
// the thread is archived or the thread is locked and the bot does not have permission to manage threads.
|
||||
@@ -824,8 +829,8 @@ class Message extends Base {
|
||||
* .then(msg => console.log(`Updated the content of a message to ${msg.content}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
edit(options) {
|
||||
if (!this.channel) return Promise.reject(new DiscordjsError(ErrorCodes.ChannelNotCached));
|
||||
async edit(options) {
|
||||
if (!this.channel) throw new DiscordjsError(ErrorCodes.ChannelNotCached);
|
||||
return this.channel.messages.edit(this, options);
|
||||
}
|
||||
|
||||
@@ -840,8 +845,8 @@ class Message extends Base {
|
||||
* .catch(console.error);
|
||||
* }
|
||||
*/
|
||||
crosspost() {
|
||||
if (!this.channel) return Promise.reject(new DiscordjsError(ErrorCodes.ChannelNotCached));
|
||||
async crosspost() {
|
||||
if (!this.channel) throw new DiscordjsError(ErrorCodes.ChannelNotCached);
|
||||
return this.channel.messages.crosspost(this.id);
|
||||
}
|
||||
|
||||
@@ -939,8 +944,8 @@ class Message extends Base {
|
||||
* .then(() => console.log(`Replied to message "${message.content}"`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
reply(options) {
|
||||
if (!this.channel) return Promise.reject(new DiscordjsError(ErrorCodes.ChannelNotCached));
|
||||
async reply(options) {
|
||||
if (!this.channel) throw new DiscordjsError(ErrorCodes.ChannelNotCached);
|
||||
let data;
|
||||
|
||||
if (options instanceof MessagePayload) {
|
||||
@@ -956,6 +961,24 @@ class Message extends Base {
|
||||
return this.channel.send(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Forwards this message
|
||||
*
|
||||
* @param {TextBasedChannelResolvable} channel The channel to forward this message to.
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
forward(channel) {
|
||||
const resolvedChannel = this.client.channels.resolve(channel);
|
||||
if (!resolvedChannel) throw new DiscordjsError(ErrorCodes.InvalidType, 'channel', 'TextBasedChannelResolvable');
|
||||
return resolvedChannel.send({
|
||||
forward: {
|
||||
message: this.id,
|
||||
channel: this.channelId,
|
||||
guild: this.guildId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for starting a thread on a message.
|
||||
* @typedef {Object} StartThreadOptions
|
||||
@@ -972,12 +995,12 @@ class Message extends Base {
|
||||
* @param {StartThreadOptions} [options] Options for starting a thread on this message
|
||||
* @returns {Promise<ThreadChannel>}
|
||||
*/
|
||||
startThread(options = {}) {
|
||||
if (!this.channel) return Promise.reject(new DiscordjsError(ErrorCodes.ChannelNotCached));
|
||||
async startThread(options = {}) {
|
||||
if (!this.channel) throw new DiscordjsError(ErrorCodes.ChannelNotCached);
|
||||
if (![ChannelType.GuildText, ChannelType.GuildAnnouncement].includes(this.channel.type)) {
|
||||
return Promise.reject(new DiscordjsError(ErrorCodes.MessageThreadParent));
|
||||
throw new DiscordjsError(ErrorCodes.MessageThreadParent);
|
||||
}
|
||||
if (this.hasThread) return Promise.reject(new DiscordjsError(ErrorCodes.MessageExistingThread));
|
||||
if (this.hasThread) throw new DiscordjsError(ErrorCodes.MessageExistingThread);
|
||||
return this.channel.threads.create({ ...options, startMessage: this });
|
||||
}
|
||||
|
||||
@@ -986,8 +1009,8 @@ class Message extends Base {
|
||||
* @param {boolean} [force=true] Whether to skip the cache check and request the API
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
fetch(force = true) {
|
||||
if (!this.channel) return Promise.reject(new DiscordjsError(ErrorCodes.ChannelNotCached));
|
||||
async fetch(force = true) {
|
||||
if (!this.channel) throw new DiscordjsError(ErrorCodes.ChannelNotCached);
|
||||
return this.channel.messages.fetch({ message: this.id, force });
|
||||
}
|
||||
|
||||
@@ -995,9 +1018,9 @@ class Message extends Base {
|
||||
* Fetches the webhook used to create this message.
|
||||
* @returns {Promise<?Webhook>}
|
||||
*/
|
||||
fetchWebhook() {
|
||||
if (!this.webhookId) return Promise.reject(new DiscordjsError(ErrorCodes.WebhookMessage));
|
||||
if (this.webhookId === this.applicationId) return Promise.reject(new DiscordjsError(ErrorCodes.WebhookApplication));
|
||||
async fetchWebhook() {
|
||||
if (!this.webhookId) throw new DiscordjsError(ErrorCodes.WebhookMessage);
|
||||
if (this.webhookId === this.applicationId) throw new DiscordjsError(ErrorCodes.WebhookApplication);
|
||||
return this.client.fetchWebhook(this.webhookId);
|
||||
}
|
||||
|
||||
@@ -1032,7 +1055,7 @@ class Message extends Base {
|
||||
* @returns {?MessageActionRowComponent}
|
||||
*/
|
||||
resolveComponent(customId) {
|
||||
return this.components.flatMap(row => row.components).find(component => component.customId === customId) ?? null;
|
||||
return findComponentByCustomId(this.components, customId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ const { lazy } = require('@discordjs/util');
|
||||
const BaseInteraction = require('./BaseInteraction');
|
||||
const InteractionWebhook = require('./InteractionWebhook');
|
||||
const InteractionResponses = require('./interfaces/InteractionResponses');
|
||||
const { findComponentByCustomId } = require('../util/Components');
|
||||
|
||||
const getMessage = lazy(() => require('./Message').Message);
|
||||
|
||||
@@ -79,13 +80,11 @@ class MessageComponentInteraction extends BaseInteraction {
|
||||
|
||||
/**
|
||||
* The component which was interacted with
|
||||
* @type {MessageActionRowComponent|APIMessageActionRowComponent}
|
||||
* @type {MessageActionRowComponent|APIComponentInMessageActionRow}
|
||||
* @readonly
|
||||
*/
|
||||
get component() {
|
||||
return this.message.components
|
||||
.flatMap(row => row.components)
|
||||
.find(component => (component.customId ?? component.custom_id) === this.customId);
|
||||
return findComponentByCustomId(this.message.components, this.customId);
|
||||
}
|
||||
|
||||
// These are here only for documentation purposes - they are implemented by InteractionResponses
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
const { Buffer } = require('node:buffer');
|
||||
const { lazy, isJSONEncodable } = require('@discordjs/util');
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const { MessageFlags } = require('discord-api-types/v10');
|
||||
const ActionRowBuilder = require('./ActionRowBuilder');
|
||||
const { MessageFlags, MessageReferenceType } = require('discord-api-types/v10');
|
||||
const { DiscordjsError, DiscordjsRangeError, ErrorCodes } = require('../errors');
|
||||
const { resolveFile } = require('../util/DataResolver');
|
||||
const MessageFlagsBitField = require('../util/MessageFlagsBitField');
|
||||
@@ -149,7 +148,7 @@ class MessagePayload {
|
||||
}
|
||||
|
||||
const components = this.options.components?.map(component =>
|
||||
(isJSONEncodable(component) ? component : new ActionRowBuilder(component)).toJSON(),
|
||||
isJSONEncodable(component) ? component.toJSON() : this.target.client.options.jsonTransformer(component),
|
||||
);
|
||||
|
||||
let username;
|
||||
@@ -166,9 +165,7 @@ class MessagePayload {
|
||||
let flags;
|
||||
if (
|
||||
// eslint-disable-next-line eqeqeq
|
||||
this.options.flags != null ||
|
||||
(this.isMessage && this.options.reply === undefined) ||
|
||||
this.isMessageManager
|
||||
this.options.flags != null
|
||||
) {
|
||||
flags = new MessageFlagsBitField(this.options.flags).bitfield;
|
||||
}
|
||||
@@ -199,6 +196,22 @@ class MessagePayload {
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof this.options.forward === 'object') {
|
||||
const reference = this.options.forward.message;
|
||||
const channel_id = reference.channelId ?? this.target.client.channels.resolveId(this.options.forward.channel);
|
||||
const guild_id = reference.guildId ?? this.target.client.guilds.resolveId(this.options.forward.guild);
|
||||
const message_id = this.target.messages.resolveId(reference);
|
||||
if (message_id) {
|
||||
if (!channel_id) throw new DiscordjsError(ErrorCodes.InvalidType, 'channelId', 'TextBasedChannelResolvable');
|
||||
message_reference = {
|
||||
type: MessageReferenceType.Forward,
|
||||
message_id,
|
||||
channel_id,
|
||||
guild_id: guild_id ?? undefined,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const attachments = this.options.files?.map((file, index) => ({
|
||||
id: index.toString(),
|
||||
description: file.description,
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
const { BaseChannel } = require('./BaseChannel');
|
||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||
const { DiscordjsError, ErrorCodes } = require('../errors');
|
||||
const PartialGroupDMMessageManager = require('../managers/PartialGroupDMMessageManager');
|
||||
|
||||
/**
|
||||
* Represents a Partial Group DM Channel on Discord.
|
||||
* @extends {BaseChannel}
|
||||
* @implements {TextBasedChannel}
|
||||
*/
|
||||
class PartialGroupDMChannel extends BaseChannel {
|
||||
constructor(client, data) {
|
||||
@@ -44,6 +46,36 @@ class PartialGroupDMChannel extends BaseChannel {
|
||||
* @type {PartialGroupDMMessageManager}
|
||||
*/
|
||||
this.messages = new PartialGroupDMMessageManager(this);
|
||||
|
||||
if ('owner_id' in data) {
|
||||
/**
|
||||
* The user id of the owner of this Group DM Channel
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.ownerId = data.owner_id;
|
||||
} else {
|
||||
this.ownerId ??= null;
|
||||
}
|
||||
|
||||
if ('last_message_id' in data) {
|
||||
/**
|
||||
* The channel's last message id, if one was sent
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.lastMessageId = data.last_message_id;
|
||||
} else {
|
||||
this.lastMessageId ??= null;
|
||||
}
|
||||
|
||||
if ('last_pin_timestamp' in data) {
|
||||
/**
|
||||
* The timestamp when the last pinned message was pinned, if there was one
|
||||
* @type {?number}
|
||||
*/
|
||||
this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
|
||||
} else {
|
||||
this.lastPinTimestamp ??= null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,13 +87,45 @@ class PartialGroupDMChannel extends BaseChannel {
|
||||
return this.icon && this.client.rest.cdn.channelIcon(this.id, this.icon, options);
|
||||
}
|
||||
|
||||
delete() {
|
||||
return Promise.reject(new DiscordjsError(ErrorCodes.DeleteGroupDMChannel));
|
||||
/**
|
||||
* Fetches the owner of this Group DM Channel.
|
||||
* @param {BaseFetchOptions} [options] The options for fetching the user
|
||||
* @returns {Promise<User>}
|
||||
*/
|
||||
async fetchOwner(options) {
|
||||
if (!this.ownerId) {
|
||||
throw new DiscordjsError(ErrorCodes.FetchOwnerId, 'group DM');
|
||||
}
|
||||
|
||||
return this.client.users.fetch(this.ownerId, options);
|
||||
}
|
||||
|
||||
fetch() {
|
||||
return Promise.reject(new DiscordjsError(ErrorCodes.FetchGroupDMChannel));
|
||||
async delete() {
|
||||
throw new DiscordjsError(ErrorCodes.DeleteGroupDMChannel);
|
||||
}
|
||||
|
||||
async fetch() {
|
||||
throw new DiscordjsError(ErrorCodes.FetchGroupDMChannel);
|
||||
}
|
||||
|
||||
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
||||
/* eslint-disable no-empty-function */
|
||||
get lastMessage() {}
|
||||
get lastPinAt() {}
|
||||
createMessageComponentCollector() {}
|
||||
awaitMessageComponent() {}
|
||||
}
|
||||
|
||||
TextBasedChannel.applyToClass(PartialGroupDMChannel, true, [
|
||||
'bulkDelete',
|
||||
'send',
|
||||
'sendTyping',
|
||||
'createMessageCollector',
|
||||
'awaitMessages',
|
||||
'fetchWebhooks',
|
||||
'createWebhook',
|
||||
'setRateLimitPerUser',
|
||||
'setNSFW',
|
||||
]);
|
||||
|
||||
module.exports = PartialGroupDMChannel;
|
||||
|
||||
@@ -180,8 +180,11 @@ class PermissionOverwrites extends Base {
|
||||
};
|
||||
}
|
||||
|
||||
const userOrRole = guild.roles.cache.get(overwrite.id) ?? guild.client.users.cache.get(overwrite.id);
|
||||
if (!userOrRole) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'parameter', 'User nor a Role');
|
||||
const userOrRole = guild.roles.resolve(overwrite.id) ?? guild.client.users.resolve(overwrite.id);
|
||||
if (!userOrRole) {
|
||||
throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'parameter', 'cached User or Role');
|
||||
}
|
||||
|
||||
const type = userOrRole instanceof Role ? OverwriteType.Role : OverwriteType.Member;
|
||||
|
||||
return {
|
||||
|
||||
@@ -97,9 +97,9 @@ class Poll extends Base {
|
||||
* Ends this poll.
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
end() {
|
||||
async end() {
|
||||
if (Date.now() > this.expiresTimestamp) {
|
||||
return Promise.reject(new DiscordjsError(ErrorCodes.PollAlreadyExpired));
|
||||
throw new DiscordjsError(ErrorCodes.PollAlreadyExpired);
|
||||
}
|
||||
|
||||
return this.message.channel.messages.endPoll(this.message.id);
|
||||
|
||||
42
packages/discord.js/src/structures/SectionComponent.js
Normal file
42
packages/discord.js/src/structures/SectionComponent.js
Normal file
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
const Component = require('./Component');
|
||||
const { createComponent } = require('../util/Components');
|
||||
|
||||
/**
|
||||
* Represents a section component
|
||||
* @extends {Component}
|
||||
*/
|
||||
class SectionComponent extends Component {
|
||||
constructor({ accessory, components, ...data }) {
|
||||
super(data);
|
||||
|
||||
/**
|
||||
* The components in this section
|
||||
* @type {Component[]}
|
||||
* @readonly
|
||||
*/
|
||||
this.components = components.map(component => createComponent(component));
|
||||
|
||||
/**
|
||||
* The accessory component of this section
|
||||
* @type {Component}
|
||||
* @readonly
|
||||
*/
|
||||
this.accessory = createComponent(accessory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the API-compatible JSON for this component
|
||||
* @returns {APISectionComponent}
|
||||
*/
|
||||
toJSON() {
|
||||
return {
|
||||
...this.data,
|
||||
accessory: this.accessory.toJSON(),
|
||||
components: this.components.map(component => component.toJSON()),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SectionComponent;
|
||||
30
packages/discord.js/src/structures/SeparatorComponent.js
Normal file
30
packages/discord.js/src/structures/SeparatorComponent.js
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
const { SeparatorSpacingSize } = require('discord-api-types/v10');
|
||||
const Component = require('./Component');
|
||||
|
||||
/**
|
||||
* Represents a separator component
|
||||
* @extends {Component}
|
||||
*/
|
||||
class SeparatorComponent extends Component {
|
||||
/**
|
||||
* The spacing of this separator
|
||||
* @type {SeparatorSpacingSize}
|
||||
* @readonly
|
||||
*/
|
||||
get spacing() {
|
||||
return this.data.spacing ?? SeparatorSpacingSize.Small;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this separator is a divider
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get divider() {
|
||||
return this.data.divider ?? true;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SeparatorComponent;
|
||||
204
packages/discord.js/src/structures/SoundboardSound.js
Normal file
204
packages/discord.js/src/structures/SoundboardSound.js
Normal file
@@ -0,0 +1,204 @@
|
||||
'use strict';
|
||||
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const Base = require('./Base.js');
|
||||
const { Emoji } = require('./Emoji.js');
|
||||
const { DiscordjsError, ErrorCodes } = require('../errors/index.js');
|
||||
|
||||
/**
|
||||
* Represents a soundboard sound.
|
||||
* @extends {Base}
|
||||
*/
|
||||
class SoundboardSound extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
/**
|
||||
* The id of this soundboard sound
|
||||
* @type {Snowflake|string}
|
||||
*/
|
||||
this.soundId = data.sound_id;
|
||||
|
||||
this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
if ('available' in data) {
|
||||
/**
|
||||
* Whether this soundboard sound is available
|
||||
* @type {?boolean}
|
||||
*/
|
||||
this.available = data.available;
|
||||
} else {
|
||||
this.available ??= null;
|
||||
}
|
||||
|
||||
if ('name' in data) {
|
||||
/**
|
||||
* The name of this soundboard sound
|
||||
* @type {?string}
|
||||
*/
|
||||
this.name = data.name;
|
||||
} else {
|
||||
this.name ??= null;
|
||||
}
|
||||
|
||||
if ('volume' in data) {
|
||||
/**
|
||||
* The volume (a double) of this soundboard sound, from 0 to 1
|
||||
* @type {?number}
|
||||
*/
|
||||
this.volume = data.volume;
|
||||
} else {
|
||||
this.volume ??= null;
|
||||
}
|
||||
|
||||
if ('emoji_id' in data) {
|
||||
/**
|
||||
* The raw emoji data of this soundboard sound
|
||||
* @type {?Object}
|
||||
* @private
|
||||
*/
|
||||
this._emoji = {
|
||||
id: data.emoji_id,
|
||||
name: data.emoji_name,
|
||||
};
|
||||
} else {
|
||||
this._emoji ??= null;
|
||||
}
|
||||
|
||||
if ('guild_id' in data) {
|
||||
/**
|
||||
* The guild id of this soundboard sound
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.guildId = data.guild_id;
|
||||
} else {
|
||||
this.guildId ??= null;
|
||||
}
|
||||
|
||||
if ('user' in data) {
|
||||
/**
|
||||
* The user who created this soundboard sound
|
||||
* @type {?User}
|
||||
*/
|
||||
this.user = this.client.users._add(data.user);
|
||||
} else {
|
||||
this.user ??= null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp this soundboard sound was created at
|
||||
* @type {number}
|
||||
* @readonly
|
||||
*/
|
||||
get createdTimestamp() {
|
||||
return DiscordSnowflake.timestampFrom(this.soundId);
|
||||
}
|
||||
|
||||
/**
|
||||
* The time this soundboard sound was created at
|
||||
* @type {Date}
|
||||
* @readonly
|
||||
*/
|
||||
get createdAt() {
|
||||
return new Date(this.createdTimestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* The emoji of this soundboard sound
|
||||
* @type {?Emoji}
|
||||
* @readonly
|
||||
*/
|
||||
get emoji() {
|
||||
if (!this._emoji) return null;
|
||||
|
||||
return this.guild?.emojis.cache.get(this._emoji.id) ?? new Emoji(this.client, this._emoji);
|
||||
}
|
||||
|
||||
/**
|
||||
* The guild this soundboard sound is part of
|
||||
* @type {?Guild}
|
||||
* @readonly
|
||||
*/
|
||||
get guild() {
|
||||
return this.client.guilds.resolve(this.guildId);
|
||||
}
|
||||
|
||||
/**
|
||||
* A link to this soundboard sound
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
get url() {
|
||||
return this.client.rest.cdn.soundboardSound(this.soundId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edits this soundboard sound.
|
||||
* @param {GuildSoundboardSoundEditOptions} options The options to provide
|
||||
* @returns {Promise<SoundboardSound>}
|
||||
* @example
|
||||
* // Update the name of a soundboard sound
|
||||
* soundboardSound.edit({ name: 'new name' })
|
||||
* .then(sound => console.log(`Updated the name of the soundboard sound to ${sound.name}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async edit(options) {
|
||||
if (!this.guildId) throw new DiscordjsError(ErrorCodes.NotGuildSoundboardSound, 'edited');
|
||||
|
||||
return this.guild.soundboardSounds.edit(this, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes this soundboard sound.
|
||||
* @param {string} [reason] Reason for deleting this soundboard sound
|
||||
* @returns {Promise<SoundboardSound>}
|
||||
* @example
|
||||
* // Delete a soundboard sound
|
||||
* soundboardSound.delete()
|
||||
* .then(sound => console.log(`Deleted soundboard sound ${sound.name}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async delete(reason) {
|
||||
if (!this.guildId) throw new DiscordjsError(ErrorCodes.NotGuildSoundboardSound, 'deleted');
|
||||
|
||||
await this.guild.soundboardSounds.delete(this, reason);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this soundboard sound is the same as another one.
|
||||
* @param {SoundboardSound|APISoundboardSound} other The soundboard sound to compare it to
|
||||
* @returns {boolean}
|
||||
*/
|
||||
equals(other) {
|
||||
if (other instanceof SoundboardSound) {
|
||||
return (
|
||||
this.soundId === other.soundId &&
|
||||
this.available === other.available &&
|
||||
this.name === other.name &&
|
||||
this.volume === other.volume &&
|
||||
this.emojiId === other.emojiId &&
|
||||
this.emojiName === other.emojiName &&
|
||||
this.guildId === other.guildId &&
|
||||
this.user?.id === other.user?.id
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
this.soundId === other.sound_id &&
|
||||
this.available === other.available &&
|
||||
this.name === other.name &&
|
||||
this.volume === other.volume &&
|
||||
this.emojiId === other.emoji_id &&
|
||||
this.emojiName === other.emoji_name &&
|
||||
this.guildId === other.guild_id &&
|
||||
this.user?.id === other.user?.id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
exports.SoundboardSound = SoundboardSound;
|
||||
@@ -182,8 +182,8 @@ class Sticker extends Base {
|
||||
* Fetches the pack that contains this sticker.
|
||||
* @returns {Promise<?StickerPack>} The sticker pack or `null` if this sticker does not belong to one.
|
||||
*/
|
||||
fetchPack() {
|
||||
if (!this.packId) return Promise.resolve(null);
|
||||
async fetchPack() {
|
||||
if (!this.packId) return null;
|
||||
return this.client.fetchStickerPacks({ packId: this.packId });
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ class Sticker extends Base {
|
||||
* @returns {Promise<Sticker>}
|
||||
* @param {string} [reason] Reason for deleting this sticker
|
||||
* @example
|
||||
* // Delete a message
|
||||
* // Delete a sticker
|
||||
* sticker.delete()
|
||||
* .then(sticker => console.log(`Deleted sticker ${sticker.name}`))
|
||||
* .catch(console.error);
|
||||
|
||||
@@ -56,6 +56,14 @@ class Subscription extends Base {
|
||||
*/
|
||||
this.status = data.status;
|
||||
|
||||
if ('renewal_sku_ids' in data) {
|
||||
/**
|
||||
* The SKU ids that this user will be subscribed to at renewal
|
||||
* @type {?Snowflake[]}
|
||||
*/
|
||||
this.renewalSkuIds = data.renewal_sku_ids;
|
||||
}
|
||||
|
||||
if ('canceled_at' in data) {
|
||||
/**
|
||||
* The timestamp of when the subscription was canceled
|
||||
|
||||
20
packages/discord.js/src/structures/TextDisplayComponent.js
Normal file
20
packages/discord.js/src/structures/TextDisplayComponent.js
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
const Component = require('./Component');
|
||||
|
||||
/**
|
||||
* Represents a text display component
|
||||
* @extends {Component}
|
||||
*/
|
||||
class TextDisplayComponent extends Component {
|
||||
/**
|
||||
* The content of this text display
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
get content() {
|
||||
return this.data.content;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TextDisplayComponent;
|
||||
@@ -317,7 +317,6 @@ class ThreadChannel extends BaseChannel {
|
||||
* @param {BaseFetchOptions} [options] Additional options for this fetch
|
||||
* @returns {Promise<?Message<true>>}
|
||||
*/
|
||||
// eslint-disable-next-line require-await
|
||||
async fetchStarterMessage(options) {
|
||||
const channel = this.parent instanceof getThreadOnlyChannel() ? this : this.parent;
|
||||
return channel?.messages.fetch({ message: this.id, ...options }) ?? null;
|
||||
@@ -407,9 +406,9 @@ class ThreadChannel extends BaseChannel {
|
||||
* @param {string} [reason] Reason for changing invite
|
||||
* @returns {Promise<ThreadChannel>}
|
||||
*/
|
||||
setInvitable(invitable = true, reason) {
|
||||
async setInvitable(invitable = true, reason) {
|
||||
if (this.type !== ChannelType.PrivateThread) {
|
||||
return Promise.reject(new DiscordjsRangeError(ErrorCodes.ThreadInvitableType, this.type));
|
||||
throw new DiscordjsRangeError(ErrorCodes.ThreadInvitableType, this.type);
|
||||
}
|
||||
return this.edit({ invitable, reason });
|
||||
}
|
||||
|
||||
49
packages/discord.js/src/structures/ThumbnailComponent.js
Normal file
49
packages/discord.js/src/structures/ThumbnailComponent.js
Normal file
@@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
|
||||
const Component = require('./Component');
|
||||
const UnfurledMediaItem = require('./UnfurledMediaItem');
|
||||
|
||||
/**
|
||||
* Represents a thumbnail component
|
||||
* @extends {Component}
|
||||
*/
|
||||
class ThumbnailComponent extends Component {
|
||||
constructor({ media, ...data }) {
|
||||
super(data);
|
||||
|
||||
/**
|
||||
* The media associated with this thumbnail
|
||||
* @type {UnfurledMediaItem}
|
||||
* @readonly
|
||||
*/
|
||||
this.media = new UnfurledMediaItem(media);
|
||||
}
|
||||
|
||||
/**
|
||||
* The description of this thumbnail
|
||||
* @type {?string}
|
||||
* @readonly
|
||||
*/
|
||||
get description() {
|
||||
return this.data.description ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this thumbnail is spoilered
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get spoiler() {
|
||||
return this.data.spoiler ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the API-compatible JSON for this component
|
||||
* @returns {APIThumbnailComponent}
|
||||
*/
|
||||
toJSON() {
|
||||
return { ...this.data, media: this.media.toJSON() };
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ThumbnailComponent;
|
||||
25
packages/discord.js/src/structures/UnfurledMediaItem.js
Normal file
25
packages/discord.js/src/structures/UnfurledMediaItem.js
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Represents a media item in a component
|
||||
*/
|
||||
class UnfurledMediaItem {
|
||||
constructor(data) {
|
||||
/**
|
||||
* The API data associated with this media item
|
||||
* @type {APIUnfurledMediaItem}
|
||||
*/
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* The URL of this media gallery item
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
get url() {
|
||||
return this.data.url;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = UnfurledMediaItem;
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { PermissionFlagsBits } = require('discord-api-types/v10');
|
||||
const { PermissionFlagsBits, Routes } = require('discord-api-types/v10');
|
||||
const BaseGuildVoiceChannel = require('./BaseGuildVoiceChannel');
|
||||
|
||||
/**
|
||||
@@ -35,6 +35,26 @@ class VoiceChannel extends BaseGuildVoiceChannel {
|
||||
permissions.has(PermissionFlagsBits.Speak, false)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} SendSoundboardSoundOptions
|
||||
* @property {string} soundId The id of the soundboard sound to send
|
||||
* @property {string} [guildId] The id of the guild the soundboard sound is a part of
|
||||
*/
|
||||
|
||||
/**
|
||||
* Send a soundboard sound to a voice channel the user is connected to.
|
||||
* @param {SoundboardSound|SendSoundboardSoundOptions} sound The sound to send
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async sendSoundboardSound(sound) {
|
||||
await this.client.rest.post(Routes.sendSoundboardSound(this.id), {
|
||||
body: {
|
||||
sound_id: sound.soundId,
|
||||
source_guild_id: sound.guildId ?? undefined,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,6 +64,15 @@ class VoiceChannelEffect {
|
||||
get channel() {
|
||||
return this.guild.channels.cache.get(this.channelId) ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The soundboard sound for soundboard effects.
|
||||
* @type {?SoundboardSound}
|
||||
* @readonly
|
||||
*/
|
||||
get soundboardSound() {
|
||||
return this.guild.soundboardSounds.cache.get(this.soundId) ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = VoiceChannelEffect;
|
||||
|
||||
@@ -141,8 +141,7 @@ class Webhook {
|
||||
|
||||
/**
|
||||
* Options that can be passed into editMessage.
|
||||
* @typedef {BaseMessageOptions} WebhookMessageEditOptions
|
||||
* @property {Attachment[]} [attachments] Attachments to send with the message
|
||||
* @typedef {MessageEditOptions} WebhookMessageEditOptions
|
||||
* @property {Snowflake} [threadId] The id of the thread this message belongs to
|
||||
* <info>For interaction webhooks, this property is ignored</info>
|
||||
*/
|
||||
|
||||
@@ -50,6 +50,56 @@ class Application extends Base {
|
||||
} else {
|
||||
this.icon ??= null;
|
||||
}
|
||||
|
||||
if ('terms_of_service_url' in data) {
|
||||
/**
|
||||
* The URL of the application's terms of service
|
||||
* @type {?string}
|
||||
*/
|
||||
this.termsOfServiceURL = data.terms_of_service_url;
|
||||
} else {
|
||||
this.termsOfServiceURL ??= null;
|
||||
}
|
||||
|
||||
if ('privacy_policy_url' in data) {
|
||||
/**
|
||||
* The URL of the application's privacy policy
|
||||
* @type {?string}
|
||||
*/
|
||||
this.privacyPolicyURL = data.privacy_policy_url;
|
||||
} else {
|
||||
this.privacyPolicyURL ??= null;
|
||||
}
|
||||
|
||||
if ('rpc_origins' in data) {
|
||||
/**
|
||||
* The application's RPC origins, if enabled
|
||||
* @type {string[]}
|
||||
*/
|
||||
this.rpcOrigins = data.rpc_origins;
|
||||
} else {
|
||||
this.rpcOrigins ??= [];
|
||||
}
|
||||
|
||||
if ('cover_image' in data) {
|
||||
/**
|
||||
* The hash of the application's cover image
|
||||
* @type {?string}
|
||||
*/
|
||||
this.cover = data.cover_image;
|
||||
} else {
|
||||
this.cover ??= null;
|
||||
}
|
||||
|
||||
if ('verify_key' in data) {
|
||||
/**
|
||||
* The hex-encoded key for verification in interactions and the GameSDK's GetTicket
|
||||
* @type {?string}
|
||||
*/
|
||||
this.verifyKey = data.verify_key;
|
||||
} else {
|
||||
this.verifyKey ??= null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -163,7 +163,7 @@ class InteractionResponses {
|
||||
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
||||
|
||||
if (typeof options !== 'string') {
|
||||
if ('fetchReply' in options) {
|
||||
if ('ephemeral' in options) {
|
||||
if (!deprecationEmittedForEphemeralOption) {
|
||||
process.emitWarning(
|
||||
`Supplying "ephemeral" for interaction response options is deprecated. Utilize flags instead.`,
|
||||
@@ -272,9 +272,11 @@ class InteractionResponses {
|
||||
* @param {string|MessagePayload|InteractionReplyOptions} options The options for the reply
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
followUp(options) {
|
||||
if (!this.deferred && !this.replied) return Promise.reject(new DiscordjsError(ErrorCodes.InteractionNotReplied));
|
||||
return this.webhook.send(options);
|
||||
async followUp(options) {
|
||||
if (!this.deferred && !this.replied) throw new DiscordjsError(ErrorCodes.InteractionNotReplied);
|
||||
const msg = await this.webhook.send(options);
|
||||
this.replied = true;
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -425,7 +427,7 @@ class InteractionResponses {
|
||||
* .then(interaction => console.log(`${interaction.customId} was submitted!`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
awaitModalSubmit(options) {
|
||||
async awaitModalSubmit(options) {
|
||||
if (typeof options.time !== 'number') throw new DiscordjsError(ErrorCodes.InvalidType, 'time', 'number');
|
||||
const _options = { ...options, max: 1, interactionType: InteractionType.ModalSubmit };
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
@@ -75,11 +75,14 @@ class TextBasedChannel {
|
||||
* @property {?string} [content=''] The content for the message. This can only be `null` when editing a message.
|
||||
* @property {Array<(EmbedBuilder|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/message#allowed-mentions-object) for more details)
|
||||
* (see {@link https://discord.com/developers/docs/resources/message#allowed-mentions-object here} for more details)
|
||||
* @property {Array<(AttachmentBuilder|Attachment|AttachmentPayload|BufferResolvable)>} [files]
|
||||
* The files to send with the message.
|
||||
* @property {Array<(ActionRowBuilder|ActionRow|APIActionRowComponent)>} [components]
|
||||
* Action rows containing interactive components for the message (buttons, select menus)
|
||||
* @property {Array<(ActionRowBuilder|MessageTopLevelComponent|APIMessageTopLevelComponent)>} [components]
|
||||
* Action rows containing interactive components for the message (buttons, select menus) and other
|
||||
* top-level components.
|
||||
* <info>When using components v2, the flag {@link MessageFlags.IsComponentsV2} needs to be set
|
||||
* and `content`, `embeds`, `stickers`, and `poll` cannot be used.</info>
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -107,13 +110,23 @@ class TextBasedChannel {
|
||||
* that message will be returned and no new message will be created
|
||||
* @property {StickerResolvable[]} [stickers=[]] The stickers to send in the message
|
||||
* @property {MessageFlags} [flags] Which flags to set for the message.
|
||||
* <info>Only `MessageFlags.SuppressEmbeds` and `MessageFlags.SuppressNotifications` can be set.</info>
|
||||
* <info>Only {@link MessageFlags.SuppressEmbeds}, {@link MessageFlags.SuppressNotifications} and
|
||||
* {@link MessageFlags.IsComponentsV2} can be set.</info>
|
||||
* <info>{@link MessageFlags.IsComponentsV2} is required if passing components that aren't action rows</info>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ForwardOptions
|
||||
* @property {MessageResolvable} message The originating message
|
||||
* @property {TextBasedChannelResolvable} [channel] The channel of the originating message
|
||||
* @property {GuildResolvable} [guild] The guild of the originating message
|
||||
*/
|
||||
|
||||
/**
|
||||
* The options for sending a message.
|
||||
* @typedef {BaseMessageCreateOptions} MessageCreateOptions
|
||||
* @property {ReplyOptions} [reply] The options for replying to a message
|
||||
* @property {ForwardOptions} [forward] The options for forwarding a message
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,6 +60,11 @@
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIChannelSelectComponent}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIContainerComponent
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIContainerComponent}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIEmbed
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIEmbed}
|
||||
@@ -80,6 +85,11 @@
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIEmoji}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIFileComponent
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIFileComponent}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIGuild
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIGuild}
|
||||
@@ -105,6 +115,11 @@
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIGuildScheduledEventRecurrenceRule}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIIncidentsData
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIIncidentsData}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIInteraction
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIInteraction}
|
||||
@@ -130,6 +145,16 @@
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIInteractionGuildMember}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIMediaGalleryComponent
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIMediaGalleryComponent}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIMediaGalleryItem
|
||||
* @se {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIMediaGalleryItem}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIMentionableSelectComponent
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIMentionableSelectComponent}
|
||||
@@ -141,8 +166,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIMessageActionRowComponent
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIMessageActionRowComponent}
|
||||
* @external APIComponentInMessageActionRow
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIComponentInMessageActionRow}
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -160,6 +185,11 @@
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIMessageInteractionMetadata}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIMessageTopLevelComponent
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIMessageTopLevelComponent}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIModalInteractionResponse
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIModalInteractionResponse}
|
||||
@@ -200,6 +230,16 @@
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIRoleSelectComponent}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APISectionComponent
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APISectionComponent}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APISeparatorComponent
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APISeparatorComponent}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APISelectMenuOption
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APISelectMenuOption}
|
||||
@@ -220,6 +260,16 @@
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APITextInputComponent}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIThumbnailComponent
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIThumbnailComponent}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIUnfurledMediaItem
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIUnfurledMediaItem}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIUser
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIUser}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
// This file contains the typedefs for camel-cased JSON data
|
||||
const { ComponentBuilder } = require('@discordjs/builders');
|
||||
const { ComponentType } = require('discord-api-types/v10');
|
||||
|
||||
/**
|
||||
* @typedef {Object} BaseComponentData
|
||||
* @property {number} [id] the id of this component
|
||||
* @property {ComponentType} type The type of component
|
||||
*/
|
||||
|
||||
@@ -16,30 +17,30 @@ const { ComponentType } = require('discord-api-types/v10');
|
||||
/**
|
||||
* @typedef {BaseComponentData} ButtonComponentData
|
||||
* @property {ButtonStyle} style The style of the button
|
||||
* @property {?boolean} disabled Whether this button is disabled
|
||||
* @property {boolean} [disabled] Whether this button is disabled
|
||||
* @property {string} label The label of this button
|
||||
* @property {?APIMessageComponentEmoji} emoji The emoji on this button
|
||||
* @property {?string} customId The custom id of the button
|
||||
* @property {?string} url The URL of the button
|
||||
* @property {APIMessageComponentEmoji} [emoji] The emoji on this button
|
||||
* @property {string} [customId] The custom id of the button
|
||||
* @property {string} [url] The URL of the button
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} SelectMenuComponentOptionData
|
||||
* @property {string} label The label of the option
|
||||
* @property {string} value The value of the option
|
||||
* @property {?string} description The description of the option
|
||||
* @property {?APIMessageComponentEmoji} emoji The emoji on the option
|
||||
* @property {?boolean} default Whether this option is selected by default
|
||||
* @property {string} [description] The description of the option
|
||||
* @property {APIMessageComponentEmoji} [emoji] The emoji on the option
|
||||
* @property {boolean} [default] Whether this option is selected by default
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {BaseComponentData} SelectMenuComponentData
|
||||
* @property {string} customId The custom id of the select menu
|
||||
* @property {?boolean} disabled Whether the select menu is disabled or not
|
||||
* @property {?number} maxValues The maximum amount of options that can be selected
|
||||
* @property {?number} minValues The minimum amount of options that can be selected
|
||||
* @property {?SelectMenuComponentOptionData[]} options The options in this select menu
|
||||
* @property {?string} placeholder The placeholder of the select menu
|
||||
* @property {boolean} [disabled] Whether the select menu is disabled or not
|
||||
* @property {number} [maxValues] The maximum amount of options that can be selected
|
||||
* @property {number} [minValues] The minimum amount of options that can be selected
|
||||
* @property {SelectMenuComponentOptionData[]} [options] The options in this select menu
|
||||
* @property {string} [placeholder] The placeholder of the select menu
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -51,15 +52,76 @@ const { ComponentType } = require('discord-api-types/v10');
|
||||
* @property {string} customId The custom id of the text input
|
||||
* @property {TextInputStyle} style The style of the text input
|
||||
* @property {string} label The text that appears on top of the text input field
|
||||
* @property {?number} minLength The minimum number of characters that can be entered in the text input
|
||||
* @property {?number} maxLength The maximum number of characters that can be entered in the text input
|
||||
* @property {?boolean} required Whether or not the text input is required or not
|
||||
* @property {?string} value The pre-filled text in the text input
|
||||
* @property {?string} placeholder Placeholder for the text input
|
||||
* @property {number} [minLength] The minimum number of characters that can be entered in the text input
|
||||
* @property {number} [maxLength] The maximum number of characters that can be entered in the text input
|
||||
* @property {boolean} [required] Whether or not the text input is required or not
|
||||
* @property {string} [value] The pre-filled text in the text input
|
||||
* @property {string} [placeholder] Placeholder for the text input
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {ActionRowData|ButtonComponentData|SelectMenuComponentData|TextInputComponentData} ComponentData
|
||||
* @typedef {Object} UnfurledMediaItemData
|
||||
* @property {string} url The url of this media item. Accepts either http:, https: or attachment: protocol
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {BaseComponentData} ThumbnailComponentData
|
||||
* @property {UnfurledMediaItemData} media The media for the thumbnail
|
||||
* @property {string} [description] The description of the thumbnail
|
||||
* @property {boolean} [spoiler] Whether the thumbnail should be spoilered
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {BaseComponentData} FileComponentData
|
||||
* @property {UnfurledMediaItemData} file The file media in this component
|
||||
* @property {boolean} [spoiler] Whether the file should be spoilered
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} MediaGalleryItemData
|
||||
* @property {UnfurledMediaItemData} media The media for the media gallery item
|
||||
* @property {string} [description] The description of the media gallery item
|
||||
* @property {boolean} [spoiler] Whether the media gallery item should be spoilered
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {BaseComponentData} MediaGalleryComponentData
|
||||
* @property {MediaGalleryItemData[]} items The media gallery items in this media gallery component
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {BaseComponentData} SeparatorComponentData
|
||||
* @property {SeparatorSpacingSize} [spacing] The spacing size of this component
|
||||
* @property {boolean} [divider] Whether the separator shows as a divider
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {BaseComponentData} SectionComponentData
|
||||
* @property {Components[]} components The components in this section
|
||||
* @property {ButtonComponentData|ThumbnailComponentData} accessory The accessory shown next to this section
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {BaseComponentData} TextDisplayComponentData
|
||||
* @property {string} content The content displayed in this component
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {ActionRowData|FileComponentData|MediaGalleryComponentData|SectionComponentData|
|
||||
* SeparatorComponentData|TextDisplayComponentData} ComponentInContainerData
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {BaseComponentData} ContainerComponentData
|
||||
* @property {ComponentInContainerData} components The components in this container
|
||||
* @property {?number} [accentColor] The accent color of this container
|
||||
* @property {boolean} [spoiler] Whether the container should be spoilered
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {ActionRowData|ButtonComponentData|SelectMenuComponentData|TextInputComponentData|
|
||||
* ThumbnailComponentData|FileComponentData|MediaGalleryComponentData|SeparatorComponentData|
|
||||
* SectionComponentData|TextDisplayComponentData|ContainerComponentData} ComponentData
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -67,10 +129,16 @@ const { ComponentType } = require('discord-api-types/v10');
|
||||
* @typedef {APIMessageComponentEmoji|string} ComponentEmojiResolvable
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {ActionRow|ContainerComponent|FileComponent|MediaGalleryComponent|
|
||||
* SectionComponent|SeparatorComponent|TextDisplayComponent} MessageTopLevelComponent
|
||||
*/
|
||||
|
||||
/**
|
||||
* Transforms API data into a component
|
||||
* @param {APIMessageComponent|Component} data The data to create the component from
|
||||
* @returns {Component}
|
||||
* @ignore
|
||||
*/
|
||||
function createComponent(data) {
|
||||
if (data instanceof Component) {
|
||||
@@ -94,6 +162,20 @@ function createComponent(data) {
|
||||
return new MentionableSelectMenuComponent(data);
|
||||
case ComponentType.ChannelSelect:
|
||||
return new ChannelSelectMenuComponent(data);
|
||||
case ComponentType.Container:
|
||||
return new ContainerComponent(data);
|
||||
case ComponentType.TextDisplay:
|
||||
return new TextDisplayComponent(data);
|
||||
case ComponentType.File:
|
||||
return new FileComponent(data);
|
||||
case ComponentType.MediaGallery:
|
||||
return new MediaGalleryComponent(data);
|
||||
case ComponentType.Section:
|
||||
return new SectionComponent(data);
|
||||
case ComponentType.Separator:
|
||||
return new SeparatorComponent(data);
|
||||
case ComponentType.Thumbnail:
|
||||
return new ThumbnailComponent(data);
|
||||
default:
|
||||
return new Component(data);
|
||||
}
|
||||
@@ -103,6 +185,7 @@ function createComponent(data) {
|
||||
* Transforms API data into a component builder
|
||||
* @param {APIMessageComponent|ComponentBuilder} data The data to create the component from
|
||||
* @returns {ComponentBuilder}
|
||||
* @ignore
|
||||
*/
|
||||
function createComponentBuilder(data) {
|
||||
if (data instanceof ComponentBuilder) {
|
||||
@@ -131,7 +214,30 @@ function createComponentBuilder(data) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { createComponent, createComponentBuilder };
|
||||
/**
|
||||
* Finds a component by customId in nested components
|
||||
* @param {Array<Component|APIMessageComponent>} components The components to search in
|
||||
* @param {string} customId The customId to search for
|
||||
* @returns {Component|APIMessageComponent}
|
||||
*/
|
||||
function findComponentByCustomId(components, customId) {
|
||||
return (
|
||||
components
|
||||
.flatMap(component => {
|
||||
switch (component.type) {
|
||||
case ComponentType.ActionRow:
|
||||
return component.components;
|
||||
case ComponentType.Section:
|
||||
return [component.accessory];
|
||||
default:
|
||||
return [component];
|
||||
}
|
||||
})
|
||||
.find(component => (component.customId ?? component.custom_id) === customId) ?? null
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = { createComponent, createComponentBuilder, findComponentByCustomId };
|
||||
|
||||
const ActionRow = require('../structures/ActionRow');
|
||||
const ActionRowBuilder = require('../structures/ActionRowBuilder');
|
||||
@@ -140,13 +246,20 @@ const ButtonComponent = require('../structures/ButtonComponent');
|
||||
const ChannelSelectMenuBuilder = require('../structures/ChannelSelectMenuBuilder');
|
||||
const ChannelSelectMenuComponent = require('../structures/ChannelSelectMenuComponent');
|
||||
const Component = require('../structures/Component');
|
||||
const ContainerComponent = require('../structures/ContainerComponent');
|
||||
const FileComponent = require('../structures/FileComponent');
|
||||
const MediaGalleryComponent = require('../structures/MediaGalleryComponent');
|
||||
const MentionableSelectMenuBuilder = require('../structures/MentionableSelectMenuBuilder');
|
||||
const MentionableSelectMenuComponent = require('../structures/MentionableSelectMenuComponent');
|
||||
const RoleSelectMenuBuilder = require('../structures/RoleSelectMenuBuilder');
|
||||
const RoleSelectMenuComponent = require('../structures/RoleSelectMenuComponent');
|
||||
const SectionComponent = require('../structures/SectionComponent');
|
||||
const SeparatorComponent = require('../structures/SeparatorComponent');
|
||||
const StringSelectMenuBuilder = require('../structures/StringSelectMenuBuilder');
|
||||
const StringSelectMenuComponent = require('../structures/StringSelectMenuComponent');
|
||||
const TextDisplayComponent = require('../structures/TextDisplayComponent');
|
||||
const TextInputBuilder = require('../structures/TextInputBuilder');
|
||||
const TextInputComponent = require('../structures/TextInputComponent');
|
||||
const ThumbnailComponent = require('../structures/ThumbnailComponent');
|
||||
const UserSelectMenuBuilder = require('../structures/UserSelectMenuBuilder');
|
||||
const UserSelectMenuComponent = require('../structures/UserSelectMenuComponent');
|
||||
|
||||
@@ -113,13 +113,14 @@ async function resolveFile(resource) {
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resolves a Base64Resolvable to a Base 64 image.
|
||||
* Resolves a Base64Resolvable to a Base 64 string.
|
||||
* @param {Base64Resolvable} data The base 64 resolvable you want to resolve
|
||||
* @param {string} [contentType='image/jpg'] The content type of the data
|
||||
* @returns {?string}
|
||||
* @private
|
||||
*/
|
||||
function resolveBase64(data) {
|
||||
if (Buffer.isBuffer(data)) return `data:image/jpg;base64,${data.toString('base64')}`;
|
||||
function resolveBase64(data, contentType = 'image/jpg') {
|
||||
if (Buffer.isBuffer(data)) return `data:${contentType};base64,${data.toString('base64')}`;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,10 @@
|
||||
* @property {string} GuildScheduledEventUpdate guildScheduledEventUpdate
|
||||
* @property {string} GuildScheduledEventUserAdd guildScheduledEventUserAdd
|
||||
* @property {string} GuildScheduledEventUserRemove guildScheduledEventUserRemove
|
||||
* @property {string} GuildSoundboardSoundCreate guildSoundboardSoundCreate
|
||||
* @property {string} GuildSoundboardSoundDelete guildSoundboardSoundDelete
|
||||
* @property {string} GuildSoundboardSoundsUpdate guildSoundboardSoundsUpdate
|
||||
* @property {string} GuildSoundboardSoundUpdate guildSoundboardSoundUpdate
|
||||
* @property {string} GuildStickerCreate stickerCreate
|
||||
* @property {string} GuildStickerDelete stickerDelete
|
||||
* @property {string} GuildStickerUpdate stickerUpdate
|
||||
@@ -61,6 +65,7 @@
|
||||
* @property {string} MessageReactionRemoveEmoji messageReactionRemoveEmoji
|
||||
* @property {string} MessageUpdate messageUpdate
|
||||
* @property {string} PresenceUpdate presenceUpdate
|
||||
* @property {string} SoundboardSounds soundboardSounds
|
||||
* @property {string} ShardDisconnect shardDisconnect
|
||||
* @property {string} ShardError shardError
|
||||
* @property {string} ShardReady shardReady
|
||||
@@ -132,6 +137,10 @@ module.exports = {
|
||||
GuildScheduledEventUpdate: 'guildScheduledEventUpdate',
|
||||
GuildScheduledEventUserAdd: 'guildScheduledEventUserAdd',
|
||||
GuildScheduledEventUserRemove: 'guildScheduledEventUserRemove',
|
||||
GuildSoundboardSoundCreate: 'guildSoundboardSoundCreate',
|
||||
GuildSoundboardSoundDelete: 'guildSoundboardSoundDelete',
|
||||
GuildSoundboardSoundsUpdate: 'guildSoundboardSoundsUpdate',
|
||||
GuildSoundboardSoundUpdate: 'guildSoundboardSoundUpdate',
|
||||
GuildStickerCreate: 'stickerCreate',
|
||||
GuildStickerDelete: 'stickerDelete',
|
||||
GuildStickerUpdate: 'stickerUpdate',
|
||||
@@ -152,6 +161,7 @@ module.exports = {
|
||||
MessageReactionRemoveEmoji: 'messageReactionRemoveEmoji',
|
||||
MessageUpdate: 'messageUpdate',
|
||||
PresenceUpdate: 'presenceUpdate',
|
||||
SoundboardSounds: 'soundboardSounds',
|
||||
Raw: 'raw',
|
||||
ShardDisconnect: 'shardDisconnect',
|
||||
ShardError: 'shardError',
|
||||
|
||||
@@ -30,7 +30,7 @@ const { version } = require('../../package.json');
|
||||
* @property {MessageMentionOptions} [allowedMentions] The default value for {@link BaseMessageOptions#allowedMentions}
|
||||
* @property {Partials[]} [partials] Structures allowed to be partial. This means events can be emitted even when
|
||||
* they're missing all the data for a particular structure. See the "Partial Structures" topic on the
|
||||
* [guide](https://discordjs.guide/popular-topics/partials.html) for some
|
||||
* {@link https://discordjs.guide/popular-topics/partials.html guide} for some
|
||||
* important usage information, as partials require you to put checks in place when handling data.
|
||||
* @property {boolean} [failIfNotExists=true] The default value for {@link MessageReplyOptions#failIfNotExists}
|
||||
* @property {PresenceData} [presence={}] Presence data to use upon login
|
||||
@@ -41,7 +41,7 @@ const { version } = require('../../package.json');
|
||||
* @property {WebsocketOptions} [ws] Options for the WebSocket
|
||||
* @property {RESTOptions} [rest] Options for the REST manager
|
||||
* @property {Function} [jsonTransformer] A function used to transform outgoing json data
|
||||
* @property {boolean} [enforceNonce=false] The default value for {@link MessageReplyOptions#enforceNonce}
|
||||
* @property {boolean} [enforceNonce=false] The default value for {@link MessageCreateOptions#enforceNonce}
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,7 @@ const { createEnum } = require('./Enums');
|
||||
* @property {number} Reaction The partial to receive uncached reactions.
|
||||
* @property {number} GuildScheduledEvent The partial to receive uncached guild scheduled events.
|
||||
* @property {number} ThreadMember The partial to receive uncached thread members.
|
||||
* @property {number} SoundboardSound The partial to receive uncached soundboard sounds.
|
||||
*/
|
||||
|
||||
// JSDoc for IntelliSense purposes
|
||||
@@ -41,4 +42,5 @@ module.exports = createEnum([
|
||||
'Reaction',
|
||||
'GuildScheduledEvent',
|
||||
'ThreadMember',
|
||||
'SoundboardSound',
|
||||
]);
|
||||
|
||||
@@ -63,16 +63,27 @@ function _transformAPIMessageInteractionMetadata(client, messageInteractionMetad
|
||||
function _transformGuildScheduledEventRecurrenceRule(recurrenceRule) {
|
||||
return {
|
||||
start: new Date(recurrenceRule.startAt).toISOString(),
|
||||
// eslint-disable-next-line eqeqeq
|
||||
end: recurrenceRule.endAt != null ? new Date(recurrenceRule.endAt).toISOString() : recurrenceRule.endAt,
|
||||
frequency: recurrenceRule.frequency,
|
||||
interval: recurrenceRule.interval,
|
||||
by_weekday: recurrenceRule.byWeekday,
|
||||
by_n_weekday: recurrenceRule.byNWeekday,
|
||||
by_month: recurrenceRule.byMonth,
|
||||
by_month_day: recurrenceRule.byMonthDay,
|
||||
by_year_day: recurrenceRule.byYearDay,
|
||||
count: recurrenceRule.count,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms API incidents data to a camel-cased variant.
|
||||
* @param {APIIncidentsData} data The incidents data to transform
|
||||
* @returns {IncidentActions}
|
||||
* @ignore
|
||||
*/
|
||||
function _transformAPIIncidentsData(data) {
|
||||
return {
|
||||
invitesDisabledUntil: data.invites_disabled_until ? new Date(data.invites_disabled_until) : null,
|
||||
dmsDisabledUntil: data.dms_disabled_until ? new Date(data.dms_disabled_until) : null,
|
||||
dmSpamDetectedAt: data.dm_spam_detected_at ? new Date(data.dm_spam_detected_at) : null,
|
||||
raidDetectedAt: data.raid_detected_at ? new Date(data.raid_detected_at) : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -81,4 +92,5 @@ module.exports = {
|
||||
_transformAPIAutoModerationAction,
|
||||
_transformAPIMessageInteractionMetadata,
|
||||
_transformGuildScheduledEventRecurrenceRule,
|
||||
_transformAPIIncidentsData,
|
||||
};
|
||||
|
||||
493
packages/discord.js/typings/index.d.ts
vendored
493
packages/discord.js/typings/index.d.ts
vendored
@@ -13,7 +13,6 @@ import {
|
||||
ModalActionRowComponentBuilder,
|
||||
ModalBuilder as BuildersModal,
|
||||
AnyComponentBuilder,
|
||||
ComponentBuilder,
|
||||
type RestOrArray,
|
||||
ApplicationCommandOptionAllowedChannelTypes,
|
||||
} from '@discordjs/builders';
|
||||
@@ -111,13 +110,13 @@ import {
|
||||
AuditLogEvent,
|
||||
APIMessageComponentEmoji,
|
||||
EmbedType,
|
||||
APIActionRowComponentTypes,
|
||||
APIComponentInActionRow,
|
||||
APIModalInteractionResponseCallbackData,
|
||||
APIModalSubmitInteraction,
|
||||
APIMessageActionRowComponent,
|
||||
APIComponentInMessageActionRow,
|
||||
TextInputStyle,
|
||||
APITextInputComponent,
|
||||
APIModalActionRowComponent,
|
||||
APIComponentInModalActionRow,
|
||||
APIModalComponent,
|
||||
APISelectMenuOption,
|
||||
APIEmbedField,
|
||||
@@ -192,8 +191,6 @@ import {
|
||||
SubscriptionStatus,
|
||||
ApplicationWebhookEventStatus,
|
||||
ApplicationWebhookEventType,
|
||||
GatewaySendPayload,
|
||||
GatewayDispatchPayload,
|
||||
RESTPostAPIInteractionCallbackWithResponseResult,
|
||||
RESTAPIInteractionCallbackObject,
|
||||
RESTAPIInteractionCallbackResourceObject,
|
||||
@@ -203,6 +200,19 @@ import {
|
||||
GatewayVoiceChannelEffectSendDispatchData,
|
||||
APIChatInputApplicationCommandInteractionData,
|
||||
APIContextMenuInteractionData,
|
||||
APISoundboardSound,
|
||||
APIComponentInContainer,
|
||||
APIContainerComponent,
|
||||
APIThumbnailComponent,
|
||||
APISectionComponent,
|
||||
APITextDisplayComponent,
|
||||
APIUnfurledMediaItem,
|
||||
APIMediaGalleryItem,
|
||||
APIMediaGalleryComponent,
|
||||
APISeparatorComponent,
|
||||
SeparatorSpacingSize,
|
||||
APIFileComponent,
|
||||
APIMessageTopLevelComponent,
|
||||
} from 'discord-api-types/v10';
|
||||
import { ChildProcess } from 'node:child_process';
|
||||
import { EventEmitter } from 'node:events';
|
||||
@@ -299,11 +309,12 @@ export class Activity {
|
||||
export type ActivityFlagsString = keyof typeof ActivityFlags;
|
||||
|
||||
export interface BaseComponentData {
|
||||
id?: number;
|
||||
type: ComponentType;
|
||||
}
|
||||
|
||||
export type MessageActionRowComponentData =
|
||||
| JSONEncodable<APIMessageActionRowComponent>
|
||||
| JSONEncodable<APIComponentInMessageActionRow>
|
||||
| ButtonComponentData
|
||||
| StringSelectMenuComponentData
|
||||
| UserSelectMenuComponentData
|
||||
@@ -311,13 +322,13 @@ export type MessageActionRowComponentData =
|
||||
| MentionableSelectMenuComponentData
|
||||
| ChannelSelectMenuComponentData;
|
||||
|
||||
export type ModalActionRowComponentData = JSONEncodable<APIModalActionRowComponent> | TextInputComponentData;
|
||||
export type ModalActionRowComponentData = JSONEncodable<APIComponentInModalActionRow> | TextInputComponentData;
|
||||
|
||||
export type ActionRowComponentData = MessageActionRowComponentData | ModalActionRowComponentData;
|
||||
|
||||
export type ActionRowComponent = MessageActionRowComponent | ModalActionRowComponent;
|
||||
|
||||
export interface ActionRowData<ComponentType extends JSONEncodable<APIActionRowComponentTypes> | ActionRowComponentData>
|
||||
export interface ActionRowData<ComponentType extends JSONEncodable<APIComponentInActionRow> | ActionRowComponentData>
|
||||
extends BaseComponentData {
|
||||
components: readonly ComponentType[];
|
||||
}
|
||||
@@ -327,8 +338,8 @@ export class ActionRowBuilder<
|
||||
> extends BuilderActionRow<ComponentType> {
|
||||
public constructor(
|
||||
data?: Partial<
|
||||
| ActionRowData<ActionRowComponentData | JSONEncodable<APIActionRowComponentTypes>>
|
||||
| APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>
|
||||
| ActionRowData<ActionRowComponentData | JSONEncodable<APIComponentInActionRow>>
|
||||
| APIActionRowComponent<APIComponentInMessageActionRow | APIComponentInModalActionRow>
|
||||
>,
|
||||
);
|
||||
public static from<ComponentType extends AnyComponentBuilder = AnyComponentBuilder>(
|
||||
@@ -348,9 +359,9 @@ export type MessageActionRowComponent =
|
||||
export type ModalActionRowComponent = TextInputComponent;
|
||||
|
||||
export class ActionRow<ComponentType extends MessageActionRowComponent | ModalActionRowComponent> extends Component<
|
||||
APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>
|
||||
APIActionRowComponent<APIComponentInMessageActionRow | APIComponentInModalActionRow>
|
||||
> {
|
||||
private constructor(data: APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>);
|
||||
private constructor(data: APIActionRowComponent<APIComponentInMessageActionRow | APIComponentInModalActionRow>);
|
||||
public readonly components: ComponentType[];
|
||||
public toJSON(): APIActionRowComponent<ReturnType<ComponentType['toJSON']>>;
|
||||
}
|
||||
@@ -441,6 +452,11 @@ export abstract class Application extends Base {
|
||||
public icon: string | null;
|
||||
public id: Snowflake;
|
||||
public name: string | null;
|
||||
public termsOfServiceURL: string | null;
|
||||
public privacyPolicyURL: string | null;
|
||||
public rpcOrigins: string[];
|
||||
public cover: string | null;
|
||||
public verifyKey: string | null;
|
||||
public coverURL(options?: ImageURLOptions): string | null;
|
||||
public iconURL(options?: ImageURLOptions): string | null;
|
||||
public toJSON(): unknown;
|
||||
@@ -779,15 +795,37 @@ export class ButtonInteraction<Cached extends CacheType = CacheType> extends Mes
|
||||
export type AnyComponent =
|
||||
| APIMessageComponent
|
||||
| APIModalComponent
|
||||
| APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>;
|
||||
| APIActionRowComponent<APIComponentInMessageActionRow | APIComponentInModalActionRow>
|
||||
| AnyComponentV2;
|
||||
|
||||
export class Component<RawComponentData extends AnyComponent = AnyComponent> {
|
||||
public readonly data: Readonly<RawComponentData>;
|
||||
public get id(): RawComponentData['id'];
|
||||
public get type(): RawComponentData['type'];
|
||||
public toJSON(): RawComponentData;
|
||||
public equals(other: this | RawComponentData): boolean;
|
||||
}
|
||||
|
||||
export type AnyComponentV2 = APIComponentInContainer | APIContainerComponent | APIThumbnailComponent;
|
||||
|
||||
export type TopLevelComponent =
|
||||
| ActionRow<MessageActionRowComponent>
|
||||
| ContainerComponent
|
||||
| FileComponent
|
||||
| MediaGalleryComponent
|
||||
| SectionComponent
|
||||
| SeparatorComponent
|
||||
| TextDisplayComponent;
|
||||
|
||||
export type TopLevelComponentData =
|
||||
| ActionRowData<MessageActionRowComponentData>
|
||||
| ContainerComponentData
|
||||
| FileComponentData
|
||||
| MediaGalleryComponentData
|
||||
| SectionComponentData
|
||||
| SeparatorComponentData
|
||||
| TextDisplayComponentData;
|
||||
|
||||
export class ButtonComponent extends Component<APIButtonComponent> {
|
||||
private constructor(data: APIButtonComponent);
|
||||
public get style(): ButtonStyle;
|
||||
@@ -1025,6 +1063,16 @@ export type If<Value extends boolean, TrueResult, FalseResult = null> = Value ex
|
||||
? FalseResult
|
||||
: TrueResult | FalseResult;
|
||||
|
||||
/** @internal */
|
||||
type AsyncEventIteratorDisposability =
|
||||
ReturnType<typeof EventEmitter.on> extends AsyncDisposable ? AsyncDisposable : {};
|
||||
/** @internal */
|
||||
interface AsyncEventIterator<Params extends any[]>
|
||||
extends AsyncIterableIterator<Params>,
|
||||
AsyncEventIteratorDisposability {
|
||||
[Symbol.asyncIterator](): AsyncEventIterator<Params>;
|
||||
}
|
||||
|
||||
export class Client<Ready extends boolean = boolean> extends BaseClient {
|
||||
public constructor(options: ClientOptions);
|
||||
private actions: unknown;
|
||||
@@ -1045,7 +1093,7 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
|
||||
eventEmitter: Emitter,
|
||||
eventName: Emitter extends Client ? Event : string | symbol,
|
||||
options?: { signal?: AbortSignal | undefined },
|
||||
): AsyncIterableIterator<Emitter extends Client ? ClientEvents[Event] : any[]>;
|
||||
): AsyncEventIterator<Emitter extends Client ? ClientEvents[Event] : any[]>;
|
||||
|
||||
public application: If<Ready, ClientApplication>;
|
||||
public channels: ChannelManager;
|
||||
@@ -1120,7 +1168,6 @@ export class ClientApplication extends Application {
|
||||
public subscriptions: SubscriptionManager;
|
||||
public guildId: Snowflake | null;
|
||||
public get guild(): Guild | null;
|
||||
public cover: string | null;
|
||||
public flags: Readonly<ApplicationFlagsBitField>;
|
||||
public approximateGuildCount: number | null;
|
||||
public approximateUserInstallCount: number | null;
|
||||
@@ -1135,7 +1182,6 @@ export class ClientApplication extends Application {
|
||||
public eventWebhooksStatus: ApplicationWebhookEventStatus | null;
|
||||
public eventWebhooksTypes: ApplicationWebhookEventType[] | null;
|
||||
public roleConnectionsVerificationURL: string | null;
|
||||
public rpcOrigins: string[];
|
||||
public edit(options: ClientApplicationEditOptions): Promise<ClientApplication>;
|
||||
public fetch(): Promise<ClientApplication>;
|
||||
public fetchRoleConnectionMetadataRecords(): Promise<ApplicationRoleConnectionMetadata[]>;
|
||||
@@ -1183,6 +1229,40 @@ export class ClientVoiceManager {
|
||||
public adapters: Map<Snowflake, InternalDiscordGatewayAdapterLibraryMethods>;
|
||||
}
|
||||
|
||||
export type ComponentInContainer =
|
||||
| ActionRow<MessageActionRowComponent>
|
||||
| FileComponent
|
||||
| MediaGalleryComponent
|
||||
| SectionComponent
|
||||
| SeparatorComponent
|
||||
| TextDisplayComponent;
|
||||
|
||||
export type ComponentInContainerData =
|
||||
| ActionRowData<ActionRowComponentData>
|
||||
| FileComponentData
|
||||
| MediaGalleryComponentData
|
||||
| SectionComponentData
|
||||
| SeparatorComponentData
|
||||
| TextDisplayComponentData;
|
||||
|
||||
export interface ContainerComponentData<
|
||||
ComponentType extends JSONEncodable<APIComponentInContainer> | ComponentInContainerData =
|
||||
| JSONEncodable<APIComponentInContainer>
|
||||
| ComponentInContainerData,
|
||||
> extends BaseComponentData {
|
||||
components: readonly ComponentType[];
|
||||
accentColor?: number;
|
||||
spoiler?: boolean;
|
||||
}
|
||||
|
||||
export class ContainerComponent extends Component<APIContainerComponent> {
|
||||
private constructor(data: APIContainerComponent);
|
||||
public get accentColor(): number;
|
||||
public get hexAccentColor(): HexColorString;
|
||||
public get spoiler(): boolean;
|
||||
public readonly components: ComponentInContainer[];
|
||||
}
|
||||
|
||||
export { Collection, ReadonlyCollection } from '@discordjs/collection';
|
||||
|
||||
export interface CollectorEventTypes<Key, Value, Extras extends unknown[] = []> {
|
||||
@@ -1367,16 +1447,10 @@ export class ContextMenuCommandInteraction<Cached extends CacheType = CacheType>
|
||||
private resolveContextMenuOptions(data: APIApplicationCommandInteractionData): CommandInteractionOption<Cached>[];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface ResolvedFile {
|
||||
data: Buffer;
|
||||
contentType?: string;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-empty-interface
|
||||
export interface DMChannel
|
||||
extends Omit<
|
||||
TextBasedChannelFields<false>,
|
||||
TextBasedChannelFields<false, true>,
|
||||
'bulkDelete' | 'fetchWebhooks' | 'createWebhook' | 'setRateLimitPerUser' | 'setNSFW'
|
||||
> {}
|
||||
export class DMChannel extends BaseChannel {
|
||||
@@ -1512,8 +1586,10 @@ export class Guild extends AnonymousGuild {
|
||||
public scheduledEvents: GuildScheduledEventManager;
|
||||
public get shard(): WebSocketShard;
|
||||
public shardId: number;
|
||||
public soundboardSounds: GuildSoundboardSoundManager;
|
||||
public stageInstances: StageInstanceManager;
|
||||
public stickers: GuildStickerManager;
|
||||
public incidentsData: IncidentActions | null;
|
||||
public get systemChannel(): TextChannel | null;
|
||||
public systemChannelFlags: Readonly<SystemChannelFlagsBitField>;
|
||||
public systemChannelId: Snowflake | null;
|
||||
@@ -1547,6 +1623,7 @@ export class Guild extends AnonymousGuild {
|
||||
public widgetImageURL(style?: GuildWidgetStyle): string;
|
||||
public leave(): Promise<Guild>;
|
||||
public disableInvites(disabled?: boolean): Promise<Guild>;
|
||||
public setIncidentActions(incidentActions: IncidentActionsEditOptions): Promise<IncidentActions>;
|
||||
public setAFKChannel(afkChannel: VoiceChannelResolvable | null, reason?: string): Promise<Guild>;
|
||||
public setAFKTimeout(afkTimeout: number, reason?: string): Promise<Guild>;
|
||||
public setBanner(banner: BufferResolvable | Base64Resolvable | null, reason?: string): Promise<Guild>;
|
||||
@@ -1579,6 +1656,16 @@ export class Guild extends AnonymousGuild {
|
||||
public toJSON(): unknown;
|
||||
}
|
||||
|
||||
export interface FileComponentData extends BaseComponentData {
|
||||
file: UnfurledMediaItemData;
|
||||
spoiler?: boolean;
|
||||
}
|
||||
export class FileComponent extends Component<APIFileComponent> {
|
||||
private constructor(data: APIFileComponent);
|
||||
public readonly file: UnfurledMediaItem;
|
||||
public get spoiler(): boolean;
|
||||
}
|
||||
|
||||
export class GuildAuditLogs<Event extends GuildAuditLogsResolvable = AuditLogEvent> {
|
||||
private constructor(guild: Guild, data: RawGuildAuditLogData);
|
||||
private applicationCommands: Collection<Snowflake, ApplicationCommand>;
|
||||
@@ -2177,6 +2264,27 @@ export class LimitedCollection<Key, Value> extends Collection<Key, Value> {
|
||||
public keepOverLimit: ((value: Value, key: Key, collection: this) => boolean) | null;
|
||||
}
|
||||
|
||||
export interface MediaGalleryComponentData extends BaseComponentData {
|
||||
items: readonly MediaGalleryItemData[];
|
||||
}
|
||||
export class MediaGalleryComponent extends Component<APIMediaGalleryComponent> {
|
||||
private constructor(data: APIMediaGalleryComponent);
|
||||
public readonly items: MediaGalleryItem[];
|
||||
}
|
||||
|
||||
export interface MediaGalleryItemData {
|
||||
media: UnfurledMediaItemData;
|
||||
description?: string;
|
||||
spoiler?: boolean;
|
||||
}
|
||||
export class MediaGalleryItem {
|
||||
private constructor(data: APIMediaGalleryItem);
|
||||
public readonly data: APIMediaGalleryItem;
|
||||
public readonly media: UnfurledMediaItem;
|
||||
public get description(): string | null;
|
||||
public get spoiler(): boolean;
|
||||
}
|
||||
|
||||
export interface MessageCall {
|
||||
get endedAt(): Date | null;
|
||||
endedTimestamp: number | null;
|
||||
@@ -2249,7 +2357,7 @@ export class Message<InGuild extends boolean = boolean> extends Base {
|
||||
public get channel(): If<InGuild, GuildTextBasedChannel, TextBasedChannel>;
|
||||
public channelId: Snowflake;
|
||||
public get cleanContent(): string;
|
||||
public components: ActionRow<MessageActionRowComponent>[];
|
||||
public components: TopLevelComponent[];
|
||||
public content: string;
|
||||
public get createdAt(): Date;
|
||||
public createdTimestamp: number;
|
||||
@@ -2312,6 +2420,7 @@ export class Message<InGuild extends boolean = boolean> extends Base {
|
||||
public reply(
|
||||
options: string | MessagePayload | MessageReplyOptions,
|
||||
): Promise<OmitPartialGroupDMChannel<Message<InGuild>>>;
|
||||
public forward(channel: Exclude<TextBasedChannelResolvable, PartialGroupDMChannel>): Promise<Message>;
|
||||
public resolveComponent(customId: string): MessageActionRowComponent | null;
|
||||
public startThread(options: StartThreadOptions): Promise<PublicThreadChannel<false>>;
|
||||
public suppressEmbeds(suppress?: boolean): Promise<OmitPartialGroupDMChannel<Message<InGuild>>>;
|
||||
@@ -2382,9 +2491,9 @@ export class MessageComponentInteraction<Cached extends CacheType = CacheType> e
|
||||
public get component(): CacheTypeReducer<
|
||||
Cached,
|
||||
MessageActionRowComponent,
|
||||
APIMessageActionRowComponent,
|
||||
MessageActionRowComponent | APIMessageActionRowComponent,
|
||||
MessageActionRowComponent | APIMessageActionRowComponent
|
||||
APIComponentInMessageActionRow,
|
||||
MessageActionRowComponent | APIComponentInMessageActionRow,
|
||||
MessageActionRowComponent | APIComponentInMessageActionRow
|
||||
>;
|
||||
public componentType: MessageComponentType;
|
||||
public customId: string;
|
||||
@@ -2592,7 +2701,7 @@ export interface ModalComponentData {
|
||||
customId: string;
|
||||
title: string;
|
||||
components: readonly (
|
||||
| JSONEncodable<APIActionRowComponent<APIModalActionRowComponent>>
|
||||
| JSONEncodable<APIActionRowComponent<APIComponentInModalActionRow>>
|
||||
| ActionRowData<ModalActionRowComponentData>
|
||||
)[];
|
||||
}
|
||||
@@ -2697,6 +2806,19 @@ export class OAuth2Guild extends BaseGuild {
|
||||
public permissions: Readonly<PermissionsBitField>;
|
||||
}
|
||||
|
||||
export interface PartialGroupDMChannel
|
||||
extends Omit<
|
||||
TextBasedChannelFields<false, false>,
|
||||
| 'bulkDelete'
|
||||
| 'send'
|
||||
| 'sendTyping'
|
||||
| 'createMessageCollector'
|
||||
| 'awaitMessages'
|
||||
| 'fetchWebhooks'
|
||||
| 'createWebhook'
|
||||
| 'setRateLimitPerUser'
|
||||
| 'setNSFW'
|
||||
> {}
|
||||
export class PartialGroupDMChannel extends BaseChannel {
|
||||
private constructor(client: Client<true>, data: RawPartialGroupDMChannelData);
|
||||
public type: ChannelType.GroupDM;
|
||||
@@ -2704,8 +2826,9 @@ export class PartialGroupDMChannel extends BaseChannel {
|
||||
public name: string | null;
|
||||
public icon: string | null;
|
||||
public recipients: PartialRecipient[];
|
||||
public messages: PartialGroupDMMessageManager;
|
||||
public ownerId: Snowflake | null;
|
||||
public iconURL(options?: ImageURLOptions): string | null;
|
||||
public fetchOwner(options?: BaseFetchOptions): Promise<User>;
|
||||
public toString(): ChannelMention;
|
||||
}
|
||||
|
||||
@@ -2742,6 +2865,7 @@ export interface ThreadOnlyChannel
|
||||
| 'awaitMessages'
|
||||
| 'createMessageComponentCollector'
|
||||
| 'awaitMessageComponent'
|
||||
| 'messages'
|
||||
> {}
|
||||
export abstract class ThreadOnlyChannel extends GuildChannel {
|
||||
public type: ChannelType.GuildForum | ChannelType.GuildMedia;
|
||||
@@ -2959,6 +3083,20 @@ export class RoleFlagsBitField extends BitField<RoleFlagsString> {
|
||||
public static resolve(bit?: BitFieldResolvable<RoleFlagsString, number>): number;
|
||||
}
|
||||
|
||||
export interface SectionComponentData extends BaseComponentData {
|
||||
accessory: ButtonComponentData | ThumbnailComponentData;
|
||||
components: readonly TextDisplayComponentData[];
|
||||
}
|
||||
|
||||
export class SectionComponent<
|
||||
AccessoryType extends ButtonComponent | ThumbnailComponent = ButtonComponent | ThumbnailComponent,
|
||||
> extends Component<APISectionComponent> {
|
||||
private constructor(data: APISectionComponent);
|
||||
public readonly accessory: AccessoryType;
|
||||
public readonly components: TextDisplayComponent[];
|
||||
public toJSON(): APISectionComponent;
|
||||
}
|
||||
|
||||
export class StringSelectMenuInteraction<
|
||||
Cached extends CacheType = CacheType,
|
||||
> extends MessageComponentInteraction<Cached> {
|
||||
@@ -3082,6 +3220,16 @@ export type AnySelectMenuInteraction<Cached extends CacheType = CacheType> =
|
||||
|
||||
export type SelectMenuType = APISelectMenuComponent['type'];
|
||||
|
||||
export interface SeparatorComponentData extends BaseComponentData {
|
||||
spacing?: SeparatorSpacingSize;
|
||||
dividier?: boolean;
|
||||
}
|
||||
export class SeparatorComponent extends Component<APISeparatorComponent> {
|
||||
private constructor(data: APISeparatorComponent);
|
||||
public get spacing(): SeparatorSpacingSize;
|
||||
public get divider(): boolean;
|
||||
}
|
||||
|
||||
export interface ShardEventTypes {
|
||||
death: [process: ChildProcess | Worker];
|
||||
disconnect: [];
|
||||
@@ -3241,6 +3389,7 @@ export class Subscription extends Base {
|
||||
public userId: Snowflake;
|
||||
public skuIds: Snowflake[];
|
||||
public entitlementIds: Snowflake[];
|
||||
public renewalSkuIds: Snowflake[] | null;
|
||||
public currentPeriodStartTimestamp: number;
|
||||
public currentPeriodEndTimestamp: number;
|
||||
public status: SubscriptionStatus;
|
||||
@@ -3443,6 +3592,15 @@ export class TextChannel extends BaseGuildTextChannel {
|
||||
public type: ChannelType.GuildText;
|
||||
}
|
||||
|
||||
export interface TextDisplayComponentData extends BaseComponentData {
|
||||
content: string;
|
||||
}
|
||||
|
||||
export class TextDisplayComponent extends Component<APITextDisplayComponent> {
|
||||
private constructor(data: APITextDisplayComponent);
|
||||
public readonly content: string;
|
||||
}
|
||||
|
||||
export type ForumThreadChannel = PublicThreadChannel<true>;
|
||||
export type TextThreadChannel = PublicThreadChannel<false> | PrivateThreadChannel;
|
||||
export type AnyThreadChannel = TextThreadChannel | ForumThreadChannel;
|
||||
@@ -3542,6 +3700,19 @@ export class ThreadMemberFlagsBitField extends BitField<ThreadMemberFlagsString>
|
||||
public static resolve(bit?: BitFieldResolvable<ThreadMemberFlagsString, number>): number;
|
||||
}
|
||||
|
||||
export interface ThumbnailComponentData extends BaseComponentData {
|
||||
media: UnfurledMediaItemData;
|
||||
description?: string;
|
||||
spoiler?: boolean;
|
||||
}
|
||||
|
||||
export class ThumbnailComponent extends Component<APIThumbnailComponent> {
|
||||
private constructor(data: APIThumbnailComponent);
|
||||
public readonly media: UnfurledMediaItem;
|
||||
public get description(): string | null;
|
||||
public get spoiler(): boolean;
|
||||
}
|
||||
|
||||
export class Typing extends Base {
|
||||
private constructor(channel: TextBasedChannel, user: PartialUser, data?: RawTypingData);
|
||||
public channel: TextBasedChannel;
|
||||
@@ -3561,6 +3732,16 @@ export interface AvatarDecorationData {
|
||||
skuId: Snowflake;
|
||||
}
|
||||
|
||||
export interface UnfurledMediaItemData {
|
||||
url: string;
|
||||
}
|
||||
|
||||
export class UnfurledMediaItem {
|
||||
private constructor(data: APIUnfurledMediaItem);
|
||||
public readonly data: APIUnfurledMediaItem;
|
||||
public get url(): string;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-empty-interface
|
||||
export interface User extends PartialTextBasedChannelFields<false> {}
|
||||
export class User extends Base {
|
||||
@@ -3683,28 +3864,6 @@ export function transformResolved<Cached extends CacheType>(
|
||||
): CommandInteractionResolvedData<Cached>;
|
||||
export function resolveSKUId(resolvable: SKUResolvable): Snowflake | null;
|
||||
|
||||
export interface MappedComponentBuilderTypes {
|
||||
[ComponentType.Button]: ButtonBuilder;
|
||||
[ComponentType.StringSelect]: StringSelectMenuBuilder;
|
||||
[ComponentType.UserSelect]: UserSelectMenuBuilder;
|
||||
[ComponentType.RoleSelect]: RoleSelectMenuBuilder;
|
||||
[ComponentType.MentionableSelect]: MentionableSelectMenuBuilder;
|
||||
[ComponentType.ChannelSelect]: ChannelSelectMenuBuilder;
|
||||
[ComponentType.ActionRow]: ActionRowBuilder;
|
||||
[ComponentType.TextInput]: TextInputBuilder;
|
||||
}
|
||||
|
||||
export interface MappedComponentTypes {
|
||||
[ComponentType.Button]: ButtonComponent;
|
||||
[ComponentType.StringSelect]: StringSelectMenuComponent;
|
||||
[ComponentType.UserSelect]: UserSelectMenuComponent;
|
||||
[ComponentType.RoleSelect]: RoleSelectMenuComponent;
|
||||
[ComponentType.MentionableSelect]: MentionableSelectMenuComponent;
|
||||
[ComponentType.ChannelSelect]: ChannelSelectMenuComponent;
|
||||
[ComponentType.ActionRow]: ActionRowComponent;
|
||||
[ComponentType.TextInput]: TextInputComponent;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface CreateChannelOptions {
|
||||
allowFromUnknownGuild?: boolean;
|
||||
@@ -3718,17 +3877,6 @@ export function createChannel(
|
||||
extras?: CreateChannelOptions,
|
||||
): Channel;
|
||||
|
||||
export function createComponent<Type extends keyof MappedComponentTypes>(
|
||||
data: APIMessageComponent & { type: Type },
|
||||
): MappedComponentTypes[Type];
|
||||
export function createComponent<Data extends Component>(data: Data): Data;
|
||||
export function createComponent(data: APIMessageComponent | Component): Component;
|
||||
export function createComponentBuilder<Type extends keyof MappedComponentBuilderTypes>(
|
||||
data: APIMessageComponent & { type: Type },
|
||||
): MappedComponentBuilderTypes[Type];
|
||||
export function createComponentBuilder<Data extends ComponentBuilder>(data: Data): Data;
|
||||
export function createComponentBuilder(data: APIMessageComponent | ComponentBuilder): ComponentBuilder;
|
||||
|
||||
/** @deprecated This class is redundant as all methods of the class can be imported from discord.js directly. */
|
||||
export class Formatters extends null {
|
||||
/** @deprecated Import this method directly from discord.js instead. */
|
||||
@@ -3767,27 +3915,22 @@ export class Formatters extends null {
|
||||
public static userMention: typeof userMention;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function resolveBase64(data: Base64Resolvable): string;
|
||||
/** @internal */
|
||||
export function resolveCode(data: string, regex: RegExp): string;
|
||||
/** @internal */
|
||||
export function resolveFile(resource: BufferResolvable | Stream): Promise<ResolvedFile>;
|
||||
/** @internal */
|
||||
export function resolveImage(resource: BufferResolvable | Base64Resolvable): Promise<string | null>;
|
||||
/** @internal */
|
||||
export function resolveInviteCode(data: InviteResolvable): string;
|
||||
/** @internal */
|
||||
export function resolveGuildTemplateCode(data: GuildTemplateResolvable): string;
|
||||
|
||||
export type ComponentData =
|
||||
| MessageActionRowComponentData
|
||||
| ModalActionRowComponentData
|
||||
| ActionRowData<MessageActionRowComponentData | ModalActionRowComponentData>;
|
||||
| ComponentInContainerData
|
||||
| ContainerComponentData
|
||||
| ThumbnailComponentData;
|
||||
|
||||
export interface SendSoundboardSoundOptions {
|
||||
soundId: Snowflake;
|
||||
guildId?: Snowflake;
|
||||
}
|
||||
|
||||
export class VoiceChannel extends BaseGuildVoiceChannel {
|
||||
public get speakable(): boolean;
|
||||
public type: ChannelType.GuildVoice;
|
||||
public sendSoundboardSound(sound: SoundboardSound | SendSoundboardSoundOptions): Promise<void>;
|
||||
}
|
||||
|
||||
export class VoiceChannelEffect {
|
||||
@@ -3801,6 +3944,7 @@ export class VoiceChannelEffect {
|
||||
public soundId: Snowflake | number | null;
|
||||
public soundVolume: number | null;
|
||||
public get channel(): VoiceChannel | null;
|
||||
public get soundboardSound(): GuildSoundboardSound | null;
|
||||
}
|
||||
|
||||
export class VoiceRegion {
|
||||
@@ -3987,6 +4131,30 @@ export class WidgetMember extends Base {
|
||||
public activity: WidgetActivity | null;
|
||||
}
|
||||
|
||||
export type SoundboardSoundResolvable = SoundboardSound | Snowflake | string;
|
||||
|
||||
export class SoundboardSound extends Base {
|
||||
private constructor(client: Client<true>, data: APISoundboardSound);
|
||||
public name: string;
|
||||
public soundId: Snowflake | string;
|
||||
public volume: number;
|
||||
private _emoji: Omit<APIEmoji, 'animated'> | null;
|
||||
public guildId: Snowflake | null;
|
||||
public available: boolean;
|
||||
public user: User | null;
|
||||
public get createdAt(): Date;
|
||||
public get createdTimestamp(): number;
|
||||
public get emoji(): Emoji | null;
|
||||
public get guild(): Guild | null;
|
||||
public get url(): string;
|
||||
public edit(options?: GuildSoundboardSoundEditOptions): Promise<GuildSoundboardSound>;
|
||||
public delete(reason?: string): Promise<GuildSoundboardSound>;
|
||||
public equals(other: SoundboardSound | APISoundboardSound): boolean;
|
||||
}
|
||||
|
||||
export type DefaultSoundboardSound = SoundboardSound & { get guild(): null; guildId: null; soundId: string };
|
||||
export type GuildSoundboardSound = SoundboardSound & { get guild(): Guild; guildId: Snowflake; soundId: Snowflake };
|
||||
|
||||
export class WelcomeChannel extends Base {
|
||||
private constructor(guild: Guild, data: RawWelcomeChannelData);
|
||||
private _emoji: Omit<APIEmoji, 'animated'>;
|
||||
@@ -4172,6 +4340,7 @@ export enum DiscordjsErrorCodes {
|
||||
GuildChannelUnowned = 'GuildChannelUnowned',
|
||||
GuildOwned = 'GuildOwned',
|
||||
GuildMembersTimeout = 'GuildMembersTimeout',
|
||||
GuildSoundboardSoundsTimeout = 'GuildSoundboardSoundsTimeout',
|
||||
GuildUncachedMe = 'GuildUncachedMe',
|
||||
ChannelNotCached = 'ChannelNotCached',
|
||||
StageChannelResolve = 'StageChannelResolve',
|
||||
@@ -4197,6 +4366,7 @@ export enum DiscordjsErrorCodes {
|
||||
/** @deprecated Use {@link DiscordjsErrorCodes.MissingManageGuildExpressionsPermission} instead. */
|
||||
MissingManageEmojisAndStickersPermission = 'MissingManageEmojisAndStickersPermission',
|
||||
|
||||
NotGuildSoundboardSound = 'NotGuildSoundboardSound',
|
||||
NotGuildSticker = 'NotGuildSticker',
|
||||
|
||||
ReactionResolveUser = 'ReactionResolveUser',
|
||||
@@ -4571,11 +4741,23 @@ export class GuildEmojiRoleManager extends DataManager<Snowflake, Role, RoleReso
|
||||
): Promise<GuildEmoji>;
|
||||
}
|
||||
|
||||
export interface FetchSoundboardSoundsOptions {
|
||||
guildIds: readonly Snowflake[];
|
||||
time?: number;
|
||||
}
|
||||
|
||||
export class GuildManager extends CachedManager<Snowflake, Guild, GuildResolvable> {
|
||||
private constructor(client: Client<true>, iterable?: Iterable<RawGuildData>);
|
||||
public create(options: GuildCreateOptions): Promise<Guild>;
|
||||
public fetch(options: Snowflake | FetchGuildOptions): Promise<Guild>;
|
||||
public fetch(options?: FetchGuildsOptions): Promise<Collection<Snowflake, OAuth2Guild>>;
|
||||
public fetchSoundboardSounds(
|
||||
options: FetchSoundboardSoundsOptions,
|
||||
): Promise<Collection<Snowflake, Collection<Snowflake, GuildSoundboardSound>>>;
|
||||
public setIncidentActions(
|
||||
guild: GuildResolvable,
|
||||
incidentActions: IncidentActionsEditOptions,
|
||||
): Promise<IncidentActions>;
|
||||
public widgetImageURL(guild: GuildResolvable, style?: GuildWidgetStyle): string;
|
||||
}
|
||||
|
||||
@@ -4663,6 +4845,36 @@ export class GuildScheduledEventManager extends CachedManager<
|
||||
): Promise<GuildScheduledEventManagerFetchSubscribersResult<Options>>;
|
||||
}
|
||||
|
||||
export interface GuildSoundboardSoundCreateOptions {
|
||||
file: BufferResolvable | Stream;
|
||||
name: string;
|
||||
contentType?: string;
|
||||
volume?: number;
|
||||
emojiId?: Snowflake;
|
||||
emojiName?: string;
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
export interface GuildSoundboardSoundEditOptions {
|
||||
name?: string;
|
||||
volume?: number | null;
|
||||
emojiId?: Snowflake | null;
|
||||
emojiName?: string | null;
|
||||
}
|
||||
|
||||
export class GuildSoundboardSoundManager extends CachedManager<Snowflake, SoundboardSound, SoundboardSoundResolvable> {
|
||||
private constructor(guild: Guild, iterable?: Iterable<APISoundboardSound>);
|
||||
public guild: Guild;
|
||||
public create(options: GuildSoundboardSoundCreateOptions): Promise<GuildSoundboardSound>;
|
||||
public edit(
|
||||
soundboardSound: SoundboardSoundResolvable,
|
||||
options: GuildSoundboardSoundEditOptions,
|
||||
): Promise<GuildSoundboardSound>;
|
||||
public delete(soundboardSound: SoundboardSoundResolvable): Promise<void>;
|
||||
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<GuildSoundboardSound>;
|
||||
public fetch(options?: BaseFetchOptions): Promise<Collection<Snowflake, GuildSoundboardSound>>;
|
||||
}
|
||||
|
||||
export class GuildStickerManager extends CachedManager<Snowflake, Sticker, StickerResolvable> {
|
||||
private constructor(guild: Guild, iterable?: Iterable<RawStickerData>);
|
||||
public guild: Guild;
|
||||
@@ -4906,13 +5118,13 @@ export interface PartialTextBasedChannelFields<InGuild extends boolean = boolean
|
||||
send(options: string | MessagePayload | MessageCreateOptions): Promise<Message<InGuild>>;
|
||||
}
|
||||
|
||||
export interface TextBasedChannelFields<InGuild extends boolean = boolean>
|
||||
export interface TextBasedChannelFields<InGuild extends boolean = boolean, InDM extends boolean = boolean>
|
||||
extends PartialTextBasedChannelFields<InGuild> {
|
||||
lastMessageId: Snowflake | null;
|
||||
get lastMessage(): Message | null;
|
||||
lastPinTimestamp: number | null;
|
||||
get lastPinAt(): Date | null;
|
||||
messages: If<InGuild, GuildMessageManager, DMMessageManager>;
|
||||
messages: If<InGuild, GuildMessageManager, If<InDM, DMMessageManager, PartialGroupDMMessageManager>>;
|
||||
awaitMessageComponent<ComponentType extends MessageComponentType>(
|
||||
options?: AwaitMessageCollectorOptionsParams<ComponentType, true>,
|
||||
): Promise<MappedInteractionTypes[ComponentType]>;
|
||||
@@ -4987,7 +5199,8 @@ export type AllowedPartial =
|
||||
| Message
|
||||
| MessageReaction
|
||||
| GuildScheduledEvent
|
||||
| ThreadMember;
|
||||
| ThreadMember
|
||||
| SoundboardSound;
|
||||
|
||||
export type AllowedThreadTypeForNewsChannel = ChannelType.AnnouncementThread;
|
||||
|
||||
@@ -5539,6 +5752,9 @@ export interface ClientEvents {
|
||||
guildMembersChunk: [members: ReadonlyCollection<Snowflake, GuildMember>, guild: Guild, data: GuildMembersChunk];
|
||||
guildMemberUpdate: [oldMember: GuildMember | PartialGuildMember, newMember: GuildMember];
|
||||
guildUpdate: [oldGuild: Guild, newGuild: Guild];
|
||||
guildSoundboardSoundCreate: [soundboardSound: SoundboardSound];
|
||||
guildSoundboardSoundDelete: [soundboardSound: SoundboardSound | PartialSoundboardSound];
|
||||
guildSoundboardSoundUpdate: [oldSoundboardSound: SoundboardSound | null, newSoundboardSound: SoundboardSound];
|
||||
inviteCreate: [invite: Invite];
|
||||
inviteDelete: [invite: Invite];
|
||||
messageCreate: [message: OmitPartialGroupDMChannel<Message>];
|
||||
@@ -5614,6 +5830,7 @@ export interface ClientEvents {
|
||||
guildScheduledEventDelete: [guildScheduledEvent: GuildScheduledEvent | PartialGuildScheduledEvent];
|
||||
guildScheduledEventUserAdd: [guildScheduledEvent: GuildScheduledEvent | PartialGuildScheduledEvent, user: User];
|
||||
guildScheduledEventUserRemove: [guildScheduledEvent: GuildScheduledEvent | PartialGuildScheduledEvent, user: User];
|
||||
soundboardSounds: [soundboardSounds: ReadonlyCollection<Snowflake, SoundboardSound>, guild: Guild];
|
||||
}
|
||||
|
||||
export interface ClientFetchInviteOptions {
|
||||
@@ -5832,6 +6049,11 @@ export enum Events {
|
||||
GuildScheduledEventDelete = 'guildScheduledEventDelete',
|
||||
GuildScheduledEventUserAdd = 'guildScheduledEventUserAdd',
|
||||
GuildScheduledEventUserRemove = 'guildScheduledEventUserRemove',
|
||||
GuildSoundboardSoundCreate = 'guildSoundboardSoundCreate',
|
||||
GuildSoundboardSoundDelete = 'guildSoundboardSoundDelete',
|
||||
GuildSoundboardSoundUpdate = 'guildSoundboardSoundUpdate',
|
||||
GuildSoundboardSoundsUpdate = 'guildSoundboardSoundsUpdate',
|
||||
SoundboardSounds = 'soundboardSounds',
|
||||
}
|
||||
|
||||
export enum ShardEvents {
|
||||
@@ -6203,7 +6425,7 @@ export type GuildAuditLogsResolvable = AuditLogEvent | null;
|
||||
export type GuildAuditLogsTargetType = GuildAuditLogsTypes[keyof GuildAuditLogsTypes][0] | 'All' | 'Unknown';
|
||||
|
||||
export type GuildAuditLogsTargets = {
|
||||
[key in GuildAuditLogsTargetType]: GuildAuditLogsTargetType;
|
||||
[Key in GuildAuditLogsTargetType]: GuildAuditLogsTargetType;
|
||||
};
|
||||
|
||||
export type GuildBanResolvable = GuildBan | UserResolvable;
|
||||
@@ -6406,18 +6628,35 @@ export interface GuildScheduledEventCreateOptions {
|
||||
recurrenceRule?: GuildScheduledEventRecurrenceRuleOptions;
|
||||
}
|
||||
|
||||
export interface GuildScheduledEventRecurrenceRuleOptions {
|
||||
export type GuildScheduledEventRecurrenceRuleOptions =
|
||||
| BaseGuildScheduledEventRecurrenceRuleOptions<
|
||||
GuildScheduledEventRecurrenceRuleFrequency.Yearly,
|
||||
{
|
||||
byMonth: readonly GuildScheduledEventRecurrenceRuleMonth[];
|
||||
byMonthDay: readonly number[];
|
||||
}
|
||||
>
|
||||
| BaseGuildScheduledEventRecurrenceRuleOptions<
|
||||
GuildScheduledEventRecurrenceRuleFrequency.Monthly,
|
||||
{
|
||||
byNWeekday: readonly GuildScheduledEventRecurrenceRuleNWeekday[];
|
||||
}
|
||||
>
|
||||
| BaseGuildScheduledEventRecurrenceRuleOptions<
|
||||
GuildScheduledEventRecurrenceRuleFrequency.Weekly | GuildScheduledEventRecurrenceRuleFrequency.Daily,
|
||||
{
|
||||
byWeekday: readonly GuildScheduledEventRecurrenceRuleWeekday[];
|
||||
}
|
||||
>;
|
||||
|
||||
type BaseGuildScheduledEventRecurrenceRuleOptions<
|
||||
Frequency extends GuildScheduledEventRecurrenceRuleFrequency,
|
||||
Extra extends {},
|
||||
> = {
|
||||
startAt: DateResolvable;
|
||||
endAt: DateResolvable;
|
||||
frequency: GuildScheduledEventRecurrenceRuleFrequency;
|
||||
interval: number;
|
||||
byWeekday: readonly GuildScheduledEventRecurrenceRuleWeekday[];
|
||||
byNWeekday: readonly GuildScheduledEventRecurrenceRuleNWeekday[];
|
||||
byMonth: readonly GuildScheduledEventRecurrenceRuleMonth[];
|
||||
byMonthDay: readonly number[];
|
||||
byYearDay: readonly number[];
|
||||
count: number;
|
||||
}
|
||||
frequency: Frequency;
|
||||
} & Extra;
|
||||
|
||||
export interface GuildScheduledEventEditOptions<
|
||||
Status extends GuildScheduledEventStatus,
|
||||
@@ -6496,6 +6735,18 @@ export interface GuildOnboardingPromptOptionData {
|
||||
|
||||
export type HexColorString = `#${string}`;
|
||||
|
||||
export interface IncidentActions {
|
||||
invitesDisabledUntil: Date | null;
|
||||
dmsDisabledUntil: Date | null;
|
||||
dmSpamDetectedAt: Date | null;
|
||||
raidDetectedAt: Date | null;
|
||||
}
|
||||
|
||||
export interface IncidentActionsEditOptions {
|
||||
invitesDisabledUntil?: DateResolvable | null | undefined;
|
||||
dmsDisabledUntil?: DateResolvable | null | undefined;
|
||||
}
|
||||
|
||||
export interface IntegrationAccount {
|
||||
id: string | Snowflake;
|
||||
name: string;
|
||||
@@ -6540,10 +6791,7 @@ export interface InteractionCollectorOptions<
|
||||
export interface InteractionDeferReplyOptions {
|
||||
/** @deprecated Use {@link InteractionDeferReplyOptions.flags} instead. */
|
||||
ephemeral?: boolean;
|
||||
flags?: BitFieldResolvable<
|
||||
Extract<MessageFlagsString, 'Ephemeral' | 'SuppressEmbeds' | 'SuppressNotifications'>,
|
||||
MessageFlags.Ephemeral | MessageFlags.SuppressEmbeds | MessageFlags.SuppressNotifications
|
||||
>;
|
||||
flags?: BitFieldResolvable<Extract<MessageFlagsString, 'Ephemeral'>, MessageFlags.Ephemeral> | undefined;
|
||||
withResponse?: boolean;
|
||||
/** @deprecated Use {@link InteractionDeferReplyOptions.withResponse} instead. */
|
||||
fetchReply?: boolean;
|
||||
@@ -6562,10 +6810,15 @@ export interface InteractionReplyOptions extends BaseMessageOptionsWithPoll {
|
||||
withResponse?: boolean;
|
||||
/** @deprecated Use {@link InteractionReplyOptions.withResponse} instead. */
|
||||
fetchReply?: boolean;
|
||||
flags?: BitFieldResolvable<
|
||||
Extract<MessageFlagsString, 'Ephemeral' | 'SuppressEmbeds' | 'SuppressNotifications'>,
|
||||
MessageFlags.Ephemeral | MessageFlags.SuppressEmbeds | MessageFlags.SuppressNotifications
|
||||
>;
|
||||
flags?:
|
||||
| BitFieldResolvable<
|
||||
Extract<MessageFlagsString, 'Ephemeral' | 'SuppressEmbeds' | 'SuppressNotifications' | 'IsComponentsV2'>,
|
||||
| MessageFlags.Ephemeral
|
||||
| MessageFlags.SuppressEmbeds
|
||||
| MessageFlags.SuppressNotifications
|
||||
| MessageFlags.IsComponentsV2
|
||||
>
|
||||
| undefined;
|
||||
}
|
||||
|
||||
export interface InteractionUpdateOptions extends MessageEditOptions {
|
||||
@@ -6744,9 +6997,10 @@ export interface BaseMessageOptions {
|
||||
| AttachmentPayload
|
||||
)[];
|
||||
components?: readonly (
|
||||
| JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>>
|
||||
| JSONEncodable<APIMessageTopLevelComponent>
|
||||
| TopLevelComponentData
|
||||
| ActionRowData<MessageActionRowComponentData | MessageActionRowComponentBuilder>
|
||||
| APIActionRowComponent<APIMessageActionRowComponent>
|
||||
| APIMessageTopLevelComponent
|
||||
)[];
|
||||
}
|
||||
|
||||
@@ -6759,11 +7013,14 @@ export interface MessageCreateOptions extends BaseMessageOptionsWithPoll {
|
||||
nonce?: string | number;
|
||||
enforceNonce?: boolean;
|
||||
reply?: ReplyOptions;
|
||||
forward?: ForwardOptions;
|
||||
stickers?: readonly StickerResolvable[];
|
||||
flags?: BitFieldResolvable<
|
||||
Extract<MessageFlagsString, 'SuppressEmbeds' | 'SuppressNotifications'>,
|
||||
MessageFlags.SuppressEmbeds | MessageFlags.SuppressNotifications
|
||||
>;
|
||||
flags?:
|
||||
| BitFieldResolvable<
|
||||
Extract<MessageFlagsString, 'SuppressEmbeds' | 'SuppressNotifications' | 'IsComponentsV2'>,
|
||||
MessageFlags.SuppressEmbeds | MessageFlags.SuppressNotifications | MessageFlags.IsComponentsV2
|
||||
>
|
||||
| undefined;
|
||||
}
|
||||
|
||||
export interface GuildForumThreadMessageCreateOptions
|
||||
@@ -6777,7 +7034,7 @@ export interface MessageEditAttachmentData {
|
||||
export interface MessageEditOptions extends Omit<BaseMessageOptions, 'content'> {
|
||||
content?: string | null;
|
||||
attachments?: readonly (Attachment | MessageEditAttachmentData)[];
|
||||
flags?: BitFieldResolvable<Extract<MessageFlagsString, 'SuppressEmbeds'>, MessageFlags.SuppressEmbeds>;
|
||||
flags?: BitFieldResolvable<Extract<MessageFlagsString, 'SuppressEmbeds'>, MessageFlags.SuppressEmbeds> | undefined;
|
||||
}
|
||||
|
||||
export type MessageReactionResolvable = MessageReaction | Snowflake | string;
|
||||
@@ -6971,6 +7228,8 @@ export interface PartialGuildScheduledEvent
|
||||
|
||||
export interface PartialThreadMember extends Partialize<ThreadMember, 'flags' | 'joinedAt' | 'joinedTimestamp'> {}
|
||||
|
||||
export interface PartialSoundboardSound extends Partialize<SoundboardSound, 'available' | 'name' | 'volume'> {}
|
||||
|
||||
export interface PartialOverwriteData {
|
||||
id: Snowflake | number;
|
||||
type?: OverwriteType;
|
||||
@@ -6990,6 +7249,7 @@ export enum Partials {
|
||||
Reaction,
|
||||
GuildScheduledEvent,
|
||||
ThreadMember,
|
||||
SoundboardSound,
|
||||
}
|
||||
|
||||
export interface PartialUser extends Partialize<User, 'username' | 'tag' | 'discriminator'> {}
|
||||
@@ -7009,7 +7269,21 @@ export interface ReplyOptions {
|
||||
failIfNotExists?: boolean;
|
||||
}
|
||||
|
||||
export interface MessageReplyOptions extends Omit<MessageCreateOptions, 'reply'> {
|
||||
export interface BaseForwardOptions {
|
||||
message: MessageResolvable;
|
||||
channel?: Exclude<TextBasedChannelResolvable, PartialGroupDMChannel>;
|
||||
guild?: GuildResolvable;
|
||||
}
|
||||
|
||||
export type ForwardOptionsWithMandatoryChannel = BaseForwardOptions & Required<Pick<BaseForwardOptions, 'channel'>>;
|
||||
|
||||
export interface ForwardOptionsWithOptionalChannel extends BaseForwardOptions {
|
||||
message: Exclude<MessageResolvable, Snowflake>;
|
||||
}
|
||||
|
||||
export type ForwardOptions = ForwardOptionsWithMandatoryChannel | ForwardOptionsWithOptionalChannel;
|
||||
|
||||
export interface MessageReplyOptions extends Omit<MessageCreateOptions, 'reply' | 'forward'> {
|
||||
failIfNotExists?: boolean;
|
||||
}
|
||||
|
||||
@@ -7274,7 +7548,7 @@ export interface WebhookEditOptions {
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
export interface WebhookMessageEditOptions extends Omit<MessageEditOptions, 'flags'> {
|
||||
export interface WebhookMessageEditOptions extends MessageEditOptions {
|
||||
threadId?: Snowflake;
|
||||
}
|
||||
|
||||
@@ -7288,7 +7562,8 @@ export interface WebhookFetchMessageOptions {
|
||||
threadId?: Snowflake;
|
||||
}
|
||||
|
||||
export interface WebhookMessageCreateOptions extends Omit<MessageCreateOptions, 'nonce' | 'reply' | 'stickers'> {
|
||||
export interface WebhookMessageCreateOptions
|
||||
extends Omit<MessageCreateOptions, 'nonce' | 'reply' | 'stickers' | 'forward'> {
|
||||
username?: string;
|
||||
avatarURL?: string;
|
||||
threadId?: Snowflake;
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
ApplicationCommandType,
|
||||
APIMessage,
|
||||
APIActionRowComponent,
|
||||
APIActionRowComponentTypes,
|
||||
APIComponentInActionRow,
|
||||
APIStringSelectComponent,
|
||||
APIUserSelectComponent,
|
||||
APIRoleSelectComponent,
|
||||
@@ -33,6 +33,10 @@ import {
|
||||
APIMentionableSelectComponent,
|
||||
APIModalInteractionResponseCallbackData,
|
||||
WebhookType,
|
||||
GuildScheduledEventRecurrenceRuleFrequency,
|
||||
GuildScheduledEventRecurrenceRuleMonth,
|
||||
GuildScheduledEventRecurrenceRuleWeekday,
|
||||
MessageFlags,
|
||||
} from 'discord-api-types/v10';
|
||||
import {
|
||||
ApplicationCommand,
|
||||
@@ -214,6 +218,17 @@ import {
|
||||
PollData,
|
||||
UserManager,
|
||||
InteractionCallbackResponse,
|
||||
GuildScheduledEventRecurrenceRuleOptions,
|
||||
ThreadOnlyChannel,
|
||||
SectionComponentData,
|
||||
TextDisplayComponentData,
|
||||
ThumbnailComponentData,
|
||||
UnfurledMediaItemData,
|
||||
MediaGalleryComponentData,
|
||||
MediaGalleryItemData,
|
||||
SeparatorComponentData,
|
||||
FileComponentData,
|
||||
ContainerComponentData,
|
||||
} from '.';
|
||||
import {
|
||||
expectAssignable,
|
||||
@@ -637,6 +652,57 @@ client.on('messageCreate', async message => {
|
||||
components: [row, rawButtonsRow, buttonsRow, rawStringSelectMenuRow, stringSelectRow],
|
||||
embeds: [embed, embedData],
|
||||
});
|
||||
|
||||
const rawTextDisplay: TextDisplayComponentData = {
|
||||
type: ComponentType.TextDisplay,
|
||||
content: 'test',
|
||||
};
|
||||
|
||||
const rawMedia: UnfurledMediaItemData = { url: 'https://discord.js.org' };
|
||||
|
||||
const rawThumbnail: ThumbnailComponentData = {
|
||||
type: ComponentType.Thumbnail,
|
||||
media: rawMedia,
|
||||
spoiler: true,
|
||||
description: 'test',
|
||||
};
|
||||
|
||||
const rawSection: SectionComponentData = {
|
||||
type: ComponentType.Section,
|
||||
components: [rawTextDisplay],
|
||||
accessory: rawThumbnail,
|
||||
};
|
||||
|
||||
const rawMediaGalleryItem: MediaGalleryItemData = {
|
||||
media: rawMedia,
|
||||
description: 'test',
|
||||
spoiler: false,
|
||||
};
|
||||
|
||||
const rawMediaGallery: MediaGalleryComponentData = {
|
||||
type: ComponentType.MediaGallery,
|
||||
items: [rawMediaGalleryItem, rawMediaGalleryItem, rawMediaGalleryItem],
|
||||
};
|
||||
|
||||
const rawSeparator: SeparatorComponentData = {
|
||||
type: ComponentType.Separator,
|
||||
spacing: 1,
|
||||
dividier: false,
|
||||
};
|
||||
|
||||
const rawFile: FileComponentData = {
|
||||
type: ComponentType.File,
|
||||
file: rawMedia,
|
||||
};
|
||||
|
||||
const rawContainer: ContainerComponentData = {
|
||||
type: ComponentType.Container,
|
||||
components: [rawSection, rawSeparator, rawMediaGallery, rawFile],
|
||||
accentColor: 0xff00ff,
|
||||
spoiler: true,
|
||||
};
|
||||
|
||||
channel.send({ flags: MessageFlags.IsComponentsV2, components: [rawContainer] });
|
||||
});
|
||||
|
||||
client.on('messageDelete', ({ client }) => expectType<Client<true>>(client));
|
||||
@@ -1317,7 +1383,7 @@ client.on('guildCreate', async g => {
|
||||
|
||||
// EventEmitter static method overrides
|
||||
expectType<Promise<[Client<true>]>>(Client.once(client, 'ready'));
|
||||
expectType<AsyncIterableIterator<[Client<true>]>>(Client.on(client, 'ready'));
|
||||
expectAssignable<AsyncIterableIterator<[Client<true>]>>(Client.on(client, 'ready'));
|
||||
|
||||
client.login('absolutely-valid-token');
|
||||
|
||||
@@ -2407,7 +2473,7 @@ EmbedBuilder.from(embedData);
|
||||
declare const embedComp: Embed;
|
||||
EmbedBuilder.from(embedComp);
|
||||
|
||||
declare const actionRowData: APIActionRowComponent<APIActionRowComponentTypes>;
|
||||
declare const actionRowData: APIActionRowComponent<APIComponentInActionRow>;
|
||||
ActionRowBuilder.from(actionRowData);
|
||||
|
||||
declare const actionRowComp: ActionRow<ActionRowComponent>;
|
||||
@@ -2419,7 +2485,7 @@ declare const buttonsActionRowComp: ActionRow<ButtonComponent>;
|
||||
expectType<ActionRowBuilder<ButtonBuilder>>(ActionRowBuilder.from<ButtonBuilder>(buttonsActionRowData));
|
||||
expectType<ActionRowBuilder<ButtonBuilder>>(ActionRowBuilder.from<ButtonBuilder>(buttonsActionRowComp));
|
||||
|
||||
declare const anyComponentsActionRowData: APIActionRowComponent<APIActionRowComponentTypes>;
|
||||
declare const anyComponentsActionRowData: APIActionRowComponent<APIComponentInActionRow>;
|
||||
declare const anyComponentsActionRowComp: ActionRow<ActionRowComponent>;
|
||||
|
||||
expectType<ActionRowBuilder>(ActionRowBuilder.from(anyComponentsActionRowData));
|
||||
@@ -2457,6 +2523,16 @@ declare const partialGroupDMChannel: PartialGroupDMChannel;
|
||||
declare const categoryChannel: CategoryChannel;
|
||||
declare const stageChannel: StageChannel;
|
||||
declare const forumChannel: ForumChannel;
|
||||
declare const mediaChannel: MediaChannel;
|
||||
declare const threadOnlyChannel: ThreadOnlyChannel;
|
||||
|
||||
// Threads have messages.
|
||||
expectType<GuildMessageManager>(threadChannel.messages);
|
||||
|
||||
// Thread-only channels have threads—not messages.
|
||||
notPropertyOf(threadOnlyChannel, 'messages');
|
||||
notPropertyOf(forumChannel, 'messages');
|
||||
notPropertyOf(mediaChannel, 'messages');
|
||||
|
||||
await forumChannel.edit({
|
||||
availableTags: [...forumChannel.availableTags, { name: 'tag' }],
|
||||
@@ -2679,3 +2755,89 @@ client.on('interactionCreate', interaction => {
|
||||
|
||||
declare const guildScheduledEventManager: GuildScheduledEventManager;
|
||||
await guildScheduledEventManager.edit(snowflake, { recurrenceRule: null });
|
||||
|
||||
{
|
||||
expectNotAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||
startAt: new Date(),
|
||||
frequency: GuildScheduledEventRecurrenceRuleFrequency.Yearly,
|
||||
interval: 1,
|
||||
byMonth: [GuildScheduledEventRecurrenceRuleMonth.May],
|
||||
byMonthDay: [4],
|
||||
// Invalid property
|
||||
byWeekday: [GuildScheduledEventRecurrenceRuleWeekday.Monday],
|
||||
});
|
||||
|
||||
expectNotAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||
startAt: new Date(),
|
||||
frequency: GuildScheduledEventRecurrenceRuleFrequency.Yearly,
|
||||
interval: 1,
|
||||
byMonth: [GuildScheduledEventRecurrenceRuleMonth.May],
|
||||
byMonthDay: [4],
|
||||
// Invalid property
|
||||
byNWeekday: [{ n: 1, day: GuildScheduledEventRecurrenceRuleWeekday.Monday }],
|
||||
});
|
||||
|
||||
expectAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||
startAt: new Date(),
|
||||
frequency: GuildScheduledEventRecurrenceRuleFrequency.Yearly,
|
||||
interval: 1,
|
||||
byMonth: [GuildScheduledEventRecurrenceRuleMonth.May],
|
||||
byMonthDay: [4],
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
expectAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||
startAt: new Date(),
|
||||
frequency: GuildScheduledEventRecurrenceRuleFrequency.Monthly,
|
||||
interval: 1,
|
||||
byNWeekday: [{ n: 1, day: GuildScheduledEventRecurrenceRuleWeekday.Monday }],
|
||||
});
|
||||
|
||||
expectNotAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||
startAt: new Date(),
|
||||
frequency: GuildScheduledEventRecurrenceRuleFrequency.Monthly,
|
||||
interval: 1,
|
||||
byNWeekday: [{ n: 1, day: GuildScheduledEventRecurrenceRuleWeekday.Monday }],
|
||||
// Invalid property
|
||||
byWeekday: [GuildScheduledEventRecurrenceRuleWeekday.Monday],
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
expectAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||
startAt: new Date(),
|
||||
frequency: GuildScheduledEventRecurrenceRuleFrequency.Weekly,
|
||||
interval: 1,
|
||||
byWeekday: [GuildScheduledEventRecurrenceRuleWeekday.Monday],
|
||||
});
|
||||
|
||||
expectNotAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||
startAt: new Date(),
|
||||
frequency: GuildScheduledEventRecurrenceRuleFrequency.Weekly,
|
||||
interval: 1,
|
||||
byWeekday: [GuildScheduledEventRecurrenceRuleWeekday.Monday],
|
||||
// Invalid property
|
||||
byNWeekday: [{ n: 1, day: GuildScheduledEventRecurrenceRuleWeekday.Monday }],
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
expectNotAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||
startAt: new Date(),
|
||||
frequency: GuildScheduledEventRecurrenceRuleFrequency.Daily,
|
||||
interval: 1,
|
||||
byWeekday: [GuildScheduledEventRecurrenceRuleWeekday.Monday],
|
||||
// Invalid property
|
||||
byNWeekday: [{ n: 1, day: GuildScheduledEventRecurrenceRuleWeekday.Monday }],
|
||||
});
|
||||
|
||||
expectNotAssignable<GuildScheduledEventRecurrenceRuleOptions>({
|
||||
startAt: new Date(),
|
||||
frequency: GuildScheduledEventRecurrenceRuleFrequency.Daily,
|
||||
interval: 1,
|
||||
byWeekday: [GuildScheduledEventRecurrenceRuleWeekday.Monday],
|
||||
// Invalid property
|
||||
byMonth: [GuildScheduledEventRecurrenceRuleMonth.May],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
<a href="https://www.npmjs.com/package/@discordjs/formatters"><img src="https://img.shields.io/npm/v/@discordjs/formatters.svg?maxAge=3600" alt="npm version" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/formatters"><img src="https://img.shields.io/npm/dt/@discordjs/formatters.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=formatters" alt="Code coverage" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/commits/main/packages/formatters"><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Fformatters"></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js"><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=formatters" alt="Code coverage" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
"homepage": "https://discord.js.org",
|
||||
"funding": "https://github.com/discordjs/discord.js?sponsor",
|
||||
"dependencies": {
|
||||
"discord-api-types": "^0.37.114"
|
||||
"discord-api-types": "^0.37.119"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@discordjs/api-extractor": "workspace:^",
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<p>
|
||||
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/commits/main/packages/next"><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Fnext"></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
"@discordjs/rest": "workspace:^",
|
||||
"@discordjs/util": "workspace:^",
|
||||
"@discordjs/ws": "workspace:^",
|
||||
"discord-api-types": "^0.37.114"
|
||||
"discord-api-types": "^0.37.119"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@discordjs/api-extractor": "workspace:^",
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
<a href="https://www.npmjs.com/package/@discordjs/proxy"><img src="https://img.shields.io/npm/v/@discordjs/proxy.svg?maxAge=3600" alt="npm version" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/proxy"><img src="https://img.shields.io/npm/dt/@discordjs/proxy.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=proxy" alt="Code coverage" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/commits/main/packages/proxy"><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Fproxy"></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js"><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=proxy" alt="Code coverage" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
"@discordjs/rest": "workspace:^",
|
||||
"@discordjs/util": "workspace:^",
|
||||
"tslib": "^2.6.3",
|
||||
"undici": "6.19.8"
|
||||
"undici": "6.21.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@discordjs/api-extractor": "workspace:^",
|
||||
|
||||
@@ -2,6 +2,19 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
# [@discordjs/rest@2.5.0](https://github.com/discordjs/discord.js/compare/@discordjs/rest@2.4.3...@discordjs/rest@2.5.0) - (2025-04-25)
|
||||
|
||||
## Features
|
||||
|
||||
- Components v2 in v14 (#10781) ([edace17](https://github.com/discordjs/discord.js/commit/edace17a131f857547163a3acf4bb6fec0c1e415))
|
||||
- Add soundboard in v14 (#10843) ([d3154cf](https://github.com/discordjs/discord.js/commit/d3154cf8f1eb027b5b4921d4048a32f464a3cd85))
|
||||
|
||||
# [@discordjs/rest@2.4.2](https://github.com/discordjs/discord.js/compare/@discordjs/rest@2.4.1...@discordjs/rest@2.4.2) - (2025-01-01)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- Correct guild member banner URL ([8d69b24](https://github.com/discordjs/discord.js/commit/8d69b24b5c83249dffa5899a417a9dcbc6f3f30c))
|
||||
|
||||
# [@discordjs/rest@2.4.2](https://github.com/discordjs/discord.js/compare/@discordjs/rest@2.4.1...@discordjs/rest@2.4.2) - (2025-01-01)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user