mirror of
https://github.com/discordjs/discord.js.git
synced 2026-05-23 12:00:09 +00:00
Compare commits
183 Commits
@discordjs
...
@discordjs
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4bc2667a5f | ||
|
|
84ead6e554 | ||
|
|
0220fb7278 | ||
|
|
6da456767e | ||
|
|
67b30355ea | ||
|
|
58d9024245 | ||
|
|
5cd6382d1d | ||
|
|
fffe625a0c | ||
|
|
7321c291da | ||
|
|
ab3efb0211 | ||
|
|
7fa9ea3f0f | ||
|
|
af0f1aa765 | ||
|
|
99cadfd82b | ||
|
|
8f572a6bad | ||
|
|
d90ba8dce8 | ||
|
|
24fbb11ba2 | ||
|
|
727dc094d5 | ||
|
|
d5be4242c6 | ||
|
|
c1ff545bf1 | ||
|
|
188877c50a | ||
|
|
a1605b3a5e | ||
|
|
9ed1b59df6 | ||
|
|
0a9a3ede29 | ||
|
|
346fa57f95 | ||
|
|
b3c85d34a6 | ||
|
|
d8e37551ce | ||
|
|
a30d46c5f5 | ||
|
|
632a9b4965 | ||
|
|
3b18e5b08d | ||
|
|
692f0fc96d | ||
|
|
0de071d0a5 | ||
|
|
99194fc270 | ||
|
|
cf72d42ea5 | ||
|
|
7295a3a94a | ||
|
|
1af7e5a0bb | ||
|
|
3bc0dce04a | ||
|
|
c40f7540cd | ||
|
|
1fc9308fef | ||
|
|
43d3b48565 | ||
|
|
8d50f2056d | ||
|
|
acc560204f | ||
|
|
ccf65c2d09 | ||
|
|
d04987f09b | ||
|
|
ca5a2626b4 | ||
|
|
3c5a4dc7a7 | ||
|
|
447652ec8a | ||
|
|
488aa58b29 | ||
|
|
a92d19212d | ||
|
|
fd8197fe5b | ||
|
|
8f4256db8a | ||
|
|
6307f81385 | ||
|
|
d26e022afc | ||
|
|
afa98793cd | ||
|
|
386f206caf | ||
|
|
351a18bc35 | ||
|
|
84f1b1890d | ||
|
|
e5effb6f6a | ||
|
|
125405f1cf | ||
|
|
bc83cabfda | ||
|
|
20268ac0c4 | ||
|
|
3c85fb21e6 | ||
|
|
4141405dcd | ||
|
|
8c782bfd52 | ||
|
|
8d97017458 | ||
|
|
ceab07bec8 | ||
|
|
7fb91c57f7 | ||
|
|
09b0382c45 | ||
|
|
719e54a921 | ||
|
|
ede9f4e5e2 | ||
|
|
df40dcdb85 | ||
|
|
53c17e00c0 | ||
|
|
dc73c938ff | ||
|
|
a48d0efb09 | ||
|
|
a73d54e43a | ||
|
|
cf8012c200 | ||
|
|
0803eb562b | ||
|
|
78381a56cf | ||
|
|
6d5840c61e | ||
|
|
75d91b52b3 | ||
|
|
766be94b93 | ||
|
|
b61e4fb0dc | ||
|
|
d64330a157 | ||
|
|
2818d7cc1d | ||
|
|
a6dbe163dd | ||
|
|
73c2f8aa17 | ||
|
|
a873ec1e85 | ||
|
|
db925fa269 | ||
|
|
8f3bd38072 | ||
|
|
8f014c65ef | ||
|
|
1716202f44 | ||
|
|
1cab79f6fd | ||
|
|
7b494aca5b | ||
|
|
cd6986854f | ||
|
|
6c2242f4f9 | ||
|
|
75308f2669 | ||
|
|
bc2798b8ee | ||
|
|
a531dc9f1c | ||
|
|
911e6eff75 | ||
|
|
1ab60f9da4 | ||
|
|
df8b6e9934 | ||
|
|
24a61495b9 | ||
|
|
e1b6eeed0e | ||
|
|
53aa24d418 | ||
|
|
9b06734445 | ||
|
|
9345d1b1ac | ||
|
|
47843493a5 | ||
|
|
6c7a5ed1e7 | ||
|
|
985def3f25 | ||
|
|
1c4a12c7d6 | ||
|
|
8107c5c0e7 | ||
|
|
b85a3f2dde | ||
|
|
3535321b98 | ||
|
|
46167a79d7 | ||
|
|
cffa5d19c9 | ||
|
|
5d6eed6414 | ||
|
|
90e243d350 | ||
|
|
590f5bc38e | ||
|
|
7196fe36e8 | ||
|
|
5351ab429b | ||
|
|
d033f925e0 | ||
|
|
13073acefc | ||
|
|
7c8849fae5 | ||
|
|
d01e8aa8af | ||
|
|
4dcc9c50f8 | ||
|
|
a51c48e743 | ||
|
|
1edd01a7a4 | ||
|
|
7b617bd22e | ||
|
|
0c175c02e9 | ||
|
|
460ac7dfe2 | ||
|
|
64324a8be1 | ||
|
|
b6162bc5b5 | ||
|
|
280ed0ce08 | ||
|
|
5b8d535fd6 | ||
|
|
c4a3120354 | ||
|
|
8482e3c95d | ||
|
|
12482b70ed | ||
|
|
fa746b079d | ||
|
|
fc3f0756a4 | ||
|
|
3bfb6197a0 | ||
|
|
5ecc4f13b5 | ||
|
|
f83a8a58c9 | ||
|
|
9ddb3ff71d | ||
|
|
7ce6bb99e9 | ||
|
|
da6de92e8c | ||
|
|
bbf80efbb0 | ||
|
|
227232112d | ||
|
|
37181ab232 | ||
|
|
cdaa0a36f5 | ||
|
|
fc5b9c523b | ||
|
|
256b68bf9f | ||
|
|
75195cc539 | ||
|
|
8d5ce32080 | ||
|
|
5bfcf93e29 | ||
|
|
28f51791a2 | ||
|
|
e6274681fd | ||
|
|
00da44a120 | ||
|
|
ab39683a50 | ||
|
|
3e80f0b384 | ||
|
|
e53b94c979 | ||
|
|
6b2c3fb9d0 | ||
|
|
d8d21cf370 | ||
|
|
8e9a2b4630 | ||
|
|
d4f12e0a0c | ||
|
|
d7b18f0681 | ||
|
|
166c961261 | ||
|
|
506f7fcd3b | ||
|
|
51d53f5117 | ||
|
|
aa32d67619 | ||
|
|
4b077e679c | ||
|
|
c190c57d64 | ||
|
|
423bfce286 | ||
|
|
5d05b7230a | ||
|
|
7e875f6919 | ||
|
|
c429763be8 | ||
|
|
1b7981e469 | ||
|
|
f2ad0762c5 | ||
|
|
6d7f3b0f5c | ||
|
|
201b002ad4 | ||
|
|
b327f4925f | ||
|
|
e262df9117 | ||
|
|
7a761d4cfb | ||
|
|
ac9bf3ac06 | ||
|
|
133a6bbf49 |
@@ -1,31 +1,33 @@
|
||||
# Packages
|
||||
node_modules/
|
||||
**/node_modules
|
||||
|
||||
# Log files
|
||||
logs/
|
||||
*.log
|
||||
npm-debug.log*
|
||||
**/logs
|
||||
**/*.log
|
||||
**/npm-debug.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
**/pids
|
||||
**/*.pid
|
||||
**/*.seed
|
||||
|
||||
# Env
|
||||
.env
|
||||
**/.env
|
||||
|
||||
# Dist
|
||||
dist/
|
||||
**/dist/
|
||||
**/dist-docs/
|
||||
|
||||
# Miscellaneous
|
||||
.tmp/
|
||||
.vscode/*
|
||||
.idea/
|
||||
.DS_Store
|
||||
.turbo
|
||||
tsconfig.tsbuildinfo
|
||||
coverage/
|
||||
__tests__/
|
||||
**/.tmp
|
||||
**/.vscode
|
||||
**/.idea
|
||||
**/.DS_Store
|
||||
**/.turbo
|
||||
**/tsconfig.tsbuildinfo
|
||||
**/coverage
|
||||
**/__tests__
|
||||
**/out
|
||||
|
||||
# yarn
|
||||
.pnp.*
|
||||
@@ -37,20 +39,29 @@ __tests__/
|
||||
!.yarn/versions
|
||||
|
||||
# Cache
|
||||
.prettiercache
|
||||
.eslintcache
|
||||
**/.prettiercache
|
||||
**/.eslintcache
|
||||
**/.vercel
|
||||
|
||||
# Docker specific
|
||||
.cliff-jumperrc.json
|
||||
api-extractor.json
|
||||
.eslintrc.json
|
||||
.lintstagedrc.cjs
|
||||
.lintstagedrc.cjs
|
||||
.prettierignore
|
||||
.prettierrc.js
|
||||
.prettierrc.cjs
|
||||
cliff.toml
|
||||
CHANGELOG.md
|
||||
README.md
|
||||
tsconfig.eslint.json
|
||||
docs/
|
||||
**/.cliff-jumperrc.json
|
||||
**/api-extractor.json
|
||||
**/api-extractor-docs.json
|
||||
**/.eslintignore
|
||||
**/.eslintrc.json
|
||||
**/.lintstagedrc.js
|
||||
**/.lintstagedrc.cjs
|
||||
**/.lintstagedrc.json
|
||||
**/.prettierignore
|
||||
**/.prettierrc.js
|
||||
**/.prettierrc.cjs
|
||||
**/.prettierrc.json
|
||||
**/cliff.toml
|
||||
**/CHANGELOG.md
|
||||
**/README.md
|
||||
**/LICENSE
|
||||
**/tsconfig.eslint.json
|
||||
**/tsconfig.docs.json
|
||||
**/docs/
|
||||
**/vitest.config.ts
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"root": true,
|
||||
"extends": ["neon/common", "neon/node", "neon/typescript", "neon/prettier"],
|
||||
"parserOptions": {
|
||||
"project": "./tsconfig.eslint.json"
|
||||
"project": ["./tsconfig.eslint.json", "./apps/*/tsconfig.eslint.json", "./packages/*/tsconfig.eslint.json"]
|
||||
},
|
||||
"rules": {
|
||||
"@typescript-eslint/consistent-type-definitions": ["error", "interface"]
|
||||
|
||||
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@@ -13,6 +13,7 @@
|
||||
/packages/builders/ @discordjs/builders
|
||||
/packages/collection/ @discordjs/collection
|
||||
/packages/core/ @discordjs/core
|
||||
/packages/create-discord-bot/ @discordjs/guide
|
||||
/packages/discord.js/ @discordjs/core
|
||||
/packages/docgen/ @iCrawl
|
||||
/packages/formatters/ @discordjs/formatters
|
||||
|
||||
2
.github/CONTRIBUTING.md
vendored
2
.github/CONTRIBUTING.md
vendored
@@ -45,4 +45,4 @@ yarn create-package <package-name> [package-description]
|
||||
```
|
||||
|
||||
This will create new package directory under `packages/` with the required configuration files. You can
|
||||
begin to make changes within the `src/` directory.
|
||||
begin to make changes within the `src/` directory. It may also be required to update the CODEOWNERS file.
|
||||
|
||||
@@ -18,11 +18,14 @@ body:
|
||||
- builders
|
||||
- collection
|
||||
- core
|
||||
- create-discord-bot
|
||||
- formatters
|
||||
- next
|
||||
- proxy
|
||||
- proxy-container
|
||||
- rest
|
||||
- ui
|
||||
- util
|
||||
- voice
|
||||
- ws
|
||||
validations:
|
||||
@@ -58,9 +61,9 @@ body:
|
||||
label: Versions
|
||||
description: List necessary versions here. This includes your package version, runtime version, operating system etc.
|
||||
placeholder: |
|
||||
- discord.js 14.9.0 (`npm ls discord.js` or another package)
|
||||
- Node.js 16.9.0 (`node --version`)
|
||||
- TypeScript 5.0.4 (`npm ls typescript` if you use it)
|
||||
- discord.js 14.12.1 (`npm ls discord.js` or another package)
|
||||
- Node.js 16.11.0 (`node --version`)
|
||||
- TypeScript 5.1.6 (`npm ls typescript` if you use it)
|
||||
- macOS Ventura 13.3.1
|
||||
validations:
|
||||
required: true
|
||||
|
||||
@@ -20,11 +20,14 @@ body:
|
||||
- builders
|
||||
- collection
|
||||
- core
|
||||
- create-discord-bot
|
||||
- formatters
|
||||
- next
|
||||
- proxy
|
||||
- proxy-container
|
||||
- rest
|
||||
- ui
|
||||
- util
|
||||
- voice
|
||||
- ws
|
||||
validations:
|
||||
|
||||
9
.github/issue-labeler.yml
vendored
9
.github/issue-labeler.yml
vendored
@@ -16,6 +16,9 @@ packages:collection:
|
||||
packages:core:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\ncore\\n"
|
||||
packages:create-discord-bot:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\ncreate-discord-bot\\n"
|
||||
packages:discord.js:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\ndiscord.js\\n"
|
||||
@@ -34,6 +37,12 @@ packages:proxy-container:
|
||||
packages:rest:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\nrest\\n"
|
||||
packages:ui:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\ui\\n"
|
||||
packages:util:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\util\\n"
|
||||
packages:voice:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\nvoice\\n"
|
||||
|
||||
9
.github/labeler.yml
vendored
9
.github/labeler.yml
vendored
@@ -16,18 +16,21 @@ packages:collection:
|
||||
packages:core:
|
||||
- packages/core/*
|
||||
- packages/core/**/*
|
||||
packages:create-discord-bot:
|
||||
- packages/create-discord-bot/*
|
||||
- packages/create-discord-bot/**/*
|
||||
packages:discord.js:
|
||||
- packages/discord.js/*
|
||||
- packages/discord.js/**/*
|
||||
packages:next:
|
||||
- packages/next/*
|
||||
- packages/next/**/*
|
||||
packages:docgen:
|
||||
- packages/docgen/*
|
||||
- packages/docgen/**/*
|
||||
packages:formatters:
|
||||
- packages/formatters/*
|
||||
- packages/formatters/**/*
|
||||
packages:next:
|
||||
- packages/next/*
|
||||
- packages/next/**/*
|
||||
packages:proxy:
|
||||
- packages/proxy/*
|
||||
- packages/proxy/**/*
|
||||
|
||||
14
.github/labels.yml
vendored
14
.github/labels.yml
vendored
@@ -1,7 +1,7 @@
|
||||
- name: api changes
|
||||
color: '5663e9'
|
||||
color: 5663e9
|
||||
- name: api support
|
||||
color: '5663e9'
|
||||
color: 5663e9
|
||||
- name: apps:guide
|
||||
color: fbca04
|
||||
- name: apps:website
|
||||
@@ -23,7 +23,7 @@
|
||||
- name: dependencies
|
||||
color: 276bd1
|
||||
- name: discord
|
||||
color: '5663e9'
|
||||
color: 5663e9
|
||||
- name: discussion
|
||||
color: b6b1f9
|
||||
- name: documentation
|
||||
@@ -41,7 +41,7 @@
|
||||
- name: has PR
|
||||
color: 4b1f8e
|
||||
- name: help wanted
|
||||
color: '008672'
|
||||
color: 008672
|
||||
- name: in progress
|
||||
color: ffccd7
|
||||
- name: in review
|
||||
@@ -60,14 +60,16 @@
|
||||
color: fbca04
|
||||
- name: packages:core
|
||||
color: fbca04
|
||||
- name: packages:discord.js
|
||||
- name: packages:create-discord-bot
|
||||
color: fbca04
|
||||
- name: packages:next
|
||||
- name: packages:discord.js
|
||||
color: fbca04
|
||||
- name: packages:docgen
|
||||
color: fbca04
|
||||
- name: packages:formatters
|
||||
color: fbca04
|
||||
- name: packages:next
|
||||
color: fbca04
|
||||
- name: packages:proxy
|
||||
color: fbca04
|
||||
- name: packages:proxy-container
|
||||
|
||||
BIN
.github/powered-by-workers.png
vendored
Normal file
BIN
.github/powered-by-workers.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
7
.github/workflows/publish-dev-docker.yml
vendored
7
.github/workflows/publish-dev-docker.yml
vendored
@@ -29,8 +29,5 @@ jobs:
|
||||
- name: Login to DockerHub
|
||||
run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
|
||||
|
||||
- name: Build the image
|
||||
run: yarn docker build @discordjs/proxy-container -t discordjs/proxy:latest
|
||||
|
||||
- name: Push image to DockerHub
|
||||
run: docker push discordjs/proxy:latest
|
||||
- name: Build & push docker image
|
||||
run: yarn docker build --buildkit @discordjs/proxy-container -t discordjs/proxy:latest --push
|
||||
|
||||
2
.github/workflows/publish-dev.yml
vendored
2
.github/workflows/publish-dev.yml
vendored
@@ -42,6 +42,8 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install node.js v18
|
||||
uses: actions/setup-node@v3
|
||||
|
||||
10
.github/workflows/publish-docker.yml
vendored
10
.github/workflows/publish-docker.yml
vendored
@@ -26,11 +26,5 @@ jobs:
|
||||
- name: Login to DockerHub
|
||||
run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
|
||||
|
||||
- name: Build docker image
|
||||
run: yarn docker build @discordjs/proxy-container -t discordjs/proxy:latest
|
||||
|
||||
- name: Tag image with major
|
||||
run: docker tag discordjs/proxy discordjs/proxy:$(cut -d '.' -f1 <<< $(jq --raw-output '.version' packages/proxy-container/package.json))
|
||||
|
||||
- name: Push image to DockerHub
|
||||
run: docker push --all-tags discordjs/proxy
|
||||
- name: Build & push docker image
|
||||
run: yarn docker build --buildkit @discordjs/proxy-container -t discordjs/proxy:$(cut -d '.' -f1 <<< $(jq --raw-output '.version' packages/proxy-container/package.json)) --push
|
||||
|
||||
18
.gitignore
vendored
18
.gitignore
vendored
@@ -1,8 +1,8 @@
|
||||
# Packages
|
||||
node_modules/
|
||||
node_modules
|
||||
|
||||
# Log files
|
||||
logs/
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
@@ -15,20 +15,20 @@ pids
|
||||
.env
|
||||
|
||||
# Dist
|
||||
dist/
|
||||
dist-docs/
|
||||
dist
|
||||
dist-docs
|
||||
|
||||
# Miscellaneous
|
||||
.tmp/
|
||||
.vscode/*
|
||||
.tmp
|
||||
.vscode
|
||||
!.vscode/extensions.json
|
||||
!.vscode/settings.json
|
||||
.idea/
|
||||
.idea
|
||||
.DS_Store
|
||||
.turbo
|
||||
tsconfig.tsbuildinfo
|
||||
coverage/
|
||||
out/
|
||||
coverage
|
||||
out
|
||||
|
||||
# yarn
|
||||
.pnp.*
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
CODEOWNERS
|
||||
CHANGELOG.md
|
||||
|
||||
@@ -215,7 +215,8 @@ module.exports = {
|
||||
await c({ workspace: e, report: t, destination: u });
|
||||
});
|
||||
}
|
||||
await i.execUtils.pipevp('docker', ['build', ...this.args, '-f', s, '.'], {
|
||||
const h = this.buildKit ? ['buildx', 'build'] : ['build'];
|
||||
await i.execUtils.pipevp('docker', [...h, ...this.args, '-f', s, '.'], {
|
||||
cwd: o,
|
||||
strict: !0,
|
||||
stdin: this.context.stdin,
|
||||
@@ -241,6 +242,7 @@ module.exports = {
|
||||
'yarn docker build --copy secret.key --copy config.json @foo/bar',
|
||||
],
|
||||
['Install production dependencies only', 'yarn docker build --production @foo/bar'],
|
||||
['Build a Docker image using BuildKit', 'yarn docker build --buildkit @foo/bar'],
|
||||
],
|
||||
})),
|
||||
d([r.Command.String()], f.prototype, 'workspaceName', void 0),
|
||||
@@ -248,6 +250,7 @@ module.exports = {
|
||||
d([r.Command.String('-f,--file')], f.prototype, 'dockerFilePath', void 0),
|
||||
d([r.Command.Array('--copy')], f.prototype, 'copyFiles', void 0),
|
||||
d([r.Command.Boolean('--production')], f.prototype, 'production', void 0),
|
||||
d([r.Command.Boolean('--buildkit')], f.prototype, 'buildKit', void 0),
|
||||
d([r.Command.Path('docker', 'build')], f.prototype, 'execute', null);
|
||||
const u = { commands: [f] };
|
||||
plugin = e;
|
||||
|
||||
222
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
222
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
17
.yarnrc.yml
17
.yarnrc.yml
@@ -1,3 +1,13 @@
|
||||
logFilters:
|
||||
- code: YN0002
|
||||
level: discard
|
||||
- code: YN0013
|
||||
level: discard
|
||||
- code: YN0032
|
||||
level: discard
|
||||
- code: YN0060
|
||||
level: discard
|
||||
|
||||
nodeLinker: node-modules
|
||||
|
||||
plugins:
|
||||
@@ -10,9 +20,4 @@ plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-docker-build.cjs
|
||||
spec: 'https://github.com/Dcard/yarn-plugins/releases/latest/download/plugin-docker-build.js'
|
||||
|
||||
yarnPath: .yarn/releases/yarn-3.5.0.cjs
|
||||
|
||||
packageExtensions:
|
||||
'@storybook/core-common@*':
|
||||
dependencies:
|
||||
'@storybook/react-vite': '7.0.7'
|
||||
yarnPath: .yarn/releases/yarn-3.6.1.cjs
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
1
apps/guide/.eslintignore
Normal file
1
apps/guide/.eslintignore
Normal file
@@ -0,0 +1 @@
|
||||
next-env.d.ts
|
||||
21
apps/guide/.gitignore
vendored
21
apps/guide/.gitignore
vendored
@@ -1,8 +1,8 @@
|
||||
# Packages
|
||||
node_modules/
|
||||
node_modules
|
||||
|
||||
# Log files
|
||||
logs/
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
@@ -16,18 +16,13 @@ pids
|
||||
.env*.local
|
||||
|
||||
# Dist
|
||||
dist/
|
||||
typings/
|
||||
.cache/
|
||||
build/
|
||||
.contentlayer
|
||||
.next
|
||||
public/searchIndex
|
||||
src/styles/unocss.css
|
||||
.next/
|
||||
|
||||
# Miscellaneous
|
||||
.tmp/
|
||||
coverage/
|
||||
.vercel
|
||||
public/searchIndex
|
||||
.tmp
|
||||
.vscode
|
||||
lighthouse-results/
|
||||
.contentlayer
|
||||
lighthouse-results
|
||||
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
# Autogenerated
|
||||
CHANGELOG.md
|
||||
.contentlayer
|
||||
.next
|
||||
.turbo
|
||||
dist/
|
||||
docs/**/*
|
||||
!docs/index.yml
|
||||
!docs/README.md
|
||||
coverage/
|
||||
.cache
|
||||
build/
|
||||
.vscode
|
||||
coverage
|
||||
src/styles/unocss.css
|
||||
api/
|
||||
.next/
|
||||
.vercel/
|
||||
.cache/
|
||||
next-env.d.ts
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -7,15 +7,14 @@
|
||||
"test": "vitest run",
|
||||
"test:lighthouse": "lighthouse http://localhost:3000 --output-path=./lighthouse-results",
|
||||
"build:local": "yarn build:prod",
|
||||
"build:prod": "yarn workspaces foreach -ptR run build && yarn build:css && yarn build:next",
|
||||
"build:prod": "yarn build:css && yarn build:next",
|
||||
"build:next": "next build",
|
||||
"build:css": "yarn generate:css",
|
||||
"build:analyze": "cross-env-shell ANALYZE=true yarn build:prod",
|
||||
"build:analyze": "cross-env ANALYZE=true yarn build:prod",
|
||||
"preview": "next start",
|
||||
"dev": "concurrently 'yarn dev:contentlayer' 'yarn dev:css' 'yarn dev:next'",
|
||||
"dev": "concurrently 'yarn dev:css' 'yarn dev:next'",
|
||||
"dev:next": "next dev",
|
||||
"dev:css": "yarn generate:css --watch",
|
||||
"dev:contentlayer": "contentlayer dev",
|
||||
"generate:css": "unocss 'src/**/*.tsx' 'contentlayer.config.ts' '../../packages/ui/src/lib/components/**/*.tsx' --out-file ./src/styles/unocss.css --config ../../unocss.config.ts",
|
||||
"lint": "prettier --check . && cross-env TIMING=1 eslint src --ext .mjs,.js,.cjs,.ts,.tsx --format=pretty",
|
||||
"format": "prettier --write . && cross-env TIMING=1 eslint src --ext .mjs,.js,.cjs,.ts,.tsx --fix --format=pretty",
|
||||
@@ -45,58 +44,55 @@
|
||||
},
|
||||
"homepage": "https://discord.js.org",
|
||||
"dependencies": {
|
||||
"@code-hike/mdx": "^0.8.2",
|
||||
"@code-hike/mdx": "^0.9.0",
|
||||
"@discordjs/ui": "workspace:^",
|
||||
"@react-icons/all-files": "^4.1.0",
|
||||
"@vercel/analytics": "^1.0.0",
|
||||
"@vercel/edge-config": "^0.1.8",
|
||||
"@vercel/og": "^0.5.4",
|
||||
"@vercel/analytics": "^1.0.2",
|
||||
"@vercel/edge-config": "^0.2.1",
|
||||
"@vercel/og": "^0.5.11",
|
||||
"ariakit": "^2.0.0-next.44",
|
||||
"cmdk": "^0.2.0",
|
||||
"contentlayer": "^0.3.2",
|
||||
"next": "^13.3.4",
|
||||
"next-contentlayer": "^0.3.2",
|
||||
"contentlayer": "0.3.1",
|
||||
"next": "^13.4.17",
|
||||
"next-contentlayer": "0.3.1",
|
||||
"next-themes": "^0.2.1",
|
||||
"react": "^18.2.0",
|
||||
"react-custom-scrollbars-2": "^4.5.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-use": "^17.4.0",
|
||||
"rehype-autolink-headings": "^6.1.1",
|
||||
"rehype-ignore": "^1.0.5",
|
||||
"rehype-raw": "^6.1.1",
|
||||
"rehype-slug": "^5.1.0",
|
||||
"remark-gfm": "^3.0.1",
|
||||
"server-only": "^0.0.1",
|
||||
"sharp": "^0.32.1"
|
||||
"sharp": "^0.32.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@next/bundle-analyzer": "^13.3.4",
|
||||
"@next/bundle-analyzer": "^13.4.17",
|
||||
"@testing-library/react": "^14.0.0",
|
||||
"@testing-library/user-event": "^14.4.3",
|
||||
"@types/html-escaper": "^3.0.0",
|
||||
"@types/node": "18.16.3",
|
||||
"@types/react": "^18.2.0",
|
||||
"@types/react-dom": "^18.2.1",
|
||||
"@unocss/cli": "^0.51.8",
|
||||
"@unocss/eslint-config": "^0.51.8",
|
||||
"@unocss/reset": "^0.51.8",
|
||||
"@vitejs/plugin-react": "^4.0.0",
|
||||
"@vitest/coverage-c8": "^0.30.1",
|
||||
"concurrently": "^8.0.1",
|
||||
"@types/node": "18.17.5",
|
||||
"@types/react": "^18.2.20",
|
||||
"@types/react-dom": "^18.2.7",
|
||||
"@unocss/cli": "^0.55.1",
|
||||
"@unocss/eslint-config": "^0.55.1",
|
||||
"@unocss/reset": "^0.55.1",
|
||||
"@vitejs/plugin-react": "^4.0.4",
|
||||
"@vitest/coverage-v8": "^0.34.2",
|
||||
"concurrently": "^8.2.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.39.0",
|
||||
"eslint-config-neon": "^0.1.42",
|
||||
"eslint": "^8.47.0",
|
||||
"eslint-config-neon": "^0.1.47",
|
||||
"eslint-formatter-pretty": "^5.0.0",
|
||||
"happy-dom": "^9.10.1",
|
||||
"happy-dom": "^10.10.2",
|
||||
"hast-util-to-string": "^2.0.0",
|
||||
"hastscript": "^7.2.0",
|
||||
"html-escaper": "^3.0.3",
|
||||
"lighthouse": "^10.1.1",
|
||||
"lighthouse": "^10.4.0",
|
||||
"prettier": "^2.8.8",
|
||||
"typescript": "^5.0.4",
|
||||
"unocss": "^0.51.8",
|
||||
"vercel": "^29.0.3",
|
||||
"vitest": "^0.29.8"
|
||||
"turbo": "^1.10.12",
|
||||
"typescript": "^5.1.6",
|
||||
"unocss": "^0.55.1",
|
||||
"vercel": "^31.4.0",
|
||||
"vitest": "^0.34.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.13.0"
|
||||
|
||||
BIN
apps/guide/public/assets/integrations-tab.png
Normal file
BIN
apps/guide/public/assets/integrations-tab.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 164 KiB |
BIN
apps/guide/public/assets/integrations-view-tab.png
Normal file
BIN
apps/guide/public/assets/integrations-view-tab.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
BIN
apps/guide/public/assets/webhook.png
Normal file
BIN
apps/guide/public/assets/webhook.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
@@ -3,7 +3,7 @@
|
||||
import { Providers } from './providers';
|
||||
import { inter } from '~/util/fonts';
|
||||
|
||||
export default function GlobalError({ error }: { error: Error }) {
|
||||
export default function GlobalError({ error }: { readonly error: Error }) {
|
||||
console.error(error);
|
||||
|
||||
return (
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
export default function Error({ error }: { error: Error }) {
|
||||
export default function Error({ error }: { readonly error: Error }) {
|
||||
console.error(error);
|
||||
|
||||
return (
|
||||
|
||||
@@ -6,7 +6,7 @@ export async function generateStaticParams() {
|
||||
return allContents.map((content) => ({ slug: [content.slug] }));
|
||||
}
|
||||
|
||||
export default function Page({ params }: { params: { slug: string[] } }) {
|
||||
export default function Page({ params }: { readonly params: { slug: string[] } }) {
|
||||
const content = allContents.find((content) => content.slug === params.slug?.join('/'));
|
||||
|
||||
if (!content) {
|
||||
@@ -14,7 +14,7 @@ export default function Page({ params }: { params: { slug: string[] } }) {
|
||||
}
|
||||
|
||||
return (
|
||||
<article className="max-w-none prose">
|
||||
<article className="max-w-none px-5 prose">
|
||||
<Mdx code={content?.body.code ?? ''} />
|
||||
</article>
|
||||
);
|
||||
|
||||
BIN
apps/guide/src/assets/powered-by-workers.png
Normal file
BIN
apps/guide/src/assets/powered-by-workers.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
91
apps/guide/src/components/DiscordAPITypesLink.tsx
Normal file
91
apps/guide/src/components/DiscordAPITypesLink.tsx
Normal file
@@ -0,0 +1,91 @@
|
||||
import { FiExternalLink } from '@react-icons/all-files/fi/FiExternalLink';
|
||||
import type { PropsWithChildren } from 'react';
|
||||
import {
|
||||
BASE_URL_DISCORD_API_TYPES,
|
||||
DISCORD_API_TYPES_VERSION,
|
||||
DISCORD_API_TYPES_VOICE_VERSION,
|
||||
} from '~/util/constants';
|
||||
|
||||
interface DiscordAPITypesLinkOptions {
|
||||
/**
|
||||
* The initial documentation enum, interface, function etc.
|
||||
*
|
||||
* @example `'RESTJSONErrorCodes'`
|
||||
*/
|
||||
readonly parent?: string;
|
||||
/**
|
||||
* The scope of where this link lives.
|
||||
*
|
||||
* @remarks API does not have a scope.
|
||||
*/
|
||||
readonly scope?: 'gateway' | 'globals' | 'payloads' | 'rest' | 'rpc' | 'utils' | 'voice';
|
||||
/**
|
||||
* The symbol belonging to the parent.
|
||||
*
|
||||
* @example '`MaximumNumberOfGuildsReached'`
|
||||
*/
|
||||
readonly symbol?: string;
|
||||
/**
|
||||
* The type of the {@link DiscordAPITypesLinkOptions.parent}.
|
||||
*
|
||||
* @example `'enum'`
|
||||
* @example `'interface'`
|
||||
*/
|
||||
readonly type?: string;
|
||||
}
|
||||
|
||||
export function DiscordAPITypesLink({
|
||||
parent,
|
||||
scope,
|
||||
symbol,
|
||||
type,
|
||||
children,
|
||||
}: PropsWithChildren<DiscordAPITypesLinkOptions>) {
|
||||
let url = BASE_URL_DISCORD_API_TYPES;
|
||||
let text = 'discord-api-types';
|
||||
|
||||
if (type || parent) {
|
||||
url += `/api/discord-api-types`;
|
||||
|
||||
switch (scope) {
|
||||
case 'globals':
|
||||
url += `-${scope}`;
|
||||
break;
|
||||
case 'gateway':
|
||||
case 'payloads':
|
||||
case 'rest':
|
||||
url += `-${scope}/common`;
|
||||
break;
|
||||
case 'rpc':
|
||||
case 'utils':
|
||||
url += `-${scope}/${DISCORD_API_TYPES_VERSION}`;
|
||||
break;
|
||||
case 'voice':
|
||||
url += `-${scope}/${DISCORD_API_TYPES_VOICE_VERSION}`;
|
||||
break;
|
||||
default:
|
||||
url += `-${DISCORD_API_TYPES_VERSION}`;
|
||||
}
|
||||
|
||||
if (type) {
|
||||
url += `/${type}/${parent}`;
|
||||
if (symbol) url += `#${symbol}`;
|
||||
} else {
|
||||
url += `#${parent}`;
|
||||
}
|
||||
|
||||
text = `${parent}${symbol ? `#${symbol}` : ''}${type?.toUpperCase() === 'FUNCTION' ? '()' : ''}`;
|
||||
}
|
||||
|
||||
return (
|
||||
<a
|
||||
className="inline-flex flex-row place-items-center gap-1"
|
||||
href={url}
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
{children ?? text}
|
||||
<FiExternalLink size={18} />
|
||||
</a>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { FiExternalLink } from '@react-icons/all-files/fi/FiExternalLink';
|
||||
import type { PropsWithChildren } from 'react';
|
||||
import { BASE_URL, BASE_URL_LEGACY, PACKAGES, VERSION } from '~/util/constants';
|
||||
|
||||
interface DocsLinkOptions {
|
||||
@@ -7,19 +8,19 @@ interface DocsLinkOptions {
|
||||
*
|
||||
* @remarks Functions automatically infer this.
|
||||
*/
|
||||
brackets?: boolean;
|
||||
readonly brackets?: boolean;
|
||||
/**
|
||||
* The package.
|
||||
*
|
||||
* @defaultValue `'discord.js'`
|
||||
*/
|
||||
package?: (typeof PACKAGES)[number];
|
||||
readonly package?: (typeof PACKAGES)[number];
|
||||
/**
|
||||
* The initial documentation class, function, interface etc.
|
||||
*
|
||||
* @example `'Client'`
|
||||
*/
|
||||
parent: string;
|
||||
readonly parent?: string;
|
||||
/**
|
||||
* Whether to reference a static property.
|
||||
*
|
||||
@@ -27,20 +28,20 @@ interface DocsLinkOptions {
|
||||
* This should only be used for the https://discord.js.org domain
|
||||
* as static properties are not identified in the URL.
|
||||
*/
|
||||
static?: boolean;
|
||||
readonly static?: boolean;
|
||||
/**
|
||||
* The symbol belonging to the parent.
|
||||
*
|
||||
* @example '`login'`
|
||||
*/
|
||||
symbol?: string;
|
||||
readonly symbol?: string;
|
||||
/**
|
||||
* The type of the {@link DocsLinkOptions.parent}.
|
||||
*
|
||||
* @example `'class'`
|
||||
* @example `'Function'`
|
||||
*/
|
||||
type: string;
|
||||
readonly type?: string;
|
||||
}
|
||||
|
||||
export function DocsLink({
|
||||
@@ -50,29 +51,35 @@ export function DocsLink({
|
||||
symbol,
|
||||
brackets,
|
||||
static: staticReference,
|
||||
}: DocsLinkOptions) {
|
||||
const bracketText = brackets || type.toUpperCase() === 'FUNCTION' ? '()' : '';
|
||||
const trimmedSymbol = symbol;
|
||||
let url;
|
||||
let text;
|
||||
children,
|
||||
}: PropsWithChildren<DocsLinkOptions>) {
|
||||
// In the case of no type and no parent, this will default to the entry point of the respective documentation.
|
||||
let url = docs === PACKAGES[0] ? `${BASE_URL_LEGACY}/${VERSION}/general/welcome` : `${BASE_URL}/${docs}/stable`;
|
||||
let text = `${docs === PACKAGES[0] ? '' : '@discordjs/'}${docs}`;
|
||||
|
||||
if (docs === PACKAGES[0]) {
|
||||
url = `${BASE_URL_LEGACY}/${VERSION}/${type}/${parent}`;
|
||||
if (trimmedSymbol) url += `?scrollTo=${trimmedSymbol}`;
|
||||
// If there is a type and parent, we need to do some parsing.
|
||||
if (type && parent) {
|
||||
const bracketText = brackets || type?.toUpperCase() === 'FUNCTION' ? '()' : '';
|
||||
|
||||
text = `${parent}${trimmedSymbol ? (trimmedSymbol.startsWith('s-') ? '.' : '#') : ''}${
|
||||
// eslint-disable-next-line prefer-named-capture-group
|
||||
trimmedSymbol ? `${trimmedSymbol.replace(/(e|s)-/, '')}` : ''
|
||||
}${bracketText}`;
|
||||
} else {
|
||||
url = `${BASE_URL}/${docs}/stable/${parent}:${type}`;
|
||||
if (trimmedSymbol) url += `#${trimmedSymbol}`;
|
||||
text = `${parent}${trimmedSymbol ? `${staticReference ? '.' : '#'}${trimmedSymbol}` : ''}${bracketText}`;
|
||||
// Legacy discord.js documentation parsing.
|
||||
if (docs === PACKAGES[0]) {
|
||||
url = `${BASE_URL_LEGACY}/${VERSION}/${type}/${parent}`;
|
||||
if (symbol) url += `?scrollTo=${symbol}`;
|
||||
|
||||
text = `${parent}${symbol ? (symbol.startsWith('s-') ? '.' : '#') : ''}${
|
||||
// eslint-disable-next-line prefer-named-capture-group
|
||||
symbol ? `${symbol.replace(/(e|s)-/, '')}` : ''
|
||||
}${bracketText}`;
|
||||
} else {
|
||||
url += `/${parent}:${type}`;
|
||||
if (symbol) url += `#${symbol}`;
|
||||
text = `${parent}${symbol ? `${staticReference ? '.' : '#'}${symbol}` : ''}${bracketText}`;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<a className="inline-flex flex-row place-items-center gap-1" href={url} rel="noopener noreferrer" target="_blank">
|
||||
{text}
|
||||
{children ?? text}
|
||||
<FiExternalLink size={18} />
|
||||
</a>
|
||||
);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import Image from 'next/image';
|
||||
import vercelLogo from '~/assets/powered-by-vercel.svg';
|
||||
import workersLogo from '~/assets/powered-by-workers.png';
|
||||
|
||||
export default function Footer() {
|
||||
return (
|
||||
<footer className="md:pl-12 md:pr-12">
|
||||
<div className="mx-auto max-w-6xl flex flex-col place-items-center gap-12 pt-12 lg:place-content-center">
|
||||
<div className="w-full flex flex-col place-content-between place-items-center gap-12 md:flex-row md:gap-0">
|
||||
<div className="flex flex-col flex-wrap place-content-center gap-6 pt-12 sm:flex-row md:gap-12">
|
||||
<div className="flex flex-wrap place-content-center place-items-center gap-4">
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"
|
||||
@@ -22,56 +23,72 @@ export default function Footer() {
|
||||
width={212}
|
||||
/>
|
||||
</a>
|
||||
<div className="flex flex-row gap-6 md:gap-12">
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="text-lg font-semibold">Community</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://discord.gg/djs"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
Discord
|
||||
</a>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://github.com/discordjs/discord.js/discussions"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
GitHub discussions
|
||||
</a>
|
||||
</div>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://www.cloudflare.com"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
title="Cloudflare Workers"
|
||||
>
|
||||
<Image
|
||||
alt="Cloudflare"
|
||||
blurDataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAABLCAQAAAA1k5H2AAAAi0lEQVR42u3SMQEAAAgDoC251a3gL2SgmfBYBRAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARCAgwWEOSWBnYbKggAAAABJRU5ErkJggg=="
|
||||
height={44}
|
||||
placeholder="blur"
|
||||
priority
|
||||
src={workersLogo}
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
<div className="flex flex-col place-self-center gap-6 sm:flex-row md:gap-12">
|
||||
<div className="max-w-max flex flex-col gap-2">
|
||||
<div className="text-lg font-semibold">Community</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://discord.gg/djs"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
Discord
|
||||
</a>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://github.com/discordjs/discord.js/discussions"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
GitHub discussions
|
||||
</a>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="text-lg font-semibold">Project</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://github.com/discordjs/discord.js"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
discord.js
|
||||
</a>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://discord.js.org/docs"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
discord.js documentation
|
||||
</a>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://discord-api-types.dev"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
discord-api-types
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div className="max-w-max flex flex-col gap-2">
|
||||
<div className="text-lg font-semibold">Project</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://github.com/discordjs/discord.js"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
discord.js
|
||||
</a>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://discord.js.org/docs"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
discord.js documentation
|
||||
</a>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://discord-api-types.dev"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
discord-api-types
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { Alert, Section, DiscordMessages, DiscordMessage, DiscordMessageEmbed } from '@discordjs/ui';
|
||||
import { useMDXComponent } from 'next-contentlayer/hooks';
|
||||
import { DiscordAPITypesLink } from './DiscordAPITypesLink';
|
||||
import { H1 } from './H1';
|
||||
import { H2 } from './H2';
|
||||
import { H3 } from './H3';
|
||||
@@ -9,7 +10,7 @@ import { H4 } from './H4';
|
||||
import { DocsLink } from '~/components/DocsLink';
|
||||
import { ResultingCode } from '~/components/ResultingCode';
|
||||
|
||||
export function Mdx({ code }: { code: string }) {
|
||||
export function Mdx({ code }: { readonly code: string }) {
|
||||
const Component = useMDXComponent(code);
|
||||
|
||||
return (
|
||||
@@ -20,6 +21,7 @@ export function Mdx({ code }: { code: string }) {
|
||||
DiscordMessages,
|
||||
DiscordMessage,
|
||||
DiscordMessageEmbed,
|
||||
DiscordAPITypesLink,
|
||||
DocsLink,
|
||||
ResultingCode,
|
||||
h1: H1,
|
||||
|
||||
@@ -5,7 +5,7 @@ const LINK_HEIGHT = 30;
|
||||
const INDICATOR_SIZE = 10;
|
||||
const INDICATOR_OFFSET = (LINK_HEIGHT - INDICATOR_SIZE) / 2;
|
||||
|
||||
export function Outline({ headings }: { headings: any[] }) {
|
||||
export function Outline({ headings }: { readonly headings: any[] }) {
|
||||
// eslint-disable-next-line react/hook-use-state
|
||||
const [active /* setActive */] = useState(0);
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
export function PageButton({ url, title, direction }: { direction: 'next' | 'prev'; title: string; url: string }) {
|
||||
export function PageButton({
|
||||
url,
|
||||
title,
|
||||
direction,
|
||||
}: {
|
||||
readonly direction: 'next' | 'prev';
|
||||
readonly title: string;
|
||||
readonly url: string;
|
||||
}) {
|
||||
return (
|
||||
<a
|
||||
className="flex flex-row flex-col transform-gpu cursor-pointer select-none appearance-none place-items-center gap-2 rounded bg-light-600 px-4 py-3 leading-none no-underline outline-none active:translate-y-px active:bg-light-800 dark:bg-dark-600 hover:bg-light-700 focus:ring focus:ring-width-2 focus:ring-blurple dark:active:bg-dark-400 dark:hover:bg-dark-500"
|
||||
|
||||
@@ -34,7 +34,7 @@ export function Sidebar() {
|
||||
<div className="flex flex-col gap-3 p-3">
|
||||
{Object.keys(itemsByCategory).map((category, idx) => (
|
||||
<Section
|
||||
buttonClassName="bg-light-600 hover:bg-light-700 active:bg-light-800 dark:bg-dark-400 dark:hover:bg-dark-300 dark:active:bg-dark-400 focus:ring-width-2 focus:ring-blurple rounded p-3 outline-none focus:ring"
|
||||
buttonClassName="bg-light-600 hover:bg-light-700 active:bg-light-800 dark:bg-dark-400 dark:hover:bg-dark-300 dark:active:bg-dark-400 focus:ring-width-2 focus:ring-blurple rounded p-3 outline-none focus:ring z-10"
|
||||
key={`${category}-${idx}`}
|
||||
title={category}
|
||||
>
|
||||
|
||||
@@ -7,11 +7,11 @@ category: Installations and preparations
|
||||
|
||||
## Installing Node.js
|
||||
|
||||
To use discord.js, you'll need to install [Node.js](https://nodejs.org/). discord.js v14 requires Node v16.9.0 or higher.
|
||||
To use discord.js, you'll need to install [Node.js](https://nodejs.org/). discord.js v14 requires Node v16.11.0 or higher.
|
||||
|
||||
<Alert title="Tip" type="success">
|
||||
To check if you already have Node installed on your machine \(e.g., if you're using a VPS\), run _`node -v`_ in your
|
||||
terminal. If it outputs _`v16.9.0`_ or higher, then you're good to go! Otherwise, continue reading.
|
||||
terminal. If it outputs _`v16.11.0`_ or higher, then you're good to go! Otherwise, continue reading.
|
||||
</Alert>
|
||||
|
||||
On Windows, it's as simple as installing any other program. Download the latest version from [the Node.js website](https://nodejs.org/), open the downloaded file, and follow the steps from the installer.
|
||||
@@ -48,7 +48,7 @@ On macOS, either:
|
||||
|
||||
On Linux, you can quickly open the terminal with <kbd>Ctrl + Alt + T</kbd>.
|
||||
|
||||
With the terminal open, run the _`node -v`_ command to make sure you've successfully installed Node.js. If it outputs _`v16.9.0`_ or higher, great!
|
||||
With the terminal open, run the _`node -v`_ command to make sure you've successfully installed Node.js. If it outputs _`v16.11.0`_ or higher, great!
|
||||
|
||||
### Initiating a project folder
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ At a minimum, the definition of a slash command must have a name and a descripti
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
/** @type {import('discord.js').RESTPostAPIApplicationCommandsJSONBody} */
|
||||
export const data = {
|
||||
name: 'ping',
|
||||
description: 'Replies with Pong!',
|
||||
@@ -68,6 +69,7 @@ The simplest way to acknowledge and respond to an interaction is the _`interacti
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
/** @param {import('discord.js').CommandInteraction} interaction */
|
||||
export async function execute(interaction) {
|
||||
await interaction.reply('Pong!');
|
||||
}
|
||||
@@ -75,6 +77,14 @@ export async function execute(interaction) {
|
||||
|
||||
</CH.Code>
|
||||
|
||||
<Alert title="@type and @param tags" type="info">
|
||||
[`@type`](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#type) and
|
||||
[`@param`](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#param-and-returns) tags allow you
|
||||
to annotate your code with type information. The tags are not required for your code to run but provide autocomplete
|
||||
and type information for fields and parameters, which can majorly improve your developer experience when working with
|
||||
them.
|
||||
</Alert>
|
||||
|
||||
Put these two together by creating a `commands/ping.js` file for your first command. Inside this file, you're going to define and export two items.
|
||||
|
||||
- The `data` property, which will provide the command definition shown above for registering to Discord.
|
||||
@@ -85,11 +95,13 @@ The _`export`_ keyword ensures these values can be imported and read by other fi
|
||||
<CH.Code>
|
||||
|
||||
```js commands/ping.js
|
||||
/** @type {import('discord.js').RESTPostAPIApplicationCommandsJSONBody} */
|
||||
export const data = {
|
||||
name: 'ping',
|
||||
description: 'Replies with Pong!',
|
||||
};
|
||||
|
||||
/** @param {import('discord.js').CommandInteraction} interaction */
|
||||
export async function execute(interaction) {
|
||||
await interaction.reply('Pong!');
|
||||
}
|
||||
@@ -109,11 +121,13 @@ That's it for your basic ping command. Below are examples of two more commands w
|
||||
<CH.Code>
|
||||
|
||||
```js commands/user.js
|
||||
/** @type {import('discord.js').RESTPostAPIApplicationCommandsJSONBody} */
|
||||
export const data = {
|
||||
name: 'user',
|
||||
description: 'Provides information about the user.',
|
||||
};
|
||||
|
||||
/** @param {import('discord.js').CommandInteraction} interaction */
|
||||
export async function execute(interaction) {
|
||||
// interaction.user is the object representing the User who ran the command
|
||||
// interaction.member is the GuildMember object, which represents the user in the specific guild
|
||||
@@ -124,11 +138,13 @@ export async function execute(interaction) {
|
||||
```
|
||||
|
||||
```js commands/server.js
|
||||
/** @type {import('discord.js').RESTPostAPIApplicationCommandsJSONBody} */
|
||||
export const data = {
|
||||
name: 'server',
|
||||
description: 'Provides information about the server.',
|
||||
};
|
||||
|
||||
/** @param {import('discord.js').CommandInteraction} interaction */
|
||||
export async function execute(interaction) {
|
||||
// interaction.guild is the object representing the Guild in which the command was run
|
||||
await interaction.reply(`This server is ${interaction.guild.name} and has
|
||||
|
||||
@@ -162,4 +162,4 @@ client.on(Events.GuildAuditLogEntryCreate, async (auditLog) => {
|
||||
|
||||
</CH.Code>
|
||||
|
||||
If you want to check who banned a user, it's the same example as above except the _`action`_ should be _`AuditLogEvent.MemberBanAdd`_. You can check the rest of the types over at the [discord-api-types documentation](https://discord-api-types.dev/api/discord-api-types-v10/enum/AuditLogEvent).
|
||||
If you want to check who banned a user, it's the same example as above except the _`action`_ should be <DiscordAPITypesLink type="enum" parent="AuditLogEvent" symbol="MemberBanAdd" />. You can check the rest of the possible actions on this page.
|
||||
|
||||
223
apps/guide/src/content/04-popular-topics/03-collectors.mdx
Normal file
223
apps/guide/src/content/04-popular-topics/03-collectors.mdx
Normal file
@@ -0,0 +1,223 @@
|
||||
---
|
||||
title: Collectors
|
||||
category: Popular topics
|
||||
---
|
||||
|
||||
# Collectors
|
||||
|
||||
## Message collectors
|
||||
|
||||
{/* prettier-ignore */}
|
||||
<DocsLink type="class" parent="Collector">Collectors</DocsLink> are useful to enable your bot to obtain _additional_ input after the first command was sent. An example would be initiating a quiz, where the bot will "await" a correct response from somebody.
|
||||
|
||||
### Basic message collector
|
||||
|
||||
Let's take a look at a basic message collector:
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
const collectorFilter = (message) => message.content.includes('discord');
|
||||
const collector = interaction.channel.createMessageCollector({ filter: collectorFilter, time: 15_000 });
|
||||
|
||||
collector.on('collect', (message) => {
|
||||
console.log(`Collected ${message.content}`);
|
||||
});
|
||||
|
||||
collector.on('end', (collected) => {
|
||||
console.log(`Collected ${collected.size} messages`);
|
||||
});
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
You can provide a _`filter`_ key to the object parameter of <DocsLink type="class" parent="TextChannel" symbol="createMessageCollector" brackets />. The value to this key should be a function that returns a boolean value to indicate if this message should be collected or not. To check for multiple conditions in your filter you can connect them using [logical operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#logical_operators). If you don't provide a filter all messages in the channel the collector was started on will be collected.
|
||||
|
||||
Note that the above example uses [implicit return](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#function_body) for the filter function and passes it to the options object using the [object property shorthand](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#property_definitions) notation.
|
||||
|
||||
If a message passes through the filter, it will trigger the <DocsLink type="class" parent="Collector" symbol="e-collect" /> event for the _`collector`_ you've created. This message is then passed into the event listener as _`collected`_ and the provided function is executed. In the above example, you simply log the message. Once the collector finishes collecting based on the provided end conditions the <DocsLink type="class" parent="Collector" symbol="e-end" /> event emits.
|
||||
|
||||
You can control when a collector ends by supplying additional option keys when creating a collector:
|
||||
|
||||
- _`time`_: Amount of time in milliseconds the collector should run for
|
||||
- _`max`_: Number of messages to successfully pass the filter
|
||||
- _`maxProcessed`_: Number of messages encountered (no matter the filter result)
|
||||
|
||||
The benefit of using an event-based collector over _`awaitMessages()`_ (its promise-based counterpart) is that you can do something directly after each message is collected, rather than just after the collector ended. You can also stop the collector manually by calling <DocsLink type="class" parent="Collector" symbol="stop" brackets />.
|
||||
|
||||
### Await messages
|
||||
|
||||
Using <DocsLink type="class" parent="TextChannel" symbol="awaitMessages" brackets /> can be easier if you understand [Promises](../additional-info/understanding-async-await), and it allows you to have cleaner code overall. It is essentially identical to <DocsLink type="class" parent="TextChannel" symbol="createMessageCollector" brackets />, except promisified. However, the drawback of using this method is that you cannot do things before the Promise is resolved or rejected, either by an error or completion. However, it should do for most purposes, such as awaiting the correct response in a quiz. Instead of taking their example, let's set up a basic quiz command using the _`.awaitMessages()`_ feature.
|
||||
|
||||
First, you'll need some questions and answers to choose from, so here's a basic set:
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"question": "What color is the sky?",
|
||||
"answers": ["blue"]
|
||||
},
|
||||
{
|
||||
"question": "How many letters are there in the alphabet?",
|
||||
"answers": ["26", "twenty-six", "twenty six", "twentysix"]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
The provided set allows for responder error with an array of answers permitted. Ideally, it would be best to place this in a JSON file, which you can call _`quiz.json`_ for simplicity.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
import quiz from './quiz.json' assert { type: 'json' };
|
||||
|
||||
// ...
|
||||
|
||||
const item = quiz[Math.floor(Math.random() * quiz.length)];
|
||||
|
||||
const collectorFilter = (response) => {
|
||||
return item.answers.some((answer) => answer.toLowerCase() === response.content.toLowerCase());
|
||||
};
|
||||
|
||||
await interaction.reply({ content: item.question });
|
||||
|
||||
try {
|
||||
const collected = await interaction.channel.awaitMessages({
|
||||
filter: collectorFilter,
|
||||
max: 1,
|
||||
time: 30_000,
|
||||
errors: ['time'],
|
||||
});
|
||||
|
||||
await interaction.followUp(`${collected.first().author} got the correct answer!`);
|
||||
} catch {
|
||||
await interaction.followUp('Looks like nobody got the answer this time.');
|
||||
}
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
<Alert title="Tip" type="info">
|
||||
If you don't understand how _`.some()`_ works, you can read about it in more detail
|
||||
[here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some).
|
||||
</Alert>
|
||||
|
||||
In this filter, you iterate through the answers to find what you want. You would like to ignore the case because simple typos can happen, so you convert each answer to its lowercase form and check if it's equal to the response in lowercase form as well. In the options section, you only want to allow one answer to pass through, hence the _`max: 1`_ setting.
|
||||
|
||||
The filter looks for messages that match one of the answers in the array of possible answers to pass through the collector. The _`max`_ option (the second parameter) specifies that only a maximum of one message can go through the filter successfully before the Promise successfully resolves. The _`errors`_ section specifies that time will cause it to error out, which will cause the Promise to reject if one correct answer is not received within the time limit of one minute. As you can see, there is no _`collect`_ event, so you are limited in that regard.
|
||||
|
||||
## Reaction collectors
|
||||
|
||||
### Basic reaction collector
|
||||
|
||||
These work quite similarly to message collectors, except that you apply them on a message rather than a channel. This example uses the <DocsLink type="class" parent="Message" symbol="createReactionCollector" brackets /> method. The filter will check for the 👍 emoji–in the default skin tone specifically, so be wary of that. It will also check that the person who reacted shares the same id as the author of the original message that the collector was assigned to.
|
||||
|
||||
```js
|
||||
const collectorFilter = (reaction, user) => {
|
||||
return reaction.emoji.name === '👍' && user.id === message.author.id;
|
||||
};
|
||||
|
||||
const collector = message.createReactionCollector({ filter: collectorFilter, time: 15_000 });
|
||||
|
||||
collector.on('collect', (reaction, user) => {
|
||||
console.log(`Collected ${reaction.emoji.name} from ${user.tag}`);
|
||||
});
|
||||
|
||||
collector.on('end', (collected) => {
|
||||
console.log(`Collected ${collected.size} items`);
|
||||
});
|
||||
```
|
||||
|
||||
### Await reactions
|
||||
|
||||
<DocsLink type="class" parent="Message" symbol="awaitReactions" brackets /> works almost the same as a reaction collector,
|
||||
except it is Promise-based. The same differences apply as with channel collectors.
|
||||
|
||||
```js
|
||||
const collectorFilter = (reaction, user) => {
|
||||
return reaction.emoji.name === '👍' && user.id === message.author.id;
|
||||
};
|
||||
|
||||
try {
|
||||
const collected = await message.awaitReactions({ filter: collectorFilter, max: 1, time: 60_000, errors: ['time'] });
|
||||
console.log(collected.size);
|
||||
} catch (collected) {
|
||||
console.log(`After a minute, the user did not react.`);
|
||||
}
|
||||
```
|
||||
|
||||
## Interaction collectors
|
||||
|
||||
The third type of collector allows you to collect interactions; such as when users activate a slash command or click on a button in a message.
|
||||
|
||||
### Basic message component collector
|
||||
|
||||
Collecting interactions from message components works similarly to reaction collectors. In the following example, you will check that the interaction came from a button, and that the user clicking the button is the same user that initiated the command.
|
||||
|
||||
One important difference to note with interaction collectors is that Discord expects a response to _all_ interactions within 3 seconds - even ones that you don't want to collect. For this reason, you may wish to _`.deferUpdate()`_ all interactions in your filter, or not use a filter at all and handle this behavior in the _`collect`_ event.
|
||||
|
||||
```js
|
||||
import { ComponentType } from 'discord.js';
|
||||
|
||||
const collector = message.createMessageComponentCollector({ componentType: ComponentType.Button, time: 15_000 });
|
||||
|
||||
collector.on('collect', (i) => {
|
||||
if (i.user.id === interaction.user.id) {
|
||||
await i.reply(`${i.user.id} clicked on the ${i.customId} button.`);
|
||||
} else {
|
||||
await i.reply({ content: `These buttons aren't for you!`, ephemeral: true });
|
||||
}
|
||||
});
|
||||
|
||||
collector.on('end', (collected) => {
|
||||
console.log(`Collected ${collected.size} interactions.`);
|
||||
});
|
||||
```
|
||||
|
||||
### Await message component
|
||||
|
||||
As before, this works similarly to the message component collector, except it is Promise-based.
|
||||
|
||||
Unlike other Promise-based collectors, this method will only ever collect one interaction that passes the filter. If no interactions are collected before the time runs out, the Promise will reject. This behavior aligns with Discord's requirement that actions should immediately receive a response. In this example, you will use _`.deferUpdate()`_ on all interactions in the filter.
|
||||
|
||||
```js
|
||||
import { ComponentType } from 'discord.js';
|
||||
|
||||
const collectorFilter = (i) => {
|
||||
i.deferUpdate();
|
||||
return i.user.id === interaction.user.id;
|
||||
};
|
||||
|
||||
try {
|
||||
const interaction = await message.awaitMessageComponent({
|
||||
filter: collectorFilter,
|
||||
componentType: ComponentType.StringSelect,
|
||||
time: 60_000,
|
||||
});
|
||||
|
||||
await interaction.editReply(`You selected ${interaction.values.join(', ')}!`);
|
||||
} catch (error) {
|
||||
console.log('No interactions were collected.');
|
||||
}
|
||||
```
|
||||
|
||||
### Await modal submit
|
||||
|
||||
If you want to wait for the submission of a modal within the context of another command or button execution, you may find the promisified collector <DocsLink type="class" parent="CommandInteraction" symbol="awaitModalSubmit" brackets /> useful.
|
||||
|
||||
As Discord does not inform you if the user dismisses the modal, supplying a maximum _`time`_ to wait for is crucial:
|
||||
|
||||
```js
|
||||
try {
|
||||
const interaction = await initialInteraction.awaitModalSubmit({ time: 60_000, filter });
|
||||
await interaction.editReply('Thank you for your submission!');
|
||||
} catch (error) {
|
||||
console.log('No modal submit interaction was collected');
|
||||
}
|
||||
```
|
||||
|
||||
For more information on working with modals, see the [modals section of this guide](../interactions/modals).
|
||||
95
apps/guide/src/content/04-popular-topics/04-formatters.mdx
Normal file
95
apps/guide/src/content/04-popular-topics/04-formatters.mdx
Normal file
@@ -0,0 +1,95 @@
|
||||
---
|
||||
title: Formatters
|
||||
category: Popular topics
|
||||
---
|
||||
|
||||
# Formatters
|
||||
|
||||
discord.js provides the <DocsLink package="formatters" /> package which contains a variety of utilities you can use when writing your Discord bot.
|
||||
|
||||
## Basic Markdown
|
||||
|
||||
These functions format strings into all the different markdown styles supported by Discord.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
import { bold, italic, strikethrough, underscore, spoiler, quote, blockQuote } from 'discord.js';
|
||||
|
||||
const string = 'Hello!';
|
||||
const boldString = bold(string);
|
||||
const italicString = italic(string);
|
||||
const strikethroughString = strikethrough(string);
|
||||
const underscoreString = underscore(string);
|
||||
const spoilerString = spoiler(string);
|
||||
const quoteString = quote(string);
|
||||
const blockquoteString = blockQuote(string);
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
## Links
|
||||
|
||||
There are also two functions to format hyperlinks. _`hyperlink()`_ will format the URL into a masked markdown link, and _`hideLinkEmbed()`_ will wrap the URL in _`<>`_, preventing it from embedding.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
import { hyperlink, hideLinkEmbed } from 'discord.js';
|
||||
|
||||
const url = 'https://discord.js.org/';
|
||||
const link = hyperlink('discord.js', url);
|
||||
const hiddenEmbed = hideLinkEmbed(url);
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
## Code blocks
|
||||
|
||||
You can use _`inlineCode()`_ and _`codeBlock()`_ to turn a string into an inline code block or a regular code block with or without syntax highlighting.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
import { inlineCode, codeBlock } from 'discord.js';
|
||||
|
||||
const jsString = 'const value = true;';
|
||||
const inline = inlineCode(jsString);
|
||||
const codeblock = codeBlock(jsString);
|
||||
const highlighted = codeBlock('js', jsString);
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
## Timestamps
|
||||
|
||||
With _`time()`_, you can format Unix timestamps and dates into a Discord time string.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
import { time, TimestampStyles } from 'discord.js';
|
||||
|
||||
const date = new Date();
|
||||
const timeString = time(date);
|
||||
const relative = time(date, TimestampStyles.RelativeTime);
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
## Mentions
|
||||
|
||||
_`userMention()`_, _`channelMention()`_, and _`roleMention()`_ all exist to format Snowflakes into mentions.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
import { channelMention, roleMention, userMention } from 'discord.js';
|
||||
|
||||
const id = '123456789012345678';
|
||||
const channel = channelMention(id);
|
||||
const role = roleMention(id);
|
||||
const user = userMention(id);
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
227
apps/guide/src/content/04-popular-topics/06-webhooks.mdx
Normal file
227
apps/guide/src/content/04-popular-topics/06-webhooks.mdx
Normal file
@@ -0,0 +1,227 @@
|
||||
---
|
||||
title: Webhooks
|
||||
category: Popular topics
|
||||
---
|
||||
|
||||
# Webhooks
|
||||
|
||||
Webhooks can send messages to a text channel without having to log in as a bot. They can also fetch, edit, and delete their own messages. There are a variety of methods in discord.js to interact with webhooks. In this section, you will learn how to create, fetch, edit, and use webhooks.
|
||||
|
||||
## What is a webhook
|
||||
|
||||
Webhooks are a utility used to send messages to text channels without needing a Discord application. Webhooks are useful for allowing something to send messages without requiring a Discord application. You can also directly edit or delete messages you sent through the webhook. There are two structures to make use of this functionality: <DocsLink type="class" parent="Webhook" /> and <DocsLink type="class" parent="WebhookClient" />. _`WebhookClient`_ is an extended version of a _`Webhook`_, which allows you to send messages through it without needing a bot client.
|
||||
|
||||
<Alert title="Tip" type="info">
|
||||
If you would like to read about using webhooks through the API without discord.js, you can read about them
|
||||
[here](https://discord.com/developers/docs/resources/webhook).
|
||||
</Alert>
|
||||
|
||||
## Detecting webhook messages
|
||||
|
||||
Bots receive webhook messages in a text channel as usual. You can detect if a webhook sent the message by checking if the _`Message.webhookId`_ is not _`null`_. In this example, we return if a webhook sent the message.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
if (message.webhookId) return;
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
If you would like to get the webhook object that sent the message, you can use <DocsLink type="class" parent="Message" symbol="fetchWebhook" brackets />.
|
||||
|
||||
## Fetching webhooks
|
||||
|
||||
<Alert title="Tip" type="info">
|
||||
Webhook fetching will always make use of collections and promises. If you do not understand either concept, revise
|
||||
them, and then come back to this section. You can read about collections [here](../additional-info/collections), and
|
||||
promises [here](../additional-info/understanding-async-await) and
|
||||
[here](https://developer.mozilla.org/docs/Web/JavaScript/Guide/Using_promises).
|
||||
</Alert>
|
||||
|
||||
### Fetching all webhooks of a guild
|
||||
|
||||
If you would like to get all webhooks of a guild, you can use the <DocsLink type="class" parent="Guild" symbol="fetchWebhooks" brackets /> method. This will return a promise which will resolve into a collection of webhooks.
|
||||
|
||||
### Fetching webhooks of a channel
|
||||
|
||||
Webhooks belonging to a channel can be fetched using the <DocsLink type="class" parent="TextChannel" symbol="fetchWebhooks" brackets /> method. This will return a promise which will resolve into a collection of webhooks. A collection will be returned even if the channel contains a single webhook. If you are certain the channel contains a single webhook, you can use the <DocsLink package="collection" type="Class" parent="Collection" symbol="first" brackets /> method on the collection to get the webhook.
|
||||
|
||||
### Fetching a single webhook
|
||||
|
||||
#### Using client
|
||||
|
||||
You can fetch a specific webhook using its _`id`_ with the <DocsLink type="class" parent="Client" symbol="fetchWebhook" brackets /> method. You can obtain the webhook id by looking at its URL: the number after _`https://discord.com/api/webhooks/`_ is the _`id`_ and the part after that is the _`token`_.
|
||||
|
||||
#### Using the WebhookClient constructor
|
||||
|
||||
If you are not using a bot client, you can get a webhook by creating a new instance of _`WebhookClient`_ and passing the _`id`_ and _`token`_ into the constructor. These credentials do not require you to have a bot application, but it also offers limited information instead of fetching it using an authorized client.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
const webhookClient = new WebhookClient({ id: 'id', token: 'token' });
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
You can also pass in just a _`url`_:
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
const webhookClient = new WebhookClient({ url: 'https://discord.com/api/webhooks/id/token' });
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
## Creating webhooks
|
||||
|
||||
### Creating webhooks through server settings
|
||||
|
||||
You can create webhooks directly through the Discord client. Go to Server Settings, and you will see an _`Integrations`_ tab.
|
||||
|
||||

|
||||
|
||||
If you already have created a webhook, the webhooks tab will look like this; you will need to click the _`View Webhooks`_ button.
|
||||
|
||||

|
||||
|
||||
Once you are there, click on the _`Create Webhook`_ / _`New Webhook`_ button; this will create a webhook. From here, you can edit the channel, the name, and the avatar. Copy the link, the first part is the id, and the second is the token.
|
||||
|
||||

|
||||
|
||||
### Creating webhooks with discord.js
|
||||
|
||||
Webhooks can be created with the <DocsLink type="class" parent="TextChannel" symbol="createWebhook" brackets /> method.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
channel
|
||||
.createWebhook({ name: 'Username', avatar: 'https://guide.discordjs.dev/assets/discordjs.png' })
|
||||
.then((webhook) => console.log(`Created webhook ${webhook}`))
|
||||
.catch(console.error);
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
## Editing webhooks
|
||||
|
||||
You can edit Webhooks and WebhookClients to change their name, avatar, and channel using <DocsLink type="class" parent="Webhook" symbol="edit" brackets />.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
webhook
|
||||
.edit({ name: 'Username', avatar: 'https://guide.discordjs.dev/assets/discordjs.png', channel: '123456789012345678' })
|
||||
.then((webhook) => console.log(`Edited webhook ${webhook}`))
|
||||
.catch(console.error);
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
## Using webhooks
|
||||
|
||||
Webhooks can send messages to text channels, as well as fetch, edit, and delete their own. These methods are the same for both _`Webhook`_ and _`WebhookClient`_.
|
||||
|
||||
### Sending messages
|
||||
|
||||
Webhooks, like bots, can send up to 10 embeds per message. They can also send attachments and normal content. The <DocsLink type="class" parent="Webhook" symbol="send" brackets /> method is very similar to the method used for sending a message to a text channel. Webhooks can also choose how the username and avatar will appear when they send the message.
|
||||
|
||||
Example using a _`WebhookClient`_:
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
import { EmbedBuilder, WebhookClient } from 'discord.js';
|
||||
import config from './config.json' assert { type: 'json' };
|
||||
const { webhookId, webhookToken } = config;
|
||||
|
||||
const webhookClient = new WebhookClient({ id: webhookId, token: webhookToken });
|
||||
const embed = new EmbedBuilder().setTitle('Some Title').setColor(0x00ffff);
|
||||
|
||||
await webhookClient.send({
|
||||
content: 'Webhook test',
|
||||
username: 'some-username',
|
||||
avatarURL: 'https://guide.discordjs.dev/assets/discordjs.png',
|
||||
embeds: [embed],
|
||||
});
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
Try to find a webhook your bot knows the token for. This makes sure your bot can execute the webhook later on.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
import { Client, EmbedBuilder, Events, GatewayIntentBits } from 'discord.js';
|
||||
import config from './config.json' assert { type: 'json' };
|
||||
const { token } = config;
|
||||
|
||||
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
|
||||
const embed = new EmbedBuilder().setTitle('Some Title').setColor(0x00ffff);
|
||||
|
||||
client.once(Events.ClientReady, async () => {
|
||||
const channel = client.channels.cache.get('123456789012345678');
|
||||
|
||||
try {
|
||||
const webhooks = await channel.fetchWebhooks();
|
||||
const webhook = webhooks.find((wh) => wh.token);
|
||||
if (!webhook) return console.log('No webhook was found that I can use!');
|
||||
|
||||
await webhook.send({
|
||||
content: 'Webhook test',
|
||||
username: 'some-username',
|
||||
avatarURL: 'https://guide.discordjs.dev/assets/discordjs.png',
|
||||
embeds: [embed],
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error trying to send a message: ', error);
|
||||
}
|
||||
});
|
||||
|
||||
client.login(token);
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
### Fetching messages
|
||||
|
||||
You can use <DocsLink type="class" parent="Webhook" symbol="fetchMessage" brackets /> to fetch messages previously sent by the Webhook.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
const message = await webhookClient.fetchMessage('123456789012345678');
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
### Editing messages
|
||||
|
||||
You can use <DocsLink type="class" parent="Webhook" symbol="editMessage" brackets /> to edit messages previously sent by the Webhook.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
const message = await webhook.editMessage('123456789012345678', {
|
||||
content: 'Edited!',
|
||||
embeds: [embed],
|
||||
});
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
|
||||
### Deleting messages
|
||||
|
||||
You can use <DocsLink type="class" parent="Webhook" symbol="deleteMessage" brackets /> to delete messages previously sent by the webhook.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
```js
|
||||
await webhookClient.deleteMessage('123456789012345678');
|
||||
```
|
||||
|
||||
</CH.Code>
|
||||
@@ -7,7 +7,7 @@ category: Additional info
|
||||
|
||||
## Before you start
|
||||
|
||||
v14 requires Node 16.9 or higher to use, so make sure you're up to date. To check your Node.js version, use _`node --version`_ in your terminal or command prompt, and if it's not high enough, update it! There are many resources online to help you with this step based on your host system.
|
||||
v14 requires Node 16.11 or higher to use, so make sure you're up to date. To check your Node.js version, use _`node --version`_ in your terminal or command prompt, and if it's not high enough, update it! There are many resources online to help you with this step based on your host system.
|
||||
|
||||
### Various packages are now included in v14
|
||||
|
||||
@@ -41,7 +41,7 @@ discord.js v14 makes the switch to Discord API v10!
|
||||
|
||||
Any areas that used to accept a _`string`_ or _`number`_ type for an enum parameter will now only accept a _`number`_.
|
||||
|
||||
In addition, the old enums exported by discord.js v13 and lower are replaced with new enums from [discord-api-types](https://discord-api-types.dev/api/discord-api-types-v10).
|
||||
In addition, the old enums exported by discord.js v13 and lower are replaced with new enums from <DiscordAPITypesLink />.
|
||||
|
||||
#### New enum differences
|
||||
|
||||
@@ -121,7 +121,7 @@ Areas like _`Client`_ initialization, JSON slash commands and JSON message compo
|
||||
|
||||
#### Channels
|
||||
|
||||
Some channel type guard methods that narrowed to one channel type have been removed. Instead compare the _`type`_ property against a [ChannelType](https://discord-api-types.dev/api/discord-api-types-v10/enum/ChannelType) enum member to narrow channels.
|
||||
Some channel type guard methods that narrowed to one channel type have been removed. Instead compare the _`type`_ property against a <DiscordAPITypesLink type="enum" parent="ChannelType" /> enum member to narrow channels.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
@@ -361,7 +361,7 @@ _`IntegrationApplication#summary`_ has been removed as it is no longer supported
|
||||
|
||||
### Interaction
|
||||
|
||||
Whenever an interaction is replied to and one fetches the reply, it could possibly give an [APIMessage](https://discord-api-types.dev/api/discord-api-types-v10/interface/APIMessage) if the guild was not cached. However, interaction replies now always return a discord.js <DocsLink type="class" parent="Message"/> object with _`fetchReply`_ as _`true`_.
|
||||
Whenever an interaction is replied to and one fetches the reply, it could possibly give an <DiscordAPITypesLink type="interface" parent="APIMessage" /> if the guild was not cached. However, interaction replies now always return a discord.js <DocsLink type="class" parent="Message"/> object with _`fetchReply`_ as _`true`_.
|
||||
|
||||
The base interaction class is now <DocsLink type="class" parent="BaseInteraction"/>.
|
||||
|
||||
@@ -419,7 +419,7 @@ The base interaction class is now <DocsLink type="class" parent="BaseInteraction
|
||||
|
||||
### MessageManager
|
||||
|
||||
The second parameter of <DocsLink type="class" parent="MessageManager" symbol="fetch" brackets /> has been removed. The <DocsLink type="class" parent="BaseFetchOptions" /> the second parameter once was is now merged into the first parameter.
|
||||
The second parameter of <DocsLink type="class" parent="MessageManager" symbol="fetch" brackets /> has been removed. The <DocsLink type="typedef" parent="BaseFetchOptions" /> the second parameter once was is now merged into the first parameter.
|
||||
|
||||
<CH.Code>
|
||||
|
||||
@@ -690,7 +690,7 @@ Added support for role connection metadata.
|
||||
|
||||
A new <DocsLink type="class" parent="Collector" symbol="e-ignore"/> event has been added which is emitted whenever an element is not collected by the collector.
|
||||
|
||||
Component collector options now use the [ComponentType](https://discord-api-types.dev/api/discord-api-types-v10/enum/ComponentType) enum values:
|
||||
Component collector options now use the <DiscordAPITypesLink type="enum" parent="ComponentType" /> enum values:
|
||||
|
||||
<CH.Code>
|
||||
|
||||
@@ -807,7 +807,7 @@ Added the _`threadName`_ property in <DocsLink type="typedef" parent="WebhookMes
|
||||
|
||||
### WebSocketManager
|
||||
|
||||
discord.js uses <PackageLink name="ws" /> internally.
|
||||
discord.js uses <DocsLink package="ws" /> internally.
|
||||
|
||||
[^1]: https://github.com/discordjs/discord.js/pull/7188
|
||||
[^2]: https://github.com/discordjs/discord.js/pull/6492
|
||||
|
||||
@@ -2,6 +2,8 @@ export const BASE_URL = 'https://discord.js.org/docs/packages' as const;
|
||||
|
||||
export const BASE_URL_LEGACY = 'https://old.discordjs.dev/#/docs/discord.js' as const;
|
||||
|
||||
export const BASE_URL_DISCORD_API_TYPES = 'https://discord-api-types.dev' as const;
|
||||
|
||||
export const DESCRIPTION = 'Imagine a guide... that explores the many possibilities for your discord.js bot.';
|
||||
|
||||
export const GITHUB_BASE_PAGES_PATH = 'https://github.com/discordjs/discord.js/tree/main/apps/guide/src/pages';
|
||||
@@ -24,4 +26,14 @@ export const PACKAGES = [
|
||||
/**
|
||||
* The stable version of discord.js.
|
||||
*/
|
||||
export const VERSION = '14.10.0' as const;
|
||||
export const VERSION = '14.11.0' as const;
|
||||
|
||||
/**
|
||||
* The API version (for discord-api-types). This is prefixed with a "v".
|
||||
*/
|
||||
export const DISCORD_API_TYPES_VERSION = 'v10' as const;
|
||||
|
||||
/**
|
||||
* The voice API version (for discord-api-types). This is prefixed with a "v".
|
||||
*/
|
||||
export const DISCORD_API_TYPES_VOICE_VERSION = 'v4' as const;
|
||||
|
||||
@@ -22,13 +22,6 @@
|
||||
"strictNullChecks": true,
|
||||
"moduleResolution": "node"
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx",
|
||||
"next-env.d.ts",
|
||||
"types.d.ts",
|
||||
".next/types/**/*.ts",
|
||||
".contentlayer/generated"
|
||||
],
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx", "next-env.d.ts", ".next/types/**/*.ts", ".contentlayer/generated"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
1
apps/guide/types.d.ts
vendored
1
apps/guide/types.d.ts
vendored
@@ -1 +0,0 @@
|
||||
declare module '*.css';
|
||||
1
apps/website/.eslintignore
Normal file
1
apps/website/.eslintignore
Normal file
@@ -0,0 +1 @@
|
||||
next-env.d.ts
|
||||
23
apps/website/.gitignore
vendored
23
apps/website/.gitignore
vendored
@@ -1,8 +1,8 @@
|
||||
# Packages
|
||||
node_modules/
|
||||
node_modules
|
||||
|
||||
# Log files
|
||||
logs/
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
@@ -16,19 +16,14 @@ pids
|
||||
.env*.local
|
||||
|
||||
# Dist
|
||||
dist/
|
||||
typings/
|
||||
.cache/
|
||||
build/
|
||||
.contentlayer
|
||||
.next
|
||||
public/searchIndex
|
||||
src/assets/readme
|
||||
src/styles/unocss.css
|
||||
.next/
|
||||
src/assets/readme/
|
||||
static/
|
||||
|
||||
# Miscellaneous
|
||||
.tmp/
|
||||
coverage/
|
||||
.vercel
|
||||
public/searchIndex
|
||||
.tmp
|
||||
.vscode
|
||||
lighthouse-results/
|
||||
lighthouse-results
|
||||
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
# Autogenerated
|
||||
CHANGELOG.md
|
||||
.next
|
||||
.turbo
|
||||
dist/
|
||||
docs/**/*
|
||||
!docs/index.yml
|
||||
!docs/README.md
|
||||
coverage/
|
||||
.cache
|
||||
build/
|
||||
src/styles/unocss.css
|
||||
api/
|
||||
.next/
|
||||
.vercel/
|
||||
.cache/
|
||||
.vscode
|
||||
coverage
|
||||
public/searchIndex
|
||||
src/assets/readme
|
||||
src/styles/unocss.css
|
||||
next-env.d.ts
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
"test": "vitest run",
|
||||
"test:lighthouse": "lighthouse http://localhost:3000 --output-path=./lighthouse-results",
|
||||
"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:local": "cross-env NEXT_PUBLIC_LOCAL_DEV=true yarn build:prod",
|
||||
"build:prod": "yarn build:copy_readme && yarn build:css && yarn build:next",
|
||||
"build:next": "next build",
|
||||
"build:css": "yarn generate:css",
|
||||
"build:search_indices": "yarn node scripts/generateAllIndices.js",
|
||||
"build:analyze": "yarn run --top-level docs --force && cross-env-shell ANALYZE=true NEXT_PUBLIC_LOCAL_DEV=true yarn build:prod",
|
||||
"build:analyze": "turbo run docs && cross-env ANALYZE=true NEXT_PUBLIC_LOCAL_DEV=true yarn build:prod",
|
||||
"preview": "next start",
|
||||
"dev": "yarn run --top-level docs && concurrently 'yarn dev:css' 'yarn dev:next'",
|
||||
"dev:next": "yarn workspaces foreach -ptR run build && next dev",
|
||||
"dev": "concurrently 'yarn dev:css' 'yarn dev:next'",
|
||||
"dev:next": "next dev",
|
||||
"dev:css": "yarn generate:css --watch",
|
||||
"generate:css": "unocss 'src/**/*.tsx' '../../packages/ui/src/lib/components/**/*.tsx' --out-file ./src/styles/unocss.css --config ../../unocss.config.ts",
|
||||
"lint": "prettier --check . && cross-env TIMING=1 eslint src --ext .mjs,.js,.cjs,.ts,.tsx --format=pretty",
|
||||
@@ -49,59 +49,56 @@
|
||||
"@discordjs/api-extractor-utils": "workspace:^",
|
||||
"@discordjs/scripts": "workspace:^",
|
||||
"@discordjs/ui": "workspace:^",
|
||||
"@microsoft/api-extractor-model": "7.26.6",
|
||||
"@microsoft/api-extractor-model": "7.27.6",
|
||||
"@microsoft/tsdoc": "0.14.2",
|
||||
"@planetscale/database": "1.7.0",
|
||||
"@react-icons/all-files": "^4.1.0",
|
||||
"@vercel/analytics": "^1.0.0",
|
||||
"@vercel/edge-config": "^0.1.8",
|
||||
"@vercel/og": "^0.5.4",
|
||||
"@vscode/codicons": "^0.0.32",
|
||||
"@vercel/analytics": "^1.0.2",
|
||||
"@vercel/edge-config": "^0.2.1",
|
||||
"@vercel/og": "^0.5.11",
|
||||
"ariakit": "^2.0.0-next.44",
|
||||
"bright": "^0.8.2",
|
||||
"class-variance-authority": "^0.6.0",
|
||||
"bright": "^0.8.4",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"cmdk": "^0.2.0",
|
||||
"meilisearch": "^0.32.3",
|
||||
"next": "^13.3.4",
|
||||
"meilisearch": "^0.34.1",
|
||||
"next": "^13.4.17",
|
||||
"next-mdx-remote": "^4.4.1",
|
||||
"next-themes": "^0.2.1",
|
||||
"react": "^18.2.0",
|
||||
"react-custom-scrollbars-2": "^4.5.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-use": "^17.4.0",
|
||||
"rehype-ignore": "^1.0.5",
|
||||
"rehype-raw": "^6.1.1",
|
||||
"rehype-slug": "^5.1.0",
|
||||
"remark-gfm": "^3.0.1",
|
||||
"server-only": "^0.0.1",
|
||||
"sharp": "^0.32.1",
|
||||
"swr": "^2.1.5"
|
||||
"sharp": "^0.32.5",
|
||||
"swr": "^2.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@next/bundle-analyzer": "^13.3.4",
|
||||
"@next/bundle-analyzer": "^13.4.17",
|
||||
"@testing-library/react": "^14.0.0",
|
||||
"@testing-library/user-event": "^14.4.3",
|
||||
"@types/node": "18.16.3",
|
||||
"@types/react": "^18.2.0",
|
||||
"@types/react-dom": "^18.2.1",
|
||||
"@unocss/cli": "^0.51.8",
|
||||
"@unocss/eslint-config": "^0.51.8",
|
||||
"@unocss/reset": "^0.51.8",
|
||||
"@vitejs/plugin-react": "^4.0.0",
|
||||
"@vitest/coverage-c8": "^0.30.1",
|
||||
"concurrently": "^8.0.1",
|
||||
"cpy-cli": "^4.2.0",
|
||||
"@types/node": "18.17.5",
|
||||
"@types/react": "^18.2.20",
|
||||
"@types/react-dom": "^18.2.7",
|
||||
"@unocss/cli": "^0.55.1",
|
||||
"@unocss/eslint-config": "^0.55.1",
|
||||
"@unocss/reset": "^0.55.1",
|
||||
"@vitejs/plugin-react": "^4.0.4",
|
||||
"@vitest/coverage-v8": "^0.34.2",
|
||||
"concurrently": "^8.2.0",
|
||||
"cpy-cli": "^5.0.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.39.0",
|
||||
"eslint-config-neon": "^0.1.42",
|
||||
"eslint": "^8.47.0",
|
||||
"eslint-config-neon": "^0.1.47",
|
||||
"eslint-formatter-pretty": "^5.0.0",
|
||||
"happy-dom": "^9.10.1",
|
||||
"lighthouse": "^10.1.1",
|
||||
"happy-dom": "^10.10.2",
|
||||
"lighthouse": "^10.4.0",
|
||||
"prettier": "^2.8.8",
|
||||
"typescript": "^5.0.4",
|
||||
"unocss": "^0.51.8",
|
||||
"vercel": "^29.0.3",
|
||||
"vitest": "^0.29.8"
|
||||
"turbo": "^1.10.12",
|
||||
"typescript": "^5.1.6",
|
||||
"vercel": "^31.4.0",
|
||||
"vitest": "^0.34.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.13.0"
|
||||
|
||||
@@ -73,7 +73,7 @@ export const metadata: Metadata = {
|
||||
},
|
||||
};
|
||||
|
||||
export default function GlobalError({ error }: { error: Error }) {
|
||||
export default function GlobalError({ error }: { readonly error: Error }) {
|
||||
console.error(error);
|
||||
|
||||
return (
|
||||
@@ -1,29 +0,0 @@
|
||||
import { get } from '@vercel/edge-config';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export const runtime = 'edge';
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const url = await get<string>('DISCORD_WEBHOOK_URL');
|
||||
const imageUrl = await get<string>('IT_IS_WEDNESDAY_MY_DUDES');
|
||||
if (url && imageUrl) {
|
||||
await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
username: 'It is wednesday, my dudes',
|
||||
embeds: [
|
||||
{
|
||||
image: {
|
||||
url: imageUrl,
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
}
|
||||
} catch {}
|
||||
|
||||
return NextResponse.json({ message: 'It is wednesday, my dudes' });
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'server-only';
|
||||
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { connect } from '@planetscale/database';
|
||||
|
||||
@@ -116,7 +116,7 @@ export async function generateStaticParams({ params: { package: packageName, ver
|
||||
}));
|
||||
}
|
||||
|
||||
function Member({ member }: { member?: ApiItem }) {
|
||||
function Member({ member }: { readonly member?: ApiItem }) {
|
||||
switch (member?.kind) {
|
||||
case 'Class':
|
||||
return <Class clazz={member as ApiClass} />;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
export default function Error({ error }: { error: Error }) {
|
||||
export default function Error({ error }: { readonly error: Error }) {
|
||||
console.error(error);
|
||||
|
||||
return (
|
||||
|
||||
@@ -2,7 +2,6 @@ import { readFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import type { SerializeOptions } from 'next-mdx-remote/dist/types';
|
||||
import { MDXRemote } from 'next-mdx-remote/rsc';
|
||||
import rehypeIgnore from 'rehype-ignore';
|
||||
import rehypeRaw from 'rehype-raw';
|
||||
import rehypeSlug from 'rehype-slug';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
@@ -17,7 +16,7 @@ const mdxOptions = {
|
||||
mdxOptions: {
|
||||
remarkPlugins: [remarkGfm],
|
||||
remarkRehypeOptions: { allowDangerousHtml: true },
|
||||
rehypePlugins: [rehypeRaw, rehypeIgnore, rehypeSlug],
|
||||
rehypePlugins: [rehypeRaw, rehypeSlug],
|
||||
format: 'md',
|
||||
},
|
||||
} satisfies SerializeOptions;
|
||||
@@ -28,7 +27,7 @@ export default async function Page({ params }: { params: VersionRouteParams }) {
|
||||
|
||||
return (
|
||||
<div className="max-w-none prose">
|
||||
{/* @ts-expect-error async component */}
|
||||
{/* @ts-expect-error SyntaxHighlighter is assignable */}
|
||||
<MDXRemote components={{ pre: SyntaxHighlighter }} options={mdxOptions} source={readmeSource} />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ export default async function Page({ params }: { params: { package: string } })
|
||||
href={`/docs/packages/${params.package}/${version}`}
|
||||
key={`${version}-${idx}`}
|
||||
>
|
||||
<div className="flex flex-row place-content-between place-items-center gap-4">
|
||||
<div className="flex grow flex-row place-content-between place-items-center gap-4">
|
||||
<div className="flex flex-row place-content-between place-items-center gap-4">
|
||||
<VscVersions size={25} />
|
||||
<h2 className="font-semibold">{version}</h2>
|
||||
|
||||
@@ -13,16 +13,11 @@ export default function Page() {
|
||||
<div className="mx-auto min-h-screen min-w-xs flex flex-col gap-8 px-4 py-6 sm:w-md lg:px-6 lg:py-6">
|
||||
<h1 className="text-2xl font-semibold">Select a package:</h1>
|
||||
<div className="flex flex-col gap-4">
|
||||
<a
|
||||
className="h-11 flex transform-gpu cursor-pointer select-none appearance-none place-content-between border border-neutral-300 rounded bg-white p-4 text-base font-semibold leading-none text-black outline-none active:translate-y-px dark:border-dark-100 active:bg-neutral-200 dark:bg-dark-400 hover:bg-neutral-100 dark:text-white focus:ring focus:ring-width-2 focus:ring-blurple dark:active:bg-dark-200 dark:hover:bg-dark-300"
|
||||
href="https://old.discordjs.dev/#/docs/discord.js"
|
||||
>
|
||||
<a className={buttonVariants({ variant: 'secondary' })} href="https://old.discordjs.dev/#/docs/discord.js">
|
||||
<div className="flex grow flex-row place-content-between place-items-center gap-4">
|
||||
<div className="flex grow flex-row place-content-between place-items-center gap-4">
|
||||
<div className="flex flex-row place-content-between place-items-center gap-4">
|
||||
<VscPackage size={25} />
|
||||
<h2 className="font-semibold">discord.js</h2>
|
||||
</div>
|
||||
<div className="flex flex-row place-content-between place-items-center gap-4">
|
||||
<VscPackage size={25} />
|
||||
<h2 className="font-semibold">discord.js</h2>
|
||||
</div>
|
||||
<VscArrowRight size={20} />
|
||||
</div>
|
||||
@@ -34,31 +29,27 @@ export default function Page() {
|
||||
key={`${pkg}-${idx}`}
|
||||
>
|
||||
<div className="flex grow flex-row place-content-between place-items-center gap-4">
|
||||
<div className="flex grow flex-row place-content-between place-items-center gap-4">
|
||||
<div className="flex flex-row place-content-between place-items-center gap-4">
|
||||
<VscPackage size={25} />
|
||||
<h2 className="font-semibold">{pkg}</h2>
|
||||
</div>
|
||||
{/* <Link href={`/docs/packages/${pkg}`}>
|
||||
<div
|
||||
className="bg-blurple focus:ring-width-2 flex h-6 transform-gpu cursor-pointer select-none appearance-none flex-row place-content-center place-items-center rounded border-0 px-2 text-xs font-semibold leading-none text-white outline-none focus:ring focus:ring-white active:translate-y-px"
|
||||
role="link"
|
||||
>
|
||||
Select version
|
||||
</div>
|
||||
</Link> */}
|
||||
<div className="flex flex-row place-content-between place-items-center gap-4">
|
||||
<VscPackage size={25} />
|
||||
<h2 className="font-semibold">{pkg}</h2>
|
||||
</div>
|
||||
{/* <Link href={`/docs/packages/${pkg}`}>
|
||||
<div
|
||||
className="bg-blurple focus:ring-width-2 flex h-6 transform-gpu cursor-pointer select-none appearance-none flex-row place-content-center place-items-center rounded border-0 px-2 text-xs font-semibold leading-none text-white outline-none focus:ring focus:ring-white active:translate-y-px"
|
||||
role="link"
|
||||
>
|
||||
Select version
|
||||
</div>
|
||||
</Link> */}
|
||||
<VscArrowRight size={20} />
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
<a className={buttonVariants({ variant: 'secondary' })} href="https://discord-api-types.dev/">
|
||||
<div className="flex grow flex-row place-content-between place-items-center gap-4">
|
||||
<div className="flex grow flex-row place-content-between place-items-center gap-4">
|
||||
<div className="flex flex-row place-content-between place-items-center gap-4">
|
||||
<VscPackage size={25} />
|
||||
<h2 className="font-semibold">discord-api-types</h2>
|
||||
</div>
|
||||
<div className="flex flex-row place-content-between place-items-center gap-4">
|
||||
<VscPackage size={25} />
|
||||
<h2 className="font-semibold">discord-api-types</h2>
|
||||
</div>
|
||||
<FiExternalLink size={20} />
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
export default function Error({ error }: { error: Error }) {
|
||||
export default function Error({ error }: { readonly error: Error }) {
|
||||
console.error(error);
|
||||
|
||||
return (
|
||||
|
||||
@@ -2,6 +2,7 @@ import { FiExternalLink } from '@react-icons/all-files/fi/FiExternalLink';
|
||||
import Image from 'next/image';
|
||||
import Link from 'next/link';
|
||||
import vercelLogo from '~/assets/powered-by-vercel.svg';
|
||||
import workersLogo from '~/assets/powered-by-workers.png';
|
||||
import { Banner } from '~/components/Banner';
|
||||
import { InstallButton } from '~/components/InstallButton';
|
||||
import { buttonVariants } from '~/styles/Button';
|
||||
@@ -19,9 +20,12 @@ export default function Page() {
|
||||
Discord bots.
|
||||
</h1>
|
||||
<p className="my-6 leading-normal text-neutral-700 dark:text-neutral-300">{DESCRIPTION}</p>
|
||||
<div className="flex flex-row gap-4">
|
||||
<Link className={buttonVariants()} href="/docs">
|
||||
<div className="flex flex-wrap place-content-center gap-4 md:flex-row">
|
||||
<a className={buttonVariants()} href="https://old.discordjs.dev/#/docs" rel="noopener noreferrer">
|
||||
Docs
|
||||
</a>
|
||||
<Link className={buttonVariants()} href="/docs">
|
||||
Module docs
|
||||
</Link>
|
||||
<a
|
||||
className={buttonVariants({ variant: 'secondary' })}
|
||||
@@ -43,23 +47,41 @@ export default function Page() {
|
||||
<InstallButton />
|
||||
</div>
|
||||
</div>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
title="Vercel"
|
||||
>
|
||||
<Image
|
||||
alt="Vercel"
|
||||
blurDataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAABLCAQAAAA1k5H2AAAAi0lEQVR42u3SMQEAAAgDoC251a3gL2SgmfBYBRAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARCAgwWEOSWBnYbKggAAAABJRU5ErkJggg=="
|
||||
height={44}
|
||||
placeholder="blur"
|
||||
priority
|
||||
src={vercelLogo}
|
||||
width={212}
|
||||
/>
|
||||
</a>
|
||||
<div className="flex flex-col gap-4 md:flex-row">
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
title="Vercel"
|
||||
>
|
||||
<Image
|
||||
alt="Vercel"
|
||||
blurDataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAABLCAQAAAA1k5H2AAAAi0lEQVR42u3SMQEAAAgDoC251a3gL2SgmfBYBRAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARCAgwWEOSWBnYbKggAAAABJRU5ErkJggg=="
|
||||
height={44}
|
||||
placeholder="blur"
|
||||
priority
|
||||
src={vercelLogo}
|
||||
width={212}
|
||||
/>
|
||||
</a>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://www.cloudflare.com"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
title="Cloudflare Workers"
|
||||
>
|
||||
<Image
|
||||
alt="Cloudflare"
|
||||
blurDataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAABLCAQAAAA1k5H2AAAAi0lEQVR42u3SMQEAAAgDoC251a3gL2SgmfBYBRAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARCAgwWEOSWBnYbKggAAAABJRU5ErkJggg=="
|
||||
height={44}
|
||||
placeholder="blur"
|
||||
priority
|
||||
src={workersLogo}
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
BIN
apps/website/src/assets/powered-by-workers.png
Normal file
BIN
apps/website/src/assets/powered-by-workers.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -1,6 +1,6 @@
|
||||
import { FiLink } from '@react-icons/all-files/fi/FiLink';
|
||||
|
||||
export function Anchor({ href }: { href: string }) {
|
||||
export function Anchor({ href }: { readonly href: string }) {
|
||||
return (
|
||||
<a className="mr-1 inline-block rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple" href={href}>
|
||||
<FiLink size={20} />
|
||||
|
||||
@@ -8,7 +8,10 @@ export enum BadgeColor {
|
||||
Warning = 'bg-yellow-500',
|
||||
}
|
||||
|
||||
export function Badge({ children, color = BadgeColor.Primary }: PropsWithChildren<{ color?: BadgeColor | undefined }>) {
|
||||
export function Badge({
|
||||
children,
|
||||
color = BadgeColor.Primary,
|
||||
}: PropsWithChildren<{ readonly color?: BadgeColor | undefined }>) {
|
||||
return (
|
||||
<span
|
||||
className={`h-5 flex flex-row place-content-center place-items-center rounded-full px-3 text-center text-xs font-semibold uppercase text-white ${color}`}
|
||||
@@ -18,7 +21,7 @@ export function Badge({ children, color = BadgeColor.Primary }: PropsWithChildre
|
||||
);
|
||||
}
|
||||
|
||||
export function Badges({ item }: { item: ApiDocumentedItem }) {
|
||||
export function Badges({ item }: { readonly item: ApiDocumentedItem }) {
|
||||
const isStatic = ApiStaticMixin.isBaseClassOf(item) && item.isStatic;
|
||||
const isProtected = ApiProtectedMixin.isBaseClassOf(item) && item.isProtected;
|
||||
const isReadonly = ApiReadonlyMixin.isBaseClassOf(item) && item.isReadonly;
|
||||
|
||||
@@ -4,7 +4,6 @@ import type { ApiItemKind } from '@microsoft/api-extractor-model';
|
||||
import { VscArrowRight } from '@react-icons/all-files/vsc/VscArrowRight';
|
||||
import { VscSymbolClass } from '@react-icons/all-files/vsc/VscSymbolClass';
|
||||
import { VscSymbolEnum } from '@react-icons/all-files/vsc/VscSymbolEnum';
|
||||
import { VscSymbolField } from '@react-icons/all-files/vsc/VscSymbolField';
|
||||
import { VscSymbolInterface } from '@react-icons/all-files/vsc/VscSymbolInterface';
|
||||
import { VscSymbolMethod } from '@react-icons/all-files/vsc/VscSymbolMethod';
|
||||
import { VscSymbolProperty } from '@react-icons/all-files/vsc/VscSymbolProperty';
|
||||
@@ -28,7 +27,7 @@ function resolveIcon(item: keyof typeof ApiItemKind) {
|
||||
case 'Property':
|
||||
return <VscSymbolProperty className="shrink-0" size={25} />;
|
||||
case 'TypeAlias':
|
||||
return <VscSymbolField className="shrink-0" size={25} />;
|
||||
return <VscSymbolVariable className="shrink-0" size={25} />;
|
||||
case 'Variable':
|
||||
return <VscSymbolVariable className="shrink-0" size={25} />;
|
||||
default:
|
||||
|
||||
@@ -5,15 +5,15 @@ export interface CodeListingProps {
|
||||
/**
|
||||
* The value of this heading.
|
||||
*/
|
||||
children: ReactNode;
|
||||
readonly children: ReactNode;
|
||||
/**
|
||||
* Additional class names to apply to the root element.
|
||||
*/
|
||||
className?: string | undefined;
|
||||
readonly className?: string | undefined;
|
||||
/**
|
||||
* The href of this heading.
|
||||
*/
|
||||
href?: string | undefined;
|
||||
readonly href?: string | undefined;
|
||||
}
|
||||
|
||||
export function CodeHeading({ href, className, children }: CodeListingProps) {
|
||||
|
||||
@@ -8,11 +8,11 @@ export interface ExcerptTextProps {
|
||||
/**
|
||||
* The tokens to render.
|
||||
*/
|
||||
excerpt: Excerpt;
|
||||
readonly excerpt: Excerpt;
|
||||
/**
|
||||
* The model to resolve item references from.
|
||||
*/
|
||||
model: ApiModel;
|
||||
readonly model: ApiModel;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ export function ExcerptText({ model, excerpt }: ExcerptTextProps) {
|
||||
<ItemLink
|
||||
className="text-blurple"
|
||||
itemURI={resolveItemURI(item)}
|
||||
key={`${item.displayName}-${item.containerKey}`}
|
||||
key={`${item.displayName}-${item.containerKey}-${idx}`}
|
||||
packageName={item.getAssociatedPackage()?.displayName.replace('@discordjs/', '')}
|
||||
>
|
||||
{token.text}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import Image from 'next/image';
|
||||
import vercelLogo from '~/assets/powered-by-vercel.svg';
|
||||
import workersLogo from '~/assets/powered-by-workers.png';
|
||||
|
||||
export default function Footer() {
|
||||
return (
|
||||
<footer className="md:pl-12 md:pr-12">
|
||||
<div className="mx-auto max-w-6xl flex flex-col place-items-center gap-12 pt-12 lg:place-content-center">
|
||||
<div className="w-full flex flex-col place-content-between place-items-center gap-12 md:flex-row md:gap-0">
|
||||
<div className="flex flex-col flex-wrap place-content-center gap-6 pt-12 sm:flex-row md:gap-12">
|
||||
<div className="flex flex-wrap place-content-center place-items-center gap-4">
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"
|
||||
@@ -22,56 +23,72 @@ export default function Footer() {
|
||||
width={212}
|
||||
/>
|
||||
</a>
|
||||
<div className="flex flex-row gap-6 md:gap-12">
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="text-lg font-semibold">Community</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://discord.gg/djs"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
Discord
|
||||
</a>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://github.com/discordjs/discord.js/discussions"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
GitHub discussions
|
||||
</a>
|
||||
</div>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://www.cloudflare.com"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
title="Cloudflare Workers"
|
||||
>
|
||||
<Image
|
||||
alt="Cloudflare"
|
||||
blurDataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAABLCAQAAAA1k5H2AAAAi0lEQVR42u3SMQEAAAgDoC251a3gL2SgmfBYBRAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARCAgwWEOSWBnYbKggAAAABJRU5ErkJggg=="
|
||||
height={44}
|
||||
placeholder="blur"
|
||||
priority
|
||||
src={workersLogo}
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
<div className="flex flex-col place-self-center gap-6 sm:flex-row md:gap-12">
|
||||
<div className="max-w-max flex flex-col gap-2">
|
||||
<div className="text-lg font-semibold">Community</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://discord.gg/djs"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
Discord
|
||||
</a>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://github.com/discordjs/discord.js/discussions"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
GitHub discussions
|
||||
</a>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="text-lg font-semibold">Project</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://github.com/discordjs/discord.js"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
discord.js
|
||||
</a>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://discordjs.guide"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
discord.js guide
|
||||
</a>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://discord-api-types.dev"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
discord-api-types
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div className="max-w-max flex flex-col gap-2">
|
||||
<div className="text-lg font-semibold">Project</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://github.com/discordjs/discord.js"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
discord.js
|
||||
</a>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://discord.js.org/docs"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
discord.js documentation
|
||||
</a>
|
||||
<a
|
||||
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
|
||||
href="https://discord-api-types.dev"
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
discord-api-types
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ApiDeclaredItem } from '@microsoft/api-extractor-model';
|
||||
import { ItemLink } from './ItemLink';
|
||||
import { resolveItemURI } from './documentation/util';
|
||||
|
||||
export function InheritanceText({ parent }: { parent: ApiDeclaredItem }) {
|
||||
export function InheritanceText({ parent }: { readonly parent: ApiDeclaredItem }) {
|
||||
return (
|
||||
<span className="font-semibold">
|
||||
Inherited from{' '}
|
||||
|
||||
@@ -10,17 +10,17 @@ export interface ItemLinkProps
|
||||
extends Omit<LinkProps, 'href'>,
|
||||
RefAttributes<HTMLAnchorElement>,
|
||||
Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof LinkProps> {
|
||||
className?: string;
|
||||
readonly className?: string;
|
||||
|
||||
/**
|
||||
* The URI of the api item to link to. (e.g. `/RestManager`)
|
||||
*/
|
||||
itemURI: string;
|
||||
readonly itemURI: string;
|
||||
|
||||
/**
|
||||
* The name of the package the item belongs to.
|
||||
*/
|
||||
packageName?: string | undefined;
|
||||
readonly packageName?: string | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@ import { useNav } from '~/contexts/nav';
|
||||
const PackageSelect = dynamic(async () => import('./PackageSelect'));
|
||||
const VersionSelect = dynamic(async () => import('./VersionSelect'));
|
||||
|
||||
export function Nav({ members }: { members: SidebarSectionItemData[] }) {
|
||||
export function Nav({ members }: { readonly members: SidebarSectionItemData[] }) {
|
||||
const { opened } = useNav();
|
||||
|
||||
return (
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Scrollbars } from './Scrollbars';
|
||||
import type { TableOfContentsSerialized } from './TableOfContentItems';
|
||||
import { TableOfContentItems } from './TableOfContentItems';
|
||||
|
||||
export function Outline({ members }: { members: TableOfContentsSerialized[] }) {
|
||||
export function Outline({ members }: { readonly members: TableOfContentsSerialized[] }) {
|
||||
return (
|
||||
<aside className="fixed bottom-0 right-0 top-[50px] z-20 hidden h-[calc(100vh_-_65px)] w-64 border-l border-light-800 bg-white pr-2 xl:block dark:border-dark-100 dark:bg-dark-600">
|
||||
<Scrollbars
|
||||
|
||||
@@ -4,17 +4,52 @@ import { VscChevronDown } from '@react-icons/all-files/vsc/VscChevronDown';
|
||||
import { VscVersions } from '@react-icons/all-files/vsc/VscVersions';
|
||||
import { Menu, MenuButton, MenuItem, useMenuState } from 'ariakit/menu';
|
||||
import type { PropsWithChildren, ReactNode } from 'react';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useCallback, useMemo, useState, useEffect } from 'react';
|
||||
|
||||
export interface OverloadSwitcherProps {
|
||||
methodName: string;
|
||||
overloads: ReactNode[];
|
||||
}
|
||||
|
||||
export default function OverloadSwitcher({ overloads, children }: PropsWithChildren<{ overloads: ReactNode[] }>) {
|
||||
export default function OverloadSwitcher({
|
||||
methodName,
|
||||
overloads,
|
||||
children,
|
||||
}: PropsWithChildren<{ readonly methodName: string; readonly overloads: ReactNode[] }>) {
|
||||
const [hash, setHash] = useState(() => (typeof window === 'undefined' ? '' : window.location.hash));
|
||||
const hashChangeHandler = useCallback(() => {
|
||||
setHash(window.location.hash);
|
||||
}, []);
|
||||
const [overloadIndex, setOverloadIndex] = useState(1);
|
||||
const overloadedNode = overloads[overloadIndex - 1]!;
|
||||
const menu = useMenuState({ gutter: 8, sameWidth: true, fitViewport: true });
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener('hashchange', hashChangeHandler);
|
||||
return () => {
|
||||
window.removeEventListener('hashchange', hashChangeHandler);
|
||||
};
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (hash) {
|
||||
const elementId = hash.replace('#', '');
|
||||
const [name, idx] = elementId.split(':');
|
||||
if (name && methodName === name) {
|
||||
if (idx) {
|
||||
const hashOverload = Number.parseInt(idx, 10);
|
||||
const resolvedOverload = Math.max(Math.min(hashOverload, overloads.length), 1);
|
||||
setOverloadIndex(Number.isNaN(resolvedOverload) ? 1 : resolvedOverload);
|
||||
}
|
||||
|
||||
const element = document.querySelector(`[id^='${name}']`);
|
||||
if (element) {
|
||||
element.scrollIntoView({ behavior: 'smooth' });
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [hash, methodName, overloads.length]);
|
||||
|
||||
const menuItems = useMemo(
|
||||
() =>
|
||||
overloads.map((_, idx) => (
|
||||
|
||||
@@ -10,7 +10,7 @@ const columnStyles = {
|
||||
Type: 'font-mono whitespace-pre-wrap break-normal',
|
||||
};
|
||||
|
||||
export function ParameterTable({ item }: { item: ApiDocumentedItem & ApiParameterListMixin }) {
|
||||
export function ParameterTable({ item }: { readonly item: ApiDocumentedItem & ApiParameterListMixin }) {
|
||||
const params = resolveParameters(item);
|
||||
|
||||
const rows = useMemo(
|
||||
|
||||
@@ -16,8 +16,8 @@ export function Property({
|
||||
children,
|
||||
inheritedFrom,
|
||||
}: PropsWithChildren<{
|
||||
inheritedFrom?: (ApiDeclaredItem & ApiItemContainerMixin) | undefined;
|
||||
item: ApiProperty | ApiPropertySignature;
|
||||
readonly inheritedFrom?: (ApiDeclaredItem & ApiItemContainerMixin) | undefined;
|
||||
readonly item: ApiProperty | ApiPropertySignature;
|
||||
}>) {
|
||||
const hasSummary = Boolean(item.tsdocComment?.summarySection);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ export function isPropertyLike(item: ApiItem): item is ApiProperty | ApiProperty
|
||||
return item.kind === ApiItemKind.Property || item.kind === ApiItemKind.PropertySignature;
|
||||
}
|
||||
|
||||
export function PropertyList({ item }: { item: ApiItemContainerMixin }) {
|
||||
export function PropertyList({ item }: { readonly item: ApiItemContainerMixin }) {
|
||||
const members = resolveMembers(item, isPropertyLike);
|
||||
|
||||
const propertyItems = useMemo(
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import type { ApiItemKind } from '@microsoft/api-extractor-model';
|
||||
import { VscSymbolClass } from '@react-icons/all-files/vsc/VscSymbolClass';
|
||||
import { VscSymbolEnum } from '@react-icons/all-files/vsc/VscSymbolEnum';
|
||||
import { VscSymbolField } from '@react-icons/all-files/vsc/VscSymbolField';
|
||||
import { VscSymbolInterface } from '@react-icons/all-files/vsc/VscSymbolInterface';
|
||||
import { VscSymbolMethod } from '@react-icons/all-files/vsc/VscSymbolMethod';
|
||||
import { VscSymbolVariable } from '@react-icons/all-files/vsc/VscSymbolVariable';
|
||||
@@ -74,7 +73,6 @@ function resolveIcon(item: string) {
|
||||
case 'Interfaces':
|
||||
return <VscSymbolInterface size={20} />;
|
||||
case 'Types':
|
||||
return <VscSymbolField size={20} />;
|
||||
case 'Variables':
|
||||
return <VscSymbolVariable size={20} />;
|
||||
default:
|
||||
@@ -82,7 +80,7 @@ function resolveIcon(item: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export function Sidebar({ members }: { members: SidebarSectionItemData[] }) {
|
||||
export function Sidebar({ members }: { readonly members: SidebarSectionItemData[] }) {
|
||||
const segment = useSelectedLayoutSegment();
|
||||
const { setOpened } = useNav();
|
||||
|
||||
@@ -94,7 +92,7 @@ export function Sidebar({ members }: { members: SidebarSectionItemData[] }) {
|
||||
.filter((group) => groupItems[group].length)
|
||||
.map((group, idx) => (
|
||||
<Section
|
||||
buttonClassName="bg-light-600 hover:bg-light-700 active:bg-light-800 dark:bg-dark-400 dark:hover:bg-dark-300 dark:active:bg-dark-400 focus:ring-width-2 focus:ring-blurple rounded p-3 outline-none focus:ring"
|
||||
buttonClassName="bg-light-600 hover:bg-light-700 active:bg-light-800 dark:bg-dark-400 dark:hover:bg-dark-300 dark:active:bg-dark-400 focus:ring-width-2 focus:ring-blurple rounded p-3 outline-none focus:ring z-10"
|
||||
icon={resolveIcon(group)}
|
||||
key={`${group}-${idx}`}
|
||||
title={group}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { ApiModel, Excerpt } from '@microsoft/api-extractor-model';
|
||||
import { ExcerptText } from './ExcerptText';
|
||||
|
||||
export function SignatureText({ excerpt, model }: { excerpt: Excerpt; model: ApiModel }) {
|
||||
export function SignatureText({ excerpt, model }: { readonly excerpt: Excerpt; readonly model: ApiModel }) {
|
||||
return (
|
||||
<h4 className="break-all font-mono text-lg font-bold">
|
||||
<h4 className="break-all text-lg font-bold font-mono">
|
||||
<ExcerptText excerpt={excerpt} model={model} />
|
||||
</h4>
|
||||
);
|
||||
|
||||
@@ -4,11 +4,9 @@ export function SyntaxHighlighter(props: typeof Code) {
|
||||
return (
|
||||
<>
|
||||
<div data-theme="dark">
|
||||
{/* @ts-expect-error async component */}
|
||||
<Code codeClassName="font-mono" lang={props.lang ?? 'typescript'} {...props} theme="github-dark-dimmed" />
|
||||
</div>
|
||||
<div className="[&_pre]:border [&_pre]:border-gray-300 [&_pre]:rounded-md" data-theme="light">
|
||||
{/* @ts-expect-error async component */}
|
||||
<Code codeClassName="font-mono" lang={props.lang ?? 'typescript'} {...props} theme="min-light" />
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -7,9 +7,9 @@ export function Table({
|
||||
columns,
|
||||
columnStyles,
|
||||
}: {
|
||||
columnStyles?: Record<string, string>;
|
||||
columns: string[];
|
||||
rows: Record<string, ReactNode>[];
|
||||
readonly columnStyles?: Record<string, string>;
|
||||
readonly columns: string[];
|
||||
readonly rows: Record<string, ReactNode>[];
|
||||
}) {
|
||||
const cols = useMemo(
|
||||
() =>
|
||||
|
||||
@@ -19,10 +19,10 @@ export interface TableOfContentsSerializedProperty {
|
||||
export type TableOfContentsSerialized = TableOfContentsSerializedMethod | TableOfContentsSerializedProperty;
|
||||
|
||||
export interface TableOfContentsItemProps {
|
||||
serializedMembers: TableOfContentsSerialized[];
|
||||
readonly serializedMembers: TableOfContentsSerialized[];
|
||||
}
|
||||
|
||||
export function TableOfContentsPropertyItem({ property }: { property: TableOfContentsSerializedProperty }) {
|
||||
export function TableOfContentsPropertyItem({ property }: { readonly property: TableOfContentsSerializedProperty }) {
|
||||
return (
|
||||
<a
|
||||
className="ml-[10px] border-l border-light-800 p-[5px] pl-6.5 text-sm outline-none focus:border-0 dark:border-dark-100 focus:rounded active:bg-light-800 hover:bg-light-700 focus:ring focus:ring-width-2 focus:ring-blurple dark:active:bg-dark-100 dark:hover:bg-dark-200"
|
||||
@@ -35,7 +35,7 @@ export function TableOfContentsPropertyItem({ property }: { property: TableOfCon
|
||||
);
|
||||
}
|
||||
|
||||
export function TableOfContentsMethodItem({ method }: { method: TableOfContentsSerializedMethod }) {
|
||||
export function TableOfContentsMethodItem({ method }: { readonly method: TableOfContentsSerializedMethod }) {
|
||||
if (method.overloadIndex && method.overloadIndex > 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ const rowElements = {
|
||||
Default: 'font-mono whitespace-pre break-normal',
|
||||
};
|
||||
|
||||
export function TypeParamTable({ item }: { item: ApiTypeParameterListMixin }) {
|
||||
export function TypeParamTable({ item }: { readonly item: ApiTypeParameterListMixin }) {
|
||||
const model = item.getAssociatedModel()!;
|
||||
const rows = useMemo(
|
||||
() =>
|
||||
|
||||
@@ -19,6 +19,7 @@ function generateIcon(kind: ApiItemKind) {
|
||||
case ApiItemKind.Interface:
|
||||
return <VscSymbolInterface />;
|
||||
case ApiItemKind.TypeAlias:
|
||||
case ApiItemKind.Variable:
|
||||
return <VscSymbolVariable />;
|
||||
default:
|
||||
return <VscSymbolMethod />;
|
||||
@@ -29,7 +30,7 @@ export function Header({
|
||||
kind,
|
||||
name,
|
||||
sourceURL,
|
||||
}: PropsWithChildren<{ kind: ApiItemKind; name: string; sourceURL?: string | undefined }>) {
|
||||
}: PropsWithChildren<{ readonly kind: ApiItemKind; readonly name: string; readonly sourceURL?: string | undefined }>) {
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<h2 className="flex flex-row place-items-center justify-between gap-2 break-all text-2xl font-bold">
|
||||
|
||||
@@ -2,7 +2,13 @@ import type { ApiClass, ApiInterface, Excerpt } from '@microsoft/api-extractor-m
|
||||
import { ApiItemKind } from '@microsoft/api-extractor-model';
|
||||
import { ExcerptText } from '../ExcerptText';
|
||||
|
||||
export function HierarchyText({ item, type }: { item: ApiClass | ApiInterface; type: 'Extends' | 'Implements' }) {
|
||||
export function HierarchyText({
|
||||
item,
|
||||
type,
|
||||
}: {
|
||||
readonly item: ApiClass | ApiInterface;
|
||||
readonly type: 'Extends' | 'Implements';
|
||||
}) {
|
||||
const model = item.getAssociatedModel()!;
|
||||
|
||||
if (
|
||||
|
||||
@@ -3,7 +3,7 @@ import { MethodsSection } from './section/MethodsSection';
|
||||
import { PropertiesSection } from './section/PropertiesSection';
|
||||
import { hasProperties, hasMethods } from './util';
|
||||
|
||||
export function Members({ item }: { item: ApiDeclaredItem & ApiItemContainerMixin }) {
|
||||
export function Members({ item }: { readonly item: ApiDeclaredItem & ApiItemContainerMixin }) {
|
||||
return (
|
||||
<>
|
||||
{hasProperties(item) ? <PropertiesSection item={item} /> : null}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Header } from './Header';
|
||||
import { SummarySection } from './section/SummarySection';
|
||||
|
||||
export interface ObjectHeaderProps {
|
||||
item: ApiDeclaredItem;
|
||||
readonly item: ApiDeclaredItem;
|
||||
}
|
||||
|
||||
export function ObjectHeader({ item }: ObjectHeaderProps) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { parametersString } from '../util';
|
||||
import { DocumentationSection } from './DocumentationSection';
|
||||
import { CodeHeading } from '~/components/CodeHeading';
|
||||
|
||||
export function ConstructorSection({ item }: { item: ApiConstructor }) {
|
||||
export function ConstructorSection({ item }: { readonly item: ApiConstructor }) {
|
||||
return (
|
||||
<DocumentationSection icon={<VscSymbolMethod size={20} />} padded title="Constructor">
|
||||
<div className="flex flex-col gap-2">
|
||||
|
||||
@@ -19,7 +19,7 @@ function isMethodLike(item: ApiItem): item is ApiMethod | ApiMethodSignature {
|
||||
);
|
||||
}
|
||||
|
||||
export function MethodsSection({ item }: { item: ApiItemContainerMixin }) {
|
||||
export function MethodsSection({ item }: { readonly item: ApiItemContainerMixin }) {
|
||||
const members = resolveMembers(item, isMethodLike);
|
||||
|
||||
const methodItems = useMemo(
|
||||
|
||||
@@ -3,7 +3,7 @@ import { VscSymbolParameter } from '@react-icons/all-files/vsc/VscSymbolParamete
|
||||
import { ParameterTable } from '../../ParameterTable';
|
||||
import { DocumentationSection } from './DocumentationSection';
|
||||
|
||||
export function ParameterSection({ item }: { item: ApiDocumentedItem & ApiParameterListMixin }) {
|
||||
export function ParameterSection({ item }: { readonly item: ApiDocumentedItem & ApiParameterListMixin }) {
|
||||
return (
|
||||
<DocumentationSection icon={<VscSymbolParameter size={20} />} padded title="Parameters">
|
||||
<ParameterTable item={item} />
|
||||
|
||||
@@ -3,7 +3,7 @@ import { VscSymbolProperty } from '@react-icons/all-files/vsc/VscSymbolProperty'
|
||||
import { PropertyList } from '../../PropertyList';
|
||||
import { DocumentationSection } from './DocumentationSection';
|
||||
|
||||
export function PropertiesSection({ item }: { item: ApiItemContainerMixin }) {
|
||||
export function PropertiesSection({ item }: { readonly item: ApiItemContainerMixin }) {
|
||||
return (
|
||||
<DocumentationSection icon={<VscSymbolProperty size={20} />} padded title="Properties">
|
||||
<PropertyList item={item} />
|
||||
|
||||
@@ -3,7 +3,7 @@ import { VscListSelection } from '@react-icons/all-files/vsc/VscListSelection';
|
||||
import { TSDoc } from '../tsdoc/TSDoc';
|
||||
import { DocumentationSection } from './DocumentationSection';
|
||||
|
||||
export function SummarySection({ item }: { item: ApiDeclaredItem }) {
|
||||
export function SummarySection({ item }: { readonly item: ApiDeclaredItem }) {
|
||||
return (
|
||||
<DocumentationSection icon={<VscListSelection size={20} />} padded separator title="Summary">
|
||||
{item.tsdocComment?.summarySection ? (
|
||||
|
||||
@@ -3,7 +3,7 @@ import { VscSymbolParameter } from '@react-icons/all-files/vsc/VscSymbolParamete
|
||||
import { TypeParamTable } from '../../TypeParamTable';
|
||||
import { DocumentationSection } from './DocumentationSection';
|
||||
|
||||
export function TypeParameterSection({ item }: { item: ApiTypeParameterListMixin }) {
|
||||
export function TypeParameterSection({ item }: { readonly item: ApiTypeParameterListMixin }) {
|
||||
return (
|
||||
<DocumentationSection icon={<VscSymbolParameter size={20} />} padded title="Type Parameters">
|
||||
<TypeParamTable item={item} />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Alert } from '@discordjs/ui';
|
||||
import type { PropsWithChildren } from 'react';
|
||||
|
||||
export function Block({ children, title }: PropsWithChildren<{ title: string }>) {
|
||||
export function Block({ children, title }: PropsWithChildren<{ readonly title: string }>) {
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<h5 className="font-bold">{title}</h5>
|
||||
@@ -13,7 +13,7 @@ export function Block({ children, title }: PropsWithChildren<{ title: string }>)
|
||||
export function ExampleBlock({
|
||||
children,
|
||||
exampleIndex,
|
||||
}: PropsWithChildren<{ exampleIndex?: number | undefined }>): JSX.Element {
|
||||
}: PropsWithChildren<{ readonly exampleIndex?: number | undefined }>): JSX.Element {
|
||||
return <Block title={`Example ${exampleIndex ? exampleIndex : ''}`}>{children}</Block>;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { SyntaxHighlighter } from '../../SyntaxHighlighter';
|
||||
import { resolveItemURI } from '../util';
|
||||
import { DefaultValueBlock, DeprecatedBlock, ExampleBlock, RemarksBlock, ReturnsBlock, SeeBlock } from './BlockComment';
|
||||
|
||||
export function TSDoc({ item, tsdoc }: { item: ApiItem; tsdoc: DocNode }): JSX.Element {
|
||||
export function TSDoc({ item, tsdoc }: { readonly item: ApiItem; readonly tsdoc: DocNode }): JSX.Element {
|
||||
const createNode = useCallback(
|
||||
(tsdoc: DocNode, idx?: number): ReactNode => {
|
||||
switch (tsdoc.kind) {
|
||||
@@ -66,7 +66,7 @@ export function TSDoc({ item, tsdoc }: { item: ApiItem; tsdoc: DocNode }): JSX.E
|
||||
case DocNodeKind.CodeSpan: {
|
||||
const { code } = tsdoc as DocFencedCode;
|
||||
return (
|
||||
<code className="font-mono text-sm" key={idx}>
|
||||
<code className="text-sm font-mono" key={idx}>
|
||||
{code}
|
||||
</code>
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ import { ConstructorSection } from '../documentation/section/ConstructorSection'
|
||||
import { TypeParameterSection } from '../documentation/section/TypeParametersSection';
|
||||
// import { serializeMembers } from '../documentation/util';
|
||||
|
||||
export function Class({ clazz }: { clazz: ApiClass }) {
|
||||
export function Class({ clazz }: { readonly clazz: ApiClass }) {
|
||||
const constructor = clazz.members.find((member) => member.kind === ApiItemKind.Constructor) as
|
||||
| ApiConstructor
|
||||
| undefined;
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ObjectHeader } from '../documentation/ObjectHeader';
|
||||
import { TypeParameterSection } from '../documentation/section/TypeParametersSection';
|
||||
// import { serializeMembers } from '../documentation/util';
|
||||
|
||||
export function Interface({ item }: { item: ApiInterface }) {
|
||||
export function Interface({ item }: { readonly item: ApiInterface }) {
|
||||
return (
|
||||
<Documentation>
|
||||
<ObjectHeader item={item} />
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user