Compare commits

..

56 Commits

Author SHA1 Message Date
iCrawl
e3cbd45e7d chore: release 2022-05-13 11:49:56 +02:00
Synbulat Biishev
ea28638a0c fix(MessageEmbed): fix a typo (#7906) 2022-05-12 10:24:54 +02:00
Almeida
43a7870b23 docs(shardingmanager): fix type of execArgv option (v13) (#7863) 2022-05-02 09:38:11 +02:00
Hyro
6dcf0bda05 docs: fix and improve localization docs (v13 backport) (#7807) 2022-04-21 19:06:28 +02:00
Almeida
816936eafb fix(GuildEditData): some fields can be null for v13 (#7633)
* fix(GuildEditData): some fields can be null for v13

* fix: make even more things nullable
2022-04-19 16:01:59 +02:00
Sasial
1d09ad4652 types: fix ModalSubmitInteraction (#7768) 2022-04-19 15:59:58 +02:00
Jiralite
5165b18b85 feat: backport (#7776) 2022-04-19 15:59:05 +02:00
Rodry
7afcd9594a types(threadchannel): fix autoArchiveDuration types (#7817) 2022-04-19 15:54:39 +02:00
Jiralite
b9802f4b6f refactor: deprecate v13 properties and methods (#7782)
* refactor: deprecate splitting

* refactor: deprecate `IntegrationApplication#summary`

https://github.com/discordjs/discord.js/pull/7729

* docs: amend store channel wording

* refactor: deprecate fetching of application assets

* docs: deprecate vip field in voice regions
2022-04-17 10:52:50 +02:00
Jiralite
1040ce0e71 docs(ApplicationCommand): Fix ApplicationCommandOptionChoice (#7798) 2022-04-17 10:47:34 +02:00
Jiralite
3eb45e30b3 feat: backport (#7787) 2022-04-14 12:48:31 +02:00
Jiralite
ab324ea6ae feat: backport (#7786) 2022-04-14 12:48:10 +02:00
Hyro
022e138b9a feat: add support for localized slash commands (v13 backport) (#7766) 2022-04-14 12:47:46 +02:00
Superchupu
9e4a900e6d feat: app authorization links and tags for v13 (#7731) 2022-04-14 12:47:11 +02:00
Jiralite
6c5613255a feat: backport (#7777) 2022-04-14 12:45:54 +02:00
Jiralite
ff49b82db7 feat: backport (#7778) 2022-04-14 12:45:35 +02:00
Jiralite
ae7f991e8d feat: backport (#7779) 2022-04-14 12:45:16 +02:00
Jiralite
cedc333940 feat: backport (#7783) 2022-04-14 12:44:24 +02:00
Jiralite
6daee1b235 feat(VoiceChannel): Support video_quality_mode (v13) (#7785) 2022-04-14 12:43:25 +02:00
Jiralite
68498a87be feat(StageInstance): add support for associated guild event (#7713) 2022-04-12 17:19:59 +02:00
Jiralite
ab6c2bad84 fix: apply v14 fix (#7756) 2022-04-12 17:11:57 +02:00
Almeida
c9e4562fd5 fix(GuildChannelManager): delete method accessing wrong id (#7771) 2022-04-12 17:08:57 +02:00
Ryan Munro
e1cdcfa9a6 feat(modals): modals, input text components and modal submits, v13 style (#7431) 2022-04-09 11:36:49 +02:00
Jiralite
5e8162a137 feat: Backport Interaction#isRepliable (#7563) 2022-04-09 11:36:15 +02:00
Rodry
9f09702854 feat: add methods to managers for v13 (#7611) 2022-04-09 11:35:17 +02:00
Jiralite
8e7d15e49d feat: Add premiumSubscriptionCount to InviteGuild (#7629) 2022-04-09 11:34:24 +02:00
Jiralite
b9c5676006 refactor: remove non-breaking stuff (#7636) 2022-04-09 11:33:44 +02:00
Almeida
dfea9c27ce fix(GuildScheduledEvent): handle missing image for v13 (#7627) 2022-03-24 20:59:19 +01:00
Jiralite
78140748ce types(InteractionCollector): Fix guild and channel types (#7624) 2022-03-10 09:00:58 +01:00
Ben
a7535a2232 feat(scheduledevents): Event cover images for v13 (#7613)
Co-authored-by: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com>
2022-03-07 19:26:57 +01:00
Rodry
7a52785f7d fix(messagementions): fix has method for v13 (#7591)
Co-authored-by: Almeida <almeidx@pm.me>
Co-authored-by: Synbulat Biishev <syjalo.dev@gmail.com>
2022-03-06 16:26:57 +01:00
Ben
13dd82d7fa fix: check if member has admininistrator on moderatable (v13) (#7578) 2022-03-02 10:38:04 +01:00
Jiralite
93cdb2f2fa feat: Backport MessageMentions channel type fixes (#7562) 2022-03-02 10:32:57 +01:00
Jiralite
611d3a7b2f feat: Backport cache types resolving to never (#7561) 2022-03-02 10:32:46 +01:00
Jiralite
29d42ed319 feat: Backport sending message flags (#7560) 2022-03-02 10:32:36 +01:00
Jiralite
1d97dcff08 feat(ThreadChannel): Backport creation timestamp (#7559) 2022-03-02 10:32:25 +01:00
Jiralite
679b87c4f8 feat: Add custom image support to version 13 (#7557) 2022-03-02 10:32:13 +01:00
Jiralite
b231bece0e feat: Backport reason on pin and unpin (#7556) 2022-03-02 10:32:03 +01:00
Jiralite
49397c0ca4 fix(ThreadChannel): Require sendable for unarchivable (#7555) 2022-03-02 10:31:51 +01:00
Jiralite
215dfe02d5 feat(GuildPreview): Add stickers to version 13 (#7554) 2022-03-02 10:31:41 +01:00
Jiralite
69ba067a65 docs: Backport version 13 fixes (#7552)
Co-authored-by: Rodry <38259440+ImRodry@users.noreply.github.com>
2022-03-02 10:31:28 +01:00
Jiralite
5f621c1995 fix: Backport MessageReaction#me being incorrectly false (#7553) 2022-03-02 10:30:13 +01:00
Jiralite
ee1698d928 feat: Backport sweepStickers method (#7558) 2022-03-02 10:29:59 +01:00
Ben
2fcf8af421 feat(scheduledevents): add image option (v13) (#7549) 2022-02-26 11:14:48 +01:00
EhsanFox
f0960698d2 fix(typings): sweepStageInstances typo (#7521) 2022-02-23 08:39:05 +01:00
ckohen
30baff7ecb fix(MessagePayload): v13 don't set reply flags to target flags (#7515) 2022-02-23 08:37:59 +01:00
Jiralite
2b3db734df feat(thread): v13 add newlyCreated to threadCreate event (#7481) 2022-02-20 13:42:23 +01:00
Jiralite
0b54089c43 types: V13 channel create overloads fix (#7480) 2022-02-20 13:39:20 +01:00
Jiralite
77b8e01911 fix(Shard): V13 EventEmitter listener warning (#7479) 2022-02-17 17:46:06 +01:00
Parbez
bc5ddc36fa fix(MessageEmbed): set footer to undefined (#7358) 2022-02-13 12:44:16 +01:00
Ryan Munro
5bcca8b97f feat(commands): attachment options (#7441) 2022-02-13 12:41:41 +01:00
iCrawl
988a51b764 chore(release): version 2022-01-13 18:24:17 +01:00
Rodry
1f4e633ce3 docs(interaction): add locale list link (#7261) 2022-01-13 18:20:35 +01:00
Suneet Tipirneni
233084a601 feat: add Locales to Interactions (#7131)
Co-authored-by: Rodry <38259440+ImRodry@users.noreply.github.com>
2022-01-13 18:18:02 +01:00
iCrawl
ac8c122c2a chore(release): version 2022-01-07 23:57:17 +01:00
ckohen
2dabd82e26 fix(sweepers): provide default for object param (#7182) 2022-01-07 23:53:27 +01:00
1404 changed files with 48975 additions and 157189 deletions

View File

@@ -1,13 +1,10 @@
{
"$schema": "https://json.schemastore.org/commitlintrc.json",
"extends": ["@commitlint/config-angular"],
"rules": {
"type-enum": [
2,
"always",
["chore", "build", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test", "types"]
],
"scope-case": [0],
"subject-exclamation-mark": [0]
}
"extends": ["@commitlint/config-angular"],
"rules": {
"type-enum": [
2,
"always",
["chore", "build", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test", "types", "typings"]
]
}
}

View File

@@ -1,67 +0,0 @@
# Packages
**/node_modules
# Log files
**/logs
**/*.log
**/npm-debug.log*
# Runtime data
**/pids
**/*.pid
**/*.seed
# Env
**/.env
# Dist
**/dist/
**/dist-docs/
# Miscellaneous
**/.tmp
**/.vscode
**/.idea
**/.DS_Store
**/.turbo
**/tsconfig.tsbuildinfo
**/coverage
**/__tests__
**/out
# yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
# Cache
**/.prettiercache
**/.eslintcache
**/.vercel
# Docker specific
**/.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

1
.eslintignore Normal file
View File

@@ -0,0 +1 @@
/typings/**/*

200
.eslintrc.json Normal file
View File

@@ -0,0 +1,200 @@
{
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"plugins": ["import"],
"parserOptions": {
"ecmaVersion": 2021
},
"env": {
"es2021": true,
"node": true
},
"rules": {
"import/order": [
"error",
{
"groups": ["builtin", "external", "internal", "index", "sibling", "parent"],
"alphabetize": {
"order": "asc"
}
}
],
"prettier/prettier": [
2,
{
"printWidth": 120,
"singleQuote": true,
"quoteProps": "as-needed",
"trailingComma": "all",
"endOfLine": "lf",
"arrowParens": "avoid"
}
],
"strict": ["error", "global"],
"no-await-in-loop": "warn",
"no-compare-neg-zero": "error",
"no-template-curly-in-string": "error",
"no-unsafe-negation": "error",
"valid-jsdoc": [
"error",
{
"requireReturn": false,
"requireReturnDescription": false,
"prefer": {
"return": "returns",
"arg": "param"
},
"preferType": {
"String": "string",
"Number": "number",
"Boolean": "boolean",
"Symbol": "symbol",
"object": "Object",
"function": "Function",
"array": "Array",
"date": "Date",
"error": "Error",
"null": "void"
}
}
],
"accessor-pairs": "warn",
"array-callback-return": "error",
"consistent-return": "error",
"curly": ["error", "multi-line", "consistent"],
"dot-location": ["error", "property"],
"dot-notation": "error",
"eqeqeq": "error",
"no-empty-function": "error",
"no-floating-decimal": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-lone-blocks": "error",
"no-multi-spaces": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-new": "error",
"no-octal-escape": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-throw-literal": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-escape": "error",
"no-useless-return": "error",
"no-void": "error",
"no-warning-comments": "warn",
"prefer-promise-reject-errors": "error",
"require-await": "warn",
"wrap-iife": "error",
"yoda": "error",
"no-label-var": "error",
"no-shadow": "error",
"no-undef-init": "error",
"callback-return": "error",
"getter-return": "off",
"handle-callback-err": "error",
"no-mixed-requires": "error",
"no-new-require": "error",
"no-path-concat": "error",
"array-bracket-spacing": "error",
"block-spacing": "error",
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"capitalized-comments": ["error", "always", { "ignoreConsecutiveComments": true }],
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error",
"comma-style": "error",
"computed-property-spacing": "error",
"consistent-this": ["error", "$this"],
"eol-last": "error",
"func-names": "error",
"func-name-matching": "error",
"func-style": ["error", "declaration", { "allowArrowFunctions": true }],
"key-spacing": "error",
"keyword-spacing": "error",
"max-depth": "error",
"max-len": ["error", 120, 2],
"max-nested-callbacks": ["error", { "max": 4 }],
"max-statements-per-line": ["error", { "max": 2 }],
"new-cap": "off",
"newline-per-chained-call": ["error", { "ignoreChainWithDepth": 3 }],
"no-array-constructor": "error",
"no-inline-comments": "error",
"no-lonely-if": "error",
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
"no-new-object": "error",
"no-spaced-func": "error",
"no-trailing-spaces": "error",
"no-unneeded-ternary": "error",
"no-whitespace-before-property": "error",
"nonblock-statement-body-position": "error",
"object-curly-spacing": ["error", "always"],
"operator-assignment": "error",
"padded-blocks": ["error", "never"],
"quote-props": ["error", "as-needed"],
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
"semi-spacing": "error",
"semi": "error",
"space-before-blocks": "error",
"space-before-function-paren": [
"error",
{
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}
],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
"template-tag-spacing": "error",
"unicode-bom": "error",
"arrow-body-style": "error",
"arrow-parens": ["error", "as-needed"],
"arrow-spacing": "error",
"no-duplicate-imports": "error",
"no-useless-computed-key": "error",
"no-useless-constructor": "error",
"prefer-arrow-callback": "error",
"prefer-numeric-literals": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
"rest-spread-spacing": "error",
"template-curly-spacing": "error",
"yield-star-spacing": "error",
"no-restricted-globals": [
"error",
{
"name": "Buffer",
"message": "Import Buffer from `node:buffer` instead"
},
{
"name": "process",
"message": "Import process from `node:process` instead"
},
{
"name": "setTimeout",
"message": "Import setTimeout from `node:timers` instead"
},
{
"name": "setInterval",
"message": "Import setInterval from `node:timers` instead"
},
{
"name": "setImmediate",
"message": "Import setImmediate from `node:timers` instead"
}
]
}
}

1
.gitattributes vendored
View File

@@ -1,2 +1 @@
* text=auto eol=lf
pnpm-lock.yaml linguist-generated=true text=auto eol=lf

11
.github/.kodiak.toml vendored
View File

@@ -1,11 +0,0 @@
version = 1
[merge]
require_automerge_label = false
blocking_labels = ['blocked', 'in review']
method = 'squash'
[merge.message]
title = 'pull_request_title'
strip_html_comments = true
include_coauthors = true

24
.github/CODEOWNERS vendored
View File

@@ -1,24 +0,0 @@
# Learn how to add code owners here:
# https://help.github.com/articles/about-code-owners
* @iCrawl
/packages/actions/ @discordjs/actions
/packages/api-extractor-utils/ @discordjs/api-extractor-utils
/packages/brokers/ @discordjs/brokers
/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
/packages/next/ @discordjs/core
/packages/proxy/ @discordjs/proxy
/packages/proxy-container/ @discordjs/proxy
/packages/rest/ @discordjs/rest
/packages/scripts/ @discordjs/scripts
/packages/ui/ @discordjs/ui
/packages/util/ @discordjs/util
/packages/voice/ @discordjs/core
/packages/ws/ @discordjs/ws

View File

@@ -7,7 +7,7 @@
Messages must be matched by the following regex:
```js
/^(revert: )?(feat|fix|docs|style|refactor|perf|test|build|ci|chore|types)(\(.+\))?!?: .{1,72}/;
/^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|build|ci|chore|types|wip)(\(.+\))?: .{1,72}/;
```
#### Examples
@@ -55,7 +55,6 @@ A commit message consists of a **header**, **body** and **footer**. The header h
```
The **header** is mandatory and the **scope** of the header is optional.
If the commit contains **Breaking Changes**, a `!` can be added before the `:` as an indicator.
### Revert
@@ -69,7 +68,7 @@ Other prefixes are up to your discretion. Suggested prefixes are `docs`, `chore`
### Scope
The scope could be anything specifying the place of the commit change. For example `GuildMember`, `Guild`, `Message`, `TextChannel` etc...
The scope could be anything specifying the place of the commit change. For example `GuildMember`, `Guild`, `Message`, `MessageEmbed` etc...
### Subject

View File

@@ -11,39 +11,7 @@ is a great boon to your development process.
To get ready to work on the codebase, please do the following:
1. Fork & clone the repository, and make sure you're on the **main** branch
2. Run `pnpm install --frozen-lockfile` ([install](https://pnpm.io/installation))
3. Run `pnpm run build` to build local packages
4. Code your heart out!
5. Run `pnpm run test` to run ESLint and ensure any JSDoc changes are valid
6. [Submit a pull request](https://github.com/discordjs/discord.js/compare) (Make sure you follow the [conventional commit format](https://github.com/discordjs/discord.js/blob/main/.github/COMMIT_CONVENTION.md))
## Testing changes locally
If you want to test changes you've made locally, you can do so by using `pnpm link <package-you-want-to-link-to-your-current-package>`. This will create a symlink to your local copy of the discord.js libraries.
1. Create a new directory `mkdir discordjs-test` and move into it `cd discordjs-test`
2. Initialize a new pnpm project `pnpm init`
3. Now link the discord.js package from the directory you cloned earlier `pnpm link {PATH_TO_DISCORDJS_REPO}/packages/<package>`. (e.g. `pnpm link ~/discord.js/packages/rest`)
4. Import the package in your source code and test them out!
### Working with TypeScript packages
When testing local changes, you may notice you need to manually recompile TypeScript projects on every change in order to get the latest code changes to test locally.
To avoid this you can use the `--watch` parameter in the package build script to automatically recompile the project when changes are detected.
For example, to automatically recompile the `@discordjs/rest` project when changes are detected, run `pnpm turbo run build --filter='@discordjs/rest' -- --watch` in the root folder of where you cloned the discord.js repo.
## Adding new packages
If you'd like to create another package under the `@discordjs` organization run the following command:
```sh
pnpm run create-package <package-name> [package-description]
```
This will create new package directory under `packages/` with the required configuration files. You may begin
to make changes within the `src/` directory. You may also need to:
- Update workflows that utilize packages
- Update the CODEOWNERS file
2. Run `npm ci`
3. Code your heart out!
4. Run `npm test` to run ESLint and ensure any JSDoc changes are valid
5. [Submit a pull request](https://github.com/discordjs/discord.js/compare) (Make sure you follow the [conventional commit format](https://github.com/discordjs/discord.js/blob/main/.github/COMMIT_CONVENTION.md))

View File

@@ -1,139 +0,0 @@
name: Bug report
description: Report an issue with discord.js or another package.
labels: [bug, need repro]
body:
- type: markdown
attributes:
value: |
Thank you for filing an issue! If you are here to ask a question, use Discord instead: https://discord.gg/djs
This issue form is for discord.js, including other packages.
- type: dropdown
id: package
attributes:
label: Which package is this bug report for?
options:
- discord.js
- brokers
- builders
- collection
- core
- create-discord-bot
- formatters
- next
- proxy
- proxy-container
- rest
- ui
- util
- voice
- ws
validations:
required: true
- type: textarea
id: description
attributes:
label: Issue description
description: Describe the issue in as much detail as possible.
placeholder: |
Steps to reproduce with below code sample:
1. Do thing
2. Do thing in Discord client
3. Observe behavior
4. See error logs below
validations:
required: true
- type: textarea
id: code_sample
attributes:
label: Code sample
description: |
Your code sample should be:
1. Minimal - Use as little code as possible that still produces the same problem (and is understandable)
2. Complete - Provide all parts someone else needs to reproduce your problem
3. Reproducible - Test the code you're about to provide to make sure it reproduces the problem
This will be automatically formatted into code, so no need for backticks.
render: typescript
- type: textarea
id: versions
attributes:
label: Versions
description: List necessary versions here. This includes your package version, runtime version, operating system etc.
placeholder: |
- 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
- type: dropdown
id: priority
attributes:
label: Issue priority
description: Please be realistic. If you need to elaborate on your reasoning, please use the issue description field above.
options:
- Low (slightly annoying)
- Medium (should be fixed soon)
- High (immediate attention needed)
validations:
required: true
- type: dropdown
id: partials
attributes:
label: Which partials do you have configured?
description: Check your `Client` constructor for the `partials` key.
options:
- Not applicable
- No Partials
- User
- Channel
- GuildMember
- Message
- Reaction
- GuildScheduledEvent
- ThreadMember
multiple: true
validations:
required: true
- type: dropdown
id: intents
attributes:
label: Which gateway intents are you subscribing to?
description: Check your `Client` constructor for the `intents` key.
options:
- Not applicable
- No Intents
- Guilds
- GuildMembers
- GuildModeration
- GuildEmojisAndStickers
- GuildIntegrations
- GuildWebhooks
- GuildInvites
- GuildVoiceStates
- GuildPresences
- GuildMessages
- GuildMessageReactions
- GuildMessageTyping
- DirectMessages
- DirectMessageReactions
- DirectMessageTyping
- MessageContent
- GuildScheduledEvents
- AutoModerationConfiguration
- AutoModerationExecution
- GuildMessagePolls
- DirectMessagePolls
multiple: true
validations:
required: true
- type: input
id: dev_release
attributes:
label: I have tested this issue on a development release
placeholder: d23280c (commit hash)
description: |
The issue might already be fixed in a development release or main. This is not required, but helps us greatly.
[discord.js only] To install the latest development release run `npm i discord.js@dev` in your project directory.
Run `npm list discord.js` and use the last part of the printed information (`d23280c` for `discord.js@xx.x.x-dev.1530234593.d23280c`)

View File

@@ -1,58 +0,0 @@
name: Websites bug report
description: Report an issue with the documentation or guide websites.
labels: [bug, need repro]
body:
- type: markdown
attributes:
value: |
Thank you for filing an issue! If you are here to ask a question, use Discord instead: https://discord.gg/djs
This issue form is for our documentation and guide websites.
- type: dropdown
id: application
attributes:
label: Which application is this bug report for?
options:
- Documentation
- Guide
validations:
required: true
- type: textarea
id: description
attributes:
label: Issue description
description: Describe the issue in as much detail as possible.
validations:
required: true
- type: textarea
id: steps_to_reproduce
attributes:
label: Steps to Reproduce
description: What steps must be taken to reproduce this issue?
placeholder: |
1. Visit a page
2. Click a link
3. ...
validations:
required: true
- type: textarea
id: versions
attributes:
label: Versions
description: List necessary versions here. This includes your browser, operating system etc.
placeholder: |
- Safari 16.4 (18615.1.26.11.23)
- macOS Ventura 13.3.1
validations:
required: true
- type: dropdown
id: priority
attributes:
label: Issue priority
description: Please be realistic. If you need to elaborate on your reasoning, please use the issue description field above.
options:
- Low (slightly annoying)
- Medium (should be fixed soon)
- High (immediate attention needed)
validations:
required: true

138
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@@ -0,0 +1,138 @@
name: Bug report
description: Report incorrect or unexpected behavior of discord.js
labels: [bug, need repro]
body:
- type: markdown
attributes:
value: |
Use Discord for questions: https://discord.gg/djs
If you are reporting a voice issue, please post your issue at https://github.com/discordjs/voice/issues
- type: textarea
id: description
attributes:
label: Issue description
description: |
Describe the issue in as much detail as possible.
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files into it.
placeholder: |
Steps to reproduce with below code sample:
1. do thing
2. do thing in Discord client
3. observe behavior
4. see error logs below
validations:
required: true
- type: textarea
id: codesample
attributes:
label: Code sample
description: Include a reproducible, minimal code sample. This will be automatically formatted into code, so no need for backticks.
render: typescript
placeholder: |
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
});
client.login('token');
- type: input
id: djs-version
attributes:
label: discord.js version
description: Which version of discord.js are you using? Run `npm list discord.js` in your project directory and paste the output.
placeholder: 13.x.x (we no longer support version 12 or earlier)
validations:
required: true
- type: input
id: node-version
attributes:
label: Node.js version
description: |
Which version of Node.js are you using? Run `node --version` in your project directory and paste the output.
If you are using TypeScript, please include its version (`npm list typescript`) as well.
placeholder: Node.js version 16.6+ is required for version 13.0.0+
validations:
required: true
- type: input
id: os
attributes:
label: Operating system
description: Which OS does your application run on?
- type: dropdown
id: priority
attributes:
label: Priority this issue should have
description: Please be realistic. If you need to elaborate on your reasoning, please use the Issue description field above.
options:
- Low (slightly annoying)
- Medium (should be fixed soon)
- High (immediate attention needed)
validations:
required: true
- type: dropdown
id: partials
attributes:
label: Which partials do you have configured?
description: |
Check your Client constructor for the `partials` key.
Tip: you can select multiple items
options:
- No Partials
- USER
- CHANNEL
- GUILD_MEMBER
- MESSAGE
- REACTION
- GUILD_SCHEDULED_EVENT
multiple: true
validations:
required: true
- type: dropdown
id: intents
attributes:
label: Which gateway intents are you subscribing to?
description: |
Check your Client constructor for the `intents` key.
Tip: you can select multiple items
options:
- GUILDS
- GUILD_MEMBERS
- GUILD_BANS
- GUILD_EMOJIS_AND_STICKERS
- GUILD_INTEGRATIONS
- GUILD_WEBHOOKS
- GUILD_INVITES
- GUILD_VOICE_STATES
- GUILD_PRESENCES
- GUILD_MESSAGES
- GUILD_MESSAGE_REACTIONS
- GUILD_MESSAGE_TYPING
- DIRECT_MESSAGES
- DIRECT_MESSAGE_REACTIONS
- DIRECT_MESSAGE_TYPING
- GUILD_SCHEDULED_EVENTS
multiple: true
validations:
required: true
- type: input
id: dev-release
attributes:
label: I have tested this issue on a development release
placeholder: d23280c
description: |
The issue might already be fixed in a development release. This is not required, but helps us greatly.
To install the latest development release run `npm i discord.js@dev` in your project directory.
Run `npm list discord.js` and use the last part of the printed information (`d23280c` for `discord.js@xx.x.x-dev.1530234593.d23280c`)

View File

@@ -1,37 +1,13 @@
name: Feature request
description: Request a new feature (discord.js accepts documented features of the official Discord developer API only!)
description: Request a new feature (documented features of the official Discord developer API only!)
labels: [feature request]
body:
- type: markdown
attributes:
value: |
We can only implement features that Discord publishes, documents, and merges into the Discord API documentation.
We can only implement features that Discord publishes, documents and merges into the Discord API documentation.
We do not implement unreleased features.
Use Discord for questions: https://discord.gg/djs
- type: dropdown
id: application_or_package
attributes:
label: Which application or package is this feature request for?
options:
- discord.js
- Documentation
- Guide
- brokers
- builders
- collection
- core
- create-discord-bot
- formatters
- next
- proxy
- proxy-container
- rest
- ui
- util
- voice
- ws
validations:
required: true
- type: textarea
id: description
attributes:
@@ -53,7 +29,7 @@ body:
label: Alternative solutions or implementations
description: A clear and concise description of any alternative solutions or features you have considered.
- type: textarea
id: additional_context
id: additional-context
attributes:
label: Other context
description: Any other context, screenshots, or file uploads that help us understand your feature request.

View File

@@ -1,5 +1,7 @@
**Please describe the changes this PR makes and why it should be merged:**
**Status and versioning classification:**
<!--

View File

@@ -1,51 +0,0 @@
apps:guide:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\nGuide\\n"
apps:website:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\nDocumentation\\n"
packages:brokers:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\nbrokers\\n"
packages:builders:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\nbuilders\\n"
packages:collection:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\ncollection\\n"
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"
packages:formatters:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\nformatters\\n"
packages:next:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\nnext\\n"
packages:proxy:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\nproxy\\n"
packages:proxy-container:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\nproxy-container\\n"
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"
packages:ws:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\nws\\n"

100
.github/labeler.yml vendored
View File

@@ -1,100 +0,0 @@
apps:guide:
- changed-files:
- any-glob-to-any-file:
- apps/guide/*
- apps/guide/**/*
apps:website:
- changed-files:
- any-glob-to-any-file:
- apps/website/*
- apps/website/**/*
packages:api-extractor:
- changed-files:
- any-glob-to-any-file:
- packages/api-extractor/*
- packages/api-extractor/**/*
packages:api-extractor-model:
- changed-files:
- any-glob-to-any-file:
- packages/api-extractor-model/*
- packages/api-extractor-model/**/*
packages:brokers:
- changed-files:
- any-glob-to-any-file:
- packages/brokers/*
- packages/brokers/**/*
packages:builders:
- changed-files:
- any-glob-to-any-file:
- packages/builders/*
- packages/builders/**/*
packages:collection:
- changed-files:
- any-glob-to-any-file:
- packages/collection/*
- packages/collection/**/*
packages:core:
- changed-files:
- any-glob-to-any-file:
- packages/core/*
- packages/core/**/*
packages:create-discord-bot:
- changed-files:
- any-glob-to-any-file:
- packages/create-discord-bot/*
- packages/create-discord-bot/**/*
packages:discord.js:
- changed-files:
- any-glob-to-any-file:
- packages/discord.js/*
- packages/discord.js/**/*
packages:docgen:
- changed-files:
- any-glob-to-any-file:
- packages/docgen/*
- packages/docgen/**/*
packages:formatters:
- changed-files:
- any-glob-to-any-file:
- packages/formatters/*
- packages/formatters/**/*
packages:next:
- changed-files:
- any-glob-to-any-file:
- packages/next/*
- packages/next/**/*
packages:proxy:
- changed-files:
- any-glob-to-any-file:
- packages/proxy/*
- packages/proxy/**/*
packages:proxy-container:
- changed-files:
- any-glob-to-any-file:
- packages/proxy-container/*
- packages/proxy-container/**/*
packages:rest:
- changed-files:
- any-glob-to-any-file:
- packages/rest/*
- packages/rest/**/*
packages:ui:
- changed-files:
- any-glob-to-any-file:
- packages/ui/*
- packages/ui/**/*
packages:util:
- changed-files:
- any-glob-to-any-file:
- packages/util/*
- packages/util/**/*
packages:voice:
- changed-files:
- any-glob-to-any-file:
- packages/voice/*
- packages/voice/**/*
packages:ws:
- changed-files:
- any-glob-to-any-file:
- packages/ws/*
- packages/ws/**/*

196
.github/labels.yml vendored
View File

@@ -1,124 +1,80 @@
- name: api changes
- name: 'api changes'
color: '5663e9'
- name: api support
- name: 'api support'
color: '5663e9'
- name: apps:guide
color: fbca04
- name: apps:website
color: fbca04
- name: backlog
color: 7ef7ef
- name: backport
color: 88aabb
- name: blocked
color: fc1423
- name: bug
color: d73a4a
- name: caching
color: 80c042
- name: chore
color: ffffff
- name: ci
color: 0075ca
- name: dependencies
color: 276bd1
- name: discord
- name: 'backlog'
color: '7ef7ef'
- name: 'bug'
color: 'd73a4a'
- name: 'caching'
color: '80c042'
- name: 'chore'
color: 'ffffff'
- name: 'ci'
color: '0075ca'
- name: 'dependencies'
color: '276bd1'
- name: 'discussion'
color: 'b6b1f9'
- name: 'discord'
color: '5663e9'
- name: discussion
color: b6b1f9
- name: documentation
color: 0075ca
- name: duplicate
color: cfd3d7
- name: error handling
color: 80c042
- name: feature request
color: fcf95a
- name: gateway
color: 80c042
- name: good first issue
color: 7057ff
- name: has PR
color: 4b1f8e
- name: help wanted
- name: 'documentation'
color: '0075ca'
- name: 'duplicate'
color: 'cfd3d7'
- name: 'error handling'
color: '80c042'
- name: 'feature request'
color: 'fcf95a'
- name: 'gateway'
color: '80c042'
- name: 'good first issue'
color: '7057ff'
- name: 'has PR'
color: '4b1f8e'
- name: 'help wanted'
color: '008672'
- name: in progress
color: ffccd7
- name: in review
color: aed5fc
- name: interactions
color: 80c042
- name: invalid
color: e4e669
- name: need repro
color: c66037
- name: packages:api-extractor
color: fbca04
- name: packages:api-extractor-model
color: fbca04
- name: packages:brokers
color: fbca04
- name: packages:builders
color: fbca04
- name: packages:collection
color: fbca04
- name: packages:core
color: fbca04
- name: packages:create-discord-bot
color: fbca04
- 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
color: fbca04
- name: packages:rest
color: fbca04
- name: packages:ui
color: fbca04
- name: packages:util
color: fbca04
- name: packages:voice
color: fbca04
- name: packages:ws
color: fbca04
- name: performance
color: 80c042
- name: permissions
color: 80c042
- name: priority:high
color: fc1423
- name: question (please use Discord instead)
color: d876e3
- name: ratelimits
color: 80c042
- name: refactor
color: 1d637f
- name: regression
color: ea8785
- name: REST
color: 80c042
- name: semver:major
color: c10f47
- name: semver:minor
color: e4f486
- name: semver:patch
color: e8be8b
- name: sharding
color: 80c042
- name: tests
color: f06dff
- name: threads
color: 80c042
- name: typings
color: 80c042
- name: utility
color: 80c042
- name: wontfix
color: ffffff
- name: 'interactions'
color: '80c042'
- name: 'in progress'
color: 'ffccd7'
- name: 'in review'
color: 'aed5fc'
- name: 'invalid'
color: 'e4e669'
- name: 'need repro'
color: 'c66037'
- name: 'performance'
color: '80c042'
- name: 'permissions'
color: '80c042'
- name: 'priority:high'
color: 'fc1423'
- name: 'question (please use Discord instead)'
color: 'd876e3'
- name: 'ratelimits'
color: '80c042'
- name: 'refactor'
color: '1d637f'
- name: 'regression'
color: 'ea8785'
- name: 'REST'
color: '80c042'
- name: 'semver:major'
color: 'c10f47'
- name: 'semver:minor'
color: 'e4f486'
- name: 'semver:patch'
color: 'e8be8b'
- name: 'sharding'
color: '80c042'
- name: 'tests'
color: 'f06dff'
- name: 'threads'
color: '80c042'
- name: 'typings'
color: '80c042'
- name: 'utility'
color: '80c042'
- name: 'wontfix'
color: 'ffffff'

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

32
.github/tsc.json vendored
View File

@@ -1,18 +1,18 @@
{
"problemMatcher": [
{
"owner": "tsc",
"pattern": [
{
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),(\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"code": 5,
"message": 6
}
]
}
]
"problemMatcher": [
{
"owner": "tsc",
"pattern": [
{
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),(\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"code": 5,
"message": 6
}
]
}
]
}

26
.github/workflows/auto-deprecate.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: npm auto deprecate
on:
workflow_dispatch:
schedule:
- cron: '0 1 * * *'
jobs:
auto-deprecate:
name: npm auto deprecate
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Node v16
uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Deprecate versions
run: 'npm exec --no npm-deprecate -- --name "*dev*" --package "discord.js"'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

View File

@@ -1,35 +0,0 @@
# https://docs.github.com/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
name: Cleanup caches
on:
pull_request:
types:
- closed
workflow_dispatch:
jobs:
cleanup:
name: Cleanup caches
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cleanup caches
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

29
.github/workflows/deploy.yml vendored Normal file
View File

@@ -0,0 +1,29 @@
name: Deployment
on:
push:
branches:
- '*'
- '!docs'
tags:
- '*'
jobs:
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Node v16
uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
- name: Install dependencies
run: npm ci
- name: Build and deploy documentation
uses: discordjs/action-docs@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,50 +0,0 @@
name: Deprecate version
on:
workflow_dispatch:
inputs:
package:
description: Package
required: true
type: choice
options:
- '@discordjs/brokers'
- '@discordjs/builders'
- '@discordjs/collection'
- '@discordjs/core'
- 'create-discord-bot'
- '@discordjs/formatters'
- 'discord.js'
- '@discordjs/next'
- '@discordjs/proxy'
- '@discordjs/rest'
- '@discordjs/util'
- '@discordjs/voice'
- '@discordjs/ws'
version:
description: Version(s)
required: true
type: string
message:
description: Deprecation message
required: false
type: string
jobs:
deprecate:
runs-on: ubuntu-latest
if: github.repository_owner == 'discordjs'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
uses: ./packages/actions/src/pnpmCache
- name: Deprecate
run: pnpm exec npm-deprecate --name "${{inputs.version}}" --message "${{inputs.message || 'This version is deprecated. Please use a newer version.'}}" --package ${{inputs.package}}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

View File

@@ -1,163 +0,0 @@
name: Documentation
on:
push:
paths:
- 'packages/*/src/**'
- '!packages/create-discord-bot/**'
- '!packages/proxy-container/**'
- '!packages/ui/**'
tags:
- '**'
workflow_dispatch:
inputs:
ref:
description: 'The tag to checkout'
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build-docs:
name: Build & upload documentation
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
if: github.repository_owner == 'discordjs'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || '' }}
- name: Install Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
uses: ./packages/actions/src/pnpmCache
- name: Build dependencies
run: pnpm run build
- name: Checkout main repository
uses: actions/checkout@v4
with:
path: 'main'
- name: Build main
shell: bash
run: |
cd main
pnpm install --frozen-lockfile --prefer-offline --loglevel error
pnpm run build
cd ..
- name: Extract package and semver from tag
id: extract-tag
uses: ./packages/actions/src/formatTag
with:
tag: ${{ inputs.ref || github.ref_name }}
- name: Build docs
run: pnpm run docs
- name: Build docs with main api-extractor
run: |
declare -a PACKAGES=("brokers" "builders" "collection" "core" "discord.js" "formatters" "next" "proxy" "rest" "util" "voice" "ws")
for PACKAGE in "${PACKAGES[@]}"; do
cd "packages/${PACKAGE}"
sed -i 's!https://github.com/discordjs/discord.js/tree/main!https://github.com/discordjs/discord.js/tree/${{ inputs.ref || github.ref_name }}!' api-extractor.json
../../main/packages/api-extractor/bin/api-extractor run --local --minify
../../main/packages/scripts/bin/generateSplitDocumentation.js
cd ../..
done
- name: Checkout docs repository
uses: actions/checkout@v4
with:
repository: 'discordjs/docs'
token: ${{ secrets.DJS_DOCS }}
path: 'out'
- name: Upload documentation to database
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
CF_D1_DOCS_API_KEY: ${{ secrets.CF_D1_DOCS_API_KEY }}
CF_D1_DOCS_ID: ${{ secrets.CF_D1_DOCS_ID }}
CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
CF_R2_DOCS_URL: ${{ secrets.CF_R2_DOCS_URL }}
CF_R2_DOCS_ACCESS_KEY_ID: ${{ secrets.CF_R2_DOCS_ACCESS_KEY_ID }}
CF_R2_DOCS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_DOCS_SECRET_ACCESS_KEY }}
CF_R2_DOCS_BUCKET: ${{ secrets.CF_R2_DOCS_BUCKET }}
CF_R2_DOCS_BUCKET_URL: ${{ secrets.CF_R2_DOCS_BUCKET_URL }}
uses: ./main/packages/actions/src/uploadDocumentation
with:
package: ${{ steps.extract-tag.outputs.package }}
version: ${{ steps.extract-tag.outputs.semver }}
- name: Upload split documentation to blob storage
env:
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
CF_R2_DOCS_URL: ${{ secrets.CF_R2_DOCS_URL }}
CF_R2_DOCS_ACCESS_KEY_ID: ${{ secrets.CF_R2_DOCS_ACCESS_KEY_ID }}
CF_R2_DOCS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_DOCS_SECRET_ACCESS_KEY }}
CF_R2_DOCS_BUCKET: ${{ secrets.CF_R2_DOCS_BUCKET }}
uses: ./main/packages/actions/src/uploadSplitDocumentation
with:
package: ${{ steps.extract-tag.outputs.package }}
version: ${{ steps.extract-tag.outputs.semver }}
- name: Move docs to correct directory
env:
PACKAGE: ${{ steps.extract-tag.outputs.package }}
SEMVER: ${{ steps.extract-tag.outputs.semver }}
run: |
mkdir -p "out/${PACKAGE}"
if [[ "${PACKAGE}" == "discord.js" ]]; then
mv "packages/${PACKAGE}/docs/docs.json" "out/${PACKAGE}/${SEMVER}.json"
mv "packages/${PACKAGE}/docs/docs.api.json" "out/${PACKAGE}/${SEMVER}.api.json"
else
mv "packages/${PACKAGE}/docs/docs.api.json" "out/${PACKAGE}/${SEMVER}.api.json"
fi
- name: Commit and push
run: |
cd out
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git add .
git commit -m "Docs build for ${GITHUB_REF_TYPE} ${GITHUB_REF_NAME}: ${GITHUB_SHA}" || true
git push
build-indices:
needs: build-docs
name: Build & upload search indices
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
if: github.repository_owner == 'discordjs'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
uses: ./packages/actions/src/pnpmCache
- name: Build dependencies
run: pnpm run build
- name: Upload search indices to meilisearch
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
SEARCH_API_URL: ${{ secrets.SEARCH_API_URL }}
SEARCH_API_KEY: ${{ secrets.SEARCH_API_KEY }}
uses: ./packages/actions/src/uploadSearchIndices

View File

@@ -1,14 +0,0 @@
name: 'Issue Labeler'
on:
issues:
types: [opened]
jobs:
issue-triage:
runs-on: ubuntu-latest
steps:
- uses: github/issue-labeler@v3.4
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
configuration-path: .github/issue-labeler.yml
not-before: 2023-01-13T10:25:03.847Z
enable-versioned-regex: 0

View File

@@ -1,4 +1,4 @@
name: Label sync
name: Label Sync
on:
schedule:
- cron: '0 0 * * *'
@@ -9,15 +9,14 @@ on:
paths:
- '.github/labels.yml'
jobs:
label-sync:
name: Label sync
labeler:
name: Labeler
runs-on: ubuntu-latest
if: github.repository_owner == 'discordjs'
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v2
- name: Label sync
uses: crazy-max/ghaction-github-labeler@v5
- name: Run Label Sync
uses: crazy-max/ghaction-github-labeler@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,19 +0,0 @@
name: Lock Ancient Issues
on:
schedule:
- cron: '0 16 * * *'
workflow_dispatch:
concurrency:
group: lock
jobs:
action:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: dessant/lock-threads@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
issue-inactive-days: 365
issue-lock-reason: resolved
process-only: issues

View File

@@ -1,35 +0,0 @@
name: 'PR Triage'
on:
pull_request_target:
types:
- opened
- edited
- reopened
- synchronize
jobs:
label:
name: Label
if: github.event.action != 'edited'
runs-on: ubuntu-latest
steps:
- name: Label pull request
uses: actions/labeler@v5
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
sync-labels: true
validate-title:
name: Validate title
if: github.event.action != 'synchronize'
runs-on: ubuntu-latest
steps:
- name: Validate pull request title
env:
TITLE: ${{ github.event.pull_request.title }}
run: |
REGEX="^(revert: )?(feat|fix|docs|style|refactor|perf|test|build|ci|chore|types)(\\(.+\\))?!?: .{1,72}$"
echo "Title: \"$TITLE\""
if [[ ! "$TITLE" =~ $REGEX ]]; then
exit 1
fi

View File

@@ -1,30 +0,0 @@
name: Publish dev docker images
on:
schedule:
- cron: '0 */12 * * *'
workflow_dispatch:
jobs:
docker-publish:
name: Docker publish
runs-on: ubuntu-latest
if: github.repository_owner == 'discordjs'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
uses: ./packages/actions/src/pnpmCache
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Build & push docker image
run: docker build -f packages/proxy-container/Dockerfile -t discordjs/proxy:latest --push .

View File

@@ -1,84 +1,44 @@
name: Publish dev
on:
workflow_dispatch:
schedule:
- cron: '0 */12 * * *'
workflow_dispatch:
jobs:
npm-publish:
name: npm publish
strategy:
fail-fast: false
matrix:
include:
- package: '@discordjs/brokers'
folder: 'brokers'
- package: '@discordjs/builders'
folder: 'builders'
- package: '@discordjs/collection'
folder: 'collection'
- package: '@discordjs/core'
folder: 'core'
- package: '@discordjs/formatters'
folder: 'formatters'
- package: 'discord.js'
folder: 'discord.js'
- package: '@discordjs/next'
folder: 'next'
- package: '@discordjs/proxy'
folder: 'proxy'
- package: '@discordjs/rest'
folder: 'rest'
- package: '@discordjs/util'
folder: 'util'
- package: '@discordjs/voice'
folder: 'voice'
- package: '@discordjs/ws'
folder: 'ws'
npm:
name: npm
runs-on: ubuntu-latest
permissions:
id-token: write
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
if: github.repository_owner == 'discordjs'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
uses: actions/checkout@v2
- name: Install Node.js v20
uses: actions/setup-node@v4
- name: Install Node v16
uses: actions/setup-node@v2
with:
node-version: 20
node-version: 16
registry-url: https://registry.npmjs.org/
cache: npm
- name: Check the current development version
id: release-check
- name: Check previous released version
id: pre-release
run: |
if [[ $(npm view ${{ matrix.package }}@dev version | grep -e "$(git rev-parse --short HEAD)") ]]; \
then echo "RELEASE=0" >> "$GITHUB_OUTPUT"; \
else echo "RELEASE=1" >> "$GITHUB_OUTPUT"; \
fi
if [[ $(npm view discord.js@dev version | grep -e "$(jq --raw-output '.version' package.json).*.$(git rev-parse --short HEAD | cut -b1-3)") ]]; \
then echo '::set-output name=release::false'; \
else echo '::set-output name=release::true'; fi
- name: Install dependencies
if: steps.release-check.outputs.release == '1'
uses: ./packages/actions/src/pnpmCache
if: steps.pre-release.outputs.release == 'true'
run: npm ci --ignore-scripts
- name: Build dependencies
if: steps.release-check.outputs.release == '1'
run: pnpm run build
- name: Deprecate old versions
if: steps.pre-release.outputs.release == 'true'
run: npm deprecate discord.js@"~$(jq --raw-output '.version' package.json)" "no longer supported" || true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: Publish package
if: steps.release-check.outputs.release == '1'
- name: Publish
if: steps.pre-release.outputs.release == 'true'
run: |
pnpm --filter=${{ matrix.package }} run release --preid "dev.$(date +%s)-$(git rev-parse --short HEAD)" --skip-changelog
pnpm --filter=${{ matrix.package }} publish --provenance --no-git-checks --tag dev || true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: Deprecate prior development releases
if: steps.release-check.outputs.release == '1'
run: pnpm exec npm-deprecate --name "*dev*" --message "This version is deprecated. Please use a newer version." --package ${{ matrix.package }}
npm version --git-tag-version=false $(jq --raw-output '.version' package.json).$(date +%s).$(git rev-parse --short HEAD)
npm publish --tag dev || true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

View File

@@ -1,27 +0,0 @@
name: Publish docker images
on:
workflow_dispatch:
jobs:
docker-publish:
name: Docker publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
uses: ./packages/actions/src/pnpmCache
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Build & push docker image
run: docker build -f packages/proxy-container/Dockerfile -t discordjs/proxy:$(cut -d '.' -f1 <<< $(jq --raw-output '.version' packages/proxy-container/package.json)) --push .

View File

@@ -1,41 +0,0 @@
name: Publish Release
on:
release:
types: [released]
jobs:
npm-publish:
name: npm publish
runs-on: ubuntu-latest
permissions:
id-token: write
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
if: github.repository_owner == 'discordjs'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- name: Install dependencies
uses: ./packages/actions/src/pnpmCache
- name: Build dependencies
run: pnpm run build
- name: Extract package and semver from tag
id: extract-tag
uses: ./packages/actions/src/formatTag
with:
tag: ${{ github.ref_name }}
- name: Publish package
run: |
pnpm --filter=${{ steps.extract-tag.outputs.subpackage == 'true' && '@discordjs/' || '' }}${{ steps.extract-tag.outputs.package }} publish --provenance --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

81
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,81 @@
name: Tests
on: [push, pull_request]
jobs:
lint:
name: ESLint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Node v16
uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint
typings:
name: TSLint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Node v16
uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
- name: Install dependencies
run: npm ci
- name: Run TSLint
run: npm run lint:typings
typescript:
name: TypeScript
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Node v16
uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
- name: Install dependencies
run: npm ci
- name: Register Problem Matcher
run: echo "##[add-matcher].github/tsc.json"
- name: Run Type Tests
run: npm run test:typescript
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Node v16
uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
- name: Install dependencies
run: npm ci
- name: Test documentation
run: npm run docs:test

View File

@@ -1,66 +0,0 @@
name: Tests
on:
push:
pull_request:
concurrency:
# Group based on workflow name and PR if it exists, if no PR, let it run so carryforward flags work
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
uses: ./packages/actions/src/pnpmCache
- name: Build dependencies (PR)
if: ${{ github.event_name != 'push' }}
run: pnpm exec turbo run build --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4
- name: Build dependencies (Push)
if: ${{ github.event_name == 'push' }}
run: pnpm exec turbo run build --filter="...[HEAD^1]" --concurrency=4
- name: Tests (PR)
if: ${{ github.event_name != 'push' }}
run: pnpm exec turbo run test --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4
- name: Tests (Push)
if: ${{ github.event_name == 'push' }}
run: pnpm exec turbo run test --filter="...[HEAD^1]" --concurrency=4
- name: ESLint (PR)
if: ${{ github.event_name != 'push' }}
run: pnpm exec turbo run lint --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4 -- --format=compact
- name: ESLint (Push)
if: ${{ github.event_name == 'push' }}
run: pnpm exec turbo run lint --filter="...[HEAD^1]" --concurrency=4 -- --format=compact
- name: Docs (PR)
if: ${{ github.event_name != 'push' }}
run: pnpm exec turbo run docs --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4
- name: Docs (Push)
if: ${{ github.event_name == 'push' }}
run: pnpm exec turbo run docs --filter="...[HEAD^1]" --concurrency=4
- name: Upload Coverage
if: github.repository_owner == 'discordjs'
uses: ./packages/actions/src/uploadCoverage
with:
codecov_token: ${{ secrets.CODECOV_TOKEN }}

49
.gitignore vendored
View File

@@ -1,8 +1,8 @@
# Packages
node_modules
node_modules/
# Log files
logs
logs/
*.log
npm-debug.log*
@@ -13,42 +13,19 @@ pids
# Env
.env
test/auth.json
test/auth.js
docs/deploy/deploy_key
docs/deploy/deploy_key.pub
deploy/deploy_key
deploy/deploy_key.pub
# Dist
dist
dist-docs
dist/
docs/docs.json
# Miscellaneous
.tmp
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
.idea
.tmp/
.idea/
.DS_Store
.turbo
tsconfig.tsbuildinfo
coverage
out
package.tgz
tsup.config.bundled*
vitest.config.ts.timestamp*
# Deno
deno.lock
# Bun
bun.lockb
# yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
# Cache
.prettiercache
.eslintcache
.vercel
.yarn/

View File

@@ -1 +1,4 @@
pnpm exec commitlint --edit $1
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install commitlint --edit $1

View File

@@ -1 +1,4 @@
pnpm run build:affected && pnpm exec lint-staged
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install lint-staged

View File

@@ -1,6 +1,4 @@
{
"$schema": "https://json.schemastore.org/lintstagedrc.schema.json",
"*": "prettier --ignore-unknown --write",
"{src/**,__tests__/**}.{mjs,js,cjs,ts,tsx}": "eslint --fix",
"src/**.ts": "vitest related --run --config ../../vitest.config.ts"
"*.{mjs,js}": "eslint --fix --ext mjs,js,ts",
"*.{ts,json,yml,yaml}": "prettier --write"
}

11
.npmrc
View File

@@ -1,6 +1,5 @@
auto-install-peers=false
resolution-mode=highest
public-hoist-pattern[]=*eslint*
public-hoist-pattern[]=*prettier*
public-hoist-pattern[]=*@rushstack/node-core-library*
public-hoist-pattern[]=*jju*
audit=false
fund=false
legacy-peer-deps=true
tag-version-prefix=""
message="chore(Release): %s"

View File

@@ -1,5 +0,0 @@
CODEOWNERS
CHANGELOG.md
tsup.config.bundled*
vitest.config.ts.timestamp*
pnpm-lock.yaml

View File

@@ -1,9 +1,7 @@
{
"$schema": "https://json.schemastore.org/prettierrc.json",
"printWidth": 120,
"useTabs": true,
"singleQuote": true,
"quoteProps": "as-needed",
"trailingComma": "all",
"endOfLine": "lf"
"singleQuote": true,
"printWidth": 120,
"trailingComma": "all",
"endOfLine": "lf",
"arrowParens": "avoid"
}

14
.tern-project Normal file
View File

@@ -0,0 +1,14 @@
{
"ecmaVersion": 7,
"libs": [],
"loadEagerly": ["./src/*.js"],
"dontLoad": ["node_modules/**"],
"plugins": {
"es_modules": {},
"node": {},
"doc_comment": {
"fullDocs": true,
"strong": true
},
}
}

View File

@@ -1,13 +0,0 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"tamasfe.even-better-toml",
"github.vscode-pull-request-github",
"codezombiech.gitignore",
"eamodio.gitlens",
"christian-kohler.npm-intellisense",
"christian-kohler.path-intellisense",
"unifiedjs.vscode-mdx"
]
}

31
.vscode/settings.json vendored
View File

@@ -1,31 +0,0 @@
{
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"eslint.useFlatConfig": true,
"eslint.workingDirectories": [{ "directory": "${workspaceFolder}" }, { "pattern": "./packages/*/" }],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "never",
"source.fixAll.eslint": "explicit",
"source.fixAll": "explicit"
},
"editor.trimAutoWhitespace": false,
"files.associations": {
"api-extractor.json": "jsonc",
"api-extractor-docs.json": "jsonc",
"tsconfig.json": "jsonc",
"tsconfig.eslint.json": "jsonc",
"tsconfig.docs.json": "jsonc"
},
"files.insertFinalNewline": true,
"files.eol": "\n",
"npm.packageManager": "pnpm",
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"unocss.disable": true,
"deno.enable": false,
"deno.enablePaths": ["./packages/create-discord-bot/template/Deno"],
"deno.lint": false,
"deno.unstable": [],
"deno.config": "./packages/create-discord-bot/template/Deno/deno.jsonc"
}

2052
CHANGELOG.md Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -175,8 +175,8 @@
END OF TERMS AND CONDITIONS
Copyright 2021 Noel Buechler
Copyright 2015 Amish Shah
Copyright 2015 - 2021 Noel Buechler
Copyright 2015 - 2021 Amish Shah
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

176
README.md
View File

@@ -1,89 +1,125 @@
<div align="center">
<br />
<p>
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
</p>
<br />
<p>
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
<a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/v/discord.js.svg?maxAge=3600" alt="npm version" /></a>
<a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/dt/discord.js.svg?maxAge=3600" alt="npm downloads" /></a>
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Tests status" /></a>
<a href="https://github.com/discordjs/discord.js/commits/main"><img src="https://img.shields.io/github/last-commit/discordjs/discord.js.svg?logo=github&logoColor=ffffff" alt="Last commit." /></a>
<a href="https://github.com/discordjs/discord.js/graphs/contributors"><img src="https://img.shields.io/github/contributors/discordjs/discord.js.svg?maxAge=3600&logo=github&logoColor=fff&color=00c7be" alt="contributors" /></a>
<a href="https://codecov.io/gh/discordjs/discord.js"><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2" alt="Code coverage" /></a>
</p>
<p>
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
<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>
<br />
<p>
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
</p>
<br />
<p>
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
<a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/v/discord.js.svg?maxAge=3600" alt="npm version" /></a>
<a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/dt/discord.js.svg?maxAge=3600" alt="npm downloads" /></a>
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/workflows/Testing/badge.svg" alt="Tests status" /></a>
</p>
</div>
## About
This repository contains multiple packages with separate [releases][github-releases]. You can find the assembled Discord API wrapper at [`discord.js`][source]. It is a powerful [Node.js](https://nodejs.org/en) module that allows you to easily interact with the [Discord API](https://discord.com/developers/docs/intro).
discord.js is a powerful [Node.js](https://nodejs.org) module that allows you to easily interact with the
[Discord API](https://discord.com/developers/docs/intro).
## Packages
- Object-oriented
- Predictable abstractions
- Performant
- 100% coverage of the Discord API
- `discord.js` ([source][source]) - A powerful Node.js module for interacting with the Discord API
- `@discordjs/brokers` ([source][brokers-source]) - A collection of brokers for use with discord.js
- `@discordjs/builders` ([source][builders-source]) - A utility package for easily building Discord API payloads
- `@discordjs/collection` ([source][collection-source]) - A powerful utility data structure
- `@discordjs/core` ([source][core-source]) - A thinly abstracted wrapper around the core components of the Discord API
- `@discordjs/formatters` ([source][formatters-source]) - A collection of functions for formatting strings
- `@discordjs/proxy` ([source][proxy-source]) - A wrapper around `@discordjs/rest` for running an HTTP proxy
- `@discordjs/rest` ([source][rest-source]) - A module for interacting with the Discord REST API
- `@discordjs/voice` ([source][voice-source]) - A module for interacting with the Discord Voice API
- `@discordjs/util` ([source][util-source]) - A collection of utility functions
- `@discordjs/ws` ([source][ws-source]) - A wrapper around Discord's gateway
## Installation
**Node.js 16.6.0 or newer is required.**
```sh-session
npm install discord.js
yarn add discord.js
pnpm add discord.js
```
### Optional packages
- [zlib-sync](https://www.npmjs.com/package/zlib-sync) for WebSocket data compression and inflation (`npm install zlib-sync`)
- [erlpack](https://github.com/discord/erlpack) for significantly faster WebSocket data (de)serialisation (`npm install discord/erlpack`)
- [bufferutil](https://www.npmjs.com/package/bufferutil) for a much faster WebSocket connection (`npm install bufferutil`)
- [utf-8-validate](https://www.npmjs.com/package/utf-8-validate) in combination with `bufferutil` for much faster WebSocket processing (`npm install utf-8-validate`)
- [@discordjs/voice](https://github.com/discordjs/voice) for interacting with the Discord Voice API (`npm install @discordjs/voice`)
## Example usage
Install all required dependencies:
```sh-session
npm install discord.js @discordjs/rest discord-api-types
yarn add discord.js @discordjs/rest discord-api-types
pnpm add discord.js @discordjs/rest discord-api-types
```
Register a slash command against the Discord API:
```js
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const commands = [{
name: 'ping',
description: 'Replies with Pong!'
}];
const rest = new REST({ version: '9' }).setToken('token');
(async () => {
try {
console.log('Started refreshing application (/) commands.');
await rest.put(
Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID),
{ body: commands },
);
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
```
Afterwards we can create a quite simple example bot:
```js
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
});
client.login('token');
```
## Links
- [Website][website] ([source][website-source])
- [Documentation][documentation]
- [Guide][guide] ([source][guide-source])
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
- [discord.js Discord server][discord]
- [Discord API Discord server][discord-api]
- [GitHub][source]
- [npm][npm]
- [Related libraries][related-libs]
- [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website))
- [Documentation](https://discord.js.org/#/docs)
- [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide))
See also the [Update Guide](https://discordjs.guide/additional-info/changes-in-v13.html), including updated and removed items in the library.
- [discord.js Discord server](https://discord.gg/djs)
- [Discord API Discord server](https://discord.gg/discord-api)
- [GitHub](https://github.com/discordjs/discord.js)
- [npm](https://www.npmjs.com/package/discord.js)
- [Related libraries](https://discord.com/developers/docs/topics/community-resources#libraries)
### Extensions
- [RPC][rpc] ([source][rpc-source])
- [RPC](https://www.npmjs.com/package/discord-rpc) ([source](https://github.com/discordjs/RPC))
## Contributing
Please read through our [contribution guidelines][contributing] before starting a pull request. We welcome contributions of all kinds, not just code! If you're stuck for ideas, look for the [good first issue][good-first-issue] label on issues in the repository. If you have any questions about the project, feel free to ask them on [Discord][discord]. Before creating your own issue or pull request, always check to see if one already exists! Don't rush contributions, take your time and ensure you're doing it correctly.
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
[documentation](https://discord.js.org/#/docs).
See [the contribution guide](https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md) if you'd like to submit a PR.
## Help
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please join our [Discord server][discord].
[website]: https://discord.js.org
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
[documentation]: https://discord.js.org/docs
[guide]: https://discordjs.guide/
[guide-source]: https://github.com/discordjs/guide
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
[discord]: https://discord.gg/djs
[discord-api]: https://discord.gg/discord-api
[source]: https://github.com/discordjs/discord.js/tree/main/packages/discord.js
[npm]: https://www.npmjs.com/package/discord.js
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
[rpc]: https://www.npmjs.com/package/discord-rpc
[rpc-source]: https://github.com/discordjs/RPC
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
[github-releases]: https://github.com/discordjs/discord.js/releases
[brokers-source]: https://github.com/discordjs/discord.js/tree/main/packages/brokers
[builders-source]: https://github.com/discordjs/discord.js/tree/main/packages/builders
[collection-source]: https://github.com/discordjs/discord.js/tree/main/packages/collection
[core-source]: https://github.com/discordjs/discord.js/tree/main/packages/core
[formatters-source]: https://github.com/discordjs/discord.js/tree/main/packages/formatters
[proxy-source]: https://github.com/discordjs/discord.js/tree/main/packages/proxy
[rest-source]: https://github.com/discordjs/discord.js/tree/main/packages/rest
[voice-source]: https://github.com/discordjs/discord.js/tree/main/packages/voice
[util-source]: https://github.com/discordjs/discord.js/tree/main/packages/util
[ws-source]: https://github.com/discordjs/discord.js/tree/main/packages/ws
[good-first-issue]: https://github.com/discordjs/discord.js/contribute
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle
nudge in the right direction, please don't hesitate to join our official [discord.js Server](https://discord.gg/djs).

View File

@@ -1,425 +0,0 @@
/**
* Config file for API Extractor. For more info, please visit: https://api-extractor.com
*/
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
/**
* Optionally specifies another JSON config file that this file extends from. This provides a way for
* standard settings to be shared across multiple projects.
*
* If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains
* the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
* resolved using NodeJS require().
*
* SUPPORTED TOKENS: none
* DEFAULT VALUE: ""
*/
// "extends": "./shared/api-extractor-base.json"
// "extends": "my-package/include/api-extractor-base.json"
/**
* Determines the "<projectFolder>" token that can be used with other config file settings. The project folder
* typically contains the tsconfig.json and package.json config files, but the path is user-defined.
*
* The path is resolved relative to the folder of the config file that contains the setting.
*
* The default value for "projectFolder" is the token "<lookup>", which means the folder is determined by traversing
* parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder
* that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error
* will be reported.
*
* SUPPORTED TOKENS: <lookup>
* DEFAULT VALUE: "<lookup>"
*/
// "projectFolder": "..",
/**
* (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor
* analyzes the symbols exported by this module.
*
* The file extension must be ".d.ts" and not ".ts".
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
*/
"mainEntryPointFilePath": "<projectFolder>/dist-docs/index.d.ts",
/**
* A list of NPM package names whose exports should be treated as part of this package.
*
* For example, suppose that Webpack is used to generate a distributed bundle for the project "library1",
* and another NPM package "library2" is embedded in this bundle. Some types from library2 may become part
* of the exported API for library1, but by default API Extractor would generate a .d.ts rollup that explicitly
* imports library2. To avoid this, we can specify:
*
* "bundledPackages": [ "library2" ],
*
* This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been
* local files for library1.
*/
"bundledPackages": [],
/**
* Determines how the TypeScript compiler engine will be invoked by API Extractor.
*/
"compiler": {
/**
* Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* Note: This setting will be ignored if "overrideTsconfig" is used.
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<projectFolder>/tsconfig.json"
*/
// "tsconfigFilePath": "<projectFolder>/tsconfig.json",
/**
* Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk.
* The object must conform to the TypeScript tsconfig schema:
*
* http://json.schemastore.org/tsconfig
*
* If omitted, then the tsconfig.json file will be read from the "projectFolder".
*
* DEFAULT VALUE: no overrideTsconfig section
*/
"overrideTsconfig": {
"compilerOptions": {
// Type Checking
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": false,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
// Modules
"allowArbitraryExtensions": false,
"allowImportingTsExtensions": false,
"module": "ESNext",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"resolvePackageJsonExports": false,
"resolvePackageJsonImports": false,
// Emit
"declaration": true,
"declarationMap": true,
"importHelpers": false,
"newLine": "lf",
"noEmitHelpers": true,
"outDir": "dist",
"removeComments": false,
"sourceMap": true,
// Interop Constraints
"esModuleInterop": false,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
// Language and Environment
"experimentalDecorators": true,
"lib": ["ESNext"],
"target": "ES2022",
"useDefineForClassFields": true
}
}
/**
* This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended
* and may cause API Extractor to produce incomplete or incorrect declarations, but it may be required when
* dependencies contain declarations that are incompatible with the TypeScript engine that API Extractor uses
* for its analysis. Where possible, the underlying issue should be fixed rather than relying on skipLibCheck.
*
* DEFAULT VALUE: false
*/
// "skipLibCheck": true,
},
/**
* Configures how the API report file (*.api.md) will be generated.
*/
"apiReport": {
/**
* (REQUIRED) Whether to generate an API report.
*/
"enabled": false
/**
* The filename for the API report files. It will be combined with "reportFolder" or "reportTempFolder" to produce
* a full file path.
*
* The file extension should be ".api.md", and the string should not contain a path separator such as "\" or "/".
*
* SUPPORTED TOKENS: <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<unscopedPackageName>.api.md"
*/
// "reportFileName": "<unscopedPackageName>.api.md",
/**
* Specifies the folder where the API report file is written. The file name portion is determined by
* the "reportFileName" setting.
*
* The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy,
* e.g. for an API review.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<projectFolder>/temp/"
*/
// "reportFolder": "<projectFolder>/temp/",
/**
* Specifies the folder where the temporary report file is written. The file name portion is determined by
* the "reportFileName" setting.
*
* After the temporary file is written to disk, it is compared with the file in the "reportFolder".
* If they are different, a production build will fail.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<projectFolder>/temp/"
*/
// "reportTempFolder": "<projectFolder>/temp/"
},
/**
* Configures how the doc model file (*.api.json) will be generated.
*/
"docModel": {
/**
* (REQUIRED) Whether to generate a doc model file.
*/
"enabled": true,
/**
* The output path for the doc model file. The file extension should be ".api.json".
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<projectFolder>/temp/<unscopedPackageName>.api.json"
*/
"apiJsonFilePath": "<projectFolder>/docs/docs.api.json"
},
/**
* Configures how the .d.ts rollup file will be generated.
*/
"dtsRollup": {
/**
* (REQUIRED) Whether to generate the .d.ts rollup file.
*/
"enabled": false,
/**
* Specifies the output path for a .d.ts rollup file to be generated without any trimming.
* This file will include all declarations that are exported by the main entry point.
*
* If the path is an empty string, then this file will not be written.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<projectFolder>/dist/<unscopedPackageName>.d.ts"
*/
"untrimmedFilePath": "<projectFolder>/dist-docs/index.d.ts"
/**
* Specifies the output path for a .d.ts rollup file to be generated with trimming for an "alpha" release.
* This file will include only declarations that are marked as "@public", "@beta", or "@alpha".
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: ""
*/
// "alphaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-alpha.d.ts",
/**
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release.
* This file will include only declarations that are marked as "@public" or "@beta".
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: ""
*/
// "betaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-beta.d.ts",
/**
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release.
* This file will include only declarations that are marked as "@public".
*
* If the path is an empty string, then this file will not be written.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: ""
*/
// "publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts",
/**
* When a declaration is trimmed, by default it will be replaced by a code comment such as
* "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the
* declaration completely.
*
* DEFAULT VALUE: false
*/
// "omitTrimmingComments": true
},
/**
* Configures how the tsdoc-metadata.json file will be generated.
*/
"tsdocMetadata": {
/**
* Whether to generate the tsdoc-metadata.json file.
*
* DEFAULT VALUE: true
*/
// "enabled": true,
/**
* Specifies where the TSDoc metadata file should be written.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* The default value is "<lookup>", which causes the path to be automatically inferred from the "tsdocMetadata",
* "typings" or "main" fields of the project's package.json. If none of these fields are set, the lookup
* falls back to "tsdoc-metadata.json" in the package folder.
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<lookup>"
*/
// "tsdocMetadataFilePath": "<projectFolder>/dist/tsdoc-metadata.json"
},
/**
* Specifies what type of newlines API Extractor should use when writing output files. By default, the output files
* will be written with Windows-style newlines. To use POSIX-style newlines, specify "lf" instead.
* To use the OS's default newline kind, specify "os".
*
* DEFAULT VALUE: "crlf"
*/
"newlineKind": "lf",
/**
* Configures how API Extractor reports error and warning messages produced during analysis.
*
* There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages.
*/
"messages": {
/**
* Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing
* the input .d.ts files.
*
* TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551"
*
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
*/
"compilerMessageReporting": {
/**
* Configures the default routing for messages that don't match an explicit rule in this table.
*/
"default": {
/**
* Specifies whether the message should be written to the the tool's output log. Note that
* the "addToApiReportFile" property may supersede this option.
*
* Possible values: "error", "warning", "none"
*
* Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail
* and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes
* the "--local" option), the warning is displayed but the build will not fail.
*
* DEFAULT VALUE: "warning"
*/
"logLevel": "warning"
/**
* When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md),
* then the message will be written inside that file; otherwise, the message is instead logged according to
* the "logLevel" option.
*
* DEFAULT VALUE: false
*/
// "addToApiReportFile": false
}
// "TS2551": {
// "logLevel": "warning",
// "addToApiReportFile": true
// },
//
// . . .
},
/**
* Configures handling of messages reported by API Extractor during its analysis.
*
* API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag"
*
* DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings
*/
"extractorMessageReporting": {
"default": {
"logLevel": "warning"
// "addToApiReportFile": false
},
// Disable the following warning:
// (ae-missing-release-tag) "x" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
"ae-missing-release-tag": {
"logLevel": "none"
}
// "ae-extra-release-tag": {
// "logLevel": "warning",
// "addToApiReportFile": true
// },
//
// . . .
},
/**
* Configures handling of messages reported by the TSDoc parser when analyzing code comments.
*
* TSDoc message identifiers start with "tsdoc-". For example: "tsdoc-link-tag-unescaped-text"
*
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
*/
"tsdocMessageReporting": {
"default": {
"logLevel": "warning"
// "addToApiReportFile": false
}
// "tsdoc-link-tag-unescaped-text": {
// "logLevel": "warning",
// "addToApiReportFile": true
// },
//
// . . .
}
}
}

View File

@@ -1,36 +0,0 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "tab",
"indentWidth": 2,
"lineWidth": 120,
"lineEnding": "lf",
"ignore": [
".turbo",
".vercel",
".contentlayer",
".next",
"coverage",
"dist",
"dist-docs",
"docs",
"CHANGELOG.md",
"tsup.config.bundled*"
]
},
"javascript": {
"formatter": {
"enabled": true,
"quoteStyle": "single",
"quoteProperties": "asNeeded",
"trailingComma": "all",
"semicolons": "always"
}
},
"files": {
"ignoreUnknown": true,
"maxSize": 1000000
}
}

61
cliff.toml Normal file
View File

@@ -0,0 +1,61 @@
[changelog]
header = """
# Changelog
All notable changes to this project will be documented in this file.\n
"""
body = """
{% if version %}\
# [{{ version | trim_start_matches(pat="v") }}]\
{% if previous %}\
{% if previous.version %}\
(https://github.com/discordjs/discord.js/compare/{{ previous.version }}...{{ version }})\
{% else %}
(https://github.com/discordjs/discord.js/tree/{{ version }}\
{% endif %}\
{% endif %} \
- ({{ timestamp | date(format="%Y-%m-%d") }})
{% else %}\
# [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
## {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.breaking %}\
[**breaking**] \
{% endif %}\
{% if commit.scope %}\
**{{commit.scope}}:** \
{% endif %}\
{{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}](https://github.com/discordjs/discord.js/commit/{{ commit.id }}))\
{% endfor %}
{% endfor %}\n
"""
trim = true
footer = ""
[git]
conventional_commits = true
filter_unconventional = true
commit_parsers = [
{ message = "^feat", group = "Features"},
{ message = "^fix", group = "Bug Fixes"},
{ message = "^docs", group = "Documentation"},
{ message = "^perf", group = "Performance"},
{ message = "^refactor", group = "Refactor"},
{ message = "^typings", group = "Typings"},
{ message = "^types", group = "Typings"},
{ message = ".*deprecated", body = ".*deprecated", group = "Deprecation"},
{ message = "^revert", skip = true},
{ message = "^style", group = "Styling"},
{ message = "^test", group = "Testing"},
{ message = "^chore", skip = true},
{ message = "^ci", skip = true},
{ message = "^build", skip = true},
{ body = ".*security", group = "Security"},
]
filter_commits = true
tag_pattern = "[0-9]*"
skip_tags = "v[0-9]*|11|12"
ignore_tags = ""
topo_order = false
sort_commits = "newest"

View File

@@ -1,27 +0,0 @@
codecov:
notify:
after_n_builds: 6
strict_yaml_branch: main
coverage:
range: '50...90'
status:
project:
default:
target: auto
threshold: 5%
informational: true
patch: off
flag_management:
default_rules:
carryforward: true
statuses:
- type: project
target: auto
threshold: 2%
informational: true
comment:
require_changes: true
after_n_builds: 6

1
docs/README.md Normal file
View File

@@ -0,0 +1 @@
## [View the documentation here.](https://discord.js.org/#/docs)

5
docs/index.yml Normal file
View File

@@ -0,0 +1,5 @@
- name: General
files:
- name: Welcome
id: welcome
path: ../../README.md

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@@ -1,139 +0,0 @@
import unocss from '@unocss/eslint-plugin';
import common from 'eslint-config-neon/flat/common.js';
import edge from 'eslint-config-neon/flat/edge.js';
import next from 'eslint-config-neon/flat/next.js';
import node from 'eslint-config-neon/flat/node.js';
import prettier from 'eslint-config-neon/flat/prettier.js';
import react from 'eslint-config-neon/flat/react.js';
import typescript from 'eslint-config-neon/flat/typescript.js';
// import oxlint from 'eslint-plugin-oxlint';
import merge from 'lodash.merge';
import tseslint from 'typescript-eslint';
const commonFiles = '{js,mjs,cjs,ts,mts,cts,jsx,tsx}';
const commonRuleset = merge(...common, { files: [`**/*${commonFiles}`] });
const nodeRuleset = merge(...node, { files: [`**/*${commonFiles}`] });
const typeScriptRuleset = merge(...typescript, {
files: [`**/*${commonFiles}`],
languageOptions: {
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
allowAutomaticSingleRunInference: true,
project: ['tsconfig.eslint.json', 'packages/*/tsconfig.eslint.json'],
},
},
rules: {
'@typescript-eslint/consistent-type-definitions': [2, 'interface'],
'@typescript-eslint/naming-convention': [
2,
{
selector: 'typeParameter',
format: ['PascalCase'],
custom: {
regex: '^\\w{3,}',
match: true,
},
},
],
},
settings: {
'import/resolver': {
typescript: {
project: ['tsconfig.eslint.json', 'packages/*/tsconfig.eslint.json'],
},
},
},
});
const reactRuleset = merge(...react, {
files: [`packages/ui/**/*${commonFiles}`],
rules: {
'@next/next/no-html-link-for-pages': 0,
'react/react-in-jsx-scope': 0,
'react/jsx-filename-extension': [1, { extensions: ['.tsx'] }],
},
});
const prettierRuleset = merge(...prettier, { files: [`**/*${commonFiles}`] });
// const oxlintRuleset = merge({ rules: oxlint.rules }, { files: [`**/*${commonFiles}`] });
export default tseslint.config(
{
ignores: [
'**/node_modules/',
'.git/',
'**/dist/',
'**/template/',
'**/coverage/',
'**/storybook-static/',
'**/.next/',
'packages/discord.js/',
],
},
commonRuleset,
nodeRuleset,
typeScriptRuleset,
{
files: ['**/*{ts,mts,cts,tsx}'],
rules: { 'jsdoc/no-undefined-types': 0 },
},
{
files: [`packages/{api-extractor,brokers,create-discord-bot,docgen,ws}/**/*${commonFiles}`],
rules: { 'n/no-sync': 0 },
},
{
files: [`packages/rest/**/*${commonFiles}`],
rules: {
'n/prefer-global/url': 0,
'n/prefer-global/url-search-params': 0,
'n/prefer-global/buffer': 0,
'n/prefer-global/process': 0,
'no-restricted-globals': 0,
'unicorn/prefer-node-protocol': 0,
},
},
{
files: [`packages/voice/**/*${commonFiles}`],
rules: { 'no-restricted-globals': 0 },
},
{
files: [`packages/api-extractor-model/**/*${commonFiles}`],
rules: {
'@typescript-eslint/no-namespace': 0,
'no-prototype-builtins': 0,
'consistent-this': 0,
'unicorn/no-this-assignment': 0,
'@typescript-eslint/no-this-alias': 0,
},
},
{
files: [`packages/api-extractor/**/*${commonFiles}`],
rules: {
'consistent-this': 0,
'unicorn/no-this-assignment': 0,
'@typescript-eslint/no-this-alias': 0,
},
},
{
files: [`packages/{api-extractor,api-extractor-model,api-extractor-utils}/**/*${commonFiles}`],
rules: { '@typescript-eslint/naming-convention': 0 },
},
reactRuleset,
{
files: [`packages/ui/**/*${commonFiles}`],
plugins: { '@unocss': unocss },
rules: {
'@unocss/order': 2,
},
},
{
files: ['**/*{js,mjs,cjs,jsx}'],
rules: { 'tsdoc/syntax': 0 },
},
prettierRuleset,
// oxlintRuleset,
);

21576
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,99 +1,88 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@discordjs/discord.js",
"version": "0.0.0",
"description": "A powerful library for interacting with the Discord API",
"private": true,
"scripts": {
"build": "turbo run build --concurrency=4",
"build:affected": "turbo run build --filter=...[origin/v14] --concurrency=4",
"test": "turbo run test --concurrency=4",
"test:affected": "turbo run test --filter=...[origin/v14] --concurrency=4",
"lint": "turbo run lint --concurrency=4",
"lint:affected": "turbo run lint --filter=...[origin/v14] --concurrency=4",
"format": "turbo run format --concurrency=4",
"format:affected": "turbo run format --filter=...[origin/v14] --concurrency=4",
"fmt": "turbo run format --concurrency=4",
"fmt:affected": "turbo run format --filter=...[origin/v14] --concurrency=4",
"docs": "turbo run docs --concurrency=4",
"docs:affected": "turbo run docs --filter=...[origin/v14] --concurrency=4",
"prepare": "is-ci || husky",
"update": "pnpm --recursive update --interactive",
"update:latest": "pnpm --recursive update --interactive --latest",
"create-package": "turbo gen create-package --args"
},
"type": "module",
"contributors": [
"Crawl <icrawltogo@gmail.com>",
"Amish Shah <amishshah.2k@gmail.com>",
"Vlad Frangu <me@vladfrangu.dev>",
"SpaceEEC <spaceeec@yahoo.com>",
"Aura Román <kyradiscord@gmail.com>"
],
"keywords": [
"discord",
"api",
"bot",
"client",
"node",
"discordapp"
],
"repository": {
"type": "git",
"url": "https://github.com/discordjs/discord.js.git"
},
"bugs": {
"url": "https://github.com/discordjs/discord.js/issues"
},
"homepage": "https://discord.js.org",
"funding": "https://github.com/discordjs/discord.js?sponsor",
"devDependencies": {
"@commitlint/cli": "^19.4.0",
"@commitlint/config-angular": "^19.3.0",
"@favware/cliff-jumper": "^4.1.0",
"@favware/npm-deprecate": "^1.0.7",
"@types/lodash.merge": "^4.6.9",
"@unocss/eslint-plugin": "^0.59.4",
"@vitest/coverage-v8": "^2.0.5",
"conventional-changelog-cli": "^4.1.0",
"eslint": "^8.57.1",
"eslint-config-neon": "^0.1.62",
"husky": "^9.1.5",
"is-ci": "^3.0.1",
"lint-staged": "^15.2.9",
"lodash.merge": "^4.6.2",
"prettier": "^3.8.1",
"tsup": "^8.5.1",
"turbo": "^2.8.10",
"typescript": "~5.8.3",
"typescript-eslint": "^8.56.0",
"unocss": "^0.60.4",
"vercel": "^37.0.0",
"vitest": "^2.0.5"
},
"pnpm": {
"peerDependencyRules": {
"ignoreMissing": [
"*"
],
"allowedAny": [
"*"
]
},
"overrides": {
"@contentlayer/utils>@opentelemetry/core": "^1.15.1",
"@contentlayer/utils>@opentelemetry/exporter-trace-otlp-grpc": "^0.41.1",
"@contentlayer/utils>@opentelemetry/resources": "^1.15.1",
"@contentlayer/utils>@opentelemetry/sdk-trace-base": "^1.15.1",
"@contentlayer/utils>@opentelemetry/sdk-trace-node": "^1.15.1",
"@contentlayer/utils>@opentelemetry/semantic-conventions": "^1.15.1"
},
"patchedDependencies": {
"@microsoft/tsdoc-config@0.16.2": "patches/@microsoft__tsdoc-config@0.16.2.patch"
}
},
"engines": {
"node": ">=18"
},
"packageManager": "pnpm@9.8.0"
"name": "discord.js",
"version": "13.7.0",
"description": "A powerful library for interacting with the Discord API",
"scripts": {
"test": "npm run lint && npm run docs:test && npm run lint:typings && npm run test:typescript",
"test:typescript": "tsc --noEmit && tsd",
"lint": "eslint src",
"lint:fix": "eslint src --fix",
"lint:typings": "tslint typings/index.d.ts",
"format": "prettier --write src/**/*.js typings/**/*.ts",
"prepare": "is-ci || husky install",
"docs": "docgen --source src --custom docs/index.yml --output docs/docs.json",
"docs:test": "docgen --source src --custom docs/index.yml",
"prepublishOnly": "npm run test",
"changelog": "git cliff --prepend CHANGELOG.md -u"
},
"main": "./src/index.js",
"types": "./typings/index.d.ts",
"files": [
"src",
"typings"
],
"directories": {
"lib": "src",
"test": "test"
},
"contributors": [
"Crawl <icrawltogo@gmail.com>",
"Amish Shah <amishshah.2k@gmail.com>",
"Vlad Frangu <kingdgrizzle@gmail.com>",
"SpaceEEC <spaceeec@yahoo.com>",
"Antonio Roman <kyradiscord@gmail.com>"
],
"license": "Apache-2.0",
"keywords": [
"discord",
"api",
"bot",
"client",
"node",
"discordapp"
],
"repository": {
"type": "git",
"url": "https://github.com/discordjs/discord.js.git"
},
"bugs": {
"url": "https://github.com/discordjs/discord.js/issues"
},
"homepage": "https://discord.js.org",
"dependencies": {
"@discordjs/builders": "^0.13.0",
"@discordjs/collection": "^0.6.0",
"@sapphire/async-queue": "^1.3.1",
"@types/node-fetch": "^2.6.1",
"@types/ws": "^8.5.3",
"discord-api-types": "^0.30.0",
"form-data": "^4.0.0",
"node-fetch": "^2.6.1",
"ws": "^8.6.0"
},
"devDependencies": {
"@commitlint/cli": "^16.2.4",
"@commitlint/config-angular": "^16.2.4",
"@discordjs/docgen": "^0.11.1",
"@favware/npm-deprecate": "^1.0.4",
"@types/node": "^16.11.12",
"conventional-changelog-cli": "^2.2.2",
"dtslint": "^4.2.1",
"eslint": "^8.15.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^8.0.1",
"is-ci": "^3.0.1",
"jest": "^28.1.0",
"lint-staged": "^12.4.1",
"prettier": "^2.6.2",
"tsd": "^0.20.0",
"tslint": "^6.1.3",
"typescript": "^4.6.4"
},
"engines": {
"node": ">=16.6.0",
"npm": ">=7.0.0"
}
}

View File

@@ -1,23 +0,0 @@
# Packages
node_modules
# Log files
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Env
.env
# Dist
dist
# Miscellaneous
.turbo
.tmp
coverage

View File

@@ -1,2 +0,0 @@
/** @type {import('lint-staged').Config} */
module.exports = require('../../.lintstagedrc.json');

View File

@@ -1,4 +0,0 @@
.turbo
coverage
dist
tsup.config.bundled*

View File

@@ -1,2 +0,0 @@
/** @type {import('prettier').Config} */
module.exports = require('../../.prettierrc.json');

View File

@@ -1,190 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
Copyright 2022 Noel Buechler
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -1,45 +0,0 @@
<div align="center">
<br />
<p>
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
</p>
<br />
<p>
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
</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>
## Links
- [Website][website] ([source][website-source])
- [Guide][guide] ([source][guide-source])
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
- [discord.js Discord server][discord]
- [Discord API Discord server][discord-api]
- [GitHub][source]
- [Related libraries][related-libs]
## Contributing
Before creating an issue, please ensure that it hasn't already been reported/suggested.
See [the contribution guide][contributing] if you'd like to submit a PR.
## Help
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official [discord.js Server][discord].
[website]: https://discord.js.org
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
[guide]: https://discordjs.guide/
[guide-source]: https://github.com/discordjs/guide
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
[discord]: https://discord.gg/djs
[discord-api]: https://discord.gg/discord-api
[source]: https://github.com/discordjs/discord.js/tree/main/packages/actions
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md

View File

@@ -1,55 +0,0 @@
import { describe, test, expect } from 'vitest';
import { formatTag } from '../src/index.js';
describe('Format Tag', () => {
test('GIVEN tag with a prefix THEN format tag to not contain the prefix', () => {
expect(formatTag('@discordjs/rest@0.4.0')).toEqual({
isSubpackage: true,
package: 'rest',
semver: '0.4.0',
});
expect(formatTag('@discordjs/collection@0.6.0')).toEqual({
isSubpackage: true,
package: 'collection',
semver: '0.6.0',
});
expect(formatTag('@discordjs/proxy@0.1.0')).toEqual({
isSubpackage: true,
package: 'proxy',
semver: '0.1.0',
});
expect(formatTag('@discordjs/builders@0.13.0')).toEqual({
isSubpackage: true,
package: 'builders',
semver: '0.13.0',
});
expect(formatTag('@discordjs/voice@0.9.0')).toEqual({
isSubpackage: true,
package: 'voice',
semver: '0.9.0',
});
});
test('GIVEN tag with no prefix THEN return tag', () => {
expect(formatTag('13.5.1')).toEqual({
isSubpackage: false,
package: 'discord.js',
semver: '13.5.1',
});
expect(formatTag('13.7.0')).toEqual({
isSubpackage: false,
package: 'discord.js',
semver: '13.7.0',
});
expect(formatTag('create-discord-bot@1.0.0')).toEqual({
isSubpackage: false,
package: 'create-discord-bot',
semver: '1.0.0',
});
});
test('GIVEN no or invalid tag THEN return null', () => {
expect(formatTag('')).toEqual(null);
expect(formatTag('abc')).toEqual(null);
});
});

View File

@@ -1,74 +0,0 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@discordjs/actions",
"version": "0.1.0",
"description": "A set of actions that we use for our workflows",
"private": true,
"scripts": {
"test": "vitest run",
"build": "tsc --noEmit --lib ESNext,DOM && tsup",
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
"fmt": "pnpm run format"
},
"type": "module",
"directories": {
"lib": "src",
"test": "__tests__"
},
"files": [
"dist"
],
"contributors": [
"Crawl <icrawltogo@gmail.com>"
],
"license": "Apache-2.0",
"keywords": [
"api",
"bot",
"client",
"node",
"discordjs"
],
"repository": {
"type": "git",
"url": "https://github.com/discordjs/discord.js.git",
"directory": "packages/actions"
},
"bugs": {
"url": "https://github.com/discordjs/discord.js/issues"
},
"homepage": "https://discord.js.org",
"funding": "https://github.com/discordjs/discord.js?sponsor",
"dependencies": {
"@actions/core": "^1.11.1",
"@actions/glob": "^0.5.1",
"@aws-sdk/client-s3": "^3.995.0",
"@discordjs/scripts": "workspace:^",
"@vercel/blob": "^0.27.3",
"@vercel/postgres": "^0.9.0",
"cloudflare": "^4.2.0",
"meilisearch": "^0.38.0",
"p-limit": "^6.2.0",
"p-queue": "^8.1.0",
"tslib": "^2.8.1",
"undici": "7.22.0"
},
"devDependencies": {
"@types/node": "^22.19.11",
"@vitest/coverage-v8": "^3.1.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.1",
"eslint-config-neon": "^0.1.62",
"eslint-formatter-pretty": "^6.0.1",
"prettier": "^3.8.1",
"terser": "^5.46.0",
"tsup": "^8.5.1",
"turbo": "^2.8.10",
"typescript": "~5.8.3",
"vitest": "^3.1.1"
},
"engines": {
"node": ">=18"
}
}

View File

@@ -1,16 +0,0 @@
name: 'Format Tag'
description: 'Formats a git tag to remove potentially prefixes'
inputs:
tag:
description: 'The input tag'
required: true
outputs:
subpackage:
description: 'Whether this tag is a subpackage tag'
package:
description: 'The package string that was extracted from this tag'
semver:
description: 'The semver string that was extracted from this tag'
runs:
using: node20
main: ../../dist/formatTag/index.js

View File

@@ -1,18 +0,0 @@
export function formatTag(tag: string) {
const parsed = /(?:^@.*\/(?<package>.*)@v?)?(?<semver>\d+.\d+.\d+)-?.*/.exec(tag);
const parsedPackage = /(?<package>.*)@v?-?.*/.exec(tag);
if (parsed?.groups) {
const isSubpackage = typeof parsed.groups.package === 'string';
const pkg = isSubpackage ? parsed.groups.package : (parsedPackage?.groups?.package ?? 'discord.js');
const semver = parsed.groups.semver;
return {
isSubpackage,
package: pkg,
semver,
};
}
return null;
}

View File

@@ -1,11 +0,0 @@
import { getInput, setOutput } from '@actions/core';
import { formatTag } from './formatTag.js';
const tag = getInput('tag', { required: true });
const parsed = formatTag(tag);
if (parsed) {
setOutput('subpackage', parsed.isSubpackage);
setOutput('package', parsed.package);
setOutput('semver', parsed.semver);
}

View File

@@ -1 +0,0 @@
export * from './formatTag/formatTag.js';

View File

@@ -1,42 +0,0 @@
name: 'pnpm install'
description: 'Run pnpm install with cache enabled'
runs:
using: 'composite'
steps:
- name: Set up swap space
if: runner.os == 'Linux'
uses: pierotofy/set-swap-space@v1.0
with:
swap-size-gb: 10
- uses: pnpm/action-setup@v4.1.0
name: Install pnpm
with:
run_install: false
- name: Expose pnpm config(s) through "$GITHUB_OUTPUT"
id: pnpm-config
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Cache rotation keys
id: cache-rotation
shell: bash
run: |
echo "YEAR_MONTH=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-config.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-
- name: Install dependencies
shell: bash
run: |
pnpm install --frozen-lockfile --prefer-offline --loglevel error
env:
HUSKY: '0'

View File

@@ -1,116 +0,0 @@
name: 'Upload Coverage'
description: 'Uploads code coverage reports to codecov with separate flags for separate packages'
inputs:
codecov_token:
description: 'Codecov token.'
required: true
runs:
using: 'composite'
steps:
- name: Upload Brokers Coverage
if: ${{ hashFiles('packages/brokers/coverage/cobertura-coverage.xml') != '' }}
uses: codecov/codecov-action@v4
with:
files: ./packages/brokers/coverage/cobertura-coverage.xml
disable_search: true
flags: brokers
token: ${{ inputs.CODECOV_TOKEN }}
- name: Upload Builders Coverage
if: ${{ hashFiles('packages/builders/coverage/cobertura-coverage.xml') != '' }}
uses: codecov/codecov-action@v4
with:
files: ./packages/builders/coverage/cobertura-coverage.xml
disable_search: true
flags: builders
token: ${{ inputs.CODECOV_TOKEN }}
- name: Upload Collection Coverage
if: ${{ hashFiles('packages/collection/coverage/cobertura-coverage.xml') != '' }}
uses: codecov/codecov-action@v4
with:
files: ./packages/collection/coverage/cobertura-coverage.xml
disable_search: true
flags: collection
token: ${{ inputs.CODECOV_TOKEN }}
- name: Upload Discord.js Coverage
if: ${{ hashFiles('packages/discord.js/coverage/cobertura-coverage.xml') != '' }}
uses: codecov/codecov-action@v4
with:
files: ./packages/discord.js/coverage/cobertura-coverage.xml
disable_search: true
flags: discord.js
token: ${{ inputs.CODECOV_TOKEN }}
- name: Upload Formatters Coverage
if: ${{ hashFiles('packages/formatters/coverage/cobertura-coverage.xml') != '' }}
uses: codecov/codecov-action@v4
with:
files: ./packages/formatters/coverage/cobertura-coverage.xml
disable_search: true
flags: formatters
token: ${{ inputs.CODECOV_TOKEN }}
- name: Upload Next Coverage
if: ${{ hashFiles('packages/next/coverage/cobertura-coverage.xml') != '' }}
uses: codecov/codecov-action@v4
with:
files: ./packages/next/coverage/cobertura-coverage.xml
disable_search: true
flags: next
token: ${{ inputs.CODECOV_TOKEN }}
- name: Upload Proxy Coverage
if: ${{ hashFiles('packages/proxy/coverage/cobertura-coverage.xml') != '' }}
uses: codecov/codecov-action@v4
with:
files: ./packages/proxy/coverage/cobertura-coverage.xml
disable_search: true
flags: proxy
token: ${{ inputs.CODECOV_TOKEN }}
- name: Upload Rest Coverage
if: ${{ hashFiles('packages/rest/coverage/cobertura-coverage.xml') != '' }}
uses: codecov/codecov-action@v4
with:
files: ./packages/rest/coverage/cobertura-coverage.xml
disable_search: true
flags: rest
token: ${{ inputs.CODECOV_TOKEN }}
- name: Upload Voice Coverage
if: ${{ hashFiles('packages/voice/coverage/cobertura-coverage.xml') != '' }}
uses: codecov/codecov-action@v4
with:
files: ./packages/voice/coverage/cobertura-coverage.xml
disable_search: true
flags: voice
token: ${{ inputs.CODECOV_TOKEN }}
- name: Upload WS Coverage
if: ${{ hashFiles('packages/ws/coverage/cobertura-coverage.xml') != '' }}
uses: codecov/codecov-action@v4
with:
files: ./packages/ws/coverage/cobertura-coverage.xml
disable_search: true
flags: ws
token: ${{ inputs.CODECOV_TOKEN }}
- name: Upload Util Coverage
if: ${{ hashFiles('packages/util/coverage/cobertura-coverage.xml') != '' }}
uses: codecov/codecov-action@v4
with:
files: ./packages/util/coverage/cobertura-coverage.xml
disable_search: true
flags: util
token: ${{ inputs.CODECOV_TOKEN }}
- name: Upload Utilities Coverage
if: ${{ hashFiles('packages/actions/coverage/cobertura-coverage.xml') != '' || hashFiles('packages/scripts/coverage/cobertura-coverage.xml') != '' }}
uses: codecov/codecov-action@v4
with:
files: ./packages/actions/coverage/cobertura-coverage.xml, ./packages/scripts/coverage/cobertura-coverage.xml
disable_search: true
flags: utilities
token: ${{ inputs.CODECOV_TOKEN }}

View File

@@ -1,10 +0,0 @@
name: 'Upload documentation'
description: 'Uploads the docs.api.json file to a neon postgresql database'
inputs:
package:
description: 'The package string'
version:
description: 'The semver string'
runs:
using: node20
main: ../../dist/uploadDocumentation/index.js

View File

@@ -1,96 +0,0 @@
/* eslint-disable @typescript-eslint/no-loop-func */
import { readFile } from 'node:fs/promises';
import process from 'node:process';
import { getInput, setFailed } from '@actions/core';
import { create } from '@actions/glob';
import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
import { put } from '@vercel/blob';
import { createPool } from '@vercel/postgres';
import Cloudflare from 'cloudflare';
import pLimit from 'p-limit';
if (
!process.env.DATABASE_URL ||
!process.env.CF_R2_DOCS_URL ||
!process.env.CF_R2_DOCS_ACCESS_KEY_ID ||
!process.env.CF_R2_DOCS_SECRET_ACCESS_KEY ||
!process.env.CF_R2_DOCS_BUCKET ||
!process.env.CF_R2_DOCS_BUCKET_URL ||
!process.env.CF_D1_DOCS_API_KEY ||
!process.env.CF_D1_DOCS_ID ||
!process.env.CF_ACCOUNT_ID
) {
setFailed('Missing environment variables');
}
const pkg = getInput('package') || '*';
const version = getInput('version') || 'main';
const pool = createPool({
connectionString: process.env.DATABASE_URL,
});
const S3 = new S3Client({
region: 'auto',
endpoint: process.env.CF_R2_DOCS_URL!,
credentials: {
accessKeyId: process.env.CF_R2_DOCS_ACCESS_KEY_ID!,
secretAccessKey: process.env.CF_R2_DOCS_SECRET_ACCESS_KEY!,
},
requestChecksumCalculation: 'WHEN_REQUIRED',
responseChecksumValidation: 'WHEN_REQUIRED',
});
const client = new Cloudflare({
apiToken: process.env.CF_D1_DOCS_API_KEY,
});
const limit = pLimit(10);
const promises = [];
const globber = await create(`packages/${pkg}/docs/docs.api.json`);
console.log('Glob: ', await globber.glob());
for await (const file of globber.globGenerator()) {
const data = await readFile(file, 'utf8');
try {
promises.push(
limit(async () => {
console.log(`Uploading ${file} with ${version}...`);
const json = JSON.parse(data);
const name = json.name ?? json.n;
const key = `${name.replace('@discordjs/', '')}/${version}.json`;
const { url } = await put(key, data, {
access: 'public',
addRandomSuffix: false,
});
await pool.sql`insert into documentation (name, version, url) values (${name.replace(
'@discordjs/',
'',
)}, ${version}, ${url}) on conflict (name, version) do update set url = EXCLUDED.url`;
await S3.send(
new PutObjectCommand({
Bucket: process.env.CF_R2_DOCS_BUCKET,
Key: key,
Body: data,
}),
);
await client.d1.database.raw(process.env.CF_D1_DOCS_ID!, {
account_id: process.env.CF_ACCOUNT_ID!,
sql: `insert into documentation (name, version, url) values (?, ?, ?) on conflict (name, version) do update set url = excluded.url;`,
params: [name.replace('@discordjs/', ''), version, process.env.CF_R2_DOCS_BUCKET_URL + '/' + key],
});
}),
);
} catch (error) {
console.log(error);
}
}
try {
await Promise.all(promises);
} catch (error) {
console.log(error);
}

View File

@@ -1,5 +0,0 @@
name: 'Upload search indices'
description: 'Uploads the search indices to a meilisearch database'
runs:
using: node20
main: ../../dist/uploadSearchIndices/index.js

View File

@@ -1,86 +0,0 @@
import process from 'node:process';
import { setFailed } from '@actions/core';
import { generateAllIndices } from '@discordjs/scripts';
import { createPool } from '@vercel/postgres';
import { MeiliSearch } from 'meilisearch';
import pLimit from 'p-limit';
import { fetch } from 'undici';
if (!process.env.DATABASE_URL) {
setFailed('DATABASE_URL is not set');
}
if (!process.env.SEARCH_API_URL) {
setFailed('SEARCH_API_URL is not set');
}
if (!process.env.SEARCH_API_KEY) {
setFailed('SEARCH_API_KEY is not set');
}
const pool = createPool({
connectionString: process.env.DATABASE_URL,
});
const client = new MeiliSearch({
host: process.env.SEARCH_API_URL!,
apiKey: process.env.SEARCH_API_KEY!,
});
const limit = pLimit(10);
let promises: Promise<any>[] = [];
try {
console.log('Generating all indices...');
const indices = await generateAllIndices({
fetchPackageVersions: async (pkg) => {
console.log(`Fetching versions for ${pkg}...`);
const { rows } = await pool.sql`select version from documentation where name = ${pkg}`;
return rows.map((row) => row.version);
},
fetchPackageVersionDocs: async (pkg, version) => {
console.log(`Fetching data for ${pkg} ${version}...`);
const { rows } = await pool.sql`select url from documentation where name = ${pkg} and version = ${version}`;
const res = await fetch(rows[0]?.url ?? '');
return res.json();
},
writeToFile: false,
});
console.log('Generated all indices.');
console.log('Uploading indices...');
try {
promises = indices.map(async (index) =>
limit(async () => {
console.log(`Uploading ${index.index}...`);
let task;
try {
task = await client.createIndex(index.index);
} catch {}
if (task) {
await client.waitForTask(task.taskUid);
}
const searchIndex = client.index(index.index);
await searchIndex.updateSettings({ sortableAttributes: ['type'] });
await searchIndex.addDocuments(index.data);
}),
);
} catch {}
console.log('Uploaded all indices.');
} catch (error) {
const err = error as Error;
setFailed(err.message);
}
try {
await Promise.all(promises);
} catch (error) {
console.log(error);
}

View File

@@ -1,10 +0,0 @@
name: 'Upload split documentation'
description: 'Splits and uploads the docs.api.json file into more fine-grained [item].api.json files'
inputs:
package:
description: 'The package string'
version:
description: 'The semver string'
runs:
using: node20
main: ../../dist/uploadSplitDocumentation/index.js

View File

@@ -1,94 +0,0 @@
/* eslint-disable @typescript-eslint/no-loop-func */
import { readFile } from 'node:fs/promises';
import { basename, dirname, relative, sep } from 'node:path';
import process from 'node:process';
import { setTimeout as sleep } from 'node:timers/promises';
import { setFailed, getInput } from '@actions/core';
import { create } from '@actions/glob';
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
import { put } from '@vercel/blob';
import PQueue from 'p-queue';
if (
!process.env.CF_R2_DOCS_URL ||
!process.env.CF_R2_DOCS_ACCESS_KEY_ID ||
!process.env.CF_R2_DOCS_SECRET_ACCESS_KEY ||
!process.env.CF_R2_DOCS_BUCKET
) {
setFailed('Missing environment variables');
}
const pkg = getInput('package') || '*';
const version = getInput('version') || 'main';
const queue = new PQueue({ concurrency: 10, interval: 60_000, intervalCap: 1_000 });
const promises = [];
const failedUploads: string[] = [];
const S3 = new S3Client({
region: 'auto',
endpoint: process.env.CF_R2_DOCS_URL!,
credentials: {
accessKeyId: process.env.CF_R2_DOCS_ACCESS_KEY_ID!,
secretAccessKey: process.env.CF_R2_DOCS_SECRET_ACCESS_KEY!,
},
requestChecksumCalculation: 'WHEN_REQUIRED',
responseChecksumValidation: 'WHEN_REQUIRED',
});
const globber = await create(`packages/${pkg}/docs/${pkg}/split/*.api.json`);
console.log('Glob: ', await globber.glob());
for await (const file of globber.globGenerator()) {
const data = await readFile(file, 'utf8');
const pkgName = dirname(relative(process.cwd(), file)).split(sep)[1];
try {
promises.push(
queue.add(async () => {
console.log(`Uploading ${file} with ${version} from ${pkgName}...`);
const name = basename(file).replace('main.', '');
async function upload(retries = 0) {
try {
await put(`rewrite/${pkgName}/${version}.${name}`, data, {
access: 'public',
addRandomSuffix: false,
});
await S3.send(
new PutObjectCommand({
Bucket: process.env.CF_R2_DOCS_BUCKET,
Key: `${pkgName}/${version}.${name}`,
Body: data,
}),
);
} catch (error) {
if (retries > 3) {
console.error(`Could not upload ${file} after 3 retries`, error);
failedUploads.push(name);
return;
}
if (typeof error === 'object' && error && 'retryAfter' in error && typeof error.retryAfter === 'number') {
await sleep(error.retryAfter * 1_000);
return upload(retries + 1);
} else {
console.error(`Could not upload ${file}`, error);
failedUploads.push(name);
}
}
}
await upload();
}),
);
} catch (error) {
console.log(error);
}
}
try {
await Promise.all(promises);
if (failedUploads.length) {
setFailed(`Failed to upload ${failedUploads.length} files: ${failedUploads.join(', ')}`);
}
} catch (error) {
console.log(error);
}

View File

@@ -1,48 +0,0 @@
name: 'yarn install'
description: 'Run yarn install with node_modules linker and cache enabled'
runs:
using: 'composite'
steps:
- name: Set up swap space
if: runner.os == 'Linux'
uses: pierotofy/set-swap-space@v1.0
with:
swap-size-gb: 10
- name: Expose yarn config as "$GITHUB_OUTPUT"
id: yarn-config
shell: bash
env:
YARN_ENABLE_GLOBAL_CACHE: 'false'
run: |
echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
echo "CURRENT_NODE_VERSION="node-$(node --version)"" >> $GITHUB_OUTPUT
echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g')" >> $GITHUB_OUTPUT
echo "NPM_GLOBAL_CACHE_FOLDER=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: Restore yarn cache
uses: actions/cache@v4
id: yarn-download-cache
with:
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }}
key: yarn-download-cache-default-${{ hashFiles(yarn.lock, .yarnrc.yml) }}
restore-keys: |
yarn-download-cache-default-
- name: Restore global npm cache folder
id: npm-global-cache
uses: actions/cache@v4
with:
path: ${{ steps.yarn-config.outputs.NPM_GLOBAL_CACHE_FOLDER }}
key: npm-global-cache-default-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ hashFiles(yarn.lock, .yarnrc.yml) }}
- name: Install dependencies
shell: bash
run: |
yarn install --immutable --inline-builds
env:
YARN_ENABLE_GLOBAL_CACHE: 'false'
YARN_ENABLE_MIRROR: 'false'
YARN_NM_MODE: 'hardlinks-local'
YARN_INSTALL_STATE_PATH: '.yarn/ci-cache/install-state.gz'
HUSKY: '0'

View File

@@ -1,22 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"allowJs": true
},
"include": [
"*.ts",
"*.js",
"*.cjs",
"*.mjs",
"src/**/*.ts",
"src/**/*.js",
"src/**/*.cjs",
"src/**/*.mjs",
"bin",
"scripts",
"__tests__",
"__mocks__"
],
"exclude": ["node_modules"]
}

View File

@@ -1,6 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "../../tsconfig.json",
"include": ["src/**/*.ts", "src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "bin"],
"exclude": ["node_modules"]
}

View File

@@ -1,10 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": true,
"skipLibCheck": true
},
"include": ["__tests__/**/*.ts"],
"exclude": ["node_modules"]
}

View File

@@ -1,14 +0,0 @@
import { createTsupConfig } from '../../tsup.config.js';
export default createTsupConfig({
entry: [
'src/index.ts',
'src/formatTag/index.ts',
'src/uploadDocumentation/index.ts',
'src/uploadSearchIndices/index.ts',
'src/uploadSplitDocumentation/index.ts',
],
dts: false,
format: 'esm',
minify: 'terser',
});

View File

@@ -1,23 +0,0 @@
# Packages
node_modules
# Log files
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Env
.env
# Dist
dist
# Miscellaneous
.turbo
.tmp
coverage

View File

@@ -1,2 +0,0 @@
/** @type {import('lint-staged').Config} */
module.exports = require('../../.lintstagedrc.json');

View File

@@ -1,30 +0,0 @@
# THIS IS A STANDARD TEMPLATE FOR .npmignore FILES IN THIS REPO.
# Ignore all files by default, to avoid accidentally publishing unintended files.
*
# Use negative patterns to bring back the specific things we want to publish.
!/bin/**
!/lib/**
!/lib-*/**
!/dist/**
!ThirdPartyNotice.txt
# Ignore certain patterns that should not get published.
/dist/*.stats.*
/lib/**/test/
/lib-*/**/test/
*.test.js
# NOTE: These don't need to be specified, because NPM includes them automatically.
#
# package.json
# README (and its variants)
# CHANGELOG (and its variants)
# LICENSE / LICENCE
#--------------------------------------------
# DO NOT MODIFY THE TEMPLATE ABOVE THIS LINE
#--------------------------------------------
# (Add your project-specific overrides here)

View File

@@ -1,5 +0,0 @@
.turbo
coverage
dist
CHANGELOG.md
tsup.config.bundled*

View File

@@ -1,2 +0,0 @@
/** @type {import('prettier').Config} */
module.exports = require('../../.prettierrc.json');

File diff suppressed because it is too large Load Diff

View File

@@ -1,965 +0,0 @@
# Change Log - @microsoft/api-extractor-model
This log was last generated on Thu, 28 Sep 2023 20:53:16 GMT and should not be manually modified.
## 7.28.2
Thu, 28 Sep 2023 20:53:16 GMT
_Version update only_
## 7.28.1
Tue, 26 Sep 2023 09:30:33 GMT
### Patches
- Update type-only imports to include the type modifier.
## 7.28.0
Fri, 15 Sep 2023 00:36:58 GMT
### Minor changes
- Update @types/node from 14 to 18
## 7.27.6
Tue, 08 Aug 2023 07:10:40 GMT
_Version update only_
## 7.27.5
Wed, 19 Jul 2023 00:20:32 GMT
_Version update only_
## 7.27.4
Thu, 06 Jul 2023 00:16:20 GMT
_Version update only_
## 7.27.3
Thu, 15 Jun 2023 00:21:01 GMT
_Version update only_
## 7.27.2
Wed, 07 Jun 2023 22:45:16 GMT
_Version update only_
## 7.27.1
Mon, 29 May 2023 15:21:15 GMT
_Version update only_
## 7.27.0
Mon, 22 May 2023 06:34:32 GMT
### Minor changes
- Upgrade the TypeScript dependency to ~5.0.4
## 7.26.9
Fri, 12 May 2023 00:23:05 GMT
_Version update only_
## 7.26.8
Thu, 04 May 2023 00:20:28 GMT
### Patches
- Fix a mistake in the documentation for ApiParameterListMixin.overloadIndex
## 7.26.7
Mon, 01 May 2023 15:23:20 GMT
_Version update only_
## 7.26.6
Sat, 29 Apr 2023 00:23:03 GMT
_Version update only_
## 7.26.5
Thu, 27 Apr 2023 17:18:43 GMT
_Version update only_
## 7.26.4
Fri, 10 Feb 2023 01:18:51 GMT
_Version update only_
## 7.26.3
Sun, 05 Feb 2023 03:02:02 GMT
_Version update only_
## 7.26.2
Wed, 01 Feb 2023 02:16:34 GMT
_Version update only_
## 7.26.1
Mon, 30 Jan 2023 16:22:30 GMT
_Version update only_
## 7.26.0
Wed, 25 Jan 2023 07:26:55 GMT
### Minor changes
- Add new .api.json field `isAbstract` to track `abstract` modifier in ApiClass, ApiMethod, and ApiProperty via ApiAbstractMixin (GitHub #3661)
## 7.25.3
Fri, 09 Dec 2022 16:18:28 GMT
_Version update only_
## 7.25.2
Wed, 26 Oct 2022 00:16:16 GMT
### Patches
- Update the @microsoft/tsdoc dependency version to 0.14.2.
## 7.25.1
Thu, 13 Oct 2022 00:20:15 GMT
_Version update only_
## 7.25.0
Tue, 11 Oct 2022 23:49:12 GMT
### Minor changes
- Add a new fileUrlPath property to relevant API items and serialize this to the .api.json. Additionally, add a SourceFile helper class for constructing file URLs from these paths and the projectFolderUrl.
## 7.24.4
Mon, 10 Oct 2022 15:23:44 GMT
_Version update only_
## 7.24.3
Thu, 29 Sep 2022 07:13:06 GMT
_Version update only_
## 7.24.2
Wed, 21 Sep 2022 20:21:10 GMT
_Version update only_
## 7.24.1
Thu, 15 Sep 2022 00:18:52 GMT
_Version update only_
## 7.24.0
Fri, 02 Sep 2022 17:48:42 GMT
### Minor changes
- Add new ApiExportedMixin mixin class for determining whether an API item is exported or not
## 7.23.3
Wed, 24 Aug 2022 03:01:22 GMT
_Version update only_
## 7.23.2
Wed, 24 Aug 2022 00:14:38 GMT
### Patches
- Remove use of LegacyAdapters.sortStable
## 7.23.1
Fri, 19 Aug 2022 00:17:19 GMT
_Version update only_
## 7.23.0
Wed, 03 Aug 2022 18:40:35 GMT
### Minor changes
- Upgrade TypeScript dependency to 4.7
## 7.22.2
Mon, 01 Aug 2022 02:45:32 GMT
_Version update only_
## 7.22.1
Thu, 21 Jul 2022 23:30:27 GMT
### Patches
- Improve IFindApiItemMessage and fix two small bugs with ApiItemContainerMixin.findMembersWithInheritance()
## 7.22.0
Thu, 21 Jul 2022 00:16:14 GMT
### Minor changes
- Add a new ApiItemContainerMixin.findMembersWithInheritance() method for finding an item's inherited members
## 7.21.0
Thu, 30 Jun 2022 04:48:53 GMT
### Minor changes
- Update model to reflect that index signatures can also be readonly
## 7.20.3
Tue, 28 Jun 2022 22:47:13 GMT
_Version update only_
## 7.20.2
Tue, 28 Jun 2022 00:23:32 GMT
_Version update only_
## 7.20.1
Mon, 27 Jun 2022 18:43:09 GMT
_Version update only_
## 7.20.0
Sat, 25 Jun 2022 21:00:40 GMT
### Minor changes
- Add a new initializerTokenRange field to ApiProperty and ApiVariable items.
## 7.19.1
Sat, 25 Jun 2022 01:54:29 GMT
_Version update only_
## 7.19.0
Fri, 24 Jun 2022 07:16:47 GMT
### Minor changes
- Added new configuration for ItemContainerMixin member ordering
## 7.18.2
Fri, 17 Jun 2022 09:17:54 GMT
_Version update only_
## 7.18.1
Fri, 17 Jun 2022 00:16:18 GMT
_Version update only_
## 7.18.0
Tue, 07 Jun 2022 09:37:04 GMT
### Minor changes
- Add an "isReadonly" field to ApiProperty, ApiPropertySignature, and ApiVariable
- Add an "isProtected" field to ApiConstructor, ApiMethod, and ApiProperty
## 7.17.3
Tue, 10 May 2022 01:20:43 GMT
_Version update only_
## 7.17.2
Sat, 23 Apr 2022 02:13:07 GMT
_Version update only_
## 7.17.1
Fri, 15 Apr 2022 00:12:36 GMT
_Version update only_
## 7.17.0
Wed, 13 Apr 2022 15:12:40 GMT
### Minor changes
- Add a new isOptional property to TypeParameters deserialized from the .api.json file with api-extractor-model.
## 7.16.2
Tue, 12 Apr 2022 02:58:32 GMT
### Patches
- Update TSDoc dependencies.
## 7.16.1
Sat, 09 Apr 2022 02:24:26 GMT
### Patches
- Rename the "master" branch to "main".
- Update a path in the README.
## 7.16.0
Thu, 31 Mar 2022 02:06:05 GMT
### Minor changes
- Updated api-extractor-model to store whether a parameter is optional.
## 7.15.4
Tue, 15 Mar 2022 19:15:53 GMT
_Version update only_
## 7.15.3
Wed, 05 Jan 2022 16:07:47 GMT
_Version update only_
## 7.15.2
Mon, 27 Dec 2021 16:10:40 GMT
_Version update only_
## 7.15.1
Thu, 09 Dec 2021 20:34:41 GMT
_Version update only_
## 7.15.0
Thu, 09 Dec 2021 00:21:54 GMT
### Minor changes
- Replace const enums with conventional enums to allow for compatibility with JavaScript consumers.
## 7.14.0
Wed, 08 Dec 2021 16:14:05 GMT
### Minor changes
- Update to TypeScript 4.5
## 7.13.18
Mon, 06 Dec 2021 16:08:33 GMT
_Version update only_
## 7.13.17
Fri, 03 Dec 2021 03:05:22 GMT
_Version update only_
## 7.13.16
Sat, 06 Nov 2021 00:09:13 GMT
_Version update only_
## 7.13.15
Fri, 05 Nov 2021 15:09:18 GMT
_Version update only_
## 7.13.14
Wed, 27 Oct 2021 00:08:15 GMT
### Patches
- Update the package.json repository field to include the directory property.
## 7.13.13
Wed, 13 Oct 2021 15:09:54 GMT
_Version update only_
## 7.13.12
Fri, 08 Oct 2021 08:08:34 GMT
_Version update only_
## 7.13.11
Thu, 07 Oct 2021 07:13:35 GMT
_Version update only_
## 7.13.10
Tue, 05 Oct 2021 15:08:38 GMT
_Version update only_
## 7.13.9
Fri, 24 Sep 2021 00:09:29 GMT
_Version update only_
## 7.13.8
Thu, 23 Sep 2021 00:10:40 GMT
### Patches
- Upgrade the `@types/node` dependency to version to version 12.
## 7.13.7
Tue, 14 Sep 2021 01:17:04 GMT
_Version update only_
## 7.13.6
Mon, 13 Sep 2021 15:07:06 GMT
_Version update only_
## 7.13.5
Wed, 11 Aug 2021 00:07:21 GMT
_Version update only_
## 7.13.4
Mon, 12 Jul 2021 23:08:26 GMT
_Version update only_
## 7.13.3
Fri, 04 Jun 2021 19:59:53 GMT
_Version update only_
## 7.13.2
Wed, 19 May 2021 00:11:39 GMT
_Version update only_
## 7.13.1
Mon, 03 May 2021 15:10:29 GMT
_Version update only_
## 7.13.0
Tue, 20 Apr 2021 04:59:51 GMT
### Minor changes
- The .api.json file format now stores the TSDoc configuration used for parsing doc comments
## 7.12.5
Mon, 12 Apr 2021 15:10:28 GMT
_Version update only_
## 7.12.4
Thu, 08 Apr 2021 06:05:31 GMT
### Patches
- Fix minor typo in README.md
## 7.12.3
Tue, 06 Apr 2021 15:14:22 GMT
_Version update only_
## 7.12.2
Fri, 05 Feb 2021 16:10:42 GMT
_Version update only_
## 7.12.1
Thu, 10 Dec 2020 23:25:49 GMT
### Patches
- Enable support for @decorator
## 7.12.0
Wed, 18 Nov 2020 08:19:54 GMT
### Minor changes
- Introduce an ApiOptionalMixin base class for representing optional properties and methods
## 7.11.0
Wed, 18 Nov 2020 06:21:57 GMT
### Minor changes
- Update .api.json file format to store a new field "isOptional" for documenting optional properties
## 7.10.10
Wed, 11 Nov 2020 01:08:59 GMT
_Version update only_
## 7.10.9
Tue, 10 Nov 2020 23:13:12 GMT
_Version update only_
## 7.10.8
Fri, 30 Oct 2020 06:38:39 GMT
_Version update only_
## 7.10.7
Fri, 30 Oct 2020 00:10:14 GMT
_Version update only_
## 7.10.6
Thu, 29 Oct 2020 06:14:19 GMT
### Patches
- Fix .d.ts error when the library is imported by a project using TypeScript 4.0
## 7.10.5
Wed, 28 Oct 2020 01:18:03 GMT
_Version update only_
## 7.10.4
Tue, 27 Oct 2020 15:10:14 GMT
_Version update only_
## 7.10.3
Tue, 06 Oct 2020 00:24:06 GMT
_Version update only_
## 7.10.2
Mon, 05 Oct 2020 22:36:57 GMT
_Version update only_
## 7.10.1
Wed, 30 Sep 2020 18:39:17 GMT
### Patches
- Update to build with @rushstack/heft-node-rig
## 7.10.0
Wed, 30 Sep 2020 06:53:53 GMT
### Minor changes
- Upgrade compiler; the API now requires TypeScript 3.9 or newer
### Patches
- Update README.md
## 7.9.7
Tue, 22 Sep 2020 05:45:57 GMT
_Version update only_
## 7.9.6
Tue, 22 Sep 2020 01:45:31 GMT
_Version update only_
## 7.9.5
Tue, 22 Sep 2020 00:08:53 GMT
_Version update only_
## 7.9.4
Sat, 19 Sep 2020 04:37:27 GMT
_Version update only_
## 7.9.3
Sat, 19 Sep 2020 03:33:07 GMT
_Version update only_
## 7.9.2
Fri, 18 Sep 2020 22:57:24 GMT
_Version update only_
## 7.9.1
Fri, 18 Sep 2020 21:49:54 GMT
_Version update only_
## 7.9.0
Sun, 13 Sep 2020 01:53:20 GMT
### Minor changes
- Add support for system selectors in declaration references
## 7.8.22
Fri, 11 Sep 2020 02:13:35 GMT
_Version update only_
## 7.8.21
Mon, 07 Sep 2020 07:37:37 GMT
_Version update only_
## 7.8.20
Sat, 05 Sep 2020 18:56:34 GMT
### Patches
- Fix "Converting circular structure to JSON" error (GitHub #2152)
## 7.8.19
Thu, 27 Aug 2020 11:27:06 GMT
_Version update only_
## 7.8.18
Mon, 24 Aug 2020 07:35:20 GMT
_Version update only_
## 7.8.17
Sat, 22 Aug 2020 05:55:43 GMT
_Version update only_
## 7.8.16
Tue, 18 Aug 2020 23:59:42 GMT
_Version update only_
## 7.8.15
Mon, 17 Aug 2020 04:53:23 GMT
_Version update only_
## 7.8.14
Wed, 12 Aug 2020 00:10:05 GMT
### Patches
- Updated project to build with Heft
## 7.8.13
Wed, 05 Aug 2020 18:27:33 GMT
_Version update only_
## 7.8.12
Fri, 03 Jul 2020 15:09:04 GMT
_Version update only_
## 7.8.11
Thu, 25 Jun 2020 06:43:35 GMT
_Version update only_
## 7.8.10
Wed, 24 Jun 2020 09:50:48 GMT
_Version update only_
## 7.8.9
Wed, 24 Jun 2020 09:04:28 GMT
_Version update only_
## 7.8.8
Wed, 10 Jun 2020 20:48:30 GMT
_Version update only_
## 7.8.7
Sat, 30 May 2020 02:59:54 GMT
_Version update only_
## 7.8.6
Thu, 28 May 2020 05:59:02 GMT
_Version update only_
## 7.8.5
Wed, 27 May 2020 05:15:11 GMT
_Version update only_
## 7.8.4
Tue, 26 May 2020 23:00:25 GMT
_Version update only_
## 7.8.3
Fri, 22 May 2020 15:08:43 GMT
_Version update only_
## 7.8.2
Thu, 21 May 2020 23:09:44 GMT
_Version update only_
## 7.8.1
Thu, 21 May 2020 15:42:00 GMT
_Version update only_
## 7.8.0
Wed, 06 May 2020 08:23:45 GMT
### Minor changes
- Enable canonicalReference to ApiItem lookup
## 7.7.11
Wed, 08 Apr 2020 04:07:33 GMT
_Version update only_
## 7.7.10
Sat, 28 Mar 2020 00:37:16 GMT
### Patches
- Upgrade to TSdoc 0.12.19
## 7.7.9
Wed, 18 Mar 2020 15:07:47 GMT
### Patches
- Upgrade cyclic dependencies
## 7.7.8
Tue, 17 Mar 2020 23:55:58 GMT
### Patches
- Replace dependencies whose NPM scope was renamed from `@microsoft` to `@rushstack`
## 7.7.7
Tue, 28 Jan 2020 02:23:44 GMT
_Version update only_
## 7.7.6
Thu, 23 Jan 2020 01:07:56 GMT
_Version update only_
## 7.7.5
Tue, 21 Jan 2020 21:56:14 GMT
_Version update only_
## 7.7.4
Sun, 19 Jan 2020 02:26:52 GMT
### Patches
- Upgrade Node typings to Node 10
## 7.7.3
Fri, 17 Jan 2020 01:08:23 GMT
_Version update only_
## 7.7.2
Thu, 09 Jan 2020 06:44:13 GMT
_Version update only_
## 7.7.1
Wed, 08 Jan 2020 00:11:31 GMT
_Version update only_
## 7.7.0
Tue, 03 Dec 2019 03:17:43 GMT
### Minor changes
- Improve declaration reference syntax to allow linking to overloaded functions/methods
## 7.6.0
Sun, 24 Nov 2019 00:54:04 GMT
### Minor changes
- Added support for `@throws`
## 7.5.6
Fri, 15 Nov 2019 04:50:50 GMT
_Version update only_
## 7.5.5
Mon, 11 Nov 2019 16:07:56 GMT
_Version update only_
## 7.5.4
Tue, 05 Nov 2019 06:49:28 GMT
### Patches
- Fix an issue where API reports sometimes were ordered differently depending on the version of NodeJS (GitHub #1552)
## 7.5.3
Tue, 05 Nov 2019 01:08:39 GMT
### Patches
- Clarified an error message
## 7.5.2
Tue, 22 Oct 2019 06:24:44 GMT
### Patches
- Refactor some code as part of migration from TSLint to ESLint
## 7.5.1
Sun, 29 Sep 2019 23:56:29 GMT
### Patches
- Update repository URL
## 7.5.0
Wed, 25 Sep 2019 15:15:31 GMT
### Minor changes
- Add ApiItem.getMergedSiblings() API
## 7.4.2
Mon, 23 Sep 2019 15:14:55 GMT
### Patches
- Remove unnecessary dependency on @types/node
## 7.4.1
Tue, 10 Sep 2019 22:32:23 GMT
### Patches
- Update documentation
## 7.4.0
Tue, 10 Sep 2019 20:38:33 GMT
### Minor changes
- Add 'canonicalReference' to ExcerptToken
## 7.3.4
Wed, 04 Sep 2019 18:28:06 GMT
_Version update only_
## 7.3.3
Wed, 04 Sep 2019 15:15:37 GMT
### Patches
- Update TSDoc dependency to 0.12.14
## 7.3.2
Thu, 08 Aug 2019 15:14:17 GMT
_Version update only_
## 7.3.1
Thu, 08 Aug 2019 00:49:05 GMT
### Patches
- (Experimental) Add ApiExtractor.canonicalReference which is a beta implementation of the revised TSDoc declaration reference notation
## 7.3.0
Mon, 22 Jul 2019 19:13:10 GMT
### Minor changes
- Rename `ApiItem.canonicalReference` to `.containerKey`; rename `ApiItemContainerMixin.tryGetMember()` to `.tryGetMemberByKey()`; rename `Api___.getCanonicalReference()` to `.getContainerKey()`
## 7.2.0
Tue, 11 Jun 2019 00:48:06 GMT
### Minor changes
- Add API support for type parameters and type alias types
### Patches
- Improve the .api.json deserializer to validate the schema version and support backwards compatibility
## 7.1.3
Wed, 05 Jun 2019 19:12:34 GMT
### Patches
- Fix an issue where TSDoc index selectors (ApiParameterListMixin.overloadIndex) started from 0, whereas TSDoc requires a nonzero number
## 7.1.2
Tue, 04 Jun 2019 05:51:53 GMT
### Patches
- Fix an issue where ApiConstructor inherited from ApiStaticMixin, but TypeScript constructors cannot be static
## 7.1.1
Mon, 27 May 2019 04:13:44 GMT
### Patches
- Make the strings returned by ApiItem.displayName less verbose
- Improve formatting of the strings returned by ApiItem.getScopedNameWithinPackage()
## 7.1.0
Tue, 16 Apr 2019 11:01:37 GMT
### Minor changes
- Initial stable release of API Extractor 7
## 7.0.28
Wed, 20 Mar 2019 19:14:49 GMT
_Version update only_
## 7.0.27
Mon, 18 Mar 2019 04:28:43 GMT
### Patches
- Add helper functions for ReleaseTag
- Export IApiItemConstructor to eliminate the ae-forgotten-export warning
## 7.0.26
Wed, 13 Mar 2019 19:13:14 GMT
### Patches
- Refactor code to move the IndentedWriter API from api-extractor-model to api-documenter
## 7.0.25
Wed, 13 Mar 2019 01:14:05 GMT
### Patches
- Upgrade TSDoc
## 7.0.24
Mon, 11 Mar 2019 16:13:36 GMT
### Patches
- Initial setup of new package @microsoft/api-extractor-model

View File

@@ -1,24 +0,0 @@
@microsoft/api-extractor
Copyright (c) Microsoft Corporation. All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,67 +0,0 @@
# @discordjs/api-extractor-model
Use this library to read and write \*.api.json files as defined by the [API Extractor](https://api-extractor.com/) tool.
These files are used to generate a documentation website for your TypeScript package. The files store the
API signatures and doc comments that were extracted from your package.
API documentation for this package: https://rushstack.io/pages/api/api-extractor-model/
## Example Usage
The following code sample shows how to load `example.api.json`, which would be generated by API Extractor
when it analyzes a hypothetical NPM package called `example`:
```ts
import { ApiModel, ApiPackage } from '@discordjs/api-extractor-model';
const apiModel: ApiModel = new ApiModel();
const apiPackage: ApiPackage = apiModel.loadPackage('example.api.json');
for (const member of apiPackage.members) {
console.log(member.displayName);
}
```
The `ApiModel` is acts as a container for various packages that are loaded and operated on as a group.
For example, a documentation tool may need to resolve `@link` references across different packages.
In this case we would load the various packages into the `ApiModel`, and then use
the `ApiModel.resolveDeclarationReference()` to resolve the `@link` targets.
The data structure forms a tree of various classes that start with the `Api` prefix. The nesting hierarchy
might look like this:
```
- ApiModel
- ApiPackage
- ApiEntryPoint
- ApiClass
- ApiMethod
- ApiProperty
- ApiEnum
- ApiEnumMember
- ApiInterface
- ApiMethodSignature
- ApiPropertySignature
- ApiNamespace
- (ApiClass, ApiEnum, ApiInterface, ...)
```
You can use the `ApiItem.members` property to traverse this tree.
Note that the non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use
TypeScript "mixin" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various
features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class
to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components:
the function that generates a subclass, an interface that describes the members of the subclass, and
a namespace containing static members of the class.
> For a complete project that uses these APIs to generate an API reference web site,
> see the [@microsoft/api-documenter](https://www.npmjs.com/package/@microsoft/api-documenter) source code.
## Links
- [CHANGELOG.md](https://github.com/discordjs/discord.js/blob/main/packages/api-extractor-model/CHANGELOG.md) - Find
out what's new in the latest version
- [API Reference](https://rushstack.io/pages/api/api-extractor-model/)
API Extractor is part of the [Rush Stack](https://rushstack.io/) family of projects.

View File

@@ -1,20 +0,0 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts",
"apiReport": {
"enabled": true,
"reportFolder": "../../../common/reviews/api"
},
"docModel": {
"enabled": true,
"apiJsonFilePath": "../../../common/temp/api/<unscopedPackageName>.api.json"
},
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "<projectFolder>/dist/rollup.d.ts"
}
}

View File

@@ -1,11 +0,0 @@
{
"extends": "@rushstack/heft-node-rig/profiles/default/config/jest.config.json",
// Enable code coverage for Jest
"collectCoverage": true,
"coverageDirectory": "<rootDir>/coverage",
"coverageReporters": ["cobertura", "html"],
// Use v8 coverage provider to avoid Babel
"coverageProvider": "v8"
}

View File

@@ -1,51 +0,0 @@
{
"name": "@discordjs/api-extractor-model",
"version": "7.28.2",
"description": "A helper library for loading and saving the .api.json files created by API Extractor",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/discordjs/discord.js.git",
"directory": "packages/api-extractor-model"
},
"homepage": "https://discord.js.org",
"funding": "https://github.com/discordjs/discord.js?sponsor",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "tsc --noEmit && tsup",
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src"
},
"exports": {
".": {
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
}
}
},
"dependencies": {
"@microsoft/tsdoc": "0.14.2",
"@microsoft/tsdoc-config": "0.16.2",
"@rushstack/node-core-library": "4.1.0"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/node": "^18.19.130",
"cross-env": "^7.0.3",
"eslint": "^8.57.1",
"eslint-config-neon": "^0.1.62",
"eslint-formatter-pretty": "^6.0.1",
"jest": "^29.7.0",
"prettier": "^3.8.1",
"tsup": "^8.5.1",
"turbo": "^2.8.10",
"typescript": "~5.8.3"
}
}

View File

@@ -1,68 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import { TSDocConfiguration, TSDocTagDefinition, TSDocTagSyntaxKind, StandardTags } from '@microsoft/tsdoc';
/**
* @internal
* @deprecated - tsdoc configuration is now constructed from tsdoc.json files associated with each package.
*/
export class AedocDefinitions {
public static readonly betaDocumentation: TSDocTagDefinition = new TSDocTagDefinition({
tagName: '@betaDocumentation',
syntaxKind: TSDocTagSyntaxKind.ModifierTag,
});
public static readonly internalRemarks: TSDocTagDefinition = new TSDocTagDefinition({
tagName: '@internalRemarks',
syntaxKind: TSDocTagSyntaxKind.BlockTag,
});
public static readonly preapprovedTag: TSDocTagDefinition = new TSDocTagDefinition({
tagName: '@preapproved',
syntaxKind: TSDocTagSyntaxKind.ModifierTag,
});
public static get tsdocConfiguration(): TSDocConfiguration {
if (!AedocDefinitions._tsdocConfiguration) {
const configuration: TSDocConfiguration = new TSDocConfiguration();
configuration.addTagDefinitions(
[AedocDefinitions.betaDocumentation, AedocDefinitions.internalRemarks, AedocDefinitions.preapprovedTag],
true,
);
configuration.setSupportForTags(
[
StandardTags.alpha,
StandardTags.beta,
StandardTags.decorator,
StandardTags.defaultValue,
StandardTags.deprecated,
StandardTags.eventProperty,
StandardTags.example,
StandardTags.inheritDoc,
StandardTags.internal,
StandardTags.link,
StandardTags.override,
StandardTags.packageDocumentation,
StandardTags.param,
StandardTags.privateRemarks,
StandardTags.public,
StandardTags.readonly,
StandardTags.remarks,
StandardTags.returns,
StandardTags.sealed,
StandardTags.throws,
StandardTags.virtual,
],
true,
);
AedocDefinitions._tsdocConfiguration = configuration;
}
return AedocDefinitions._tsdocConfiguration;
}
private static _tsdocConfiguration: TSDocConfiguration | undefined;
}

View File

@@ -1,88 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
/**
* A "release tag" is a custom TSDoc tag that is applied to an API to communicate the level of support
* provided for third-party developers.
*
* @remarks
*
* The four release tags are: `@internal`, `@alpha`, `@beta`, and `@public`. They are applied to API items such
* as classes, member functions, enums, etc. The release tag applies recursively to members of a container
* (e.g. class or interface). For example, if a class is marked as `@beta`, then all of its members automatically
* have this status; you DON'T need add the `@beta` tag to each member function. However, you could add
* `@internal` to a member function to give it a different release status.
* @public
*/
export enum ReleaseTag {
/**
* No release tag was specified in the AEDoc summary.
*/
None = 0,
/**
* Indicates that an API item is meant only for usage by other NPM packages from the same
* maintainer. Third parties should never use "internal" APIs. (To emphasize this, their
* names are prefixed by underscores.)
*/
Internal = 1,
/**
* Indicates that an API item is eventually intended to be public, but currently is in an
* early stage of development. Third parties should not use "alpha" APIs.
*/
Alpha = 2,
/**
* Indicates that an API item has been released in an experimental state. Third parties are
* encouraged to try it and provide feedback. However, a "beta" API should NOT be used
* in production.
*/
Beta = 3,
/**
* Indicates that an API item has been officially released. It is part of the supported
* contract (e.g. SemVer) for a package.
*/
Public = 4,
}
/**
* Helper functions for working with the `ReleaseTag` enum.
*
* @public
*/
// export namespace ReleaseTag {
/**
* Returns the TSDoc tag name for a `ReleaseTag` value.
*
* @remarks
* For example, `getTagName(ReleaseTag.Internal)` would return the string `@internal`.
*/
export function getTagName(releaseTag: ReleaseTag): string {
switch (releaseTag) {
case ReleaseTag.None:
return '(none)';
case ReleaseTag.Internal:
return '@internal';
case ReleaseTag.Alpha:
return '@alpha';
case ReleaseTag.Beta:
return '@beta';
case ReleaseTag.Public:
return '@public';
default:
throw new Error('Unsupported release tag');
}
}
/**
* Compares two `ReleaseTag` values. Their values must not be `ReleaseTag.None`.
*
* @returns 0 if `a` and `b` are equal, a positive number if `a` is more public than `b`,
* and a negative number if `a` is less public than `b`.
* @remarks
* For example, `compareReleaseTag(ReleaseTag.Beta, ReleaseTag.Alpha)` will return a positive
* number because beta is more public than alpha.
*/
export function compare(a: ReleaseTag, b: ReleaseTag): number {
return a - b;
}
// }

View File

@@ -1,85 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
/**
* Use this library to read and write *.api.json files as defined by the
* {@link https://api-extractor.com/ | API Extractor} tool. These files are used to generate a documentation
* website for your TypeScript package. The files store the API signatures and doc comments that were extracted
* from your package.
*
* @packageDocumentation
*/
export { AedocDefinitions } from './aedoc/AedocDefinitions.js';
export { ReleaseTag, compare as releaseTagCompare, getTagName as releaseTagGetTagName } from './aedoc/ReleaseTag.js';
// items
export { type IApiDeclaredItemOptions, ApiDeclaredItem } from './items/ApiDeclaredItem.js';
export { type IApiDocumentedItemOptions, ApiDocumentedItem } from './items/ApiDocumentedItem.js';
export { ApiItemKind, type IApiItemOptions, ApiItem, type IApiItemConstructor } from './items/ApiItem.js';
export { type IApiPropertyItemOptions, ApiPropertyItem } from './items/ApiPropertyItem.js';
// mixins
export {
type IApiParameterListMixinOptions,
type IApiParameterOptions,
ApiParameterListMixin,
} from './mixins/ApiParameterListMixin.js';
export {
type IApiTypeParameterOptions,
type IApiTypeParameterListMixinOptions,
ApiTypeParameterListMixin,
} from './mixins/ApiTypeParameterListMixin.js';
export { type IApiAbstractMixinOptions, ApiAbstractMixin } from './mixins/ApiAbstractMixin.js';
export { type IApiItemContainerMixinOptions, ApiItemContainerMixin } from './mixins/ApiItemContainerMixin.js';
export { type IApiProtectedMixinOptions, ApiProtectedMixin } from './mixins/ApiProtectedMixin.js';
export { type IApiReleaseTagMixinOptions, ApiReleaseTagMixin } from './mixins/ApiReleaseTagMixin.js';
export { type IApiReturnTypeMixinOptions, ApiReturnTypeMixin } from './mixins/ApiReturnTypeMixin.js';
export { type IApiStaticMixinOptions, ApiStaticMixin } from './mixins/ApiStaticMixin.js';
export { type IApiNameMixinOptions, ApiNameMixin } from './mixins/ApiNameMixin.js';
export { type IApiOptionalMixinOptions, ApiOptionalMixin } from './mixins/ApiOptionalMixin.js';
export { type IApiReadonlyMixinOptions, ApiReadonlyMixin } from './mixins/ApiReadonlyMixin.js';
export { type IApiInitializerMixinOptions, ApiInitializerMixin } from './mixins/ApiInitializerMixin.js';
export { type IApiExportedMixinOptions, ApiExportedMixin } from './mixins/ApiExportedMixin.js';
export {
type IFindApiItemsResult,
type IFindApiItemsMessage,
FindApiItemsMessageId,
} from './mixins/IFindApiItemsResult.js';
export {
ExcerptTokenKind,
type IExcerptTokenRange,
type IExcerptToken,
ExcerptToken,
Excerpt,
} from './mixins/Excerpt.js';
export type { Constructor, PropertiesOf } from './mixins/Mixin.js';
// model
export { type IApiCallSignatureOptions, ApiCallSignature } from './model/ApiCallSignature.js';
export { type IApiClassOptions, ApiClass, type IExcerptTokenRangeWithTypeParameters } from './model/ApiClass.js';
export { type IApiConstructorOptions, ApiConstructor } from './model/ApiConstructor.js';
export { type IApiConstructSignatureOptions, ApiConstructSignature } from './model/ApiConstructSignature.js';
export { type IApiEntryPointOptions, ApiEntryPoint } from './model/ApiEntryPoint.js';
export { type IApiEnumOptions, ApiEnum } from './model/ApiEnum.js';
export { type IApiEnumMemberOptions, ApiEnumMember, EnumMemberOrder } from './model/ApiEnumMember.js';
export { type IApiEventOptions, ApiEvent } from './model/ApiEvent.js';
export { type IApiFunctionOptions, ApiFunction } from './model/ApiFunction.js';
export { type IApiIndexSignatureOptions, ApiIndexSignature } from './model/ApiIndexSignature.js';
export { type IApiInterfaceOptions, ApiInterface } from './model/ApiInterface.js';
export { type IApiMethodOptions, ApiMethod } from './model/ApiMethod.js';
export { type IApiMethodSignatureOptions, ApiMethodSignature } from './model/ApiMethodSignature.js';
export { ApiModel } from './model/ApiModel.js';
export { type IApiNamespaceOptions, ApiNamespace } from './model/ApiNamespace.js';
export { type IApiPackageOptions, ApiPackage, type IApiPackageSaveOptions } from './model/ApiPackage.js';
export { type IParameterOptions, Parameter } from './model/Parameter.js';
export { type IApiPropertyOptions, ApiProperty } from './model/ApiProperty.js';
export { type IApiPropertySignatureOptions, ApiPropertySignature } from './model/ApiPropertySignature.js';
export { type IApiTypeAliasOptions, ApiTypeAlias } from './model/ApiTypeAlias.js';
export { type ITypeParameterOptions, TypeParameter } from './model/TypeParameter.js';
export { type IApiVariableOptions, ApiVariable } from './model/ApiVariable.js';
export type { IResolveDeclarationReferenceResult } from './model/ModelReferenceResolver.js';
export { HeritageType } from './model/HeritageType.js';
export { type ISourceLocationOptions, SourceLocation } from './model/SourceLocation.js';
export { Navigation, Meaning } from './items/ApiItem.js';

View File

@@ -1,225 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference.js';
import { Excerpt, ExcerptToken, type IExcerptTokenRange, type IExcerptToken } from '../mixins/Excerpt.js';
import type { DeserializerContext } from '../model/DeserializerContext.js';
import { SourceLocation } from '../model/SourceLocation.js';
import { ApiDocumentedItem, type IApiDocumentedItemJson, type IApiDocumentedItemOptions } from './ApiDocumentedItem.js';
import type { ApiItem } from './ApiItem.js';
/**
* Constructor options for {@link ApiDeclaredItem}.
*
* @public
*/
export interface IApiDeclaredItemOptions extends IApiDocumentedItemOptions {
excerptTokens: IExcerptToken[];
fileColumn?: number | undefined;
fileLine?: number | undefined;
fileUrlPath?: string | undefined;
}
export interface IApiDeclaredItemJson extends IApiDocumentedItemJson {
excerptTokens: IExcerptToken[];
fileColumn?: number;
fileLine?: number;
fileUrlPath?: string | undefined;
}
/**
* The base class for API items that have an associated source code excerpt containing a TypeScript declaration.
*
* @remarks
*
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
* API declarations.
*
* Most `ApiItem` subclasses have declarations and thus extend `ApiDeclaredItem`. Counterexamples include
* `ApiModel` and `ApiPackage`, which do not have any corresponding TypeScript source code.
* @public
*/
export class ApiDeclaredItem extends ApiDocumentedItem {
private readonly _excerptTokens: ExcerptToken[];
private readonly _excerpt: Excerpt;
private readonly _fileUrlPath?: string | undefined;
private readonly _fileLine?: number | undefined;
private readonly _fileColumn?: number | undefined;
private _sourceLocation?: SourceLocation;
public constructor(options: IApiDeclaredItemOptions) {
super(options);
this._excerptTokens = options.excerptTokens.map((token) => {
const canonicalReference: DeclarationReference | undefined =
token.canonicalReference === undefined ? undefined : DeclarationReference.parse(token.canonicalReference);
return new ExcerptToken(token.kind, token.text, canonicalReference);
});
this._excerpt = new Excerpt(this.excerptTokens, { startIndex: 0, endIndex: this.excerptTokens.length });
this._fileUrlPath = options.fileUrlPath;
this._fileLine = options.fileLine;
this._fileColumn = options.fileColumn;
}
/**
* @override
*/
public static override onDeserializeInto(
options: Partial<IApiDeclaredItemOptions>,
context: DeserializerContext,
jsonObject: IApiDeclaredItemJson,
): void {
super.onDeserializeInto(options, context, jsonObject);
options.excerptTokens = jsonObject.excerptTokens;
options.fileUrlPath = jsonObject.fileUrlPath;
options.fileLine = jsonObject.fileLine;
options.fileColumn = jsonObject.fileColumn;
}
/**
* The source code excerpt where the API item is declared.
*/
public get excerpt(): Excerpt {
return this._excerpt;
}
/**
* The individual source code tokens that comprise the main excerpt.
*/
public get excerptTokens(): readonly ExcerptToken[] {
return this._excerptTokens;
}
/**
* The file URL path relative to the `projectFolder` and `projectFolderURL` fields
* as defined in the `api-extractor.json` config. Is `undefined` if the path is
* the same as the parent API item's.
*/
public get fileUrlPath(): string | undefined {
return this._fileUrlPath;
}
/**
* The line in the `fileUrlPath` where the API item is declared.
*/
public get fileLine(): number | undefined {
return this._fileLine;
}
/**
* The column in the `fileUrlPath` where the API item is declared.
*/
public get fileColumn(): number | undefined {
return this._fileColumn;
}
/**
* Returns the source location where the API item is declared.
*/
public get sourceLocation(): SourceLocation {
if (!this._sourceLocation) {
this._sourceLocation = this._buildSourceLocation();
}
return this._sourceLocation;
}
/**
* If the API item has certain important modifier tags such as `@sealed`, `@virtual`, or `@override`,
* this prepends them as a doc comment above the excerpt.
*/
public getExcerptWithModifiers(): string {
const excerpt: string = this.excerpt.text;
const modifierTags: string[] = [];
if (excerpt.length > 0 && this instanceof ApiDocumentedItem) {
if (this.tsdocComment) {
if (this.tsdocComment.modifierTagSet.isSealed()) {
modifierTags.push('@sealed');
}
if (this.tsdocComment.modifierTagSet.isVirtual()) {
modifierTags.push('@virtual');
}
if (this.tsdocComment.modifierTagSet.isOverride()) {
modifierTags.push('@override');
}
}
if (modifierTags.length > 0) {
return '/** ' + modifierTags.join(' ') + ' */\n' + excerpt;
}
}
return excerpt;
}
/**
* @override
*/
public override serializeInto(jsonObject: Partial<IApiDeclaredItemJson>): void {
super.serializeInto(jsonObject);
jsonObject.excerptTokens = this.excerptTokens.map((x) => {
const excerptToken: IExcerptToken = { kind: x.kind, text: x.text };
if (x.canonicalReference !== undefined) {
excerptToken.canonicalReference = x.canonicalReference.toString();
}
return excerptToken;
});
// Only serialize this API item's file URL path if it exists and it's different from its parent's
// (a little optimization to keep the doc model succinct).
if (
this.fileUrlPath &&
(!(this.parent instanceof ApiDeclaredItem) || this.fileUrlPath !== this.parent.fileUrlPath)
) {
jsonObject.fileUrlPath = this.fileUrlPath;
}
if (this.fileLine) {
jsonObject.fileLine = this.fileLine;
}
if (this.fileColumn) {
jsonObject.fileColumn = this.fileColumn;
}
}
/**
* Constructs a new {@link Excerpt} corresponding to the provided token range.
*/
public buildExcerpt(tokenRange: IExcerptTokenRange): Excerpt {
return new Excerpt(this.excerptTokens, tokenRange);
}
/**
* Builds the cached object used by the `sourceLocation` property.
*/
private _buildSourceLocation(): SourceLocation {
const projectFolderUrl: string | undefined = this.getAssociatedPackage()?.projectFolderUrl;
let fileUrlPath: string | undefined;
for (let current: ApiItem | undefined = this; current !== undefined; current = current.parent) {
if (current instanceof ApiDeclaredItem && current.fileUrlPath) {
fileUrlPath = current.fileUrlPath;
break;
}
}
return new SourceLocation({
projectFolderUrl,
fileUrlPath,
sourceFileColumn: this.fileColumn,
sourceFileLine: this.fileLine,
});
}
}

View File

@@ -1,78 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import * as tsdoc from '@microsoft/tsdoc';
import type { DeserializerContext } from '../model/DeserializerContext.js';
import { ApiItem, type IApiItemOptions, type IApiItemJson } from './ApiItem.js';
/**
* Constructor options for {@link ApiDocumentedItem}.
*
* @public
*/
export interface IApiDocumentedItemOptions extends IApiItemOptions {
docComment: tsdoc.DocComment | undefined;
}
export interface IApiDocumentedItemJson extends IApiItemJson {
docComment: string;
}
/**
* An abstract base class for API declarations that can have an associated TSDoc comment.
*
* @remarks
*
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
* API declarations.
* @public
*/
export class ApiDocumentedItem extends ApiItem {
private readonly _tsdocComment: tsdoc.DocComment | undefined;
public constructor(options: IApiDocumentedItemOptions) {
super(options);
this._tsdocComment = options.docComment;
}
/**
* @override
*/
public static override onDeserializeInto(
options: Partial<IApiDocumentedItemOptions>,
context: DeserializerContext,
jsonObject: IApiItemJson,
): void {
super.onDeserializeInto(options, context, jsonObject);
const documentedJson: IApiDocumentedItemJson = jsonObject as IApiDocumentedItemJson;
if (documentedJson.docComment) {
const tsdocParser: tsdoc.TSDocParser = new tsdoc.TSDocParser(context.tsdocConfiguration);
// NOTE: For now, we ignore TSDoc errors found in a serialized .api.json file.
// Normally these errors would have already been reported by API Extractor during analysis.
// However, they could also arise if the JSON file was edited manually, or if the file was saved
// using a different release of the software that used an incompatible syntax.
const parserContext: tsdoc.ParserContext = tsdocParser.parseString(documentedJson.docComment);
options.docComment = parserContext.docComment;
}
}
public get tsdocComment(): tsdoc.DocComment | undefined {
return this._tsdocComment;
}
/**
* @override
*/
public override serializeInto(jsonObject: Partial<IApiDocumentedItemJson>): void {
super.serializeInto(jsonObject);
if (this.tsdocComment === undefined) {
jsonObject.docComment = '';
} else {
jsonObject.docComment = this.tsdocComment.emitAsTsdoc();
}
}
}

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