Compare commits

..

51 Commits

Author SHA1 Message Date
iCrawl
d63bcbb9d4 chore(core): release @discordjs/core@0.2.0 2022-12-16 03:58:37 +01:00
iCrawl
82f4827ee5 chore(ws): release @discordjs/ws@0.6.0 2022-12-16 03:55:39 +01:00
iCrawl
e470e088ab chore(rest): release @discordjs/rest@1.5.0 2022-12-16 03:53:13 +01:00
Suneet Tipirneni
3d6fa248c0 feat(core): Add support for role connections (#8930) 2022-12-16 03:32:00 +01:00
Suneet Tipirneni
273ba45e27 chore: use satisfies where applicable (#8884)
* chore: use satisfies where applicable

* chore: remove unneeded eslint ignores

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-16 02:12:38 +00:00
Suneet Tipirneni
7a5134459c feat: add support for nsfw commands (#7976)
* chore: update

* fix: add edit changes

* chore: make requested changes

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-16 02:04:56 +00:00
Tristan Camejo
6540914b4a refactor(sharding): use switch statement (#8928) 2022-12-15 08:07:28 +00:00
Ben
627511d652 feat(InteractionResponse): createdTimestamp (#8917)
* feat(InteractionResponse): createdTimestamp

* feat(InteractionResponse): createdTimestamp

* Apply suggestions from code review

Co-authored-by: MrMythicalYT <91077061+MrMythicalYT@users.noreply.github.com>

Co-authored-by: MrMythicalYT <91077061+MrMythicalYT@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-14 21:35:40 +00:00
MrMythicalYT
a7b55c1460 refactor: use consistent naming for options (#8901)
* refactor: use consistent naming for options

* chore: update param names in typings

* chore: update forgotten `data` param

* Update packages/discord.js/src/structures/Guild.js

Co-authored-by: SpaceEEC <spaceeec@yahoo.com>

Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-14 21:32:38 +00:00
Jiralite
1b151db59c refactor(CommandInteractionOptionResolver): Loosen mentionable checks (#8910)
refactor(CommandInteractionOptionResolver): loosen mentionable checks

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-14 21:29:29 +00:00
Qjuh
aa8c57dab6 fix(WebSocketShard): clear listeners on reconnect (#8927) 2022-12-14 21:23:20 +00:00
muchnameless
b14604abde fix: re-export formatters (#8909)
* fix: re-export formatters

* future-proof typings

Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-12 08:49:24 +00:00
Almeida
73300c75fa feat: add links to each routes documentation (#8898) 2022-12-07 16:32:55 +00:00
Almeida
3dede75621 fix(thread): get() route (#8897)
Co-authored-by: Aura Román <kyradiscord@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-07 14:27:01 +00:00
Almeida
3f555d5ddf feat(interactions): add messageId parameter to deleteReply() (#8896) 2022-12-07 14:23:42 +00:00
Jiralite
976b234e9d docs: Fix deprecated links (#8907)
docs: fix malformed deprecated descriptions

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-06 16:30:48 +00:00
MrMythicalYT
c48ff5e420 docs(UserFlagsBitField): make .Flags static (#8902)
Co-authored-by: Aura Román <kyradiscord@gmail.com>
2022-12-06 16:27:12 +00:00
Jiralite
6acf759f63 fix: Deprecate workflow fix (#8903)
fix: deprecate workflow fix

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-06 10:29:35 +00:00
iCrawl
fb70df817c ci: fix ref name 2022-12-03 17:05:37 +01:00
iCrawl
86959bad49 chore: update next 2022-12-03 10:43:51 +01:00
iCrawl
a0d6bc49c6 refactor: remove revalidation 2022-12-02 19:09:58 +01:00
MrMythicalYT
45faa19982 feat(Guild): add disableInvites method (#8801)
* feat(GuildInviteManager): add setDisabled method

* fix: formatting

* refactor: move helper method to `Guild`

* fix: rename method

* fix: add newline before jsdoc

* fix: remove disallowed trailing space

* Update packages/discord.js/src/structures/Guild.js

Co-authored-by: Hackerboi 69 <62872992+thehackerboi69github@users.noreply.github.com>

Co-authored-by: Hackerboi 69 <62872992+thehackerboi69github@users.noreply.github.com>
Co-authored-by: Aura Román <kyradiscord@gmail.com>
2022-12-02 13:21:59 +00:00
DD
8f552a0e17 refactor(WebSocketShard): identify throttling (#8888)
* refactor(WebSocketShard): identify throttling

* chore: add worker handling

* refactor: worker handling

* chore: update tests

* chore: use satisfies where applicable

* chore: add informative comment

* chore: apply suggestions

* refactor(SimpleContextFetchingStrategy): support multiple managers
2022-12-02 13:04:09 +00:00
Suneet Tipirneni
3fca638a84 feat: add @discordjs/formatters (#8889)
* feat: add @discordjs/formatters

* chore: make requested changes

* chore: make requested changes

* chore: fix other places

* chore: make requested changes

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-02 12:55:00 +00:00
iCrawl
4e4cbb3418 fix: revalidate on page level instead 2022-12-02 11:31:59 +01:00
iCrawl
52f56d3c2e chore: deps 2022-12-01 21:01:19 +01:00
DD
40b504a208 fix(WebSocketShard): send ratelimit handling (#8887)
* fix(WebSocketShard): send ratelimit handling

* chore: remove unnecessary else

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-01 10:58:00 +00:00
iCrawl
322cb99049 chore(discord.js): release discord.js@14.7.1 2022-12-01 11:53:40 +01:00
Jiralite
11d195d04f fix: Prevent crash on no select menu option (#8881)
* fix: no crash on no option

* refactor: consistency in ??

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-01 10:49:14 +00:00
Almeida
f13ff5c6d3 feat(createPackage): sort label files (#8892)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-01 10:02:44 +00:00
Jiralite
5e4331062b chore: Add brokers to package list and labels in issue forms (#8893)
chore: add brokers and sort list

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-01 10:00:04 +00:00
Almeida
fff3602a8a fix(createPackage): invalid label/path on labeler file (#8891)
* fix(createPackage): invalid label/path on labeler file

* fix: `packages:ui` label
2022-12-01 09:55:31 +00:00
iCrawl
72c30d1578 revert: theme fix 2022-11-30 04:41:07 +01:00
iCrawl
2cb1000a3a fix: move back to old theming 2022-11-30 04:34:47 +01:00
iCrawl
8a39c14921 fix: generate correct paths after moving catch-all 2022-11-30 04:26:40 +01:00
iCrawl
4ae029dfe2 fix: path generation 2022-11-30 04:16:27 +01:00
iCrawl
2849af0118 refactor: correctly generate routes 2022-11-30 03:55:23 +01:00
iCrawl
90d192078f fix: generate paths 2022-11-30 03:17:47 +01:00
iCrawl
b0f9b9c344 fix: next-themes 2022-11-30 02:22:00 +01:00
iCrawl
6bcebd4867 fix: including readme files 2022-11-29 01:06:02 +01:00
iCrawl
1efa95337f fix: dynamicParams bug 2022-11-29 00:36:23 +01:00
iCrawl
2f4bdf7394 fix: remove output file tracing option 2022-11-29 00:20:23 +01:00
iCrawl
4b9b62416b fix: reading readme files 2022-11-29 00:10:01 +01:00
iCrawl
208378b214 chore: fix changelog 2022-11-28 23:19:34 +01:00
iCrawl
6e65b45b31 chore(discord.js): release discord.js@14.7.0 2022-11-28 23:00:38 +01:00
iCrawl
2b260bd4bb chore: deps 2022-11-28 22:53:19 +01:00
iCrawl
cab692409d chore(voice): release @discordjs/voice@0.14.0 2022-11-28 22:51:40 +01:00
iCrawl
0fe503b516 chore(ws): release @discordjs/ws@0.5.0 2022-11-28 22:50:16 +01:00
iCrawl
999bc2069e chore(proxy): release @discordjs/proxy@1.2.1 2022-11-28 22:48:38 +01:00
iCrawl
b89bd6f67c chore(rest): release @discordjs/rest@1.4.0 2022-11-28 22:46:13 +01:00
iCrawl
5235ad5bfe chore(collection): release @discordjs/collection@1.3.0 2022-11-28 22:44:33 +01:00
137 changed files with 2759 additions and 1397 deletions

View File

@@ -16,9 +16,10 @@ body:
- builders
- collection
- core
- rest
- formatters
- proxy
- proxy-container
- rest
- voice
- ws
validations:

View File

@@ -14,12 +14,14 @@ body:
label: Which package is the feature request for?
options:
- discord.js
- brokers
- builders
- collection
- core
- rest
- formatters
- proxy
- proxy-container
- rest
- voice
- ws
validations:

10
.github/labeler.yml vendored
View File

@@ -4,7 +4,6 @@ apps:guide:
apps:website:
- apps/website/*
- apps/website/**/*
packages:brokers:
- packages/brokers/*
- packages/brokers/**/*
@@ -23,6 +22,9 @@ packages:discord.js:
packages:docgen:
- packages/docgen/*
- packages/docgen/**/*
packages:formatters:
- packages/formatters/*
- packages/formatters/**/*
packages:proxy:
- packages/proxy/*
- packages/proxy/**/*
@@ -32,9 +34,9 @@ packages:proxy-container:
packages:rest:
- packages/rest/*
- packages/rest/**/*
packages/ui:
- packages:ui/*
- packages:ui/**/*
packages:ui:
- packages/ui/*
- packages/ui/**/*
packages:util:
- packages/util/*
- packages/util/**/*

10
.github/labels.yml vendored
View File

@@ -20,10 +20,10 @@
color: 0075ca
- name: dependencies
color: 276bd1
- name: discussion
color: b6b1f9
- name: discord
color: '5663e9'
- name: discussion
color: b6b1f9
- name: documentation
color: 0075ca
- name: duplicate
@@ -40,12 +40,12 @@
color: 4b1f8e
- name: help wanted
color: '008672'
- name: interactions
color: 80c042
- name: in progress
color: ffccd7
- name: in review
color: aed5fc
- name: interactions
color: 80c042
- name: invalid
color: e4e669
- name: need repro
@@ -62,6 +62,8 @@
color: fbca04
- name: packages:docgen
color: fbca04
- name: packages:formatters
color: fbca04
- name: packages:proxy
color: fbca04
- name: packages:proxy-container

View File

@@ -67,7 +67,20 @@ jobs:
max-parallel: 1
fail-fast: false
matrix:
package: ['brokers', 'builders', 'collection', 'core', 'discord.js', 'proxy', 'rest', 'util', 'voice', 'ws']
package:
[
'brokers',
'builders',
'collection',
'core',
'discord.js',
'formatters',
'proxy',
'rest',
'util',
'voice',
'ws',
]
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
@@ -111,7 +124,7 @@ jobs:
id: extract-tag
uses: ./packages/actions/src/formatTag
with:
tag: ${{ env.GITHUB_REF_NAME }}
tag: ${{ github.ref_name }}
- name: Move docs to correct directory
if: ${{ github.ref_type == 'tag' && matrix.package == steps.extract-tag.outputs.package }}

View File

@@ -21,6 +21,6 @@ jobs:
uses: ./packages/actions/src/yarnCache
- name: Deprecate versions
run: 'yarn npm-deprecate --name "*dev*" --package @discordjs/brokers @discordjs/builders @discordjs/collection @discordjs/core discord.js @discordjs/proxy @discordjs/rest @discordjs/util @discordjs/voice @discordjs/ws'
run: 'yarn npm-deprecate --name "*dev*" --package @discordjs/brokers @discordjs/builders @discordjs/collection @discordjs/core @discordjs/formatters discord.js @discordjs/proxy @discordjs/rest @discordjs/util @discordjs/voice @discordjs/ws'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

View File

@@ -18,6 +18,8 @@ jobs:
folder: 'collection'
- package: '@discordjs/core'
folder: 'core'
- package: '@discordjs/formatters'
folder: 'formatters'
- package: 'discord.js'
folder: 'discord.js'
- package: '@discordjs/proxy'

View File

@@ -42,27 +42,27 @@
"react": "^18.2.0",
"react-custom-scrollbars-2": "^4.5.0",
"react-dom": "^18.2.0",
"react-icons": "^4.6.0",
"react-icons": "^4.7.1",
"react-use": "^17.4.0"
},
"devDependencies": {
"@astrojs/image": "^0.11.6",
"@astrojs/image": "^0.12.0",
"@astrojs/mdx": "^0.12.0",
"@astrojs/prefetch": "^0.1.1",
"@astrojs/react": "^1.2.2",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
"@types/node": "16.18.3",
"@types/node": "16.18.4",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
"@types/react-syntax-highlighter": "^15.5.5",
"@unocss/cli": "^0.46.5",
"@unocss/reset": "^0.46.5",
"@unocss/cli": "^0.47.5",
"@unocss/reset": "^0.47.5",
"@vitejs/plugin-react": "^2.2.0",
"@vitest/coverage-c8": "^0.25.3",
"astro": "^1.6.11",
"astro-compress": "^1.1.12",
"astro-critters": "^1.1.12",
"astro": "^1.6.12",
"astro-compress": "^1.1.15",
"astro-critters": "^1.1.15",
"cross-env": "^7.0.3",
"eslint": "^8.28.0",
"eslint-config-neon": "^0.1.40",
@@ -79,8 +79,8 @@
"sharp": "^0.31.2",
"shiki": "^0.11.1",
"typescript": "^4.9.3",
"unocss": "^0.46.5",
"vercel": "^28.5.6",
"unocss": "^0.47.5",
"vercel": "^28.7.0",
"vitest": "^0.25.3"
},
"engines": {

View File

@@ -21,6 +21,7 @@ typings/
build/
src/styles/unocss.css
.next/
src/assets/readme/
# Miscellaneous
.tmp/

View File

@@ -14,7 +14,12 @@ export default withBundleAnalyzer({
eslint: {
ignoreDuringBuilds: true,
},
// Until Next.js fixes their type issues
typescript: {
ignoreBuildErrors: true,
},
cleanDistDir: true,
outputFileTracing: true,
experimental: {
appDir: true,
serverComponentsExternalPackages: ['@microsoft/api-extractor-model', 'jju', 'shiki'],

View File

@@ -5,8 +5,9 @@
"private": true,
"scripts": {
"test": "vitest run",
"build:local": "yarn run --top-level docs --force && cross-env-shell NEXT_PUBLIC_LOCAL_DEV=true yarn build:prod",
"build:prod": "yarn workspaces foreach -ptR run build && yarn build:css && yarn build:next",
"build:copy_readme": "cpy '../../packages/*/README.md' 'src/assets/readme' --rename='home-{{basename}}'",
"build:local": "yarn run --top-level docs --force && yarn build:copy_readme && cross-env-shell NEXT_PUBLIC_LOCAL_DEV=true yarn build:prod",
"build:prod": "yarn workspaces foreach -ptR run build && yarn build:copy_readme && yarn build:css && yarn build:next",
"build:next": "next build",
"build:css": "yarn generate:css",
"build:search_indicies": "yarn node scripts/generateAllIndicies.js",
@@ -53,10 +54,9 @@
"ariakit": "^2.0.0-next.41",
"cmdk": "^0.1.20",
"meilisearch": "^0.30.0",
"next": "^13.0.5",
"next": "^13.0.7-canary.1",
"next-mdx-remote": "^4.2.0",
"next-progress": "^2.2.0",
"next-themes": "^0.2.1",
"next-themes": "npm:@wits/next-themes@latest",
"react": "^18.2.0",
"react-custom-scrollbars-2": "^4.5.0",
"react-dom": "^18.2.0",
@@ -72,18 +72,19 @@
"swr": "^1.3.0"
},
"devDependencies": {
"@next/bundle-analyzer": "^13.0.5",
"@next/bundle-analyzer": "^13.0.6",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
"@types/node": "16.18.3",
"@types/node": "16.18.4",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
"@types/react-syntax-highlighter": "^15.5.5",
"@unocss/cli": "^0.46.5",
"@unocss/reset": "^0.46.5",
"@unocss/cli": "^0.47.5",
"@unocss/reset": "^0.47.5",
"@vitejs/plugin-react": "^2.2.0",
"@vitest/coverage-c8": "^0.25.3",
"concurrently": "^7.6.0",
"cpy-cli": "^4.2.0",
"cross-env": "^7.0.3",
"eslint": "^8.28.0",
"eslint-config-neon": "^0.1.40",
@@ -92,8 +93,8 @@
"prettier": "^2.8.0",
"prettier-plugin-tailwindcss": "^0.2.0",
"typescript": "^4.9.3",
"unocss": "^0.46.5",
"vercel": "^28.5.6",
"unocss": "^0.47.5",
"vercel": "^28.7.0",
"vitest": "^0.25.3"
},
"engines": {

View File

@@ -1,13 +0,0 @@
'use client';
import type { PropsWithChildren } from 'react';
import { CmdKProvider } from '~/contexts/cmdK';
import { NavProvider } from '~/contexts/nav';
export function Providers({ children }: PropsWithChildren) {
return (
<NavProvider>
<CmdKProvider>{children}</CmdKProvider>
</NavProvider>
);
}

View File

@@ -3,7 +3,7 @@ import { Providers } from './providers';
import { CmdKDialog } from '~/components/CmdK';
import { Header } from '~/components/Header';
export default function SidebarLayout({ children }: PropsWithChildren<any>) {
export default function SidebarLayout({ children }: PropsWithChildren) {
return (
<Providers>
<Header />

View File

@@ -30,7 +30,7 @@ import shikiLangJavascript from 'shiki/languages/javascript.tmLanguage.json';
import shikiLangTypescript from 'shiki/languages/typescript.tmLanguage.json';
import shikiThemeDarkPlus from 'shiki/themes/dark-plus.json';
import shikiThemeLightPlus from 'shiki/themes/light-plus.json';
import vercelLogo from '../../../assets/powered-by-vercel.svg';
import vercelLogo from '../../../../../assets/powered-by-vercel.svg';
import { MDXRemote } from '~/components/MDXRemote';
import { Nav } from '~/components/Nav';
import { Class } from '~/components/model/Class';
@@ -44,90 +44,93 @@ import { DESCRIPTION, PACKAGES } from '~/util/constants';
import { findMember, findMemberByKey } from '~/util/model.server';
import { tryResolveDescription } from '~/util/summary';
export async function generateStaticParams() {
return (
await Promise.all(
PACKAGES.map(async (packageName) => {
try {
let data: any[] = [];
let versions: string[] = [];
if (process.env.NEXT_PUBLIC_LOCAL_DEV) {
const res = await readFile(
join(cwd(), '..', '..', 'packages', packageName, 'docs', 'docs.api.json'),
'utf8',
);
data = JSON.parse(res);
} else {
const response = await fetch(`https://docs.discordjs.dev/api/info?package=${packageName}`);
versions = await response.json();
versions = versions.slice(-2);
export async function generateStaticParams({ params }: { params?: { package: string } }) {
const packageName = params?.package ?? 'builders';
for (const version of versions) {
const res = await fetch(`https://docs.discordjs.dev/docs/${packageName}/${version}.api.json`);
data = [...data, await res.json()];
try {
let data: any[] = [];
let versions: string[] = [];
if (process.env.NEXT_PUBLIC_LOCAL_DEV) {
const res = await readFile(join(cwd(), '..', '..', 'packages', packageName, 'docs', 'docs.api.json'), 'utf8');
data = JSON.parse(res);
} else {
const response = await fetch(`https://docs.discordjs.dev/api/info?package=${packageName}`, {
next: { revalidate: 3_600 },
});
versions = await response.json();
versions = versions.slice(-2);
for (const version of versions) {
const res = await fetch(`https://docs.discordjs.dev/docs/${packageName}/${version}.api.json`);
data = [...data, await res.json()];
}
}
if (Array.isArray(data)) {
const models = data.map((innerData) => createApiModel(innerData));
const pkgs = models.map((model) => findPackage(model, packageName)) as ApiPackage[];
return [
...versions.map((version) => ({ slug: [version] })),
...pkgs.flatMap((pkg, idx) =>
getMembers(pkg, versions[idx] ?? 'main').map((member) => {
if (member.kind === ApiItemKind.Function && member.overloadIndex && member.overloadIndex > 1) {
return {
slug: [versions[idx] ?? 'main', `${member.name}:${member.overloadIndex}:${member.kind}`],
};
}
}
if (Array.isArray(data)) {
const models = data.map((innerData) => createApiModel(innerData));
const pkgs = models.map((model) => findPackage(model, packageName)) as ApiPackage[];
return {
slug: [versions[idx] ?? 'main', `${member.name}:${member.kind}`],
};
}),
),
];
}
return [
...versions.map((version) => ({ slug: ['packages', packageName, version] })),
...pkgs.flatMap((pkg, idx) =>
getMembers(pkg, versions[idx] ?? 'main').map((member) => {
if (member.kind === ApiItemKind.Function && member.overloadIndex && member.overloadIndex > 1) {
return {
slug: [
'packages',
packageName,
versions[idx] ?? 'main',
`${member.name}:${member.overloadIndex}:${member.kind}`,
],
};
}
const model = createApiModel(data);
const pkg = findPackage(model, packageName)!;
return {
slug: ['packages', packageName, versions[idx] ?? 'main', `${member.name}:${member.kind}`],
};
}),
),
];
}
const model = createApiModel(data);
const pkg = findPackage(model, packageName)!;
return [
{ slug: ['packages', packageName, 'main'] },
...getMembers(pkg, 'main').map((member) => {
if (member.kind === ApiItemKind.Function && member.overloadIndex && member.overloadIndex > 1) {
return {
slug: ['packages', packageName, 'main', `${member.name}:${member.overloadIndex}:${member.kind}`],
};
}
return { slug: ['packages', packageName, 'main', `${member.name}:${member.kind}`] };
}),
];
} catch {
return { slug: [] };
return [
{ slug: ['main'] },
...getMembers(pkg, 'main').map((member) => {
if (member.kind === ApiItemKind.Function && member.overloadIndex && member.overloadIndex > 1) {
return {
slug: ['main', `${member.name}:${member.overloadIndex}:${member.kind}`],
};
}
return { slug: ['main', `${member.name}:${member.kind}`] };
}),
)
).flat();
];
} catch {
return [{ slug: ['main'] }];
}
}
async function getData(slug: string[]) {
const [path, packageName = 'builders', branchName = 'main', member] = slug;
async function getData(packageName: string, slug: string[]) {
const [branchName = 'main', member] = slug;
if (path !== 'packages' || !PACKAGES.includes(packageName)) {
if (!PACKAGES.includes(packageName)) {
notFound();
}
let data;
try {
if (process.env.NEXT_PUBLIC_LOCAL_DEV) {
const res = await readFile(join(cwd(), '..', '..', 'packages', packageName, 'docs', 'docs.api.json'), 'utf8');
data = JSON.parse(res);
} else {
const res = await fetch(`https://docs.discordjs.dev/docs/${packageName}/${branchName}.api.json`);
data = await res.json();
}
} catch {
notFound();
}
const [memberName, overloadIndex] = member?.split('%3A') ?? [];
const readme = await readFile(join(cwd(), '..', '..', 'packages', packageName, 'README.md'), 'utf8');
const readme = await readFile(join(cwd(), 'src', 'assets', 'readme', packageName, 'home-README.md'), 'utf8');
const mdxSource = await serialize(readme, {
mdxOptions: {
@@ -161,17 +164,6 @@ async function getData(slug: string[]) {
},
});
let data;
if (process.env.NEXT_PUBLIC_LOCAL_DEV) {
const res = await readFile(join(cwd(), '..', '..', 'packages', packageName, 'docs', 'docs.api.json'), 'utf8');
data = JSON.parse(res);
} else {
const res = await fetch(`https://docs.discordjs.dev/docs/${packageName}/${branchName}.api.json`, {
next: { revalidate: 3_600 },
});
data = await res.json();
}
const model = createApiModel(data);
const pkg = findPackage(model, packageName);
@@ -257,8 +249,8 @@ function member(props?: ApiItemJSON | undefined) {
}
}
export default async function Page({ params }: { params: { slug: string[] } }) {
const data = await getData(params.slug);
export default async function Page({ params }: { params: { package: string; slug: string[] } }) {
const data = await getData(params.package, params.slug);
// const name = useMemo(
// () => `discord.js${params.data?.member?.name ? ` | ${params.data.member.name}` : ''}`,
@@ -388,7 +380,3 @@ export default async function Page({ params }: { params: { slug: string[] } }) {
</MemberProvider>
);
}
export const config = {
unstable_includeFiles: [`../../packages/{brokers,builders,collection,core,proxy,rest,util,voice,ws}/README.md`],
};

View File

@@ -0,0 +1,27 @@
'use client';
// import { ThemeProvider } from 'next-themes';
import type { PropsWithChildren } from 'react';
import { CmdKProvider } from '~/contexts/cmdK';
import { NavProvider } from '~/contexts/nav';
export function Providers({ children }: PropsWithChildren) {
return (
<NavProvider>
<CmdKProvider>
{/* <ThemeProvider
attribute="class"
cookieName="theme"
defaultTheme="system"
disableTransitionOnChange
value={{
light: 'light',
dark: 'dark',
}}
> */}
{children}
{/* </ThemeProvider> */}
</CmdKProvider>
</NavProvider>
);
}

View File

@@ -0,0 +1,10 @@
import type { PropsWithChildren } from 'react';
import { PACKAGES } from '~/util/constants';
export async function generateStaticParams() {
return PACKAGES.map((packageName) => ({ package: packageName }));
}
export default function PackageLayout({ children }: PropsWithChildren) {
return children;
}

View File

@@ -5,12 +5,6 @@ import Link from 'next/link';
import { notFound } from 'next/navigation';
import { PACKAGES } from '~/util/constants';
export const dynamicParams = false;
export async function generateStaticParams() {
return PACKAGES.map((packageName) => ({ package: packageName }));
}
async function getData(pkg: string) {
if (!PACKAGES.includes(pkg)) {
notFound();

View File

@@ -1,5 +1,5 @@
import { ServerThemeProvider } from 'next-themes';
import type { PropsWithChildren } from 'react';
import { Providers } from './providers';
import '@unocss/reset/tailwind.css';
import '../styles/inter.css';
@@ -9,11 +9,19 @@ import '../styles/main.css';
export default function RootLayout({ children }: PropsWithChildren) {
return (
<html lang="en">
<head />
<body className="dark:bg-dark-800 bg-white">
<Providers>{children}</Providers>
</body>
</html>
<ServerThemeProvider
attribute="class"
defaultTheme="system"
disableTransitionOnChange
value={{
light: 'light',
dark: 'dark',
}}
>
<html lang="en">
<head />
<body className="dark:bg-dark-800 bg-white">{children}</body>
</html>
</ServerThemeProvider>
);
}

View File

@@ -23,6 +23,7 @@ export default function Page() {
<Link
className="bg-blurple focus:ring-width-2 flex h-11 transform-gpu cursor-pointer select-none appearance-none flex-row place-items-center rounded border-0 px-6 text-base font-semibold leading-none text-white no-underline outline-0 focus:ring focus:ring-white active:translate-y-px"
href="/docs"
prefetch={false}
>
Docs
</Link>

View File

@@ -1,20 +0,0 @@
'use client';
import { ThemeProvider } from 'next-themes';
import type { PropsWithChildren } from 'react';
export function Providers({ children }: PropsWithChildren) {
return (
<ThemeProvider
attribute="class"
defaultTheme="system"
disableTransitionOnChange
value={{
light: 'light',
dark: 'dark',
}}
>
{children}
</ThemeProvider>
);
}

View File

@@ -1,14 +1,14 @@
'use client';
import { FiCommand } from '@react-icons/all-files/fi/FiCommand';
import { VscColorMode } from '@react-icons/all-files/vsc/VscColorMode';
// import { VscColorMode } from '@react-icons/all-files/vsc/VscColorMode';
import { VscGithubInverted } from '@react-icons/all-files/vsc/VscGithubInverted';
import { VscMenu } from '@react-icons/all-files/vsc/VscMenu';
import { VscSearch } from '@react-icons/all-files/vsc/VscSearch';
import { Button } from 'ariakit/button';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { useTheme } from 'next-themes';
// import { useTheme } from 'next-themes';
import { Fragment, useEffect, useMemo, useState } from 'react';
import { useCmdK } from '~/contexts/cmdK';
import { useNav } from '~/contexts/nav';
@@ -17,9 +17,9 @@ export function Header() {
const pathname = usePathname();
// eslint-disable-next-line @typescript-eslint/unbound-method
const { setOpened } = useNav();
const { resolvedTheme, setTheme } = useTheme();
// const { resolvedTheme, setTheme } = useTheme();
const dialog = useCmdK();
const toggleTheme = () => setTheme(resolvedTheme === 'light' ? 'dark' : 'light');
// const toggleTheme = () => setTheme(resolvedTheme === 'light' ? 'dark' : 'light');
const [asPathWithoutQueryAndAnchor, setAsPathWithoutQueryAndAnchor] = useState('');
useEffect(() => {
@@ -111,13 +111,13 @@ export function Header() {
>
<VscGithubInverted size={24} />
</Button>
<Button
{/* <Button
aria-label="Toggle theme"
className="focus:ring-width-2 focus:ring-blurple flex h-6 w-6 transform-gpu cursor-pointer select-none appearance-none flex-row place-items-center rounded-full rounded border-0 bg-transparent p-0 text-sm font-semibold leading-none no-underline outline-0 focus:ring active:translate-y-px"
onClick={() => toggleTheme()}
>
<VscColorMode size={24} />
</Button>
</Button> */}
</div>
</div>
</div>

View File

@@ -7,6 +7,7 @@ export default async function middleware(request: NextRequest) {
}
if (PACKAGES.some((pkg) => request.nextUrl.pathname.includes(pkg))) {
// eslint-disable-next-line prefer-named-capture-group
const packageName = /\/docs\/packages\/([^/]+)\/.*/.exec(request.nextUrl.pathname)?.[1] ?? 'builders';
const res = await fetch(`https://docs.discordjs.dev/api/info?package=${packageName}`);
const data: string[] = await res.json();

View File

@@ -1,4 +1,15 @@
export const PACKAGES = ['brokers', 'builders', 'collection', 'core', 'proxy', 'rest', 'util', 'voice', 'ws'];
export const PACKAGES = [
'brokers',
'builders',
'collection',
'core',
'formatters',
'proxy',
'rest',
'util',
'voice',
'ws',
];
export const DESCRIPTION =
"discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.";

View File

@@ -49,7 +49,7 @@
"@commitlint/cli": "^17.3.0",
"@commitlint/config-angular": "^17.3.0",
"@favware/cliff-jumper": "^1.9.0",
"@favware/npm-deprecate": "^1.0.6",
"@favware/npm-deprecate": "^1.0.7",
"conventional-changelog-cli": "^2.2.2",
"husky": "^8.0.2",
"is-ci": "^3.0.1",
@@ -57,7 +57,7 @@
"tsup": "^6.5.0",
"turbo": "^1.6.3",
"typescript": "^4.9.3",
"unocss": "^0.46.5",
"unocss": "^0.47.5",
"vitest": "^0.25.3"
},
"resolutions": {

View File

@@ -43,7 +43,7 @@
"tslib": "^2.4.1"
},
"devDependencies": {
"@types/node": "16.18.3",
"@types/node": "16.18.4",
"@vitest/coverage-c8": "^0.25.3",
"cross-env": "^7.0.3",
"eslint": "^8.28.0",

View File

@@ -35,7 +35,7 @@
"@microsoft/tsdoc": "0.14.1"
},
"devDependencies": {
"@types/node": "16.18.3",
"@types/node": "16.18.4",
"cross-env": "^7.0.3",
"eslint": "^8.28.0",
"eslint-config-neon": "^0.1.40",

View File

@@ -63,7 +63,7 @@
"devDependencies": {
"@favware/cliff-jumper": "^1.9.0",
"@microsoft/api-extractor": "^7.33.6",
"@types/node": "16.18.3",
"@types/node": "16.18.4",
"@vitest/coverage-c8": "^0.25.3",
"cross-env": "^7.0.3",
"eslint": "^8.28.0",

View File

@@ -34,7 +34,7 @@ export interface BaseBrokerOptions {
/**
* Default broker options
*/
export const DefaultBrokerOptions: Required<BaseBrokerOptions> = {
export const DefaultBrokerOptions = {
name: randomBytes(20).toString('hex'),
maxChunk: 10,
blockTimeout: 5_000,
@@ -43,7 +43,7 @@ export const DefaultBrokerOptions: Required<BaseBrokerOptions> = {
return Buffer.from(encoded.buffer, encoded.byteOffset, encoded.byteLength);
},
decode: (data): unknown => decode(data),
};
} as const satisfies Required<BaseBrokerOptions>;
export type ToEventMap<
TRecord extends Record<string, any>,

View File

@@ -21,10 +21,10 @@ export interface RPCRedisBrokerOptions extends RedisBrokerOptions {
/**
* Default values used for the {@link RPCRedisBrokerOptions}
*/
export const DefaultRPCRedisBrokerOptions: Required<Omit<RPCRedisBrokerOptions, 'redisClient'>> = {
export const DefaultRPCRedisBrokerOptions = {
...DefaultBrokerOptions,
timeout: 5_000,
};
} as const satisfies Required<Omit<RPCRedisBrokerOptions, 'redisClient'>>;
/**
* RPC broker powered by Redis

View File

@@ -54,6 +54,7 @@
},
"homepage": "https://discord.js.org",
"dependencies": {
"@discordjs/formatters": "workspace:^",
"@discordjs/util": "workspace:^",
"@sapphire/shapeshift": "^3.7.1",
"discord-api-types": "^0.37.20",
@@ -64,7 +65,7 @@
"devDependencies": {
"@favware/cliff-jumper": "^1.9.0",
"@microsoft/api-extractor": "^7.33.6",
"@types/node": "16.18.3",
"@types/node": "16.18.4",
"@vitest/coverage-c8": "^0.25.3",
"cross-env": "^7.0.3",
"esbuild-plugin-version-injector": "^1.0.2",

View File

@@ -1,6 +1,7 @@
export * as EmbedAssertions from './messages/embed/Assertions.js';
export * from './messages/embed/Embed.js';
export * from './messages/formatters.js';
// TODO: Consider removing this dep in the next major version
export * from '@discordjs/formatters';
export * as ComponentAssertions from './components/Assertions.js';
export * from './components/ActionRow.js';

View File

@@ -94,3 +94,7 @@ const memberPermissionPredicate = s.union(
export function validateDefaultMemberPermissions(permissions: unknown) {
return memberPermissionPredicate.parse(permissions);
}
export function validateNSFW(value: unknown): asserts value is boolean {
booleanPredicate.parse(value);
}

View File

@@ -13,6 +13,7 @@ import {
validateDMPermission,
validateMaxOptionsLength,
validateRequiredParameters,
validateNSFW,
} from './Assertions.js';
import { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands.js';
import { SharedNameAndDescription } from './mixins/NameAndDescription.js';
@@ -64,6 +65,11 @@ export class SlashCommandBuilder {
*/
public readonly dm_permission: boolean | undefined = undefined;
/**
* Whether this command is NSFW
*/
public readonly nsfw: boolean | undefined = undefined;
/**
* Returns the final data that should be sent to Discord.
*
@@ -134,6 +140,18 @@ export class SlashCommandBuilder {
return this;
}
/**
* Sets whether this command is NSFW
*
* @param nsfw - Whether this command is NSFW
*/
public setNSFW(nsfw = true) {
// Assert the value matches the conditions
validateNSFW(nsfw);
Reflect.set(this, 'nsfw', nsfw);
return this;
}
/**
* Adds a new subcommand group to this command
*

View File

@@ -2,6 +2,16 @@
All notable changes to this project will be documented in this file.
# [@discordjs/collection@1.3.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.2.0...@discordjs/collection@1.3.0) - (2022-11-28)
## Bug Fixes
- Pin @types/node version ([9d8179c](https://github.com/discordjs/discord.js/commit/9d8179c6a78e1c7f9976f852804055964d5385d4))
## Features
- Add `Collection#subtract()` (#8393) ([291f36c](https://github.com/discordjs/discord.js/commit/291f36cd736b5dea058145a1335bf7c78ec1d81d))
# [@discordjs/collection@1.2.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.1.0...@discordjs/collection@1.2.0) - (2022-10-08)
## Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@discordjs/collection",
"version": "1.2.0",
"version": "1.3.0",
"description": "Utility data structure used in discord.js",
"scripts": {
"test": "vitest run",
@@ -52,7 +52,7 @@
"devDependencies": {
"@favware/cliff-jumper": "^1.9.0",
"@microsoft/api-extractor": "^7.33.6",
"@types/node": "16.18.3",
"@types/node": "16.18.4",
"@vitest/coverage-c8": "^0.25.3",
"cross-env": "^7.0.3",
"esbuild-plugin-version-injector": "^1.0.2",

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "@discordjs/core",
"version": "0.1.0",
"version": "0.2.0",
"description": "A thinly abstracted wrapper around the rest API, and gateway.",
"scripts": {
"test": "vitest run",
@@ -48,12 +48,12 @@
"@discordjs/rest": "workspace:^",
"@discordjs/ws": "workspace:^",
"@vladfrangu/async_event_emitter": "^2.1.2",
"discord-api-types": "^0.37.20"
"discord-api-types": "^0.37.23"
},
"devDependencies": {
"@favware/cliff-jumper": "^1.9.0",
"@microsoft/api-extractor": "^7.33.6",
"@types/node": "16.18.3",
"@types/node": "16.18.4",
"@vitest/coverage-c8": "^0.25.3",
"cross-env": "^7.0.3",
"eslint": "^8.28.0",

View File

@@ -24,6 +24,7 @@ export class ApplicationCommandsAPI {
/**
* Fetches all global commands for a application
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands}
* @param applicationId - The application id to fetch commands for
* @param options - The options to use when fetching commands
*/
@@ -36,6 +37,7 @@ export class ApplicationCommandsAPI {
/**
* Creates a new global command
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#create-global-application-command}
* @param applicationId - The application id to create the command for
* @param data - The data to use when creating the command
*/
@@ -48,6 +50,7 @@ export class ApplicationCommandsAPI {
/**
* Fetches a global command
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#get-global-application-command}
* @param applicationId - The application id to fetch the command from
* @param commandId - The command id to fetch
*/
@@ -60,6 +63,7 @@ export class ApplicationCommandsAPI {
/**
* Edits a global command
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command}
* @param applicationId - The application id of the command
* @param commandId - The id of the command to edit
* @param data - The data to use when editing the command
@@ -77,6 +81,7 @@ export class ApplicationCommandsAPI {
/**
* Deletes a global command
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#delete-global-application-command}
* @param applicationId - The application id of the command
* @param commandId - The id of the command to delete
*/
@@ -87,6 +92,7 @@ export class ApplicationCommandsAPI {
/**
* Overwrites global commands
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands}
* @param applicationId - The application id to overwrite commands for
* @param data - The data to use when overwriting commands
*/
@@ -99,6 +105,7 @@ export class ApplicationCommandsAPI {
/**
* Fetches all commands for a guild
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands}
* @param applicationId - The application id to fetch commands for
* @param guildId - The guild id to fetch commands for
* @param data - The data to use when fetching commands
@@ -116,6 +123,7 @@ export class ApplicationCommandsAPI {
/**
* Creates a new command for a guild
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command}
* @param applicationId - The application id to create the command for
* @param guildId - The guild id to create the command for
* @param data - The data to use when creating the command
@@ -133,6 +141,7 @@ export class ApplicationCommandsAPI {
/**
* Fetches a guild command
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command}
* @param applicationId - The application id to fetch the command from
* @param guildId - The guild id to fetch the command from
* @param commandId - The command id to fetch
@@ -146,6 +155,7 @@ export class ApplicationCommandsAPI {
/**
* Edits a guild command
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command}
* @param applicationId - The application id of the command
* @param guildId - The guild id of the command
* @param commandId - The command id to edit
@@ -165,6 +175,7 @@ export class ApplicationCommandsAPI {
/**
* Deletes a guild command
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#delete-guild-application-command}
* @param applicationId - The application id of the command
* @param guildId - The guild id of the command
* @param commandId - The id of the command to delete
@@ -176,6 +187,7 @@ export class ApplicationCommandsAPI {
/**
* Bulk overwrites guild commands
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands}
* @param applicationId - The application id to overwrite commands for
* @param guildId - The guild id to overwrite commands for
* @param data - The data to use when overwriting commands
@@ -193,6 +205,7 @@ export class ApplicationCommandsAPI {
/**
* Fetches the permissions for a guild command
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions}
* @param applicationId - The application id to get the permissions for
* @param guildId - The guild id of the command
* @param commandId - The command id to get the permissions for
@@ -206,6 +219,7 @@ export class ApplicationCommandsAPI {
/**
* Fetches all permissions for all commands in a guild
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions}
* @param applicationId - The application id to get the permissions for
* @param guildId - The guild id to get the permissions for
*/
@@ -218,6 +232,7 @@ export class ApplicationCommandsAPI {
/**
* Edits the permissions for a guild command
*
* @see {@link https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions}
* @param userToken - The token of the user to edit permissions on behalf of
* @param applicationId - The application id to edit the permissions for
* @param guildId - The guild id to edit the permissions for

View File

@@ -30,6 +30,7 @@ export class ChannelsAPI {
/**
* Sends a message in a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#create-message}
* @param channelId - The id of the channel to send the message in
* @param data - The data to use when sending the message
*/
@@ -46,6 +47,7 @@ export class ChannelsAPI {
/**
* Edits a message
*
* @see {@link https://discord.com/developers/docs/resources/channel#edit-message}
* @param channelId - The id of the channel the message is in
* @param messageId - The id of the message to edit
* @param data - The data to use when editing the message
@@ -64,6 +66,7 @@ export class ChannelsAPI {
/**
* Fetches the reactions for a message
*
* @see {@link https://discord.com/developers/docs/resources/channel#get-reactions}
* @param channelId - The id of the channel the message is in
* @param messageId - The id of the message to get the reactions for
* @param emoji - The emoji to get the reactions for
@@ -83,6 +86,7 @@ export class ChannelsAPI {
/**
* Deletes a reaction for the current user
*
* @see {@link https://discord.com/developers/docs/resources/channel#delete-own-reaction}
* @param channelId - The id of the channel the message is in
* @param messageId - The id of the message to delete the reaction for
* @param emoji - The emoji to delete the reaction for
@@ -94,6 +98,7 @@ export class ChannelsAPI {
/**
* Deletes a reaction for a user
*
* @see {@link https://discord.com/developers/docs/resources/channel#delete-user-reaction}
* @param channelId - The id of the channel the message is in
* @param messageId - The id of the message to delete the reaction for
* @param emoji - The emoji to delete the reaction for
@@ -106,6 +111,7 @@ export class ChannelsAPI {
/**
* Deletes all reactions for a message
*
* @see {@link https://discord.com/developers/docs/resources/channel#delete-all-reactions}
* @param channelId - The id of the channel the message is in
* @param messageId - The id of the message to delete the reactions for
*/
@@ -116,6 +122,7 @@ export class ChannelsAPI {
/**
* Deletes all reactions of an emoji for a message
*
* @see {@link https://discord.com/developers/docs/resources/channel#delete-all-reactions-for-emoji}
* @param channelId - The id of the channel the message is in
* @param messageId - The id of the message to delete the reactions for
* @param emoji - The emoji to delete the reactions for
@@ -127,6 +134,7 @@ export class ChannelsAPI {
/**
* Adds a reaction to a message
*
* @see {@link https://discord.com/developers/docs/resources/channel#create-reaction}
* @param channelId - The id of the channel the message is in
* @param messageId - The id of the message to add the reaction to
* @param emoji - The emoji to add the reaction with
@@ -138,6 +146,7 @@ export class ChannelsAPI {
/**
* Fetches a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#get-channel}
* @param channelId - The id of the channel
*/
public async get(channelId: Snowflake) {
@@ -147,6 +156,7 @@ export class ChannelsAPI {
/**
* Edits a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#modify-channel}
* @param channelId - The id of the channel to edit
* @param data - The new channel data
*/
@@ -157,6 +167,7 @@ export class ChannelsAPI {
/**
* Deletes a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#deleteclose-channel}
* @param channelId - The id of the channel to delete
*/
public async delete(channelId: Snowflake) {
@@ -166,6 +177,7 @@ export class ChannelsAPI {
/**
* Fetches the messages of a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#get-channel-messages}
* @param channelId - The id of the channel to fetch messages from
* @param options - The options to use when fetching messages
*/
@@ -178,6 +190,7 @@ export class ChannelsAPI {
/**
* Shows a typing indicator in a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#trigger-typing-indicator}
* @param channelId - The id of the channel to show the typing indicator in
*/
public async showTyping(channelId: Snowflake) {
@@ -187,6 +200,7 @@ export class ChannelsAPI {
/**
* Fetches the pinned messages of a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#get-pinned-messages}
* @param channelId - The id of the channel to fetch pinned messages from
*/
public async getPins(channelId: Snowflake) {
@@ -196,6 +210,7 @@ export class ChannelsAPI {
/**
* Pins a message in a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#pin-message}
* @param channelId - The id of the channel to pin the message in
* @param messageId - The id of the message to pin
* @param reason - The reason for pinning the message
@@ -207,6 +222,7 @@ export class ChannelsAPI {
/**
* Deletes a message
*
* @see {@link https://discord.com/developers/docs/resources/channel#delete-message}
* @param channelId - The id of the channel the message is in
* @param messageId - The id of the message to delete
* @param reason - The reason for deleting the message
@@ -218,6 +234,7 @@ export class ChannelsAPI {
/**
* Bulk deletes messages
*
* @see {@link https://discord.com/developers/docs/resources/channel#bulk-delete-messages}
* @param channelId - The id of the channel the messages are in
* @param messageIds - The ids of the messages to delete
*/
@@ -228,6 +245,7 @@ export class ChannelsAPI {
/**
* Fetches a message
*
* @see {@link https://discord.com/developers/docs/resources/channel#get-channel-message}
* @param channelId - The id of the channel the message is in
* @param messageId - The id of the message to fetch
*/
@@ -238,6 +256,7 @@ export class ChannelsAPI {
/**
* Crossposts a message
*
* @see {@link https://discord.com/developers/docs/resources/channel#crosspost-message}
* @param channelId - The id of the channel the message is in
* @param messageId - The id of the message to crosspost
*/
@@ -250,6 +269,7 @@ export class ChannelsAPI {
/**
* Unpins a message in a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#unpin-message}
* @param channelId - The id of the channel to unpin the message in
* @param messageId - The id of the message to unpin
* @param reason - The reason for unpinning the message
@@ -261,6 +281,7 @@ export class ChannelsAPI {
/**
* Follows an announcement channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#follow-announcement-channel}
* @param channelId - The id of the announcement channel to follow
* @param webhookChannelId - The id of the webhook channel to follow the announcements in
*/
@@ -273,6 +294,7 @@ export class ChannelsAPI {
/**
* Creates a new invite for a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#create-channel-invite}
* @param channelId - The id of the channel to create an invite for
* @param data - The data to use when creating the invite
*/
@@ -286,6 +308,7 @@ export class ChannelsAPI {
/**
* Fetches the invites of a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#get-channel-invites}
* @param channelId - The id of the channel to fetch invites from
*/
public async getInvites(channelId: Snowflake) {
@@ -295,6 +318,8 @@ export class ChannelsAPI {
/**
* Fetches the archived threads of a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#list-public-archived-threads}
* @see {@link https://discord.com/developers/docs/resources/channel#list-private-archived-threads}
* @param channelId - The id of the channel to fetch archived threads from
* @param archivedStatus - The archived status of the threads to fetch
* @param options - The options to use when fetching archived threads
@@ -312,6 +337,7 @@ export class ChannelsAPI {
/**
* Fetches the private joined archived threads of a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#list-joined-private-archived-threads}
* @param channelId - The id of the channel to fetch joined archived threads from
* @param options - The options to use when fetching joined archived threads
*/

View File

@@ -91,6 +91,7 @@ export class GuildsAPI {
/**
* Fetches a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild}
* @param guildId - The id of the guild
*/
public async get(guildId: string) {
@@ -100,6 +101,7 @@ export class GuildsAPI {
/**
* Fetches a guild preview
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-preview}
* @param guildId - The id of the guild to fetch the preview from
*/
public async getPreview(guildId: Snowflake) {
@@ -109,6 +111,7 @@ export class GuildsAPI {
/**
* Creates a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#create-guild}
* @param data - The guild to create
*/
public async create(data: RESTPostAPIGuildsJSONBody) {
@@ -118,6 +121,7 @@ export class GuildsAPI {
/**
* Edits a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild}
* @param guildId - The id of the guild to edit
* @param data - The new guild data
* @param reason - The reason for editing this guild
@@ -129,6 +133,7 @@ export class GuildsAPI {
/**
* Deletes a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#delete-guild}
* @param guildId - The id of the guild to delete
* @param reason - The reason for deleting this guild
*/
@@ -139,6 +144,7 @@ export class GuildsAPI {
/**
* Fetches all the members of a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#list-guild-members}
* @param guildId - The id of the guild
* @param options - The options to use when fetching the guild members
*/
@@ -151,6 +157,7 @@ export class GuildsAPI {
/**
* Fetches a guild's channels
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-channels}
* @param guildId - The id of the guild to fetch the channels from
*/
public async getChannels(guildId: Snowflake) {
@@ -160,6 +167,7 @@ export class GuildsAPI {
/**
* Creates a guild channel
*
* @see {@link https://discord.com/developers/docs/resources/guild#create-guild-channel}
* @param guildId - The id of the guild to create the channel in
* @param data - The data to create the new channel
* @param reason - The reason for creating this channel
@@ -174,6 +182,7 @@ export class GuildsAPI {
/**
* Edits a guild channel's positions
*
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions}
* @param guildId - The id of the guild to edit the channel positions from
* @param data - The data to edit the channel positions with
* @param reason - The reason for editing the channel positions
@@ -189,6 +198,7 @@ export class GuildsAPI {
/**
* Fetches the active threads in a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#list-active-guild-threads}
* @param guildId - The id of the guild to fetch the active threads from
*/
public async getActiveThreads(guildId: Snowflake) {
@@ -198,6 +208,7 @@ export class GuildsAPI {
/**
* Fetches a guild member ban
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-bans}
* @param guildId - The id of the guild to fetch the ban from
*/
public async getMemberBans(guildId: Snowflake) {
@@ -207,6 +218,7 @@ export class GuildsAPI {
/**
* Bans a user from a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#create-guild-ban}
* @param guildId - The id of the guild to ban the member in
* @param userId - The id of the user to ban
* @param options - Options for banning the user
@@ -224,6 +236,7 @@ export class GuildsAPI {
/**
* Unbans a user from a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#remove-guild-ban}
* @param guildId - The id of the guild to unban the member in
* @param userId - The id of the user to unban
* @param reason - The reason for unbanning the user
@@ -235,6 +248,7 @@ export class GuildsAPI {
/**
* Gets all the roles in a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-roles}
* @param guildId - The id of the guild to fetch the roles from
*/
public async getRoles(guildId: Snowflake) {
@@ -244,6 +258,7 @@ export class GuildsAPI {
/**
* Creates a guild role
*
* @see {@link https://discord.com/developers/docs/resources/guild#create-guild-role}
* @param guildId - The id of the guild to create the role in
* @param data - The data to create the role with
* @param reason - The reason for creating the role
@@ -255,6 +270,7 @@ export class GuildsAPI {
/**
* Sets role positions in a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-role-positions}
* @param guildId - The id of the guild to set role positions for
* @param data - The data for setting a role position
* @param reason - The reason for setting the role position
@@ -269,6 +285,7 @@ export class GuildsAPI {
/**
* Edits a guild role
*
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-role}
* @param guildId - The id of the guild to edit the role in
* @param roleId - The id of the role to edit
* @param data - data for editing the role
@@ -284,6 +301,7 @@ export class GuildsAPI {
/**
* Deletes a guild role
*
* @see {@link https://discord.com/developers/docs/resources/guild#delete-guild-role}
* @param guildId - The id of the guild to delete the role in
* @param roleId - The id of the role to delete
* @param reason - The reason for deleting the role
@@ -295,6 +313,7 @@ export class GuildsAPI {
/**
* Edits the multi-factor-authentication (MFA) level of a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-mfa-level}
* @param guildId - The id of the guild to edit the MFA level for
* @param level - The new MFA level
* @param reason - The reason for editing the MFA level
@@ -309,6 +328,7 @@ export class GuildsAPI {
/**
* Fetch the number of members that can be pruned from a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-prune-count}
* @param guildId - The id of the guild to fetch the number of pruned members from
* @param options - The options for fetching the number of pruned members
*/
@@ -321,6 +341,7 @@ export class GuildsAPI {
/**
* Prunes members in a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#begin-guild-prune}
* @param guildId - The id of the guild to prune members in
* @param options - The options for pruning members
* @param reason - The reason for pruning members
@@ -335,6 +356,7 @@ export class GuildsAPI {
/**
* Fetches voice regions for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-voice-regions}
* @param guildId - The id of the guild to fetch the voice regions from
*/
public async getVoiceRegions(guildId: Snowflake) {
@@ -344,6 +366,7 @@ export class GuildsAPI {
/**
* Fetches the invites for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-invites}
* @param guildId - The id of the guild to fetch the invites from
*/
public async getInvites(guildId: Snowflake) {
@@ -353,6 +376,7 @@ export class GuildsAPI {
/**
* Fetches the integrations for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-integrations}
* @param guildId - The id of the guild to fetch the integrations from
*/
public async getIntegrations(guildId: Snowflake) {
@@ -362,6 +386,7 @@ export class GuildsAPI {
/**
* Deletes an integration from a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#delete-guild-integration}
* @param guildId - The id of the guild to delete the integration from
* @param integrationId - The id of the integration to delete
* @param reason - The reason for deleting the integration
@@ -373,6 +398,7 @@ export class GuildsAPI {
/**
* Fetches the widget settings for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-widget-settings}
* @param guildId - The id of the guild to fetch the widget settings from
*/
public async getWidgetSettings(guildId: Snowflake) {
@@ -382,6 +408,7 @@ export class GuildsAPI {
/**
* Edits the widget settings for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-widget}
* @param guildId - The id of the guild to edit the widget settings from
* @param data - The new widget settings data
* @param reason - The reason for editing the widget settings
@@ -396,6 +423,7 @@ export class GuildsAPI {
/**
* Fetches the widget for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-widget}
* @param guildId - The id of the guild to fetch the widget from
*/
public async getWidget(guildId: Snowflake) {
@@ -405,6 +433,7 @@ export class GuildsAPI {
/**
* Fetches the vanity url for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-vanity-url}
* @param guildId - The id of the guild to fetch the vanity url from
*/
public async getVanityURL(guildId: Snowflake) {
@@ -414,6 +443,7 @@ export class GuildsAPI {
/**
* Fetches the widget image for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-widget-image}
* @param guildId - The id of the guild to fetch the widget image from
* @param style - The style of the widget image
*/
@@ -426,6 +456,7 @@ export class GuildsAPI {
/**
* Fetches the welcome screen for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen}
* @param guildId - The id of the guild to fetch the welcome screen from
*/
public async getWelcomeScreen(guildId: Snowflake) {
@@ -435,6 +466,7 @@ export class GuildsAPI {
/**
* Edits the welcome screen for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen}
* @param guildId - The id of the guild to edit the welcome screen for
* @param data - The new welcome screen data
* @param reason - The reason for editing the welcome screen
@@ -449,6 +481,7 @@ export class GuildsAPI {
/**
* Edits a user's voice state in a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#modify-user-voice-state}
* @param guildId - The id of the guild to edit the current user's voice state in
* @param userId - The id of the user to edit the voice state for
* @param data - The data for editing the voice state
@@ -466,6 +499,7 @@ export class GuildsAPI {
/**
* Fetches all emojis for a guild
*
* @see {@link https://discord.com/developers/docs/resources/emoji#list-guild-emojis}
* @param guildId - The id of the guild to fetch the emojis from
*/
public async getEmojis(guildId: Snowflake) {
@@ -475,6 +509,7 @@ export class GuildsAPI {
/**
* Fetches an emoji for a guild
*
* @see {@link https://discord.com/developers/docs/resources/emoji#get-guild-emoji}
* @param guildId - The id of the guild to fetch the emoji from
* @param emojiId - The id of the emoji to fetch
*/
@@ -485,6 +520,7 @@ export class GuildsAPI {
/**
* Creates a new emoji for a guild
*
* @see {@link https://discord.com/developers/docs/resources/emoji#create-guild-emoji}
* @param guildId - The id of the guild to create the emoji from
* @param data - The data for creating the emoji
* @param reason - The reason for creating the emoji
@@ -499,6 +535,7 @@ export class GuildsAPI {
/**
* Edits an emoji for a guild
*
* @see {@link https://discord.com/developers/docs/resources/emoji#modify-guild-emoji}
* @param guildId - The id of the guild to edit the emoji from
* @param emojiId - The id of the emoji to edit
* @param data - The data for editing the emoji
@@ -519,6 +556,7 @@ export class GuildsAPI {
/**
* Deletes an emoji for a guild
*
* @see {@link https://discord.com/developers/docs/resources/emoji#delete-guild-emoji}
* @param guildId - The id of the guild to delete the emoji from
* @param emojiId - The id of the emoji to delete
* @param reason - The reason for deleting the emoji
@@ -530,6 +568,7 @@ export class GuildsAPI {
/**
* Fetches all scheduled events for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#list-scheduled-events-for-guild}
* @param guildId - The id of the guild to fetch the scheduled events from
* @param options - The options for fetching the scheduled events
*/
@@ -542,6 +581,7 @@ export class GuildsAPI {
/**
* Creates a new scheduled event for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event}
* @param guildId - The id of the guild to create the scheduled event from
* @param data - The data to create the event with
* @param reason - The reason for creating the scheduled event
@@ -556,6 +596,7 @@ export class GuildsAPI {
/**
* Fetches a scheduled event for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event}
* @param guildId - The id of the guild to fetch the scheduled event from
* @param eventId - The id of the scheduled event to fetch
* @param options - The options for fetching the scheduled event
@@ -573,6 +614,7 @@ export class GuildsAPI {
/**
* Edits a scheduled event for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event}
* @param guildId - The id of the guild to edit the scheduled event from
* @param eventId - The id of the scheduled event to edit
* @param data - The new event data
@@ -593,6 +635,7 @@ export class GuildsAPI {
/**
* Deletes a scheduled event for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#delete-guild-scheduled-event}
* @param guildId - The id of the guild to delete the scheduled event from
* @param eventId - The id of the scheduled event to delete
* @param reason - The reason for deleting the scheduled event
@@ -604,6 +647,7 @@ export class GuildsAPI {
/**
* Gets all users that are interested in a scheduled event
*
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users}
* @param guildId - The id of the guild to fetch the scheduled event users from
* @param eventId - The id of the scheduled event to fetch the users for
* @param options - The options for fetching the scheduled event users
@@ -621,6 +665,7 @@ export class GuildsAPI {
/**
* Fetches all the templates for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild-template#get-guild-templates}
* @param guildId - The id of the guild to fetch the templates from
*/
public async getTemplates(guildId: Snowflake) {
@@ -630,6 +675,7 @@ export class GuildsAPI {
/**
* Syncs a template for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild-template#sync-guild-template}
* @param guildId - The id of the guild to sync the template from
* @param templateCode - The code of the template to sync
*/
@@ -640,6 +686,7 @@ export class GuildsAPI {
/**
* Edits a template for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild-template#modify-guild-template}
* @param guildId - The id of the guild to edit the template from
* @param templateCode - The code of the template to edit
* @param data - The data for editing the template
@@ -653,6 +700,7 @@ export class GuildsAPI {
/**
* Deletes a template for a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild-template#delete-guild-template}
* @param guildId - The id of the guild to delete the template from
* @param templateCode - The code of the template to delete
*/
@@ -663,6 +711,7 @@ export class GuildsAPI {
/**
* Fetches all the stickers for a guild
*
* @see {@link https://discord.com/developers/docs/resources/sticker#list-guild-stickers}
* @param guildId - The id of the guild to fetch the stickers from
*/
public async getStickers(guildId: Snowflake) {
@@ -672,6 +721,7 @@ export class GuildsAPI {
/**
* Fetches a sticker for a guild
*
* @see {@link https://discord.com/developers/docs/resources/sticker#get-guild-sticker}
* @param guildId - The id of the guild to fetch the sticker from
* @param stickerId - The id of the sticker to fetch
*/
@@ -682,6 +732,7 @@ export class GuildsAPI {
/**
* Creates a sticker for a guild
*
* @see {@link https://discord.com/developers/docs/resources/sticker#create-guild-sticker}
* @param guildId - The id of the guild to create the sticker for
* @param data - The data for creating the sticker
* @param reason - The reason for creating the sticker
@@ -704,6 +755,7 @@ export class GuildsAPI {
/**
* Edits a sticker for a guild
*
* @see {@link https://discord.com/developers/docs/resources/sticker#modify-guild-sticker}
* @param guildId - The id of the guild to edit the sticker from
* @param stickerId - The id of the sticker to edit
* @param data - The data for editing the sticker
@@ -724,6 +776,7 @@ export class GuildsAPI {
/**
* Deletes a sticker for a guild
*
* @see {@link https://discord.com/developers/docs/resources/sticker#delete-guild-sticker}
* @param guildId - The id of the guild to delete the sticker from
* @param stickerId - The id of the sticker to delete
* @param reason - The reason for deleting the sticker
@@ -735,6 +788,7 @@ export class GuildsAPI {
/**
* Fetches the audit logs for a guild
*
* @see {@link https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log}
* @param guildId - The id of the guild to fetch the audit logs from
* @param options - The options for fetching the audit logs
*/
@@ -747,6 +801,7 @@ export class GuildsAPI {
/**
* Fetches all auto moderation rules for a guild
*
* @see {@link https://discord.com/developers/docs/resources/auto-moderation#list-auto-moderation-rules-for-guild}
* @param guildId - The id of the guild to fetch the auto moderation rules from
*/
public async getAutoModerationRules(guildId: Snowflake) {
@@ -756,6 +811,7 @@ export class GuildsAPI {
/**
* Fetches an auto moderation rule for a guild
*
* @see {@link https://discord.com/developers/docs/resources/auto-moderation#get-auto-moderation-rule}
* @param guildId - The id of the guild to fetch the auto moderation rule from
* @param ruleId - The id of the auto moderation rule to fetch
*/
@@ -768,6 +824,7 @@ export class GuildsAPI {
/**
* Creates a new auto moderation rule for a guild
*
* @see {@link https://discord.com/developers/docs/resources/auto-moderation#create-auto-moderation-rule}
* @param guildId - The id of the guild to create the auto moderation rule from
* @param data - The data for creating the auto moderation rule
*/
@@ -785,6 +842,7 @@ export class GuildsAPI {
/**
* Edits an auto moderation rule for a guild
*
* @see {@link https://discord.com/developers/docs/resources/auto-moderation#modify-auto-moderation-rule}
* @param guildId - The id of the guild to edit the auto moderation rule from
* @param ruleId - The id of the auto moderation rule to edit
* @param data - The data for editing the auto moderation rule
@@ -805,6 +863,7 @@ export class GuildsAPI {
/**
* Deletes an auto moderation rule for a guild
*
* @see {@link https://discord.com/developers/docs/resources/auto-moderation#delete-auto-moderation-rule}
* @param guildId - The id of the guild to delete the auto moderation rule from
* @param ruleId - The id of the auto moderation rule to delete
* @param reason - The reason for deleting the auto moderation rule
@@ -816,6 +875,7 @@ export class GuildsAPI {
/**
* Fetches a guild member
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-member}
* @param guildId - The id of the guild
* @param userId - The id of the user
*/
@@ -826,6 +886,7 @@ export class GuildsAPI {
/**
* Searches for guild members
*
* @see {@link https://discord.com/developers/docs/resources/guild#search-guild-members}
* @param guildId - The id of the guild to search in
* @param query - The query to search for
* @param limit - The maximum number of members to return
@@ -839,6 +900,7 @@ export class GuildsAPI {
/**
* Edits a guild member
*
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-member}
* @param guildId - The id of the guild
* @param userId - The id of the user
* @param data - The data to use when editing the guild member
@@ -859,6 +921,7 @@ export class GuildsAPI {
/**
* Adds a role to a guild member
*
* @see {@link https://discord.com/developers/docs/resources/guild#add-guild-member-role}
* @param guildId - The id of the guild
* @param userId - The id of the user
* @param roleId - The id of the role
@@ -871,6 +934,7 @@ export class GuildsAPI {
/**
* Removes a role from a guild member
*
* @see {@link https://discord.com/developers/docs/resources/guild#remove-guild-member-role}
* @param guildId - The id of the guild
* @param userId - The id of the user
* @param roleId - The id of the role
@@ -883,6 +947,7 @@ export class GuildsAPI {
/**
* Fetches a guild template
*
* @see {@link https://discord.com/developers/docs/resources/guild-template#get-guild-template}
* @param templateCode - The code of the template
*/
public async getTemplate(templateCode: string) {
@@ -892,6 +957,7 @@ export class GuildsAPI {
/**
* Creates a new template
*
* @see {@link https://discord.com/developers/docs/resources/guild-template#create-guild-template}
* @param templateCode - The code of the template
* @param data - The data to use when creating the template
*/

View File

@@ -16,6 +16,7 @@ export class InteractionsAPI {
/**
* Replies to an interaction
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
* @param interactionId - The id of the interaction
* @param interactionToken - The token of the interaction
* @param data - The data to use when replying
@@ -37,6 +38,7 @@ export class InteractionsAPI {
/**
* Defers the reply to an interaction
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
* @param interactionId - The id of the interaction
* @param interactionToken - The token of the interaction
*/
@@ -51,6 +53,7 @@ export class InteractionsAPI {
/**
* Defers an update from a message component interaction
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
* @param interactionId - The id of the interaction
* @param interactionToken - The token of the interaction
*/
@@ -65,6 +68,7 @@ export class InteractionsAPI {
/**
* Reply to a deferred interaction
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message}
* @param applicationId - The application id of the interaction
* @param interactionToken - The token of the interaction
* @param data - The data to use when replying
@@ -80,6 +84,8 @@ export class InteractionsAPI {
/**
* Edits the initial reply to an interaction
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response}
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message}
* @param applicationId - The application id of the interaction
* @param interactionToken - The token of the interaction
* @param data - The data to use when editing the reply
@@ -89,7 +95,7 @@ export class InteractionsAPI {
applicationId: Snowflake,
interactionToken: string,
data: APIInteractionResponseCallbackData & { files?: RawFile[] },
messageId?: string,
messageId?: Snowflake | '@original',
) {
return this.webhooks.editMessage(applicationId, interactionToken, messageId ?? '@original', data);
}
@@ -97,6 +103,7 @@ export class InteractionsAPI {
/**
* Fetches the initial reply to an interaction
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response}
* @param applicationId - The application id of the interaction
* @param interactionToken - The token of the interaction
*/
@@ -111,16 +118,20 @@ export class InteractionsAPI {
/**
* Deletes the initial reply to an interaction
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#delete-original-interaction-response}
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-message}
* @param applicationId - The application id of the interaction
* @param interactionToken - The token of the interaction
* @param messageId - The id of the message to delete. If omitted, the original reply will be deleted
*/
public async deleteReply(applicationId: Snowflake, interactionToken: string) {
await this.webhooks.deleteMessage(applicationId, interactionToken, '@original');
public async deleteReply(applicationId: Snowflake, interactionToken: string, messageId?: Snowflake | '@original') {
await this.webhooks.deleteMessage(applicationId, interactionToken, messageId ?? '@original');
}
/**
* Updates the the message the component interaction was triggered on
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
* @param interactionId - The id of the interaction
* @param interactionToken - The token of the interaction
* @param data - The data to use when updating the interaction
@@ -142,6 +153,7 @@ export class InteractionsAPI {
/**
* Sends an autocomplete response to an interaction
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
* @param interactionId - The id of the interaction
* @param interactionToken - The token of the interaction
* @param data - Data for the autocomplete response
@@ -162,6 +174,7 @@ export class InteractionsAPI {
/**
* Sends a modal response to an interaction
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
* @param interactionId - The id of the interaction
* @param interactionToken - The token of the interaction
* @param data - The modal to send

View File

@@ -7,6 +7,7 @@ export class InvitesAPI {
/**
* Fetches an invite
*
* @see {@link https://discord.com/developers/docs/resources/invite#get-invite}
* @param code - The invite code
*/
public async get(code: string, options: RESTGetAPIInviteQuery = {}) {
@@ -18,6 +19,7 @@ export class InvitesAPI {
/**
* Deletes an invite
*
* @see {@link https://discord.com/developers/docs/resources/invite#delete-invite}
* @param code - The invite code
* @param reason - The reason for deleting the invite
*/

View File

@@ -0,0 +1,40 @@
import type { REST } from '@discordjs/rest';
import {
Routes,
type RESTGetAPIApplicationRoleConnectionMetadataResult,
type RESTPutAPIApplicationRoleConnectionMetadataResult,
type RESTPutAPIApplicationCommandPermissionsJSONBody,
type Snowflake,
} from 'discord-api-types/v10';
export class RoleConnectionsAPI {
public constructor(private readonly rest: REST) {}
/**
* Gets the role connection metadata records for the application
*
* @see {@link https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records}
* @param applicationId - The id of the application to get role connection metadata records for
*/
public async getMetadataRecords(applicationId: Snowflake) {
return this.rest.get(
Routes.applicationRoleConnectionMetadata(applicationId),
) as Promise<RESTGetAPIApplicationRoleConnectionMetadataResult>;
}
/**
* Updates the role connection metadata records for the application
*
* @see {@link https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records}
* @param applicationId - The id of the application to update role connection metadata records for
* @param options - The new role connection metadata records
*/
public async updateMetadataRecords(
applicationId: Snowflake,
options: RESTPutAPIApplicationCommandPermissionsJSONBody,
) {
return this.rest.put(Routes.applicationRoleConnectionMetadata(applicationId), {
body: options,
}) as Promise<RESTPutAPIApplicationRoleConnectionMetadataResult>;
}
}

View File

@@ -11,6 +11,8 @@ export class StickersAPI {
/**
* Fetches all of the nitro sticker packs
*
* @see {@link https://discord.com/developers/docs/resources/sticker#list-nitro-sticker-packs}
*/
public async getNitroStickers() {
return this.rest.get(Routes.nitroStickerPacks()) as Promise<RESTGetNitroStickerPacksResult>;
@@ -19,6 +21,7 @@ export class StickersAPI {
/**
* Fetches a sticker
*
* @see {@link https://discord.com/developers/docs/resources/sticker#get-sticker}
* @param stickerId - The id of the sticker
*/
public async get(stickerId: Snowflake) {

View File

@@ -24,16 +24,18 @@ export class ThreadsAPI {
/**
* Fetches a thread
*
* @param channelId - The id of the channel to fetch the thread from
* @see {@link https://discord.com/developers/docs/resources/channel#get-channel}
* @param threadId - The id of the thread
*/
public async get(channelId: Snowflake, threadId: Snowflake) {
return this.rest.get(Routes.threads(channelId, threadId)) as Promise<APIThreadChannel>;
public async get(threadId: Snowflake) {
return this.rest.get(Routes.channel(threadId)) as Promise<APIThreadChannel>;
}
/**
* Creates a new thread
*
* @see {@link https://discord.com/developers/docs/resources/channel#start-thread-from-message}
* @see {@link https://discord.com/developers/docs/resources/channel#start-thread-without-message}
* @param channelId - The id of the channel to start the thread in
* @param data - The data to use when starting the thread
*/
@@ -44,6 +46,7 @@ export class ThreadsAPI {
/**
* Creates a new forum post
*
* @see {@link https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel}
* @param channelId - The id of the forum channel to start the thread in
* @param data - The data to use when starting the thread
*/
@@ -61,6 +64,7 @@ export class ThreadsAPI {
/**
* Adds the current user to a thread
*
* @see {@link https://discord.com/developers/docs/resources/channel#join-thread}
* @param threadId - The id of the thread to join
*/
public async join(threadId: Snowflake) {
@@ -70,6 +74,7 @@ export class ThreadsAPI {
/**
* Adds a member to a thread
*
* @see {@link https://discord.com/developers/docs/resources/channel#add-thread-member}
* @param threadId - The id of the thread to add the member to
* @param userId - The id of the user to add to the thread
*/
@@ -80,6 +85,7 @@ export class ThreadsAPI {
/**
* Removes the current user from a thread
*
* @see {@link https://discord.com/developers/docs/resources/channel#leave-thread}
* @param threadId - The id of the thread to leave
*/
public async leave(threadId: Snowflake) {
@@ -89,6 +95,7 @@ export class ThreadsAPI {
/**
* Removes a member from a thread
*
* @see {@link https://discord.com/developers/docs/resources/channel#remove-thread-member}
* @param threadId - The id of the thread to remove the member from
* @param userId - The id of the user to remove from the thread
*/
@@ -99,6 +106,7 @@ export class ThreadsAPI {
/**
* Fetches a member of a thread
*
* @see {@link https://discord.com/developers/docs/resources/channel#get-thread-member}
* @param threadId - The id of the thread to fetch the member from
* @param userId - The id of the user
*/
@@ -109,6 +117,7 @@ export class ThreadsAPI {
/**
* Fetches all members of a thread
*
* @see {@link https://discord.com/developers/docs/resources/channel#list-thread-members}
* @param threadId - The id of the thread to fetch the members from
*/
public async getAllMembers(threadId: Snowflake) {

View File

@@ -1,6 +1,8 @@
import { makeURLSearchParams, type REST } from '@discordjs/rest';
import {
Routes,
type RESTGetAPICurrentUserApplicationRoleConnectionResult,
type RESTGetAPICurrentUserConnectionsResult,
type RESTGetAPICurrentUserGuildsQuery,
type RESTGetAPICurrentUserGuildsResult,
type RESTGetAPICurrentUserResult,
@@ -13,6 +15,8 @@ import {
type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody,
type RESTPatchAPIGuildVoiceStateCurrentMemberResult,
type RESTPostAPICurrentUserCreateDMChannelResult,
type RESTPutAPICurrentUserApplicationRoleConnectionJSONBody,
type RESTPutAPICurrentUserApplicationRoleConnectionResult,
type Snowflake,
} from 'discord-api-types/v10';
@@ -22,6 +26,7 @@ export class UsersAPI {
/**
* Fetches a user by their id
*
* @see {@link https://discord.com/developers/docs/resources/user#get-user}
* @param userId - The id of the user to fetch
*/
public async get(userId: Snowflake) {
@@ -30,6 +35,8 @@ export class UsersAPI {
/**
* Returns the user object of the requester's account
*
* @see {@link https://discord.com/developers/docs/resources/user#get-current-user}
*/
public async getCurrent() {
return this.rest.get(Routes.user('@me')) as Promise<RESTGetAPICurrentUserResult>;
@@ -38,6 +45,7 @@ export class UsersAPI {
/**
* Returns a list of partial guild objects the current user is a member of
*
* @see {@link https://discord.com/developers/docs/resources/user#get-current-user-guilds}
* @param options - The options to use when fetching the current user's guilds
*/
public async getGuilds(options: RESTGetAPICurrentUserGuildsQuery = {}) {
@@ -49,6 +57,7 @@ export class UsersAPI {
/**
* Leaves the guild with the given id
*
* @see {@link https://discord.com/developers/docs/resources/user#leave-guild}
* @param guildId - The id of the guild
*/
public async leaveGuild(guildId: Snowflake) {
@@ -58,6 +67,7 @@ export class UsersAPI {
/**
* Edits the current user
*
* @see {@link https://discord.com/developers/docs/resources/user#modify-current-user}
* @param user - The new data for the current user
*/
public async edit(user: RESTPatchAPICurrentUserJSONBody) {
@@ -67,6 +77,7 @@ export class UsersAPI {
/**
* Fetches the guild member for the current user
*
* @see {@link https://discord.com/developers/docs/resources/user#get-current-user-guild-member}
* @param guildId - The id of the guild
*/
public async getGuildMember(guildId: Snowflake) {
@@ -76,6 +87,7 @@ export class UsersAPI {
/**
* Edits the guild member for the current user
*
* @see {@link https://discord.com/developers/docs/resources/guild#modify-current-member}
* @param guildId - The id of the guild
* @param member - The new data for the guild member
* @param reason - The reason for editing this guild member
@@ -90,6 +102,7 @@ export class UsersAPI {
/**
* Sets the voice state for the current user
*
* @see {@link https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state}
* @param guildId - The id of the guild
* @param options - The options to use when setting the voice state
*/
@@ -102,6 +115,7 @@ export class UsersAPI {
/**
* Opens a new DM channel with a user
*
* @see {@link https://discord.com/developers/docs/resources/user#create-dm}
* @param userId - The id of the user to open a DM channel with
*/
public async createDM(userId: Snowflake) {
@@ -109,4 +123,41 @@ export class UsersAPI {
body: { recipient_id: userId },
}) as Promise<RESTPostAPICurrentUserCreateDMChannelResult>;
}
/**
* Gets the current user's connections
*
* @see {@link https://discord.com/developers/docs/resources/user#get-user-connections}
*/
public async getConnections() {
return this.rest.get(Routes.userConnections()) as Promise<RESTGetAPICurrentUserConnectionsResult>;
}
/**
* Gets the current user's active application role connection
*
* @see {@link https://discord.com/developers/docs/resources/user#get-user-application-role-connection}
* @param applicationId - The id of the application
*/
public async getApplicationRoleConnection(applicationId: Snowflake) {
return this.rest.get(
Routes.userApplicationRoleConnection(applicationId),
) as Promise<RESTGetAPICurrentUserApplicationRoleConnectionResult>;
}
/**
* Updates the current user's application role connection
*
* @see {@link https://discord.com/developers/docs/resources/user#update-user-application-role-connection}
* @param applicationId - The id of the application
* @param options - The options to use when updating the application role connection
*/
public async updateApplicationRoleConnection(
applicationId: Snowflake,
options: RESTPutAPICurrentUserApplicationRoleConnectionJSONBody,
) {
return this.rest.put(Routes.userApplicationRoleConnection(applicationId), {
body: options,
}) as Promise<RESTPutAPICurrentUserApplicationRoleConnectionResult>;
}
}

View File

@@ -6,6 +6,8 @@ export class VoiceAPI {
/**
* Fetches all voice regions
*
* @see {@link https://discord.com/developers/docs/resources/voice#list-voice-regions}
*/
public async getVoiceRegions() {
return this.rest.get(Routes.voiceRegions()) as Promise<GetAPIVoiceRegionsResult>;

View File

@@ -23,6 +23,8 @@ export class WebhooksAPI {
/**
* Fetches a webhook
*
* @see {@link https://discord.com/developers/docs/resources/webhook#get-webhook}
* @see {@link https://discord.com/developers/docs/resources/webhook#get-webhook-with-token}
* @param id - The id of the webhook
* @param token - The token of the webhook
*/
@@ -33,6 +35,7 @@ export class WebhooksAPI {
/**
* Creates a new webhook
*
* @see {@link https://discord.com/developers/docs/resources/webhook#create-webhook}
* @param channelId - The id of the channel to create the webhook in
* @param data - The data to use when creating the webhook
* @param reason - The reason for creating the webhook
@@ -47,6 +50,8 @@ export class WebhooksAPI {
/**
* Edits a webhook
*
* @see {@link https://discord.com/developers/docs/resources/webhook#modify-webhook}
* @see {@link https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token}
* @param id - The id of the webhook to edit
* @param webhook - The new webhook data
* @param options - The options to use when editing the webhook
@@ -62,6 +67,8 @@ export class WebhooksAPI {
/**
* Deletes a webhook
*
* @see {@link https://discord.com/developers/docs/resources/webhook#delete-webhook}
* @see {@link https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token}
* @param id - The id of the webhook to delete
* @param options - The options to use when deleting the webhook
*/
@@ -72,6 +79,7 @@ export class WebhooksAPI {
/**
* Executes a webhook and returns the created message
*
* @see {@link https://discord.com/developers/docs/resources/webhook#execute-webhook}
* @param id - The id of the webhook
* @param token - The token of the webhook
* @param data - The data to use when executing the webhook
@@ -85,6 +93,7 @@ export class WebhooksAPI {
/**
* Executes a webhook
*
* @see {@link https://discord.com/developers/docs/resources/webhook#execute-webhook}
* @param id - The id of the webhook
* @param token - The token of the webhook
* @param data - The data to use when executing the webhook
@@ -98,6 +107,7 @@ export class WebhooksAPI {
/**
* Executes a webhook
*
* @see {@link https://discord.com/developers/docs/resources/webhook#execute-webhook}
* @param id - The id of the webhook
* @param token - The token of the webhook
* @param data - The data to use when executing the webhook
@@ -124,6 +134,7 @@ export class WebhooksAPI {
/**
* Executes a slack webhook
*
* @see {@link https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook}
* @param id - The id of the webhook
* @param token - The token of the webhook
* @param options - The options to use when executing the webhook
@@ -144,6 +155,7 @@ export class WebhooksAPI {
/**
* Executes a github webhook
*
* @see {@link https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook}
* @param id - The id of the webhook
* @param token - The token of the webhook
* @param options - The options to use when executing the webhook
@@ -164,6 +176,7 @@ export class WebhooksAPI {
/**
* Fetches an associated message from a webhook
*
* @see {@link https://discord.com/developers/docs/resources/webhook#get-webhook-message}
* @param id - The id of the webhook
* @param token - The token of the webhook
* @param messageId - The id of the message to fetch
@@ -179,6 +192,7 @@ export class WebhooksAPI {
/**
* Edits an associated message from a webhook
*
* @see {@link https://discord.com/developers/docs/resources/webhook#edit-webhook-message}
* @param id - The id of the webhook
* @param token - The token of the webhook
* @param messageId - The id of the message to edit
@@ -200,6 +214,7 @@ export class WebhooksAPI {
/**
* Deletes an associated message from a webhook
*
* @see {@link https://discord.com/developers/docs/resources/webhook#delete-webhook-message}
* @param id - The id of the webhook
* @param token - The token of the webhook
* @param messageId - The id of the message to delete

View File

@@ -2,6 +2,51 @@
All notable changes to this project will be documented in this file.
# [14.7.1](https://github.com/discordjs/discord.js/compare/14.7.0...14.7.1) - (2022-12-01)
## Bug Fixes
- Prevent crash on no select menu option (#8881) ([11d195d](https://github.com/discordjs/discord.js/commit/11d195d04ff57d51adb0f0d3a0a7342f9e34aba0))
# [14.7.0](https://github.com/discordjs/discord.js/compare/14.6.0...14.7.0) - (2022-11-28)
## Bug Fixes
- **MessageMentions:** Add `InGuild` generic (#8828) ([f982803](https://github.com/discordjs/discord.js/commit/f9828034cd21e6f702762a46923e0f42115596f6))
- **Activity:** Fix equals() not checking for differing emoji (#8841) ([7e06f68](https://github.com/discordjs/discord.js/commit/7e06f68185423ba7cb310220b213f445b6571e29))
- Fixed react/astro/guide/discord.js build, updated dependencies, fix crawlvatar (#8861) ([d0c8256](https://github.com/discordjs/discord.js/commit/d0c82561b8a1765a1daa362ca903f3ffb3fa33ee))
- **escapeMarkdown:** Fix double escaping (#8798) ([d6873b7](https://github.com/discordjs/discord.js/commit/d6873b7159352479475b3a0daa215bddbdd3a79b))
- **Transfomers:** Call `.toJSON` in `toSnakeCase` (#8790) ([017f9b1](https://github.com/discordjs/discord.js/commit/017f9b1ed4014dc1db0b78c1a77e463b4403de5d))
- Censor token in debug output (#8764) ([53d8e87](https://github.com/discordjs/discord.js/commit/53d8e87d7f3a329608250656950bd0a200adb1c7))
- Pin @types/node version ([9d8179c](https://github.com/discordjs/discord.js/commit/9d8179c6a78e1c7f9976f852804055964d5385d4))
## Documentation
- Describe InteractionEditReplyOptions (#8840) ([cb77fd0](https://github.com/discordjs/discord.js/commit/cb77fd02d083438de2aff6f0769baf7d1797bc65))
- **AutoModerationRuleManager:** Describe cache (#8848) ([d275480](https://github.com/discordjs/discord.js/commit/d2754802cc3479e6288cdbfcd48c76bf57e09a07))
- Fix message action row components (#8819) ([65bc0ad](https://github.com/discordjs/discord.js/commit/65bc0adbf4d7870d33b92585ca18f964f24bc84e))
- Specify `ActionRowBuilder` for `components` (#8834) ([8ed5c1b](https://github.com/discordjs/discord.js/commit/8ed5c1beb622f71ce0bd89e4cbeff50e464da8fe))
- Add `@extends` for select menu classes (#8824) ([09f65b7](https://github.com/discordjs/discord.js/commit/09f65b724b0d2f36bbe89b83570c0d18093b5126))
- Make WebSocketShard.lastPingTimestamp public (#8768) ([68c9cb3](https://github.com/discordjs/discord.js/commit/68c9cb37bc3df6326b720291827ea477e421faf2))
- **MessageReplyOptions:** Remove duplicate stickers field (#8766) ([6e348ff](https://github.com/discordjs/discord.js/commit/6e348ffd1d8db8d8ad2da7823460814695e01a43))
## Features
- **Webhook:** Add `channel` property (#8812) ([decbce4](https://github.com/discordjs/discord.js/commit/decbce401062af75f633e6acacc88207b115a719))
- Auto Moderation (#7938) ([fd4ba5e](https://github.com/discordjs/discord.js/commit/fd4ba5eaba66898699127fc0d5f0ab52c18e3db0))
- **SelectMenuInteractions:** Add `values` property (#8805) ([b2fabd1](https://github.com/discordjs/discord.js/commit/b2fabd130a76ea54cfbfa1b871ef8659513c2c7a))
- **ThreadChannel:** Add a helper for pin and unpin (#8786) ([e74aa7f](https://github.com/discordjs/discord.js/commit/e74aa7f6b0fe04e3473fc4a62a73a7db87307685))
- Add `Message#bulkDeletable` (#8760) ([ff85481](https://github.com/discordjs/discord.js/commit/ff85481d3e7cd6f7c5e38edbe43b27b104e82fba))
- New select menus (#8793) ([5152abf](https://github.com/discordjs/discord.js/commit/5152abf7285581abf7689e9050fdc56c4abb1e2b))
- **InteractionResponses:** Add message parameter (#8773) ([8b400ca](https://github.com/discordjs/discord.js/commit/8b400ca975c6bad00060b9c67068f42bd53524ba))
- Support resume urls (#8784) ([88cd9d9](https://github.com/discordjs/discord.js/commit/88cd9d906074eb79e85df0ef49287f11133d2e0d))
- Allow deletion of ephemeral messages (#8774) ([fc10774](https://github.com/discordjs/discord.js/commit/fc107744618857bf28c2167f204253baf690ede8))
- **GuildChannelManager:** Add `.addFollower()` method (#8567) ([caeb1cb](https://github.com/discordjs/discord.js/commit/caeb1cbfdb2f2f007252c4d7e9f47a575c24bcb5))
## Refactor
- **Embed:** Use `embedLength` function from builders (#8735) ([cb3826c](https://github.com/discordjs/discord.js/commit/cb3826ce6dbcd3cf7ab639af6cdfcea80336aa1d))
# [14.6.0](https://github.com/discordjs/discord.js/compare/14.5.0...14.6.0) - (2022-10-10)
## Bug Fixes
@@ -230,7 +275,7 @@ All notable changes to this project will be documented in this file.
- **DataResolver#resolveImage:** Adjust to updated resolveFile (#8308) ([3a7e93d](https://github.com/discordjs/discord.js/commit/3a7e93df576172c797f1d8bd6483234bb6af2d00))
# [14.0.0](https://github.com/discordjs/discord.js/tree/14.0.0) - (2022-07-17)
# [14.0.0](https://github.com/discordjs/discord.js/compare/13.12.0...14.0.0) - (2022-07-17)
## Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "discord.js",
"version": "14.6.0",
"version": "14.7.1",
"description": "A powerful library for interacting with the Discord API",
"scripts": {
"test": "yarn docs:test && yarn test:typescript",
@@ -65,13 +65,13 @@
"devDependencies": {
"@discordjs/docgen": "workspace:^",
"@favware/cliff-jumper": "^1.9.0",
"@types/node": "16.18.3",
"@types/node": "16.18.4",
"dtslint": "^4.2.1",
"eslint": "^8.28.0",
"eslint-formatter-pretty": "^4.1.0",
"jest": "^29.3.1",
"prettier": "^2.8.0",
"tsd": "^0.24.1",
"tsd": "^0.25.0",
"tslint": "^6.1.3",
"typescript": "^4.9.3"
},

View File

@@ -68,7 +68,7 @@ class WebhookClient extends BaseClient {
/* eslint-disable no-empty-function, valid-jsdoc */
/**
* Sends a message with this webhook.
* @param {string|MessagePayload|WebhookCreateMessageOptions} options The content for the reply
* @param {string|MessagePayload|WebhookMessageCreateOptions} options The content for the reply
* @returns {Promise<APIMessage>}
*/
send() {}
@@ -84,7 +84,7 @@ class WebhookClient extends BaseClient {
/**
* Edits a message that was sent by this webhook.
* @param {MessageResolvable} message The message to edit
* @param {string|MessagePayload|WebhookEditMessageOptions} options The options to provide
* @param {string|MessagePayload|WebhookMessageEditOptions} options The options to provide
* @returns {Promise<APIMessage>} Returns the message edited by this webhook
*/
editMessage() {}

View File

@@ -602,6 +602,9 @@ class WebSocketShard extends EventEmitter {
`[WebSocket] did not close properly, assuming a zombie connection.\nEmitting close and reconnecting again.`,
);
// Cleanup connection listeners
this._cleanupConnection();
this.emitClose();
// Setting the variable false to check for zombie connections.
this.closeEmitted = false;

View File

@@ -206,5 +206,6 @@ exports.WebSocket = require('./WebSocket');
// External
__exportStar(require('discord-api-types/v10'), exports);
__exportStar(require('@discordjs/builders'), exports);
__exportStar(require('@discordjs/formatters'), exports);
__exportStar(require('@discordjs/rest'), exports);
__exportStar(require('@discordjs/util'), exports);

View File

@@ -252,6 +252,7 @@ class ApplicationCommandManager extends CachedManager {
name: command.name,
name_localizations: command.nameLocalizations ?? command.name_localizations,
description: command.description,
nsfw: command.nsfw,
description_localizations: command.descriptionLocalizations ?? command.description_localizations,
type: command.type,
options: command.options?.map(o => ApplicationCommand.transformOption(o)),

View File

@@ -112,14 +112,14 @@ class ApplicationCommandPermissionsManager extends BaseManager {
* Options used to set permissions for one or more Application Commands in a guild
* <warn>Omitting the `command` parameter edits the guild wide permissions
* when the manager's `commandId` is `null`</warn>
* @typedef {BaseApplicationCommandPermissionsOptions} EditApplicationCommandPermissionsOptions
* @typedef {BaseApplicationCommandPermissionsOptions} ApplicationCommandPermissionsEditOptions
* @property {ApplicationCommandPermissions[]} permissions The new permissions for the guild or overwrite
* @property {string} token The bearer token to use that authorizes the permission edit
*/
/**
* Sets the permissions for the guild or a command overwrite.
* @param {EditApplicationCommandPermissionsOptions} options Options used to set permissions
* @param {ApplicationCommandPermissionsEditOptions} options Options used to set permissions
* @returns {Promise<ApplicationCommandPermissions[]|Collection<Snowflake, ApplicationCommandPermissions[]>>}
* @example
* // Set a permission overwrite for a command
@@ -179,7 +179,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
/**
* Add permissions to a command.
* @param {EditApplicationCommandPermissionsOptions} options Options used to add permissions
* @param {ApplicationCommandPermissionsEditOptions} options Options used to add permissions
* @returns {Promise<ApplicationCommandPermissions[]>}
* @example
* // Add a rule to block a role from using a command

View File

@@ -258,7 +258,7 @@ class GuildChannelManager extends CachedManager {
/**
* Edits the channel.
* @param {GuildChannelResolvable} channel The channel to edit
* @param {GuildChannelEditOptions} data Options for editing the channel
* @param {GuildChannelEditOptions} options Options for editing the channel
* @returns {Promise<GuildChannel>}
* @example
* // Edit a channel
@@ -266,19 +266,19 @@ class GuildChannelManager extends CachedManager {
* .then(console.log)
* .catch(console.error);
*/
async edit(channel, data) {
async edit(channel, options) {
channel = this.resolve(channel);
if (!channel) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'channel', 'GuildChannelResolvable');
const parent = data.parent && this.client.channels.resolveId(data.parent);
const parent = options.parent && this.client.channels.resolveId(options.parent);
if (typeof data.position !== 'undefined') {
await this.setPosition(channel, data.position, { position: data.position, reason: data.reason });
if (typeof options.position !== 'undefined') {
await this.setPosition(channel, options.position, { position: options.position, reason: options.reason });
}
let permission_overwrites = data.permissionOverwrites?.map(o => PermissionOverwrites.resolve(o, this.guild));
let permission_overwrites = options.permissionOverwrites?.map(o => PermissionOverwrites.resolve(o, this.guild));
if (data.lockPermissions) {
if (options.lockPermissions) {
if (parent) {
const newParent = this.guild.channels.resolve(parent);
if (newParent?.type === ChannelType.GuildCategory) {
@@ -295,26 +295,27 @@ class GuildChannelManager extends CachedManager {
const newData = await this.client.rest.patch(Routes.channel(channel.id), {
body: {
name: (data.name ?? channel.name).trim(),
type: data.type,
topic: data.topic,
nsfw: data.nsfw,
bitrate: data.bitrate ?? channel.bitrate,
user_limit: data.userLimit ?? channel.userLimit,
rtc_region: 'rtcRegion' in data ? data.rtcRegion : channel.rtcRegion,
video_quality_mode: data.videoQualityMode,
name: (options.name ?? channel.name).trim(),
type: options.type,
topic: options.topic,
nsfw: options.nsfw,
bitrate: options.bitrate ?? channel.bitrate,
user_limit: options.userLimit ?? channel.userLimit,
rtc_region: 'rtcRegion' in options ? options.rtcRegion : channel.rtcRegion,
video_quality_mode: options.videoQualityMode,
parent_id: parent,
lock_permissions: data.lockPermissions,
rate_limit_per_user: data.rateLimitPerUser,
default_auto_archive_duration: data.defaultAutoArchiveDuration,
lock_permissions: options.lockPermissions,
rate_limit_per_user: options.rateLimitPerUser,
default_auto_archive_duration: options.defaultAutoArchiveDuration,
permission_overwrites,
available_tags: data.availableTags?.map(availableTag => transformGuildForumTag(availableTag)),
default_reaction_emoji: data.defaultReactionEmoji && transformGuildDefaultReaction(data.defaultReactionEmoji),
default_thread_rate_limit_per_user: data.defaultThreadRateLimitPerUser,
flags: 'flags' in data ? ChannelFlagsBitField.resolve(data.flags) : undefined,
default_sort_order: data.defaultSortOrder,
available_tags: options.availableTags?.map(availableTag => transformGuildForumTag(availableTag)),
default_reaction_emoji:
options.defaultReactionEmoji && transformGuildDefaultReaction(options.defaultReactionEmoji),
default_thread_rate_limit_per_user: options.defaultThreadRateLimitPerUser,
flags: 'flags' in options ? ChannelFlagsBitField.resolve(options.flags) : undefined,
default_sort_order: options.defaultSortOrder,
},
reason: data.reason,
reason: options.reason,
});
return this.client.actions.ChannelUpdate.handle(newData).updated;

View File

@@ -124,19 +124,19 @@ class GuildEmojiManager extends BaseGuildEmojiManager {
/**
* Edits an emoji.
* @param {EmojiResolvable} emoji The Emoji resolvable to edit
* @param {GuildEmojiEditData} data The new data for the emoji
* @param {GuildEmojiEditOptions} options The options to provide
* @returns {Promise<GuildEmoji>}
*/
async edit(emoji, data) {
async edit(emoji, options) {
const id = this.resolveId(emoji);
if (!id) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'emoji', 'EmojiResolvable', true);
const roles = data.roles?.map(r => this.guild.roles.resolveId(r));
const roles = options.roles?.map(r => this.guild.roles.resolveId(r));
const newData = await this.client.rest.patch(Routes.guildEmoji(this.guild.id, id), {
body: {
name: data.name,
name: options.name,
roles,
},
reason: data.reason,
reason: options.reason,
});
const existing = this.cache.get(id);
if (existing) {

View File

@@ -167,7 +167,7 @@ class GuildInviteManager extends CachedManager {
/**
* Create an invite to the guild from the provided channel.
* @param {GuildInvitableChannelResolvable} channel The options for creating the invite from a channel.
* @param {CreateInviteOptions} [options={}] The options for creating the invite from a channel.
* @param {InviteCreateOptions} [options={}] The options for creating the invite from a channel.
* @returns {Promise<Invite>}
* @example
* // Create an invite to a selected channel

View File

@@ -270,7 +270,7 @@ class GuildMemberManager extends CachedManager {
/**
* The data for editing a guild member.
* @typedef {Object} GuildMemberEditData
* @typedef {Object} GuildMemberEditOptions
* @property {?string} [nick] The nickname to set for the member
* @property {Collection<Snowflake, Role>|RoleResolvable[]} [roles] The roles or role ids to apply
* @property {boolean} [mute] Whether or not the member should be muted
@@ -286,43 +286,43 @@ class GuildMemberManager extends CachedManager {
* Edits a member of the guild.
* <info>The user must be a member of the guild</info>
* @param {UserResolvable} user The member to edit
* @param {GuildMemberEditData} data The data to edit the member with
* @param {GuildMemberEditOptions} options The options to provide
* @returns {Promise<GuildMember>}
*/
async edit(user, { reason, ...data }) {
async edit(user, { reason, ...options }) {
const id = this.client.users.resolveId(user);
if (!id) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'user', 'UserResolvable');
if (data.channel) {
data.channel = this.guild.channels.resolve(data.channel);
if (!(data.channel instanceof BaseGuildVoiceChannel)) {
if (options.channel) {
options.channel = this.guild.channels.resolve(options.channel);
if (!(options.channel instanceof BaseGuildVoiceChannel)) {
throw new DiscordjsError(ErrorCodes.GuildVoiceChannelResolve);
}
data.channel_id = data.channel.id;
data.channel = undefined;
} else if (data.channel === null) {
data.channel_id = null;
data.channel = undefined;
options.channel_id = options.channel.id;
options.channel = undefined;
} else if (options.channel === null) {
options.channel_id = null;
options.channel = undefined;
}
data.roles &&= data.roles.map(role => (role instanceof Role ? role.id : role));
options.roles &&= options.roles.map(role => (role instanceof Role ? role.id : role));
if (typeof data.communicationDisabledUntil !== 'undefined') {
data.communication_disabled_until =
if (typeof options.communicationDisabledUntil !== 'undefined') {
options.communication_disabled_until =
// eslint-disable-next-line eqeqeq
data.communicationDisabledUntil != null
? new Date(data.communicationDisabledUntil).toISOString()
: data.communicationDisabledUntil;
options.communicationDisabledUntil != null
? new Date(options.communicationDisabledUntil).toISOString()
: options.communicationDisabledUntil;
}
let endpoint;
if (id === this.client.user.id) {
const keys = Object.keys(data);
const keys = Object.keys(options);
if (keys.length === 1 && keys[0] === 'nick') endpoint = Routes.guildMember(this.guild.id);
else endpoint = Routes.guildMember(this.guild.id, id);
} else {
endpoint = Routes.guildMember(this.guild.id, id);
}
const d = await this.client.rest.patch(endpoint, { body: data, reason });
const d = await this.client.rest.patch(endpoint, { body: options, reason });
const clone = this.cache.get(id)?._clone();
clone?._patch(d);

View File

@@ -101,16 +101,16 @@ class GuildStickerManager extends CachedManager {
/**
* Edits a sticker.
* @param {StickerResolvable} sticker The sticker to edit
* @param {GuildStickerEditData} [data={}] The new data for the sticker
* @param {GuildStickerEditOptions} [options={}] The new data for the sticker
* @returns {Promise<Sticker>}
*/
async edit(sticker, data = {}) {
async edit(sticker, options = {}) {
const stickerId = this.resolveId(sticker);
if (!stickerId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'sticker', 'StickerResolvable');
const d = await this.client.rest.patch(Routes.guildSticker(this.guild.id, stickerId), {
body: data,
reason: data.reason,
body: options,
reason: options.reason,
});
const existing = this.cache.get(stickerId);

View File

@@ -100,7 +100,7 @@ class RoleManager extends CachedManager {
/**
* Options used to create a new role.
* @typedef {Object} CreateRoleOptions
* @typedef {Object} RoleCreateOptions
* @property {string} [name] The name of the new role
* @property {ColorResolvable} [color] The data to create the role with
* @property {boolean} [hoist] Whether or not the new role should be hoisted
@@ -117,7 +117,7 @@ class RoleManager extends CachedManager {
/**
* Creates a new role in the guild with given information.
* <warn>The position will silently reset to 1 if an invalid one is provided, or none.</warn>
* @param {CreateRoleOptions} [options] Options for creating the new role
* @param {RoleCreateOptions} [options] Options for creating the new role
* @returns {Promise<Role>}
* @example
* // Create a new role
@@ -166,14 +166,14 @@ class RoleManager extends CachedManager {
/**
* Options for editing a role
* @typedef {RoleData} EditRoleOptions
* @typedef {RoleData} RoleEditOptions
* @property {string} [reason] The reason for editing this role
*/
/**
* Edits a role of the guild.
* @param {RoleResolvable} role The role to edit
* @param {EditRoleOptions} data The new data for the role
* @param {RoleEditOptions} options The options to provide
* @returns {Promise<Role>}
* @example
* // Edit a role
@@ -181,15 +181,15 @@ class RoleManager extends CachedManager {
* .then(updated => console.log(`Edited role name to ${updated.name}`))
* .catch(console.error);
*/
async edit(role, data) {
async edit(role, options) {
role = this.resolve(role);
if (!role) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'role', 'RoleResolvable');
if (typeof data.position === 'number') {
await this.setPosition(role, data.position, { reason: data.reason });
if (typeof options.position === 'number') {
await this.setPosition(role, options.position, { reason: options.reason });
}
let icon = data.icon;
let icon = options.icon;
if (icon) {
const guildEmojiURL = this.guild.emojis.resolve(icon)?.url;
icon = guildEmojiURL ? await DataResolver.resolveImage(guildEmojiURL) : await DataResolver.resolveImage(icon);
@@ -197,16 +197,17 @@ class RoleManager extends CachedManager {
}
const body = {
name: data.name,
color: typeof data.color === 'undefined' ? undefined : resolveColor(data.color),
hoist: data.hoist,
permissions: typeof data.permissions === 'undefined' ? undefined : new PermissionsBitField(data.permissions),
mentionable: data.mentionable,
name: options.name,
color: typeof options.color === 'undefined' ? undefined : resolveColor(options.color),
hoist: options.hoist,
permissions:
typeof options.permissions === 'undefined' ? undefined : new PermissionsBitField(options.permissions),
mentionable: options.mentionable,
icon,
unicode_emoji: data.unicodeEmoji,
unicode_emoji: options.unicodeEmoji,
};
const d = await this.client.rest.patch(Routes.guildRole(this.guild.id, role.id), { body, reason: data.reason });
const d = await this.client.rest.patch(Routes.guildRole(this.guild.id, role.id), { body, reason: options.reason });
const clone = role._clone();
clone._patch(d);

View File

@@ -21,8 +21,14 @@ class Shard extends EventEmitter {
constructor(manager, id) {
super();
if (manager.mode === 'process') childProcess = require('node:child_process');
else if (manager.mode === 'worker') Worker = require('node:worker_threads').Worker;
switch (manager.mode) {
case 'process':
childProcess = require('node:child_process');
break;
case 'worker':
Worker = require('node:worker_threads').Worker;
break;
}
/**
* Manager that created the shard
@@ -112,18 +118,21 @@ class Shard extends EventEmitter {
this._exitListener = this._handleExit.bind(this, undefined, timeout);
if (this.manager.mode === 'process') {
this.process = childProcess
.fork(path.resolve(this.manager.file), this.args, {
env: this.env,
execArgv: this.execArgv,
})
.on('message', this._handleMessage.bind(this))
.on('exit', this._exitListener);
} else if (this.manager.mode === 'worker') {
this.worker = new Worker(path.resolve(this.manager.file), { workerData: this.env })
.on('message', this._handleMessage.bind(this))
.on('exit', this._exitListener);
switch (this.manager.mode) {
case 'process':
this.process = childProcess
.fork(path.resolve(this.manager.file), this.args, {
env: this.env,
execArgv: this.execArgv,
})
.on('message', this._handleMessage.bind(this))
.on('exit', this._exitListener);
break;
case 'worker':
this.worker = new Worker(path.resolve(this.manager.file), { workerData: this.env })
.on('message', this._handleMessage.bind(this))
.on('exit', this._exitListener);
break;
}
this._evals.clear();

View File

@@ -29,29 +29,32 @@ class ShardClientUtil {
*/
this.parentPort = null;
if (mode === 'process') {
process.on('message', this._handleMessage.bind(this));
client.on('ready', () => {
process.send({ _ready: true });
});
client.on('disconnect', () => {
process.send({ _disconnect: true });
});
client.on('reconnecting', () => {
process.send({ _reconnecting: true });
});
} else if (mode === 'worker') {
this.parentPort = require('node:worker_threads').parentPort;
this.parentPort.on('message', this._handleMessage.bind(this));
client.on('ready', () => {
this.parentPort.postMessage({ _ready: true });
});
client.on('disconnect', () => {
this.parentPort.postMessage({ _disconnect: true });
});
client.on('reconnecting', () => {
this.parentPort.postMessage({ _reconnecting: true });
});
switch (mode) {
case 'process':
process.on('message', this._handleMessage.bind(this));
client.on('ready', () => {
process.send({ _ready: true });
});
client.on('disconnect', () => {
process.send({ _disconnect: true });
});
client.on('reconnecting', () => {
process.send({ _reconnecting: true });
});
break;
case 'worker':
this.parentPort = require('node:worker_threads').parentPort;
this.parentPort.on('message', this._handleMessage.bind(this));
client.on('ready', () => {
this.parentPort.postMessage({ _ready: true });
});
client.on('disconnect', () => {
this.parentPort.postMessage({ _disconnect: true });
});
client.on('reconnecting', () => {
this.parentPort.postMessage({ _reconnecting: true });
});
break;
}
}
@@ -81,14 +84,17 @@ class ShardClientUtil {
*/
send(message) {
return new Promise((resolve, reject) => {
if (this.mode === 'process') {
process.send(message, err => {
if (err) reject(err);
else resolve();
});
} else if (this.mode === 'worker') {
this.parentPort.postMessage(message);
resolve();
switch (this.mode) {
case 'process':
process.send(message, err => {
if (err) reject(err);
else resolve();
});
break;
case 'worker':
this.parentPort.postMessage(message);
resolve();
break;
}
});
}

View File

@@ -25,7 +25,7 @@ class ActionRow extends Component {
* Creates a new action row builder from JSON data
* @param {JSONEncodable<APIActionRowComponent>|APIActionRowComponent} other The other data
* @returns {ActionRowBuilder}
* @deprecated Use {@link ActionRowBuilder.from()} instead.
* @deprecated Use {@link ActionRowBuilder.from} instead.
*/
static from(other) {
if (isJSONEncodable(other)) {

View File

@@ -52,6 +52,12 @@ class ApplicationCommand extends Base {
*/
this.type = data.type;
/**
* Whether this command is age-restricted (18+)
* @type {boolean}
*/
this.nsfw = data.nsfw ?? false;
this._patch(data);
}
@@ -188,6 +194,7 @@ class ApplicationCommand extends Base {
* {@link ApplicationCommandType.ChatInput}
* @property {Object<Locale, string>} [nameLocalizations] The localizations for the command name
* @property {string} description The description of the command, if type is {@link ApplicationCommandType.ChatInput}
* @property {boolean} [nsfw] Whether the command is age-restricted
* @property {Object<Locale, string>} [descriptionLocalizations] The localizations for the command description,
* if type is {@link ApplicationCommandType.ChatInput}
* @property {ApplicationCommandType} [type=ApplicationCommandType.ChatInput] The type of the command
@@ -377,6 +384,7 @@ class ApplicationCommand extends Base {
('description' in command && command.description !== this.description) ||
('version' in command && command.version !== this.version) ||
(command.type && command.type !== this.type) ||
('nsfw' in command && command.nsfw !== this.nsfw) ||
// Future proof for options being nullable
// TODO: remove ?? 0 on each when nullable
(command.options?.length ?? 0) !== (this.options?.length ?? 0) ||

View File

@@ -125,7 +125,7 @@ class BaseGuildTextChannel extends GuildChannel {
/**
* Options used to create an invite to a guild channel.
* @typedef {Object} CreateInviteOptions
* @typedef {Object} InviteCreateOptions
* @property {boolean} [temporary] Whether members that joined via the invite should be automatically
* kicked after 24 hours if they have not yet received a role
* @property {number} [maxAge] How long the invite should last (in seconds, 0 for forever)
@@ -142,7 +142,7 @@ class BaseGuildTextChannel extends GuildChannel {
/**
* Creates an invite to this guild channel.
* @param {CreateInviteOptions} [options={}] The options for creating the invite
* @param {InviteCreateOptions} [options={}] The options for creating the invite
* @returns {Promise<Invite>}
* @example
* // Create an invite to a channel

View File

@@ -98,7 +98,7 @@ class BaseGuildVoiceChannel extends GuildChannel {
/**
* Creates an invite to this guild channel.
* @param {CreateInviteOptions} [options={}] The options for creating the invite
* @param {InviteCreateOptions} [options={}] The options for creating the invite
* @returns {Promise<Invite>}
* @example
* // Create an invite to a channel

View File

@@ -275,7 +275,7 @@ class BaseInteraction extends Base {
* Indicates whether this interaction is a {@link StringSelectMenuInteraction}.
* @returns {boolean}
*
* @deprecated Use {@link Interaction#isStringSelectMenu} instead
* @deprecated Use {@link BaseInteraction#isStringSelectMenu} instead.
*/
isSelectMenu() {
return this.isStringSelectMenu();

View File

@@ -10,19 +10,21 @@ const MessageComponentInteraction = require('./MessageComponentInteraction');
class ChannelSelectMenuInteraction extends MessageComponentInteraction {
constructor(client, data) {
super(client, data);
const { resolved, values } = data.data;
/**
* An array of the selected channel ids
* @type {Snowflake[]}
*/
this.values = data.data.values ?? [];
this.values = values ?? [];
/**
* Collection of the selected channels
* @type {Collection<Snowflake, Channel|APIChannel>}
*/
this.channels = new Collection();
for (const channel of Object.values(data.data.resolved.channels)) {
for (const channel of Object.values(resolved?.channels ?? {})) {
this.channels.set(channel.id, this.client.channels._add(channel, this.guild) ?? channel);
}
}

View File

@@ -44,19 +44,19 @@ class ClientUser extends User {
/**
* Data used to edit the logged in client
* @typedef {Object} ClientUserEditData
* @typedef {Object} ClientUserEditOptions
* @property {string} [username] The new username
* @property {?(BufferResolvable|Base64Resolvable)} [avatar] The new avatar
*/
/**
* Edits the logged in client.
* @param {ClientUserEditData} data The new data
* @param {ClientUserEditOptions} options The options to provide
* @returns {Promise<ClientUser>}
*/
async edit(data) {
if (typeof data.avatar !== 'undefined') data.avatar = await DataResolver.resolveImage(data.avatar);
const newData = await this.client.rest.patch(Routes.user(), { body: data });
async edit(options) {
if (typeof options.avatar !== 'undefined') options.avatar = await DataResolver.resolveImage(options.avatar);
const newData = await this.client.rest.patch(Routes.user(), { body: options });
this.client.token = newData.token;
this.client.rest.setToken(newData.token);
const { updated } = this.client.actions.UserUpdate.handle(newData);

View File

@@ -85,18 +85,18 @@ class CommandInteractionOptionResolver {
/**
* Gets an option by name and property and checks its type.
* @param {string} name The name of the option.
* @param {ApplicationCommandOptionType} type The type of the option.
* @param {ApplicationCommandOptionType[]} allowedTypes The allowed types of the option.
* @param {string[]} properties The properties to check for for `required`.
* @param {boolean} required Whether to throw an error if the option is not found.
* @returns {?CommandInteractionOption} The option, if found.
* @private
*/
_getTypedOption(name, type, properties, required) {
_getTypedOption(name, allowedTypes, properties, required) {
const option = this.get(name, required);
if (!option) {
return null;
} else if (option.type !== type) {
throw new DiscordjsTypeError(ErrorCodes.CommandInteractionOptionType, name, option.type, type);
} else if (!allowedTypes.includes(option.type)) {
throw new DiscordjsTypeError(ErrorCodes.CommandInteractionOptionType, name, option.type, allowedTypes.join(', '));
} else if (required && properties.every(prop => option[prop] === null || typeof option[prop] === 'undefined')) {
throw new DiscordjsTypeError(ErrorCodes.CommandInteractionOptionEmpty, name, option.type);
}
@@ -134,7 +134,7 @@ class CommandInteractionOptionResolver {
* @returns {?boolean} The value of the option, or null if not set and not required.
*/
getBoolean(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.Boolean, ['value'], required);
const option = this._getTypedOption(name, [ApplicationCommandOptionType.Boolean], ['value'], required);
return option?.value ?? null;
}
@@ -146,7 +146,7 @@ class CommandInteractionOptionResolver {
* The value of the option, or null if not set and not required.
*/
getChannel(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.Channel, ['channel'], required);
const option = this._getTypedOption(name, [ApplicationCommandOptionType.Channel], ['channel'], required);
return option?.channel ?? null;
}
@@ -157,7 +157,7 @@ class CommandInteractionOptionResolver {
* @returns {?string} The value of the option, or null if not set and not required.
*/
getString(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.String, ['value'], required);
const option = this._getTypedOption(name, [ApplicationCommandOptionType.String], ['value'], required);
return option?.value ?? null;
}
@@ -168,7 +168,7 @@ class CommandInteractionOptionResolver {
* @returns {?number} The value of the option, or null if not set and not required.
*/
getInteger(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.Integer, ['value'], required);
const option = this._getTypedOption(name, [ApplicationCommandOptionType.Integer], ['value'], required);
return option?.value ?? null;
}
@@ -179,7 +179,7 @@ class CommandInteractionOptionResolver {
* @returns {?number} The value of the option, or null if not set and not required.
*/
getNumber(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.Number, ['value'], required);
const option = this._getTypedOption(name, [ApplicationCommandOptionType.Number], ['value'], required);
return option?.value ?? null;
}
@@ -190,7 +190,12 @@ class CommandInteractionOptionResolver {
* @returns {?User} The value of the option, or null if not set and not required.
*/
getUser(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.User, ['user'], required);
const option = this._getTypedOption(
name,
[ApplicationCommandOptionType.User, ApplicationCommandOptionType.Mentionable],
['user'],
required,
);
return option?.user ?? null;
}
@@ -201,7 +206,12 @@ class CommandInteractionOptionResolver {
* The value of the option, or null if the user is not present in the guild or the option is not set.
*/
getMember(name) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.User, ['member'], false);
const option = this._getTypedOption(
name,
[ApplicationCommandOptionType.User, ApplicationCommandOptionType.Mentionable],
['member'],
false,
);
return option?.member ?? null;
}
@@ -212,7 +222,12 @@ class CommandInteractionOptionResolver {
* @returns {?(Role|APIRole)} The value of the option, or null if not set and not required.
*/
getRole(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.Role, ['role'], required);
const option = this._getTypedOption(
name,
[ApplicationCommandOptionType.Role, ApplicationCommandOptionType.Mentionable],
['role'],
required,
);
return option?.role ?? null;
}
@@ -223,7 +238,7 @@ class CommandInteractionOptionResolver {
* @returns {?Attachment} The value of the option, or null if not set and not required.
*/
getAttachment(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.Attachment, ['attachment'], required);
const option = this._getTypedOption(name, [ApplicationCommandOptionType.Attachment], ['attachment'], required);
return option?.attachment ?? null;
}
@@ -237,7 +252,7 @@ class CommandInteractionOptionResolver {
getMentionable(name, required = false) {
const option = this._getTypedOption(
name,
ApplicationCommandOptionType.Mentionable,
[ApplicationCommandOptionType.Mentionable],
['user', 'member', 'role'],
required,
);
@@ -252,7 +267,7 @@ class CommandInteractionOptionResolver {
* The value of the option, or null if not set and not required.
*/
getMessage(name, required = false) {
const option = this._getTypedOption(name, '_MESSAGE', ['message'], required);
const option = this._getTypedOption(name, ['_MESSAGE'], ['message'], required);
return option?.message ?? null;
}

View File

@@ -168,7 +168,7 @@ class ForumChannel extends GuildChannel {
/**
* Creates an invite to this guild channel.
* @param {CreateInviteOptions} [options={}] The options for creating the invite
* @param {InviteCreateOptions} [options={}] The options for creating the invite
* @returns {Promise<Invite>}
* @example
* // Create an invite to a channel

View File

@@ -737,7 +737,7 @@ class Guild extends AnonymousGuild {
/**
* The data for editing a guild.
* @typedef {Object} GuildEditData
* @typedef {Object} GuildEditOptions
* @property {string} [name] The name of the guild
* @property {?GuildVerificationLevel} [verificationLevel] The verification level of the guild
* @property {?GuildExplicitContentFilter} [explicitContentFilter] The level of the explicit content filter
@@ -778,7 +778,7 @@ class Guild extends AnonymousGuild {
/**
* Updates the guild with new information - e.g. a new name.
* @param {GuildEditData} data The data to update the guild with
* @param {GuildEditOptions} options The options to provide
* @returns {Promise<Guild>}
* @example
* // Set the guild name
@@ -788,50 +788,50 @@ class Guild extends AnonymousGuild {
* .then(updated => console.log(`New guild name ${updated}`))
* .catch(console.error);
*/
async edit(data) {
async edit(options) {
const _data = {};
if (data.name) _data.name = data.name;
if (typeof data.verificationLevel !== 'undefined') {
_data.verification_level = data.verificationLevel;
if (options.name) _data.name = options.name;
if (typeof options.verificationLevel !== 'undefined') {
_data.verification_level = options.verificationLevel;
}
if (typeof data.afkChannel !== 'undefined') {
_data.afk_channel_id = this.client.channels.resolveId(data.afkChannel);
if (typeof options.afkChannel !== 'undefined') {
_data.afk_channel_id = this.client.channels.resolveId(options.afkChannel);
}
if (typeof data.systemChannel !== 'undefined') {
_data.system_channel_id = this.client.channels.resolveId(data.systemChannel);
if (typeof options.systemChannel !== 'undefined') {
_data.system_channel_id = this.client.channels.resolveId(options.systemChannel);
}
if (data.afkTimeout) _data.afk_timeout = Number(data.afkTimeout);
if (typeof data.icon !== 'undefined') _data.icon = await DataResolver.resolveImage(data.icon);
if (data.owner) _data.owner_id = this.client.users.resolveId(data.owner);
if (typeof data.splash !== 'undefined') _data.splash = await DataResolver.resolveImage(data.splash);
if (typeof data.discoverySplash !== 'undefined') {
_data.discovery_splash = await DataResolver.resolveImage(data.discoverySplash);
if (options.afkTimeout) _data.afk_timeout = Number(options.afkTimeout);
if (typeof options.icon !== 'undefined') _data.icon = await DataResolver.resolveImage(options.icon);
if (options.owner) _data.owner_id = this.client.users.resolveId(options.owner);
if (typeof options.splash !== 'undefined') _data.splash = await DataResolver.resolveImage(options.splash);
if (typeof options.discoverySplash !== 'undefined') {
_data.discovery_splash = await DataResolver.resolveImage(options.discoverySplash);
}
if (typeof data.banner !== 'undefined') _data.banner = await DataResolver.resolveImage(data.banner);
if (typeof data.explicitContentFilter !== 'undefined') {
_data.explicit_content_filter = data.explicitContentFilter;
if (typeof options.banner !== 'undefined') _data.banner = await DataResolver.resolveImage(options.banner);
if (typeof options.explicitContentFilter !== 'undefined') {
_data.explicit_content_filter = options.explicitContentFilter;
}
if (typeof data.defaultMessageNotifications !== 'undefined') {
_data.default_message_notifications = data.defaultMessageNotifications;
if (typeof options.defaultMessageNotifications !== 'undefined') {
_data.default_message_notifications = options.defaultMessageNotifications;
}
if (typeof data.systemChannelFlags !== 'undefined') {
_data.system_channel_flags = SystemChannelFlagsBitField.resolve(data.systemChannelFlags);
if (typeof options.systemChannelFlags !== 'undefined') {
_data.system_channel_flags = SystemChannelFlagsBitField.resolve(options.systemChannelFlags);
}
if (typeof data.rulesChannel !== 'undefined') {
_data.rules_channel_id = this.client.channels.resolveId(data.rulesChannel);
if (typeof options.rulesChannel !== 'undefined') {
_data.rules_channel_id = this.client.channels.resolveId(options.rulesChannel);
}
if (typeof data.publicUpdatesChannel !== 'undefined') {
_data.public_updates_channel_id = this.client.channels.resolveId(data.publicUpdatesChannel);
if (typeof options.publicUpdatesChannel !== 'undefined') {
_data.public_updates_channel_id = this.client.channels.resolveId(options.publicUpdatesChannel);
}
if (typeof data.features !== 'undefined') {
_data.features = data.features;
if (typeof options.features !== 'undefined') {
_data.features = options.features;
}
if (typeof data.description !== 'undefined') {
_data.description = data.description;
if (typeof options.description !== 'undefined') {
_data.description = options.description;
}
if (typeof data.preferredLocale !== 'undefined') _data.preferred_locale = data.preferredLocale;
if ('premiumProgressBarEnabled' in data) _data.premium_progress_bar_enabled = data.premiumProgressBarEnabled;
const newData = await this.client.rest.patch(Routes.guild(this.id), { body: _data, reason: data.reason });
if (typeof options.preferredLocale !== 'undefined') _data.preferred_locale = options.preferredLocale;
if ('premiumProgressBarEnabled' in options) _data.premium_progress_bar_enabled = options.premiumProgressBarEnabled;
const newData = await this.client.rest.patch(Routes.guild(this.id), { body: _data, reason: options.reason });
return this.client.actions.GuildUpdate.handle(newData).updated;
}
@@ -845,7 +845,7 @@ class Guild extends AnonymousGuild {
/**
* Welcome screen edit data
* @typedef {Object} WelcomeScreenEditData
* @typedef {Object} WelcomeScreenEditOptions
* @property {boolean} [enabled] Whether the welcome screen is enabled
* @property {string} [description] The description for the welcome screen
* @property {WelcomeChannelData[]} [welcomeChannels] The welcome channel data for the welcome screen
@@ -869,7 +869,7 @@ class Guild extends AnonymousGuild {
/**
* Updates the guild's welcome screen
* @param {WelcomeScreenEditData} data Data to edit the welcome screen with
* @param {WelcomeScreenEditOptions} options The options to provide
* @returns {Promise<WelcomeScreen>}
* @example
* guild.editWelcomeScreen({
@@ -883,8 +883,8 @@ class Guild extends AnonymousGuild {
* ],
* })
*/
async editWelcomeScreen(data) {
const { enabled, description, welcomeChannels } = data;
async editWelcomeScreen(options) {
const { enabled, description, welcomeChannels } = options;
const welcome_channels = welcomeChannels?.map(welcomeChannelData => {
const emoji = this.emojis.resolve(welcomeChannelData.emoji);
return {
@@ -1204,6 +1204,17 @@ class Guild extends AnonymousGuild {
return this;
}
/**
* Sets whether this guild's invites are disabled.
* @param {boolean} [disabled=true] Whether the invites are disabled
* @returns {Promise<Guild>}
*/
async disableInvites(disabled = true) {
const features = this.features.filter(feature => feature !== GuildFeature.InvitesDisabled);
if (disabled) features.push(GuildFeature.InvitesDisabled);
return this.edit({ features });
}
/**
* 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

View File

@@ -268,7 +268,7 @@ class GuildChannel extends BaseChannel {
/**
* Edits the channel.
* @param {GuildChannelEditOptions} data The new data for the channel
* @param {GuildChannelEditOptions} options The options to provide
* @returns {Promise<GuildChannel>}
* @example
* // Edit a channel
@@ -276,8 +276,8 @@ class GuildChannel extends BaseChannel {
* .then(console.log)
* .catch(console.error);
*/
edit(data) {
return this.guild.channels.edit(this, data);
edit(options) {
return this.guild.channels.edit(this, options);
}
/**

View File

@@ -78,7 +78,7 @@ class GuildEmoji extends BaseGuildEmoji {
/**
* Data for editing an emoji.
* @typedef {Object} GuildEmojiEditData
* @typedef {Object} GuildEmojiEditOptions
* @property {string} [name] The name of the emoji
* @property {Collection<Snowflake, Role>|RoleResolvable[]} [roles] Roles to restrict emoji to
* @property {string} [reason] Reason for editing this emoji
@@ -86,7 +86,7 @@ class GuildEmoji extends BaseGuildEmoji {
/**
* Edits the emoji.
* @param {GuildEmojiEditData} data The new data for the emoji
* @param {GuildEmojiEditOptions} options The options to provide
* @returns {Promise<GuildEmoji>}
* @example
* // Edit an emoji
@@ -94,8 +94,8 @@ class GuildEmoji extends BaseGuildEmoji {
* .then(e => console.log(`Edited emoji ${e}`))
* .catch(console.error);
*/
edit(data) {
return this.guild.emojis.edit(this.id, data);
edit(options) {
return this.guild.emojis.edit(this.id, options);
}
/**

View File

@@ -307,11 +307,11 @@ class GuildMember extends Base {
/**
* Edits this member.
* @param {GuildMemberEditData} data The data to edit the member with
* @param {GuildMemberEditOptions} options The options to provide
* @returns {Promise<GuildMember>}
*/
edit(data) {
return this.guild.members.edit(this, data);
edit(options) {
return this.guild.members.edit(this, options);
}
/**

View File

@@ -240,7 +240,7 @@ class GuildScheduledEvent extends Base {
/**
* Options used to create an invite URL to a {@link GuildScheduledEvent}
* @typedef {CreateInviteOptions} CreateGuildScheduledEventInviteURLOptions
* @typedef {InviteCreateOptions} GuildScheduledEventInviteURLCreateOptions
* @property {GuildInvitableChannelResolvable} [channel] The channel to create the invite in.
* <warn>This is required when the `entityType` of `GuildScheduledEvent` is
* {@link GuildScheduledEventEntityType.External}, gets ignored otherwise</warn>
@@ -248,7 +248,7 @@ class GuildScheduledEvent extends Base {
/**
* Creates an invite URL to this guild scheduled event.
* @param {CreateGuildScheduledEventInviteURLOptions} [options] The options to create the invite
* @param {GuildScheduledEventInviteURLCreateOptions} [options] The options to create the invite
* @returns {Promise<string>}
*/
async createInviteURL(options) {

View File

@@ -155,14 +155,14 @@ class GuildTemplate extends Base {
/**
* Options used to edit a guild template.
* @typedef {Object} EditGuildTemplateOptions
* @typedef {Object} GuildTemplateEditOptions
* @property {string} [name] The name of this template
* @property {string} [description] The description of this template
*/
/**
* Updates the metadata of this template.
* @param {EditGuildTemplateOptions} [options] Options for editing the template
* @param {GuildTemplateEditOptions} [options] Options for editing the template
* @returns {Promise<GuildTemplate>}
*/
async edit({ name, description } = {}) {

View File

@@ -1,5 +1,6 @@
'use strict';
const { DiscordSnowflake } = require('@sapphire/snowflake');
const { InteractionType } = require('discord-api-types/v10');
const { DiscordjsError, ErrorCodes } = require('../errors');
@@ -21,6 +22,24 @@ class InteractionResponse {
this.client = interaction.client;
}
/**
* The timestamp the interaction response was created at
* @type {number}
* @readonly
*/
get createdTimestamp() {
return DiscordSnowflake.timestampFrom(this.id);
}
/**
* The time the interaction response was created at
* @type {Date}
* @readonly
*/
get createdAt() {
return new Date(this.createdTimestamp);
}
/**
* Collects a single component interaction that passes the filter.
* The Promise will reject if the time expires.

View File

@@ -45,7 +45,7 @@ class InteractionWebhook {
/**
* Edits a message that was sent by this webhook.
* @param {MessageResolvable|'@original'} message The message to edit
* @param {string|MessagePayload|WebhookEditMessageOptions} options The options to provide
* @param {string|MessagePayload|WebhookMessageEditOptions} options The options to provide
* @returns {Promise<Message>} Returns the message edited by this webhook
*/

View File

@@ -11,14 +11,14 @@ const Events = require('../util/Events');
class MentionableSelectMenuInteraction extends MessageComponentInteraction {
constructor(client, data) {
super(client, data);
const { resolved, values } = data.data;
const { members, users, roles } = resolved ?? {};
/**
* An array of the selected user and role ids
* @type {Snowflake[]}
*/
this.values = data.data.values ?? [];
const { members, users, roles } = data.data.resolved ?? {};
this.values = values ?? [];
/**
* Collection of the selected users

View File

@@ -287,7 +287,7 @@ module.exports = MessagePayload;
/**
* A possible payload option.
* @typedef {MessageCreateOptions|MessageEditOptions|WebhookCreateMessageOptions|WebhookEditMessageOptions|
* @typedef {MessageCreateOptions|MessageEditOptions|WebhookMessageCreateOptions|WebhookMessageEditOptions|
* InteractionReplyOptions|InteractionUpdateOptions} MessagePayloadOption
*/

View File

@@ -207,7 +207,7 @@ class Role extends Base {
/**
* Edits the role.
* @param {EditRoleOptions} data The new data for the role
* @param {RoleEditOptions} options The options to provide
* @returns {Promise<Role>}
* @example
* // Edit a role
@@ -215,8 +215,8 @@ class Role extends Base {
* .then(updated => console.log(`Edited role name to ${updated.name}`))
* .catch(console.error);
*/
edit(data) {
return this.guild.roles.edit(this, data);
edit(options) {
return this.guild.roles.edit(this, options);
}
/**

View File

@@ -10,19 +10,21 @@ const MessageComponentInteraction = require('./MessageComponentInteraction');
class RoleSelectMenuInteraction extends MessageComponentInteraction {
constructor(client, data) {
super(client, data);
const { resolved, values } = data.data;
/**
* An array of the selected role ids
* @type {Snowflake[]}
*/
this.values = data.data.values ?? [];
this.values = values ?? [];
/**
* Collection of the selected roles
* @type {Collection<Snowflake, Role|APIRole>}
*/
this.roles = new Collection();
for (const role of Object.values(data.data.resolved.roles)) {
for (const role of Object.values(resolved?.roles ?? {})) {
this.roles.set(role.id, this.guild?.roles._add(role) ?? role);
}
}

View File

@@ -197,7 +197,7 @@ class Sticker extends Base {
/**
* Data for editing a sticker.
* @typedef {Object} GuildStickerEditData
* @typedef {Object} GuildStickerEditOptions
* @property {string} [name] The name of the sticker
* @property {?string} [description] The description of the sticker
* @property {string} [tags] The Discord name of a unicode emoji representing the sticker's expression
@@ -206,7 +206,7 @@ class Sticker extends Base {
/**
* Edits the sticker.
* @param {GuildStickerEditData} data The new data for the sticker
* @param {GuildStickerEditOptions} options The options to provide
* @returns {Promise<Sticker>}
* @example
* // Update the name of a sticker
@@ -214,8 +214,8 @@ class Sticker extends Base {
* .then(s => console.log(`Updated the name of the sticker to ${s.name}`))
* .catch(console.error);
*/
edit(data) {
return this.guild.stickers.edit(this, data);
edit(options) {
return this.guild.stickers.edit(this, options);
}
/**

View File

@@ -316,7 +316,7 @@ class ThreadChannel extends BaseChannel {
/**
* The options used to edit a thread channel
* @typedef {Object} ThreadEditData
* @typedef {Object} ThreadEditOptions
* @property {string} [name] The new name for the thread
* @property {boolean} [archived] Whether the thread is archived
* @property {ThreadAutoArchiveDuration} [autoArchiveDuration] The amount of time after which the thread
@@ -332,7 +332,7 @@ class ThreadChannel extends BaseChannel {
/**
* Edits this thread.
* @param {ThreadEditData} data The new data for this thread
* @param {ThreadEditOptions} options The options to provide
* @returns {Promise<ThreadChannel>}
* @example
* // Edit a thread
@@ -340,19 +340,19 @@ class ThreadChannel extends BaseChannel {
* .then(editedThread => console.log(editedThread))
* .catch(console.error);
*/
async edit(data) {
async edit(options) {
const newData = await this.client.rest.patch(Routes.channel(this.id), {
body: {
name: (data.name ?? this.name).trim(),
archived: data.archived,
auto_archive_duration: data.autoArchiveDuration,
rate_limit_per_user: data.rateLimitPerUser,
locked: data.locked,
invitable: this.type === ChannelType.PrivateThread ? data.invitable : undefined,
applied_tags: data.appliedTags,
flags: 'flags' in data ? ChannelFlagsBitField.resolve(data.flags) : undefined,
name: (options.name ?? this.name).trim(),
archived: options.archived,
auto_archive_duration: options.autoArchiveDuration,
rate_limit_per_user: options.rateLimitPerUser,
locked: options.locked,
invitable: this.type === ChannelType.PrivateThread ? options.invitable : undefined,
applied_tags: options.appliedTags,
flags: 'flags' in options ? ChannelFlagsBitField.resolve(options.flags) : undefined,
},
reason: data.reason,
reason: options.reason,
});
return this.client.actions.ChannelUpdate.handle(newData).updated;

View File

@@ -11,12 +11,13 @@ const Events = require('../util/Events');
class UserSelectMenuInteraction extends MessageComponentInteraction {
constructor(client, data) {
super(client, data);
const { resolved, values } = data.data;
/**
* An array of the selected user ids
* @type {Snowflake[]}
*/
this.values = data.data.values ?? [];
this.values = values ?? [];
/**
* Collection of the selected users
@@ -30,24 +31,19 @@ class UserSelectMenuInteraction extends MessageComponentInteraction {
*/
this.members = new Collection();
for (const user of Object.values(data.data.resolved.users)) {
for (const user of Object.values(resolved?.users ?? {})) {
this.users.set(user.id, this.client.users._add(user));
}
if (data.data.resolved.members) {
for (const [id, member] of Object.entries(data.data.resolved.members)) {
const user = data.data.resolved.users[id];
if (!user) {
this.client.emit(
Events.Debug,
`[UserSelectMenuInteraction] Received a member without a user, skipping ${id}`,
);
for (const [id, member] of Object.entries(resolved?.members ?? {})) {
const user = resolved.users[id];
continue;
}
this.members.set(id, this.guild?.members._add({ user, ...member }) ?? { user, ...member });
if (!user) {
this.client.emit(Events.Debug, `[UserSelectMenuInteraction] Received a member without a user, skipping ${id}`);
continue;
}
this.members.set(id, this.guild?.members._add({ user, ...member }) ?? { user, ...member });
}
}
}

View File

@@ -208,7 +208,7 @@ class VoiceState extends Base {
/**
* Data to edit the logged in user's own voice state with, when in a stage channel
* @typedef {Object} VoiceStateEditData
* @typedef {Object} VoiceStateEditOptions
* @property {boolean} [requestToSpeak] Whether or not the client is requesting to become a speaker.
* <info>Only available to the logged in user's own voice state.</info>
* @property {boolean} [suppressed] Whether or not the user should be suppressed.
@@ -216,35 +216,35 @@ class VoiceState extends Base {
/**
* Edits this voice state. Currently only available when in a stage channel
* @param {VoiceStateEditData} data The data to edit the voice state with
* @param {VoiceStateEditOptions} options The options to provide
* @returns {Promise<VoiceState>}
*/
async edit(data) {
async edit(options) {
if (this.channel?.type !== ChannelType.GuildStageVoice) throw new DiscordjsError(ErrorCodes.VoiceNotStageChannel);
const target = this.client.user.id === this.id ? '@me' : this.id;
if (target !== '@me' && typeof data.requestToSpeak !== 'undefined') {
if (target !== '@me' && typeof options.requestToSpeak !== 'undefined') {
throw new DiscordjsError(ErrorCodes.VoiceStateNotOwn);
}
if (!['boolean', 'undefined'].includes(typeof data.requestToSpeak)) {
if (!['boolean', 'undefined'].includes(typeof options.requestToSpeak)) {
throw new DiscordjsTypeError(ErrorCodes.VoiceStateInvalidType, 'requestToSpeak');
}
if (!['boolean', 'undefined'].includes(typeof data.suppressed)) {
if (!['boolean', 'undefined'].includes(typeof options.suppressed)) {
throw new DiscordjsTypeError(ErrorCodes.VoiceStateInvalidType, 'suppressed');
}
await this.client.rest.patch(Routes.guildVoiceState(this.guild.id, target), {
body: {
channel_id: this.channelId,
request_to_speak_timestamp: data.requestToSpeak
request_to_speak_timestamp: options.requestToSpeak
? new Date().toISOString()
: data.requestToSpeak === false
: options.requestToSpeak === false
? null
: undefined,
suppress: data.suppressed,
suppress: options.suppressed,
},
});
return this;

View File

@@ -126,7 +126,7 @@ class Webhook {
/**
* Options that can be passed into send.
* @typedef {BaseMessageOptions} WebhookCreateMessageOptions
* @typedef {BaseMessageOptions} WebhookMessageCreateOptions
* @property {boolean} [tts=false] Whether the message should be spoken aloud
* @property {MessageFlags} [flags] Which flags to set for the message.
* <info>Only the {@link MessageFlags.SuppressEmbeds} flag can be set.</info>
@@ -139,7 +139,7 @@ class Webhook {
/**
* Options that can be passed into editMessage.
* @typedef {BaseMessageOptions} WebhookEditMessageOptions
* @typedef {BaseMessageOptions} WebhookMessageEditOptions
* @property {Attachment[]} [attachments] Attachments to send with the message
* @property {Snowflake} [threadId] The id of the thread this message belongs to
* <info>For interaction webhooks, this property is ignored</info>
@@ -156,7 +156,7 @@ class Webhook {
/**
* Sends a message with this webhook.
* @param {string|MessagePayload|WebhookCreateMessageOptions} options The options to provide
* @param {string|MessagePayload|WebhookMessageCreateOptions} options The options to provide
* @returns {Promise<Message>}
* @example
* // Send a basic message
@@ -261,7 +261,7 @@ class Webhook {
/**
* Options used to edit a {@link Webhook}.
* @typedef {Object} WebhookEditData
* @typedef {Object} WebhookEditOptions
* @property {string} [name=this.name] The new name for the webhook
* @property {?(BufferResolvable)} [avatar] The new avatar for the webhook
* @property {GuildTextChannelResolvable} [channel] The new channel for the webhook
@@ -270,7 +270,7 @@ class Webhook {
/**
* Edits this webhook.
* @param {WebhookEditData} options Options for editing the webhook
* @param {WebhookEditOptions} options Options for editing the webhook
* @returns {Promise<Webhook>}
*/
async edit({ name = this.name, avatar, channel, reason }) {
@@ -322,7 +322,7 @@ class Webhook {
/**
* Edits a message that was sent by this webhook.
* @param {MessageResolvable|'@original'} message The message to edit
* @param {string|MessagePayload|WebhookEditMessageOptions} options The options to provide
* @param {string|MessagePayload|WebhookMessageEditOptions} options The options to provide
* @returns {Promise<Message>} Returns the message edited by this webhook
*/
async editMessage(message, options) {

View File

@@ -138,7 +138,7 @@ class InteractionResponses {
/**
* Options that can be passed into {@link InteractionResponses#editReply}.
* @typedef {WebhookEditMessageOptions} InteractionEditReplyOptions
* @typedef {WebhookMessageEditOptions} InteractionEditReplyOptions
* @property {MessageResolvable|'@original'} [message='@original'] The response to edit
*/

View File

@@ -11,6 +11,7 @@ class UserFlagsBitField extends BitField {
/**
* Numeric user flags.
* @type {UserFlags}
* @memberof UserFlagsBitField
*/
static Flags = UserFlags;
}

View File

@@ -419,6 +419,7 @@ export class ApplicationCommand<PermissionsFetchType = {}> extends Base {
>;
public type: ApplicationCommandType;
public version: Snowflake;
public nsfw: boolean;
public delete(): Promise<ApplicationCommand<PermissionsFetchType>>;
public edit(data: Partial<ApplicationCommandData>): Promise<ApplicationCommand<PermissionsFetchType>>;
public setName(name: string): Promise<ApplicationCommand<PermissionsFetchType>>;
@@ -555,6 +556,8 @@ export class InteractionResponse<Cached extends boolean = boolean> {
public interaction: Interaction<WrapBooleanCache<Cached>>;
public client: Client;
public id: Snowflake;
public get createdAt(): Date;
public get createdTimestamp(): number;
public awaitMessageComponent<T extends MessageComponentType>(
options?: AwaitMessageCollectorOptionsParams<T, Cached>,
): Promise<MappedInteractionTypes<Cached>[T]>;
@@ -597,7 +600,7 @@ export class BaseGuildTextChannel extends TextBasedChannelMixin(GuildChannel, tr
public nsfw: boolean;
public threads: GuildTextThreadManager<AllowedThreadTypeForTextChannel | AllowedThreadTypeForNewsChannel>;
public topic: string | null;
public createInvite(options?: CreateInviteOptions): Promise<Invite>;
public createInvite(options?: InviteCreateOptions): Promise<Invite>;
public fetchInvites(cache?: boolean): Promise<Collection<string, Invite>>;
public setDefaultAutoArchiveDuration(
defaultAutoArchiveDuration: ThreadAutoArchiveDuration,
@@ -616,7 +619,7 @@ export class BaseGuildVoiceChannel extends GuildChannel {
public rtcRegion: string | null;
public bitrate: number;
public userLimit: number;
public createInvite(options?: CreateInviteOptions): Promise<Invite>;
public createInvite(options?: InviteCreateOptions): Promise<Invite>;
public setRTCRegion(rtcRegion: string | null, reason?: string): Promise<this>;
public fetchInvites(cache?: boolean): Promise<Collection<string, Invite>>;
}
@@ -977,7 +980,7 @@ export class ClientUser extends User {
public mfaEnabled: boolean;
public get presence(): ClientPresence;
public verified: boolean;
public edit(data: ClientUserEditData): Promise<this>;
public edit(options: ClientUserEditOptions): Promise<this>;
public setActivity(options?: ActivityOptions): ClientPresence;
public setActivity(name: string, options?: ActivityOptions): ClientPresence;
public setAFK(afk?: boolean, shardId?: number | number[]): ClientPresence;
@@ -1089,13 +1092,13 @@ export class CommandInteractionOptionResolver<Cached extends CacheType = CacheTy
private _subcommand: string | null;
private _getTypedOption(
name: string,
type: ApplicationCommandOptionType,
allowedTypes: ApplicationCommandOptionType[],
properties: (keyof ApplicationCommandOption)[],
required: true,
): CommandInteractionOption<Cached>;
private _getTypedOption(
name: string,
type: ApplicationCommandOptionType,
allowedTypes: ApplicationCommandOptionType[],
properties: (keyof ApplicationCommandOption)[],
required: boolean,
): CommandInteractionOption<Cached> | null;
@@ -1265,8 +1268,8 @@ export class Guild extends AnonymousGuild {
public createTemplate(name: string, description?: string): Promise<GuildTemplate>;
public delete(): Promise<Guild>;
public discoverySplashURL(options?: ImageURLOptions): string | null;
public edit(data: GuildEditData): Promise<Guild>;
public editWelcomeScreen(data: WelcomeScreenEditData): Promise<WelcomeScreen>;
public edit(options: GuildEditOptions): Promise<Guild>;
public editWelcomeScreen(options: WelcomeScreenEditOptions): Promise<WelcomeScreen>;
public equals(guild: Guild): boolean;
public fetchAuditLogs<T extends GuildAuditLogsResolvable = null>(
options?: GuildAuditLogsFetchOptions<T>,
@@ -1281,6 +1284,7 @@ export class Guild extends AnonymousGuild {
public fetchWidget(): Promise<Widget>;
public fetchWidgetSettings(): Promise<GuildWidgetSettings>;
public leave(): Promise<Guild>;
public disableInvites(disabled?: boolean): Promise<Guild>;
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>;
@@ -1387,7 +1391,7 @@ export abstract class GuildChannel extends BaseChannel {
public get viewable(): boolean;
public clone(options?: GuildChannelCloneOptions): Promise<this>;
public delete(reason?: string): Promise<this>;
public edit(data: GuildChannelEditOptions): Promise<this>;
public edit(options: GuildChannelEditOptions): Promise<this>;
public equals(channel: GuildChannel): boolean;
public lockPermissions(): Promise<this>;
public permissionsFor(memberOrRole: GuildMember | Role, checkAdmin?: boolean): Readonly<PermissionsBitField>;
@@ -1412,7 +1416,7 @@ export class GuildEmoji extends BaseGuildEmoji {
public get roles(): GuildEmojiRoleManager;
public get url(): string;
public delete(reason?: string): Promise<GuildEmoji>;
public edit(data: GuildEmojiEditData): Promise<GuildEmoji>;
public edit(options: GuildEmojiEditOptions): Promise<GuildEmoji>;
public equals(other: GuildEmoji | unknown): boolean;
public fetchAuthor(): Promise<User>;
public setName(name: string, reason?: string): Promise<GuildEmoji>;
@@ -1453,7 +1457,7 @@ export class GuildMember extends PartialTextBasedChannel(Base) {
public createDM(force?: boolean): Promise<DMChannel>;
public deleteDM(): Promise<DMChannel>;
public displayAvatarURL(options?: ImageURLOptions): string;
public edit(data: GuildMemberEditData): Promise<GuildMember>;
public edit(options: GuildMemberEditOptions): Promise<GuildMember>;
public isCommunicationDisabled(): this is GuildMember & {
communicationDisabledUntilTimestamp: number;
readonly communicationDisabledUntil: Date;
@@ -1515,7 +1519,7 @@ export class GuildScheduledEvent<S extends GuildScheduledEventStatus = GuildSche
public get url(): string;
public image: string | null;
public coverImageURL(options?: Readonly<BaseImageURLOptions>): string | null;
public createInviteURL(options?: CreateGuildScheduledEventInviteURLOptions): Promise<string>;
public createInviteURL(options?: GuildScheduledEventInviteURLCreateOptions): Promise<string>;
public edit<T extends GuildScheduledEventSetStatusArg<S>>(
options: GuildScheduledEventEditOptions<S, T>,
): Promise<GuildScheduledEvent<T>>;
@@ -1558,7 +1562,7 @@ export class GuildTemplate extends Base {
public unSynced: boolean | null;
public createGuild(name: string, icon?: BufferResolvable | Base64Resolvable): Promise<Guild>;
public delete(): Promise<GuildTemplate>;
public edit(options?: EditGuildTemplateOptions): Promise<GuildTemplate>;
public edit(options?: GuildTemplateEditOptions): Promise<GuildTemplate>;
public sync(): Promise<GuildTemplate>;
public static GuildTemplatesPattern: RegExp;
}
@@ -1680,7 +1684,7 @@ export class BaseInteraction<Cached extends CacheType = CacheType> extends Base
public isMessageContextMenuCommand(): this is MessageContextMenuCommandInteraction<Cached>;
public isModalSubmit(): this is ModalSubmitInteraction<Cached>;
public isUserContextMenuCommand(): this is UserContextMenuCommandInteraction<Cached>;
/** @deprecated Use {@link BaseInteraction#isStringSelectMenu} instead */
/** @deprecated Use {@link isStringSelectMenu} instead. */
public isSelectMenu(): this is StringSelectMenuInteraction<Cached>;
public isAnySelectMenu(): this is AnySelectMenuInteraction<Cached>;
public isStringSelectMenu(): this is StringSelectMenuInteraction<Cached>;
@@ -1729,7 +1733,7 @@ export class InteractionWebhook extends PartialWebhookMixin() {
public send(options: string | MessagePayload | InteractionReplyOptions): Promise<Message>;
public editMessage(
message: MessageResolvable | '@original',
options: string | MessagePayload | WebhookEditMessageOptions,
options: string | MessagePayload | WebhookMessageEditOptions,
): Promise<Message>;
public fetchMessage(message: Snowflake | '@original'): Promise<Message>;
}
@@ -2055,8 +2059,8 @@ export class MessageMentions<InGuild extends boolean = boolean> {
export type MessagePayloadOption =
| MessageCreateOptions
| MessageEditOptions
| WebhookCreateMessageOptions
| WebhookEditMessageOptions
| WebhookMessageCreateOptions
| WebhookMessageEditOptions
| InteractionReplyOptions
| InteractionUpdateOptions;
@@ -2253,7 +2257,7 @@ export class ForumChannel extends TextBasedChannelMixin(GuildChannel, true, [
public setAvailableTags(tags: GuildForumTagData[], reason?: string): Promise<this>;
public setDefaultReactionEmoji(emojiId: DefaultReactionEmoji | null, reason?: string): Promise<this>;
public setDefaultThreadRateLimitPerUser(rateLimit: number, reason?: string): Promise<this>;
public createInvite(options?: CreateInviteOptions): Promise<Invite>;
public createInvite(options?: InviteCreateOptions): Promise<Invite>;
public fetchInvites(cache?: boolean): Promise<Collection<string, Invite>>;
public setDefaultAutoArchiveDuration(
defaultAutoArchiveDuration: ThreadAutoArchiveDuration,
@@ -2381,7 +2385,7 @@ export class Role extends Base {
public icon: string | null;
public unicodeEmoji: string | null;
public delete(reason?: string): Promise<Role>;
public edit(data: EditRoleOptions): Promise<Role>;
public edit(options: RoleEditOptions): Promise<Role>;
public equals(role: Role): boolean;
public iconURL(options?: ImageURLOptions): string | null;
public permissionsIn(
@@ -2703,7 +2707,7 @@ export class Sticker extends Base {
public fetch(): Promise<Sticker>;
public fetchPack(): Promise<StickerPack | null>;
public fetchUser(): Promise<User | null>;
public edit(data?: GuildStickerEditData): Promise<Sticker>;
public edit(options?: GuildStickerEditOptions): Promise<Sticker>;
public delete(reason?: string): Promise<Sticker>;
public equals(other: Sticker | unknown): boolean;
}
@@ -2881,7 +2885,7 @@ export class ThreadChannel<Forum extends boolean = boolean> extends TextBasedCha
public type: ThreadChannelType;
public get unarchivable(): boolean;
public delete(reason?: string): Promise<this>;
public edit(data: ThreadEditData): Promise<AnyThreadChannel>;
public edit(options: ThreadEditOptions): Promise<AnyThreadChannel>;
public join(): Promise<AnyThreadChannel>;
public leave(): Promise<AnyThreadChannel>;
public permissionsFor(memberOrRole: GuildMember | Role, checkAdmin?: boolean): Readonly<PermissionsBitField>;
@@ -3052,12 +3056,12 @@ export interface MappedComponentTypes {
[ComponentType.TextInput]: TextInputComponent;
}
export interface CreateChannelOptions {
export interface ChannelCreateOptions {
allowFromUnknownGuild?: boolean;
fromInteraction?: boolean;
}
export function createChannel(client: Client<true>, data: APIChannel, options?: CreateChannelOptions): Channel;
export function createChannel(client: Client<true>, data: APIChannel, options?: ChannelCreateOptions): Channel;
export function createComponent<T extends keyof MappedComponentTypes>(
data: APIMessageComponent & { type: T },
@@ -3162,7 +3166,7 @@ export class VoiceState extends Base {
public setChannel(channel: GuildVoiceChannelResolvable | null, reason?: string): Promise<GuildMember>;
public setRequestToSpeak(request?: boolean): Promise<this>;
public setSuppressed(suppressed?: boolean): Promise<this>;
public edit(data: VoiceStateEditData): Promise<this>;
public edit(options: VoiceStateEditOptions): Promise<this>;
}
export class Webhook extends WebhookMixin() {
@@ -3205,10 +3209,10 @@ export class Webhook extends WebhookMixin() {
public editMessage(
message: MessageResolvable,
options: string | MessagePayload | WebhookEditMessageOptions,
options: string | MessagePayload | WebhookMessageEditOptions,
): Promise<Message>;
public fetchMessage(message: Snowflake, options?: WebhookFetchMessageOptions): Promise<Message>;
public send(options: string | MessagePayload | WebhookCreateMessageOptions): Promise<Message>;
public send(options: string | MessagePayload | WebhookMessageCreateOptions): Promise<Message>;
}
export class WebhookClient extends WebhookMixin(BaseClient) {
@@ -3218,10 +3222,10 @@ export class WebhookClient extends WebhookMixin(BaseClient) {
public token: string;
public editMessage(
message: MessageResolvable,
options: string | MessagePayload | WebhookEditMessageOptions,
options: string | MessagePayload | WebhookMessageEditOptions,
): Promise<APIMessage>;
public fetchMessage(message: Snowflake, options?: WebhookFetchMessageOptions): Promise<APIMessage>;
public send(options: string | MessagePayload | WebhookCreateMessageOptions): Promise<APIMessage>;
public send(options: string | MessagePayload | WebhookMessageCreateOptions): Promise<APIMessage>;
}
export class WebSocketManager extends EventEmitter {
@@ -3785,7 +3789,7 @@ export class GuildEmojiManager extends BaseGuildEmojiManager {
public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, GuildEmoji>>;
public fetchAuthor(emoji: EmojiResolvable): Promise<User>;
public delete(emoji: EmojiResolvable, reason?: string): Promise<void>;
public edit(emoji: EmojiResolvable, data: GuildEmojiEditData): Promise<GuildEmoji>;
public edit(emoji: EmojiResolvable, options: GuildEmojiEditOptions): Promise<GuildEmoji>;
}
export class GuildEmojiRoleManager extends DataManager<Snowflake, Role, RoleResolvable> {
@@ -3824,7 +3828,7 @@ export class GuildMemberManager extends CachedManager<Snowflake, GuildMember, Gu
): Promise<GuildMember | null>;
public add(user: UserResolvable, options: AddGuildMemberOptions): Promise<GuildMember>;
public ban(user: UserResolvable, options?: BanOptions): Promise<GuildMember | User | Snowflake>;
public edit(user: UserResolvable, data: GuildMemberEditData): Promise<GuildMember>;
public edit(user: UserResolvable, options: GuildMemberEditOptions): Promise<GuildMember>;
public fetch(
options: UserResolvable | FetchMemberOptions | (FetchMembersOptions & { user: UserResolvable }),
): Promise<GuildMember>;
@@ -3852,7 +3856,7 @@ export class GuildBanManager extends CachedManager<Snowflake, GuildBan, GuildBan
export class GuildInviteManager extends DataManager<string, Invite, InviteResolvable> {
private constructor(guild: Guild, iterable?: Iterable<RawInviteData>);
public guild: Guild;
public create(channel: GuildInvitableChannelResolvable, options?: CreateInviteOptions): Promise<Invite>;
public create(channel: GuildInvitableChannelResolvable, options?: InviteCreateOptions): Promise<Invite>;
public fetch(options: InviteResolvable | FetchInviteOptions): Promise<Invite>;
public fetch(options?: FetchInvitesOptions): Promise<Collection<string, Invite>>;
public delete(invite: InviteResolvable, reason?: string): Promise<Invite>;
@@ -3885,7 +3889,7 @@ export class GuildStickerManager extends CachedManager<Snowflake, Sticker, Stick
private constructor(guild: Guild, iterable?: Iterable<RawStickerData>);
public guild: Guild;
public create(options: GuildStickerCreateOptions): Promise<Sticker>;
public edit(sticker: StickerResolvable, data?: GuildStickerEditData): Promise<Sticker>;
public edit(sticker: StickerResolvable, data?: GuildStickerEditOptions): Promise<Sticker>;
public delete(sticker: StickerResolvable, reason?: string): Promise<void>;
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<Sticker>;
public fetch(id?: Snowflake, options?: BaseFetchOptions): Promise<Collection<Snowflake, Sticker>>;
@@ -3990,8 +3994,8 @@ export class RoleManager extends CachedManager<Snowflake, Role, RoleResolvable>
public botRoleFor(user: UserResolvable): Role | null;
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<Role | null>;
public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, Role>>;
public create(options?: CreateRoleOptions): Promise<Role>;
public edit(role: RoleResolvable, options: EditRoleOptions): Promise<Role>;
public create(options?: RoleCreateOptions): Promise<Role>;
public edit(role: RoleResolvable, options: RoleEditOptions): Promise<Role>;
public delete(role: RoleResolvable, reason?: string): Promise<void>;
public setPosition(role: RoleResolvable, position: number, options?: SetRolePositionOptions): Promise<Role>;
public setPositions(rolePositions: readonly RolePosition[]): Promise<Guild>;
@@ -4116,11 +4120,11 @@ export interface PartialWebhookFields {
deleteMessage(message: MessageResolvable | APIMessage | '@original', threadId?: Snowflake): Promise<void>;
editMessage(
message: MessageResolvable | '@original',
options: string | MessagePayload | WebhookEditMessageOptions,
options: string | MessagePayload | WebhookMessageEditOptions,
): Promise<APIMessage | Message>;
fetchMessage(message: Snowflake | '@original', options?: WebhookFetchMessageOptions): Promise<APIMessage | Message>;
send(
options: string | MessagePayload | InteractionReplyOptions | WebhookCreateMessageOptions,
options: string | MessagePayload | InteractionReplyOptions | WebhookMessageCreateOptions,
): Promise<APIMessage | Message>;
}
@@ -4128,7 +4132,7 @@ export interface WebhookFields extends PartialWebhookFields {
get createdAt(): Date;
get createdTimestamp(): number;
delete(reason?: string): Promise<void>;
edit(options: WebhookEditData): Promise<Webhook>;
edit(options: WebhookEditOptions): Promise<Webhook>;
sendSlackMessage(body: unknown): Promise<boolean>;
}
@@ -4166,6 +4170,7 @@ export interface BaseApplicationCommandData {
nameLocalizations?: LocalizationMap;
dmPermission?: boolean;
defaultMemberPermissions?: PermissionResolvable | null;
nsfw?: boolean;
}
export interface AttachmentData {
@@ -4733,7 +4738,7 @@ export interface ClientPresenceStatusData {
desktop?: ClientPresenceStatus;
}
export interface ClientUserEditData {
export interface ClientUserEditOptions {
username?: string;
avatar?: BufferResolvable | Base64Resolvable | null;
}
@@ -4939,15 +4944,15 @@ export enum Status {
Resuming = 8,
}
export interface CreateGuildScheduledEventInviteURLOptions extends CreateInviteOptions {
export interface GuildScheduledEventInviteURLCreateOptions extends InviteCreateOptions {
channel?: GuildInvitableChannelResolvable;
}
export interface CreateRoleOptions extends RoleData {
export interface RoleCreateOptions extends RoleData {
reason?: string;
}
export interface EditRoleOptions extends RoleData {
export interface RoleEditOptions extends RoleData {
reason?: string;
}
@@ -4966,7 +4971,7 @@ export interface CrosspostedChannel {
export type DateResolvable = Date | number | string;
export interface EditGuildTemplateOptions {
export interface GuildTemplateEditOptions {
name?: string;
description?: string;
}
@@ -5356,7 +5361,7 @@ export interface GuildWidgetSettings {
channel: TextChannel | NewsChannel | VoiceBasedChannel | ForumChannel | null;
}
export interface GuildEditData {
export interface GuildEditOptions {
name?: string;
verificationLevel?: GuildVerificationLevel | null;
explicitContentFilter?: GuildExplicitContentFilter | null;
@@ -5386,7 +5391,7 @@ export interface GuildEmojiCreateOptions {
reason?: string;
}
export interface GuildEmojiEditData {
export interface GuildEmojiEditOptions {
name?: string;
roles?: Collection<Snowflake, Role> | RoleResolvable[];
reason?: string;
@@ -5400,14 +5405,14 @@ export interface GuildStickerCreateOptions {
reason?: string;
}
export interface GuildStickerEditData {
export interface GuildStickerEditOptions {
name?: string;
description?: string | null;
tags?: string;
reason?: string;
}
export interface GuildMemberEditData {
export interface GuildMemberEditOptions {
nick?: string | null;
roles?: Collection<Snowflake, Role> | readonly RoleResolvable[];
mute?: boolean;
@@ -5567,7 +5572,7 @@ export interface InviteGenerationOptions {
export type GuildInvitableChannelResolvable = TextChannel | VoiceChannel | NewsChannel | StageChannel | Snowflake;
export interface CreateInviteOptions {
export interface InviteCreateOptions {
temporary?: boolean;
maxAge?: number;
maxUses?: number;
@@ -6109,7 +6114,7 @@ export interface GuildForumThreadCreateOptions extends StartThreadOptions {
appliedTags?: Snowflake[];
}
export interface ThreadEditData {
export interface ThreadEditOptions {
name?: string;
archived?: boolean;
autoArchiveDuration?: ThreadAutoArchiveDuration;
@@ -6136,7 +6141,7 @@ export type VoiceBasedChannelTypes = VoiceBasedChannel['type'];
export type VoiceChannelResolvable = Snowflake | VoiceChannel;
export interface VoiceStateEditData {
export interface VoiceStateEditOptions {
requestToSpeak?: boolean;
suppressed?: boolean;
}
@@ -6154,18 +6159,18 @@ export interface WebhookClientDataURL {
export type WebhookClientOptions = Pick<ClientOptions, 'allowedMentions' | 'rest'>;
export interface WebhookEditData {
export interface WebhookEditOptions {
name?: string;
avatar?: BufferResolvable | null;
channel?: GuildTextChannelResolvable;
reason?: string;
}
export interface WebhookEditMessageOptions extends Omit<MessageEditOptions, 'flags'> {
export interface WebhookMessageEditOptions extends Omit<MessageEditOptions, 'flags'> {
threadId?: Snowflake;
}
export interface InteractionEditReplyOptions extends WebhookEditMessageOptions {
export interface InteractionEditReplyOptions extends WebhookMessageEditOptions {
message?: MessageResolvable | '@original';
}
@@ -6173,7 +6178,7 @@ export interface WebhookFetchMessageOptions {
threadId?: Snowflake;
}
export interface WebhookCreateMessageOptions extends Omit<MessageCreateOptions, 'nonce' | 'reply' | 'stickers'> {
export interface WebhookMessageCreateOptions extends Omit<MessageCreateOptions, 'nonce' | 'reply' | 'stickers'> {
username?: string;
avatarURL?: string;
threadId?: Snowflake;
@@ -6209,7 +6214,7 @@ export interface WelcomeChannelData {
emoji?: EmojiIdentifierResolvable;
}
export interface WelcomeScreenEditData {
export interface WelcomeScreenEditOptions {
enabled?: boolean;
description?: string;
welcomeChannels?: WelcomeChannelData[];
@@ -6265,5 +6270,6 @@ export type InternalDiscordGatewayAdapterCreator = (
// External
export * from 'discord-api-types/v10';
export * from '@discordjs/builders';
export * from '@discordjs/formatters';
export * from '@discordjs/rest';
export * from '@discordjs/util';

View File

@@ -48,7 +48,7 @@
"devDependencies": {
"@favware/cliff-jumper": "^1.9.0",
"@types/jsdoc-to-markdown": "^7.0.3",
"@types/node": "16.18.3",
"@types/node": "16.18.4",
"cross-env": "^7.0.3",
"eslint": "^8.28.0",
"eslint-config-neon": "^0.1.40",

View File

@@ -0,0 +1,5 @@
{
"name": "formatters",
"org": "discordjs",
"packagePath": "packages/formatters"
}

View File

@@ -0,0 +1,3 @@
{
"extends": "../../.eslintrc.json"
}

27
packages/formatters/.gitignore vendored Normal file
View File

@@ -0,0 +1,27 @@
# Packages
node_modules/
# Log files
logs/
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Env
.env
# Dist
dist/
typings/
docs/**/*
!docs/index.json
!docs/README.md
# Miscellaneous
.tmp/
coverage/
tsconfig.tsbuildinfo

View File

@@ -0,0 +1 @@
module.exports = require('../../.lintstagedrc.json');

View File

@@ -0,0 +1,8 @@
# Autogenerated
CHANGELOG.md
.turbo
dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/

View File

@@ -0,0 +1 @@
module.exports = require('../../.prettierrc.json');

Some files were not shown because too many files have changed in this diff Show More