Compare commits

..

36 Commits

Author SHA1 Message Date
github-actions[bot]
6340f64fbc chore(release): 0.33.2 🎉 (#465)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2022-06-02 02:41:01 +03:00
Vlad Frangu
895083b8ab chore(Changelog): show who created the pull request that was merged (#329)
* feat: say who submitted the PR that was merged

* fix: actually make the changelog generation work

* chore: cleanup

* chore: safety

* fix: fetch PRs in a better way, and replace usernames with diff casings correctly

* fix: only fetch PRs if GITHUB_TOKEN is in the env

* fix: add github token to branch creation

* fix: actually patch the module on install

* chore: cleanup some more of the PR

* chore: make the script more agnostic

* chore: cleanup package-lock

* chore: use split instead for more readable code
2022-06-02 02:33:55 +03:00
Vlad Frangu
93eb3d3af6 chore(docs): write contributing guide (#464) 2022-06-02 02:14:48 +03:00
Vlad Frangu
7da033bc5b chore(docs): cleanup patches, update typedoc (#462) 2022-05-31 16:35:50 +03:00
Suneet Tipirneni
6a813be833 fix(RestPostAPIBaseApplicationJSONBody): make default_member_permissions optional (#460) 2022-05-31 02:25:01 +03:00
Vlad Frangu
b3736d8012 chore(docs): minify api-typedoc generated json (#461) 2022-05-31 02:16:29 +03:00
Suneet Tipirneni
15fcd1b2a8 fix(GatewayGuildCreateDispatch): add extra fields that were missing (#458) 2022-05-30 09:33:15 +03:00
Suneet Tipirneni
51e664d8e8 fix(docs-site): website link colors (#457) 2022-05-30 02:18:39 +03:00
Suneet Tipirneni
db99388267 chore: make navbar consistent with djs site (#452)
Co-authored-by: advaith <advaithj1@gmail.com>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2022-05-27 13:46:45 +03:00
Almeida
85802f1703 fix(APIApplicationCommand): dm_permission is not nullable and default_member_permissions is required (#454) 2022-05-27 12:36:34 +02:00
github-actions[bot]
4083a32340 chore(release): 0.33.1 🎉 (#451)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-05-26 14:26:26 +02:00
Vlad Frangu
5108d3dcca chore: some requested/suggested changes (#450) 2022-05-26 05:21:57 +02:00
Superchupu
6da0503a9f chore: use correct npm capitalization (#449) 2022-05-25 22:11:58 +03:00
Vitor
8a5fb2cdf2 docs: clarify that permissions can apply on application-level (#448) 2022-05-25 20:21:45 +03:00
Almeida
5ef49f41ce feat(RESTJSONErrorCodes): add error 50600 (#444) 2022-05-25 20:08:30 +03:00
Vlad Frangu
6d85ad6b1d fix(RESTPostAPIApplicationGuildCommands): correct types due to unions (#447) 2022-05-25 12:43:09 +03:00
Vlad Frangu
ca1110a1ae chore: website fixes (#446) 2022-05-25 09:58:30 +02:00
Suneet Tipirneni
748db34e30 feat(RESTPostAPIGuildChannels): update post body fields (#419)
* chore(guildChannel): update post body fields

* chore: add missing field
2022-05-25 09:22:51 +03:00
Superchupu
dc1c887821 chore: fix docs typo (#445) 2022-05-25 02:13:59 +03:00
dependabot[bot]
a088bb4f77 chore(deps): bump ejs from 3.1.6 to 3.1.8 in /website (#443)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Vlad <kingdgrizzle@gmail.com>
2022-05-25 00:30:42 +03:00
dependabot[bot]
f1cc0ab163 chore(deps): bump ansi-regex from 3.0.0 to 3.0.1 in /website (#442)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-25 00:29:11 +03:00
Vlad Frangu
c8ba0c9319 chore: docs site (#405) 2022-05-25 00:23:55 +03:00
github-actions[bot]
927c738162 chore(release): 0.33.0 🎉 (#439)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-05-16 14:29:43 +02:00
Splatterxl
1afce87fbe feat(rest): add missing guild routes results (#438) 2022-05-14 01:36:46 +03:00
Vitor Lopes
a0ff4f3905 refactor: add support for API v10 (#437) 2022-05-13 16:57:03 +03:00
Vitor Lopes
17f5caa671 refactor: separate GUILD_CREATE fields from APIGuild object (#423)
BREAKING CHANGE: APIGuild now correctly shows just the properties that are obtainable through rest/GUILD_UPDATE, while the extra fields have been moved to GatewayGuildCreateDispatchData to correctly represent the data received
2022-05-13 16:27:00 +03:00
Suneet Tipirneni
d3163ca22e feat: add support for application command permissions v2 (#415) 2022-05-13 02:38:59 +03:00
Vitor Lopes
1737adea1f refactor(GuildFeature): thread archive durations are no longer boost locked (#412)
BREAKING CHANGE: `SevenDayThreadArchive` and `ThreeDayThreadArchive` have been removed as they are no longer valid
2022-05-13 00:43:04 +03:00
Vitor Lopes
8f16f452ac feat(OAuth2Scopes): add new OAuth2 scopes (#435)
* feat(OAuth2Scopes): add new OAuth2 scopes

* docs: scopes require Discord approval
2022-05-11 01:04:45 +03:00
github-actions[bot]
c9c733d1c2 chore(release): 0.32.1 🎉 (#422)
Build ran for d331e0dff3

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-05-05 14:29:00 +02:00
advaith
d331e0dff3 chore(ActivityPlatform): update platform enum and mark it as unstable (#404)
* chore(ActivityPlatform): update platform enum

* chore: descs and @unstable
2022-04-30 00:20:00 +03:00
Vitor Lopes
a28c824f82 feat(RESTPostAPIGuildForumThreads): add message field (#416)
* refactor(GuildFeature): remove seven & three day thread archive

* refactor(RESTPostAPIGuildForumThreadsJSONBody): add `message` field

* chore: branch issues fix

* fix: unnecessary type & correct `message` type

* fix: use json body instead of form data

* feat: update also form data

* fix: revert order & `message` type
2022-04-29 23:37:22 +03:00
Vitor Lopes
43cfbcba28 feat(RESTJSONErrorCodes): add error 50080 (#408) 2022-04-29 23:30:09 +03:00
github-actions[bot]
b0a4f12391 chore(release): 0.32.0 🎉 (#410)
Build ran for 3fe53ced9f

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-04-25 16:20:00 +02:00
Khafra
3fe53ced9f fix: add position property to create channel options (#409) 2022-04-24 17:10:25 +03:00
Vitor Lopes
1212eb933e refactor(APIGuildIntegration): make enabled optional (#406)
BREAKING CHANGE: `enabled` is now properly marked as optional
2022-04-20 18:50:08 +03:00
181 changed files with 36552 additions and 1029 deletions

2
.github/labeler.yml vendored
View File

@@ -20,6 +20,8 @@ ci:
dependencies:
- package.json
- package-lock.json
- website/package.json
- website/package-lock.json
'topic:deno':
- scripts/deno.mjs

22
.github/problemMatchers/eslint.json vendored Normal file
View File

@@ -0,0 +1,22 @@
{
"problemMatcher": [
{
"owner": "eslint-stylish",
"pattern": [
{
"regexp": "^([^\\s].*)$",
"file": 1
},
{
"regexp": "^\\s+(\\d+):(\\d+)\\s+(error|warning|info)\\s+(.*)\\s\\s+(.*)$",
"line": 1,
"column": 2,
"severity": 3,
"message": 4,
"code": 5,
"loop": true
}
]
}
]
}

17
.github/problemMatchers/tsc.json vendored Normal file
View File

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

View File

@@ -14,15 +14,20 @@ jobs:
- name: Checkout Project
uses: actions/checkout@v2
- name: Add problem matcher
run: echo "::add-matcher::.github/problemMatchers/eslint.json" && echo "::add-matcher::.github/problemMatchers/tsc.json"
- name: Use Node.js v16
uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
- name: Install dependencies
run: npm ci
- name: Run ESLint
- name: Check lint on discord-api-types
run: npm run test:lint
- name: Run TSC

View File

@@ -30,6 +30,9 @@ jobs:
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Install website dependencies
run: pushd website && npm ci --ignore-scripts && popd
- name: Set Git User and Email
run: |
git config user.name "github-actions[bot]"
@@ -44,13 +47,15 @@ jobs:
run: |
git checkout -b "chore/release/$(jq --raw-output '.version' package.json)"
# Run changelog generation and deno scripts
# Run changelog generation, deno script, website version bump
npm run ci:pr
# Add all changes, commit and push
git add --all .
git commit -m "chore(release): $(jq --raw-output '.version' package.json) 🎉" -m "Build ran for ${GITHUB_SHA}"
git push -u origin "chore/release/$(jq --raw-output '.version' package.json)"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Pull Request
run: node ./scripts/actions/create-pr.mjs

View File

@@ -1 +1,13 @@
# Node modules
node_modules/
# Generated data
deno/
# Versioned json
website/versioned_sidebars/
website/versioned_docs/
website/versions.json
website/.docusaurus/
website/build

View File

@@ -1,3 +1,61 @@
## [0.33.2](https://github.com/discordjs/discord-api-types/compare/0.33.1...0.33.2) (2022-06-01)
### Bug Fixes
- **docs-site:** website link colors ([#457](https://github.com/discordjs/discord-api-types/issues/457)) ([51e664d](https://github.com/discordjs/discord-api-types/commit/51e664d8e826e7f0aa467c000f3a1707fc283a36))
- **GatewayGuildCreateDispatch:** add extra fields that were missing ([#458](https://github.com/discordjs/discord-api-types/issues/458)) ([15fcd1b](https://github.com/discordjs/discord-api-types/commit/15fcd1b2a85e8d1e136416a66326a4aadcc301fb))
- **RestPostAPIBaseApplicationJSONBody:** make `default_member_permissions` optional ([#460](https://github.com/discordjs/discord-api-types/issues/460)) ([6a813be](https://github.com/discordjs/discord-api-types/commit/6a813be83382e1606f1921cf00179fe1ce75c04f))
## [0.33.1](https://github.com/discordjs/discord-api-types/compare/0.33.0...0.33.1) (2022-05-26)
### Bug Fixes
- **RESTPostAPIApplicationGuildCommands:** correct types due to unions ([#447](https://github.com/discordjs/discord-api-types/issues/447)) ([6d85ad6](https://github.com/discordjs/discord-api-types/commit/6d85ad6b1d707b980f9897ea68dd4b7573b3a770))
### Features
- **RESTJSONErrorCodes:** add error `50600` ([#444](https://github.com/discordjs/discord-api-types/issues/444)) ([5ef49f4](https://github.com/discordjs/discord-api-types/commit/5ef49f41cecaa1d5937428a5c58f1d88bfc61266))
- **RESTPostAPIGuildChannels:** update post body fields ([#419](https://github.com/discordjs/discord-api-types/issues/419)) ([748db34](https://github.com/discordjs/discord-api-types/commit/748db34e30338cf4a9fd8ce7b86d1d5c7dde63b1))
# [0.33.0](https://github.com/discordjs/discord-api-types/compare/0.32.1...0.33.0) (2022-05-16)
### Code Refactoring
- **GuildFeature:** thread archive durations are no longer boost locked ([#412](https://github.com/discordjs/discord-api-types/issues/412)) ([1737ade](https://github.com/discordjs/discord-api-types/commit/1737adea1fc3d5050db30266e49c63277b7a77fc))
- separate `GUILD_CREATE` fields from `APIGuild` object ([#423](https://github.com/discordjs/discord-api-types/issues/423)) ([17f5caa](https://github.com/discordjs/discord-api-types/commit/17f5caa671da50a79d61393f5a970ce59c5d875e))
### Features
- add support for application command permissions v2 ([#415](https://github.com/discordjs/discord-api-types/issues/415)) ([d3163ca](https://github.com/discordjs/discord-api-types/commit/d3163ca22e5b7d8292f9f6ccd444aa5c93771d92))
- **OAuth2Scopes:** add new OAuth2 scopes ([#435](https://github.com/discordjs/discord-api-types/issues/435)) ([8f16f45](https://github.com/discordjs/discord-api-types/commit/8f16f452ac7dc8988617d1211fc6a9547d254795))
- **rest:** add missing guild routes results ([#438](https://github.com/discordjs/discord-api-types/issues/438)) ([1afce87](https://github.com/discordjs/discord-api-types/commit/1afce87fbef8e43ee040010e36019a4ebc6fecfe))
### BREAKING CHANGES
- APIGuild now correctly shows just the properties that are obtainable through rest/GUILD_UPDATE, while the extra fields have been moved to GatewayGuildCreateDispatchData to correctly represent the data received
- **GuildFeature:** `SevenDayThreadArchive` and `ThreeDayThreadArchive` have been removed as they are no longer valid
## [0.32.1](https://github.com/discordjs/discord-api-types/compare/0.32.0...0.32.1) (2022-05-05)
### Features
- **RESTJSONErrorCodes:** add error `50080` ([#408](https://github.com/discordjs/discord-api-types/issues/408)) ([43cfbcb](https://github.com/discordjs/discord-api-types/commit/43cfbcba284a96de6bde101b866ad9ac306992b5))
- **RESTPostAPIGuildForumThreads:** add `message` field ([#416](https://github.com/discordjs/discord-api-types/issues/416)) ([a28c824](https://github.com/discordjs/discord-api-types/commit/a28c824f82014b15a715b51b4426356428bb4ba2))
# [0.32.0](https://github.com/discordjs/discord-api-types/compare/0.31.2...0.32.0) (2022-04-25)
### Bug Fixes
- add `position` property to create channel options ([#409](https://github.com/discordjs/discord-api-types/issues/409)) ([3fe53ce](https://github.com/discordjs/discord-api-types/commit/3fe53ced9f0e61473a8b92d0503c51084e6a58f3))
### Code Refactoring
- **APIGuildIntegration:** make `enabled` optional ([#406](https://github.com/discordjs/discord-api-types/issues/406)) ([1212eb9](https://github.com/discordjs/discord-api-types/commit/1212eb933e6bf1d82b1b41164030bd317e9c59eb))
### BREAKING CHANGES
- **APIGuildIntegration:** `enabled` is now properly marked as optional
## [0.31.2](https://github.com/discordjs/discord-api-types/compare/0.31.1...0.31.2) (2022-04-18)
### Features

View File

@@ -1,5 +1,7 @@
# Discord API Types
[![discord-api-types](./website/static/svgs/logo_long_blurple.svg)](https://github.com/discordjs/discord-api-types)
[![GitHub](https://img.shields.io/github/license/discordjs/discord-api-types)](https://github.com/discordjs/discord-api-types/blob/main/LICENSE.md)
[![npm](https://img.shields.io/npm/v/discord-api-types?color=crimson&logo=npm)](https://www.npmjs.com/package/discord-api-types)
[![deno](https://img.shields.io/npm/v/discord-api-types?color=blue&label=deno&logo=deno)](https://deno.land/x/discord_api_types)
@@ -43,7 +45,7 @@ const { GatewayVersion } = require('discord-api-types/gateway/v10');
import { GatewayVersion } from 'discord-api-types/gateway/v10';
```
> _**Note:** The `v*` exports (`discord-api-type/v*`) include the appropriate version of `gateway`, `payloads`, `rest`, `rpc`, and `utils` you specified, alongside the `globals` exports_
> _**Note:** The `v*` exports (`discord-api-types/v*`) include the appropriate version of `gateway`, `payloads`, `rest`, `rpc`, and `utils` you specified, alongside the `globals` exports_
### Deno
@@ -94,4 +96,9 @@ The exports of each API version is split into three main parts:
- There may be types exported that are identical for all versions. These will be exported as is and can be found in the `globals` file. They will still be prefixed accordingly as described above.
**Warning**: This package documents just KNOWN (and documented) properties. Anything that isn't documented will NOT be added to this package (unless said properties are in an open Pull Request to Discord's [API Documentation repository](https://github.com/discord/discord-api-docs) or known through other means _and have received the green light to be used_). For clarification's sake, this means that properties that are only known through the process of data mining and have not yet been confirmed in a way as described will **NOT** be included.
**A note about how types are documented**: This package will add types only for known and documented properties that are present in Discord's [API Documentation repository](https://github.com/discord/discord-api-docs),
that are mentioned in an open pull request, or known through other means _and have received the green light to be used_.
Anything else will not be documented (for example client only types).
With that aside, we may allow certain types that are not documented in the [API Documentation repository](https://github.com/discord/discord-api-docs) on a case by case basis.
They will be documented with an `@unstable` tag and are not subject with the same versioning rules.

View File

@@ -1,3 +1,61 @@
## [0.33.2](https://github.com/discordjs/discord-api-types/compare/0.33.1...0.33.2) (2022-06-01)
### Bug Fixes
- **docs-site:** website link colors ([#457](https://github.com/discordjs/discord-api-types/issues/457)) ([51e664d](https://github.com/discordjs/discord-api-types/commit/51e664d8e826e7f0aa467c000f3a1707fc283a36))
- **GatewayGuildCreateDispatch:** add extra fields that were missing ([#458](https://github.com/discordjs/discord-api-types/issues/458)) ([15fcd1b](https://github.com/discordjs/discord-api-types/commit/15fcd1b2a85e8d1e136416a66326a4aadcc301fb))
- **RestPostAPIBaseApplicationJSONBody:** make `default_member_permissions` optional ([#460](https://github.com/discordjs/discord-api-types/issues/460)) ([6a813be](https://github.com/discordjs/discord-api-types/commit/6a813be83382e1606f1921cf00179fe1ce75c04f))
## [0.33.1](https://github.com/discordjs/discord-api-types/compare/0.33.0...0.33.1) (2022-05-26)
### Bug Fixes
- **RESTPostAPIApplicationGuildCommands:** correct types due to unions ([#447](https://github.com/discordjs/discord-api-types/issues/447)) ([6d85ad6](https://github.com/discordjs/discord-api-types/commit/6d85ad6b1d707b980f9897ea68dd4b7573b3a770))
### Features
- **RESTJSONErrorCodes:** add error `50600` ([#444](https://github.com/discordjs/discord-api-types/issues/444)) ([5ef49f4](https://github.com/discordjs/discord-api-types/commit/5ef49f41cecaa1d5937428a5c58f1d88bfc61266))
- **RESTPostAPIGuildChannels:** update post body fields ([#419](https://github.com/discordjs/discord-api-types/issues/419)) ([748db34](https://github.com/discordjs/discord-api-types/commit/748db34e30338cf4a9fd8ce7b86d1d5c7dde63b1))
# [0.33.0](https://github.com/discordjs/discord-api-types/compare/0.32.1...0.33.0) (2022-05-16)
### Code Refactoring
- **GuildFeature:** thread archive durations are no longer boost locked ([#412](https://github.com/discordjs/discord-api-types/issues/412)) ([1737ade](https://github.com/discordjs/discord-api-types/commit/1737adea1fc3d5050db30266e49c63277b7a77fc))
- separate `GUILD_CREATE` fields from `APIGuild` object ([#423](https://github.com/discordjs/discord-api-types/issues/423)) ([17f5caa](https://github.com/discordjs/discord-api-types/commit/17f5caa671da50a79d61393f5a970ce59c5d875e))
### Features
- add support for application command permissions v2 ([#415](https://github.com/discordjs/discord-api-types/issues/415)) ([d3163ca](https://github.com/discordjs/discord-api-types/commit/d3163ca22e5b7d8292f9f6ccd444aa5c93771d92))
- **OAuth2Scopes:** add new OAuth2 scopes ([#435](https://github.com/discordjs/discord-api-types/issues/435)) ([8f16f45](https://github.com/discordjs/discord-api-types/commit/8f16f452ac7dc8988617d1211fc6a9547d254795))
- **rest:** add missing guild routes results ([#438](https://github.com/discordjs/discord-api-types/issues/438)) ([1afce87](https://github.com/discordjs/discord-api-types/commit/1afce87fbef8e43ee040010e36019a4ebc6fecfe))
### BREAKING CHANGES
- APIGuild now correctly shows just the properties that are obtainable through rest/GUILD_UPDATE, while the extra fields have been moved to GatewayGuildCreateDispatchData to correctly represent the data received
- **GuildFeature:** `SevenDayThreadArchive` and `ThreeDayThreadArchive` have been removed as they are no longer valid
## [0.32.1](https://github.com/discordjs/discord-api-types/compare/0.32.0...0.32.1) (2022-05-05)
### Features
- **RESTJSONErrorCodes:** add error `50080` ([#408](https://github.com/discordjs/discord-api-types/issues/408)) ([43cfbcb](https://github.com/discordjs/discord-api-types/commit/43cfbcba284a96de6bde101b866ad9ac306992b5))
- **RESTPostAPIGuildForumThreads:** add `message` field ([#416](https://github.com/discordjs/discord-api-types/issues/416)) ([a28c824](https://github.com/discordjs/discord-api-types/commit/a28c824f82014b15a715b51b4426356428bb4ba2))
# [0.32.0](https://github.com/discordjs/discord-api-types/compare/0.31.2...0.32.0) (2022-04-25)
### Bug Fixes
- add `position` property to create channel options ([#409](https://github.com/discordjs/discord-api-types/issues/409)) ([3fe53ce](https://github.com/discordjs/discord-api-types/commit/3fe53ced9f0e61473a8b92d0503c51084e6a58f3))
### Code Refactoring
- **APIGuildIntegration:** make `enabled` optional ([#406](https://github.com/discordjs/discord-api-types/issues/406)) ([1212eb9](https://github.com/discordjs/discord-api-types/commit/1212eb933e6bf1d82b1b41164030bd317e9c59eb))
### BREAKING CHANGES
- **APIGuildIntegration:** `enabled` is now properly marked as optional
## [0.31.2](https://github.com/discordjs/discord-api-types/compare/0.31.1...0.31.2) (2022-04-18)
### Features

View File

@@ -1,5 +1,7 @@
# Discord API Types
[![discord-api-types](./website/static/svgs/logo_long_blurple.svg)](https://github.com/discordjs/discord-api-types)
[![GitHub](https://img.shields.io/github/license/discordjs/discord-api-types)](https://github.com/discordjs/discord-api-types/blob/main/LICENSE.md)
[![npm](https://img.shields.io/npm/v/discord-api-types?color=crimson&logo=npm)](https://www.npmjs.com/package/discord-api-types)
[![deno](https://img.shields.io/npm/v/discord-api-types?color=blue&label=deno&logo=deno)](https://deno.land/x/discord_api_types)
@@ -43,7 +45,7 @@ const { GatewayVersion } = require('discord-api-types/gateway/v10');
import { GatewayVersion } from 'discord-api-types/gateway/v10';
```
> _**Note:** The `v*` exports (`discord-api-type/v*`) include the appropriate version of `gateway`, `payloads`, `rest`, `rpc`, and `utils` you specified, alongside the `globals` exports_
> _**Note:** The `v*` exports (`discord-api-types/v*`) include the appropriate version of `gateway`, `payloads`, `rest`, `rpc`, and `utils` you specified, alongside the `globals` exports_
### Deno
@@ -94,4 +96,9 @@ The exports of each API version is split into three main parts:
- There may be types exported that are identical for all versions. These will be exported as is and can be found in the `globals` file. They will still be prefixed accordingly as described above.
**Warning**: This package documents just KNOWN (and documented) properties. Anything that isn't documented will NOT be added to this package (unless said properties are in an open Pull Request to Discord's [API Documentation repository](https://github.com/discord/discord-api-docs) or known through other means _and have received the green light to be used_). For clarification's sake, this means that properties that are only known through the process of data mining and have not yet been confirmed in a way as described will **NOT** be included.
**A note about how types are documented**: This package will add types only for known and documented properties that are present in Discord's [API Documentation repository](https://github.com/discord/discord-api-docs),
that are mentioned in an open pull request, or known through other means _and have received the green light to be used_.
Anything else will not be documented (for example client only types).
With that aside, we may allow certain types that are not documented in the [API Documentation repository](https://github.com/discord/discord-api-docs) on a case by case basis.
They will be documented with an `@unstable` tag and are not subject with the same versioning rules.

View File

@@ -3,6 +3,7 @@
*/
import type { Snowflake } from '../globals.ts';
import type { GatewayPresenceUpdate } from '../payloads/v10/gateway.ts';
import type {
APIApplication,
APIChannel,
@@ -195,6 +196,7 @@ export enum GatewayIntentBits {
* https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events
*/
export enum GatewayDispatchEvents {
ApplicationCommandPermissionsUpdate = 'APPLICATION_COMMAND_PERMISSIONS_UPDATE',
ChannelCreate = 'CHANNEL_CREATE',
ChannelDelete = 'CHANNEL_DELETE',
ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE',
@@ -500,15 +502,10 @@ export interface GatewayChannelPinsUpdateDispatchData {
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-update
*/
export type GatewayGuildModifyDispatch = DataPayload<
GatewayDispatchEvents.GuildCreate | GatewayDispatchEvents.GuildUpdate,
GatewayGuildModifyDispatchData
>;
export type GatewayGuildModifyDispatch = DataPayload<GatewayDispatchEvents.GuildUpdate, GatewayGuildModifyDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-update
*/
export type GatewayGuildModifyDispatchData = APIGuild;
@@ -516,12 +513,88 @@ export type GatewayGuildModifyDispatchData = APIGuild;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
*/
export type GatewayGuildCreateDispatch = GatewayGuildModifyDispatch;
export type GatewayGuildCreateDispatch = DataPayload<GatewayDispatchEvents.GuildCreate, GatewayGuildCreateDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-create-guild-create-extra-fields
*/
export type GatewayGuildCreateDispatchData = GatewayGuildModifyDispatchData;
export interface GatewayGuildCreateDispatchData extends APIGuild {
/**
* When this guild was joined at
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
joined_at: string;
/**
* `true` if this is considered a large guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
large: boolean;
/**
* Total number of members in this guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
member_count: number;
/**
* States of members currently in voice channels; lacks the `guild_id` key
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/voice#voice-state-object
*/
voice_states: Omit<GatewayVoiceState, 'guild_id'>[];
/**
* Users in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/guild#guild-member-object
*/
members: APIGuildMember[];
/**
* Channels in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
channels: APIChannel[];
/**
* Threads in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
threads: APIChannel[];
/**
* Presences of the members in the guild, will only include non-offline members if the size is greater than `large_threshold`
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/topics/gateway#presence-update
*/
presences: GatewayPresenceUpdate[];
/**
* The stage instances in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-stage-instance-structure
*/
stage_instances: APIStageInstance[];
/**
* The scheduled events in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object
*/
guild_scheduled_events: APIGuildScheduledEvent[];
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-update

View File

@@ -3,6 +3,7 @@
*/
import type { Snowflake } from '../globals.ts';
import type { GatewayPresenceUpdate } from '../payloads/v9/gateway.ts';
import type {
APIApplication,
APIChannel,
@@ -194,6 +195,7 @@ export enum GatewayIntentBits {
* https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events
*/
export enum GatewayDispatchEvents {
ApplicationCommandPermissionsUpdate = 'APPLICATION_COMMAND_PERMISSIONS_UPDATE',
ChannelCreate = 'CHANNEL_CREATE',
ChannelDelete = 'CHANNEL_DELETE',
ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE',
@@ -498,16 +500,11 @@ export interface GatewayChannelPinsUpdateDispatchData {
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-update
*/
export type GatewayGuildModifyDispatch = DataPayload<
GatewayDispatchEvents.GuildCreate | GatewayDispatchEvents.GuildUpdate,
GatewayGuildModifyDispatchData
>;
export type GatewayGuildModifyDispatch = DataPayload<GatewayDispatchEvents.GuildUpdate, GatewayGuildModifyDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-update
*/
export type GatewayGuildModifyDispatchData = APIGuild;
@@ -515,12 +512,88 @@ export type GatewayGuildModifyDispatchData = APIGuild;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
*/
export type GatewayGuildCreateDispatch = GatewayGuildModifyDispatch;
export type GatewayGuildCreateDispatch = DataPayload<GatewayDispatchEvents.GuildCreate, GatewayGuildCreateDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-create-guild-create-extra-fields
*/
export type GatewayGuildCreateDispatchData = GatewayGuildModifyDispatchData;
export interface GatewayGuildCreateDispatchData extends APIGuild {
/**
* When this guild was joined at
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
joined_at: string;
/**
* `true` if this is considered a large guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
large: boolean;
/**
* Total number of members in this guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
member_count: number;
/**
* States of members currently in voice channels; lacks the `guild_id` key
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/voice#voice-state-object
*/
voice_states: Omit<GatewayVoiceState, 'guild_id'>[];
/**
* Users in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/guild#guild-member-object
*/
members: APIGuildMember[];
/**
* Channels in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
channels: APIChannel[];
/**
* Threads in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
threads: APIChannel[];
/**
* Presences of the members in the guild, will only include non-offline members if the size is greater than `large_threshold`
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/topics/gateway#presence-update
*/
presences: GatewayPresenceUpdate[];
/**
* The stage instances in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-stage-instance-structure
*/
stage_instances: APIStageInstance[];
/**
* The scheduled events in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object
*/
guild_scheduled_events: APIGuildScheduledEvent[];
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-update

View File

@@ -1,4 +1,4 @@
import type { LocaleString } from '../v10.ts';
import type { LocaleString } from '../rest/common.ts';
/**
* https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags

View File

@@ -5,7 +5,7 @@ import type { Snowflake } from '../../../../globals.ts';
*/
export interface APIGuildApplicationCommandPermissions {
/**
* The id of the command
* The id of the command or the application id if that permission applies to all commands
*/
id: Snowflake;
/**
@@ -27,11 +27,11 @@ export interface APIGuildApplicationCommandPermissions {
*/
export interface APIApplicationCommandPermission {
/**
* The id of the role or user
* The id of the role, user or channel. Can also be a permission constant
*/
id: Snowflake;
/**
* Role or user
* Role, user or channel
*/
type: ApplicationCommandPermissionType;
/**
@@ -46,4 +46,13 @@ export interface APIApplicationCommandPermission {
export enum ApplicationCommandPermissionType {
Role = 1,
User,
Channel,
}
/**
* https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-constants
*/
export const APIApplicationCommandPermissionsConstant = {
Everyone: (guildId: string | bigint): Snowflake => String(guildId),
AllChannels: (guildId: string | bigint): Snowflake => String(BigInt(guildId) - 1n),
};

View File

@@ -70,10 +70,19 @@ export interface APIApplicationCommand {
* The parameters for the `CHAT_INPUT` command, max 25
*/
options?: APIApplicationCommandOption[];
/**
* Set of permissions represented as a bitset
*/
default_member_permissions: Permissions | null;
/**
* Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible
*/
dm_permission?: boolean;
/**
* Whether the command is enabled by default when the app is added to a guild
*
* If missing, this property should be assumed as `true`
* @deprecated Use `dm_permission` and/or `default_member_permissions` instead
*/
default_permission?: boolean;
/**

View File

@@ -53,6 +53,12 @@ export interface APIApplication {
* See https://discord.com/developers/docs/resources/user#user-object
*/
owner?: APIUser;
/**
* An empty string
*
* @deprecated This field will be removed in v11
*/
summary: string;
/**
* The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function
*

View File

@@ -16,6 +16,7 @@ import type {
GuildScheduledEventEntityType,
GuildScheduledEventStatus,
} from './guildScheduledEvent.ts';
import type { APIApplicationCommand } from './interactions.ts';
import type { APIRole } from './permissions.ts';
import type { StageInstancePrivacyLevel } from './stageInstance.ts';
import type { StickerFormatType } from './sticker.ts';
@@ -27,6 +28,12 @@ import type { Snowflake } from '../../globals.ts';
* https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure
*/
export interface APIAuditLog {
/**
* List of application commands found in the audit log
*
* See https://discord.com/developers/docs/interactions/application-commands#application-command-object
*/
application_commands: APIApplicationCommand[];
/**
* Webhooks found in the audit log
*
@@ -171,6 +178,8 @@ export enum AuditLogEvent {
ThreadCreate = 110,
ThreadUpdate,
ThreadDelete,
ApplicationCommandPermissionUpdate = 121,
}
/**
@@ -517,6 +526,12 @@ export type APIAuditLogChangeKeyPermissions = AuditLogChangeData<'permissions',
*/
export type APIAuditLogChangeKeyColor = AuditLogChangeData<'color', number>;
/**
* Represents a change where the key is a snowflake.
* Currently, the only known instance of this is returned when permissions for a command were updated (<insert name of object here>)
*/
export type APIAuditLogChangeKeySnowflake = AuditLogChangeData<Snowflake, unknown>;
/**
* Returned when a role's hoist status is changed
*/

View File

@@ -770,10 +770,6 @@ export interface APIThreadList {
* The members for the client user in each of the fetched threads
*/
members: APIThreadMember[];
/**
* Whether there are potentially additional threads
*/
has_more?: boolean;
}
/**

View File

@@ -127,6 +127,7 @@ export interface GatewayPresenceClientStatus {
export interface GatewayActivity {
/**
* The activity's id
* @unstable
*/
id: string;
/**
@@ -151,8 +152,16 @@ export interface GatewayActivity {
* Unix timestamps for start and/or end of the game
*/
timestamps?: GatewayActivityTimestamps;
/**
* The Spotify song id
* @unstable
*/
sync_id?: string;
platform?: ActivityPlatform;
/**
* The platform this activity is being done on
* @unstable You can use {@link ActivityPlatform} as a stepping stone, but this might be inaccurate
*/
platform?: string;
/**
* Application id for the game
*/
@@ -171,6 +180,9 @@ export interface GatewayActivity {
* See https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji
*/
emoji?: GatewayActivityEmoji;
/**
* @unstable
*/
session_id?: string;
/**
* Information for the current party of the player
@@ -208,10 +220,19 @@ export interface GatewayActivity {
buttons?: string[] | GatewayActivityButton[];
}
/**
* @unstable This enum is currently not documented by Discord but has known values which we will try to keep up to date.
* Values might be added or removed without a major version bump.
*/
export enum ActivityPlatform {
Desktop = 'desktop',
Samsung = 'samsung',
Xbox = 'xbox',
Samsung = 'samsung',
IOS = 'ios',
Android = 'android',
Embedded = 'embedded',
PS4 = 'ps4',
PS5 = 'ps5',
}
/**

View File

@@ -2,15 +2,11 @@
* Types extracted from https://discord.com/developers/docs/resources/guild
*/
import type { APIChannel } from './channel.ts';
import type { APIEmoji } from './emoji.ts';
import type { GatewayPresenceUpdate, PresenceUpdateStatus } from './gateway.ts';
import type { APIGuildScheduledEvent } from './guildScheduledEvent.ts';
import type { PresenceUpdateStatus } from './gateway.ts';
import type { APIRole } from './permissions.ts';
import type { APIStageInstance } from './stageInstance.ts';
import type { APISticker } from './sticker.ts';
import type { APIUser } from './user.ts';
import type { GatewayVoiceState } from './voice.ts';
import type { Permissions, Snowflake } from '../../globals.ts';
/**
@@ -196,64 +192,6 @@ export interface APIGuild extends APIPartialGuild {
* The id of the channel where Community guilds can display rules and/or guidelines
*/
rules_channel_id: Snowflake | null;
/**
* When this guild was joined at
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
joined_at?: string;
/**
* `true` if this is considered a large guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
large?: boolean;
/**
* Total number of members in this guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
member_count?: number;
/**
* States of members currently in voice channels; lacks the `guild_id` key
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/voice#voice-state-object
*/
voice_states?: Omit<GatewayVoiceState, 'guild_id'>[];
/**
* Users in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/guild#guild-member-object
*/
members?: APIGuildMember[];
/**
* Channels in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
channels?: APIChannel[];
/**
* Threads in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
threads?: APIChannel[];
/**
* Presences of the members in the guild, will only include non-offline members if the size is greater than `large_threshold`
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/topics/gateway#presence-update
*/
presences?: GatewayPresenceUpdate[];
/**
* The maximum number of presences for the guild (`null` is always returned, apart from the largest of guilds)
*/
@@ -320,14 +258,6 @@ export interface APIGuild extends APIPartialGuild {
* See https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level
*/
nsfw_level: GuildNSFWLevel;
/**
* The stage instances in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-stage-instance-structure
*/
stage_instances?: APIStageInstance[];
/**
* Custom guild stickers
*
@@ -338,14 +268,6 @@ export interface APIGuild extends APIPartialGuild {
* Whether the guild has the boost progress bar enabled.
*/
premium_progress_bar_enabled: boolean;
/**
* The scheduled events in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object
*/
guild_scheduled_events?: APIGuildScheduledEvent[];
/**
* The type of Student Hub the guild is
*/
@@ -536,14 +458,6 @@ export enum GuildFeature {
* Guild is able to set role icons
*/
RoleIcons = 'ROLE_ICONS',
/**
* Guild has access to the seven day archive time for threads
*/
SevenDayThreadArchive = 'SEVEN_DAY_THREAD_ARCHIVE',
/**
* Guild has access to the three day archive time for threads
*/
ThreeDayThreadArchive = 'THREE_DAY_THREAD_ARCHIVE',
/**
* Guild has enabled ticketed events
*/
@@ -715,7 +629,7 @@ export interface APIGuildIntegration {
/**
* Is this integration enabled
*/
enabled: boolean;
enabled?: boolean;
/**
* Is this integration syncing
*

View File

@@ -14,6 +14,10 @@ export enum OAuth2Scopes {
* See https://discord.com/developers/docs/resources/user#get-user-connections
*/
Connections = 'connections',
/**
* Allows your app to see information about the user's DMs and group DMs - requires Discord approval
*/
DMChannelsRead = 'dm_channels.read',
/**
* Enables [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) to return an `email`
*
@@ -69,6 +73,10 @@ export enum OAuth2Scopes {
* This generates a webhook that is returned in the oauth token response for authorization code grants
*/
WebhookIncoming = 'webhook.incoming',
/**
* Allows your app to connect to voice on user's behalf and see all the voice members - requires Discord approval
*/
Voice = 'voice',
/**
* Allows your app to upload/update builds for a user's applications - requires Discord approval
*/
@@ -111,4 +119,10 @@ export enum OAuth2Scopes {
* See https://discord.com/developers/docs/interactions/application-commands
*/
ApplicationsCommandsUpdate = 'applications.commands.update',
/**
* Allows your app to update permissions for its commands using a Bearer token - client credentials grant only
*
* See https://discord.com/developers/docs/interactions/application-commands
*/
ApplicationCommandsPermissionsUpdate = 'applications.commands.permissions.update',
}

View File

@@ -5,7 +5,7 @@ import type { Snowflake } from '../../../../globals.ts';
*/
export interface APIGuildApplicationCommandPermissions {
/**
* The id of the command
* The id of the command or the application id if that permission applies to all commands
*/
id: Snowflake;
/**
@@ -27,11 +27,11 @@ export interface APIGuildApplicationCommandPermissions {
*/
export interface APIApplicationCommandPermission {
/**
* The id of the role or user
* The id of the role, user or channel. Can also be a permission constant
*/
id: Snowflake;
/**
* Role or user
* Role, user or channel
*/
type: ApplicationCommandPermissionType;
/**
@@ -46,4 +46,13 @@ export interface APIApplicationCommandPermission {
export enum ApplicationCommandPermissionType {
Role = 1,
User,
Channel,
}
/**
* https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-constants
*/
export const APIApplicationCommandPermissionsConstant = {
Everyone: (guildId: string | bigint): Snowflake => String(guildId),
AllChannels: (guildId: string | bigint): Snowflake => String(BigInt(guildId) - 1n),
};

View File

@@ -70,10 +70,19 @@ export interface APIApplicationCommand {
* The parameters for the `CHAT_INPUT` command, max 25
*/
options?: APIApplicationCommandOption[];
/**
* Set of permissions represented as a bitset
*/
default_member_permissions: Permissions | null;
/**
* Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible
*/
dm_permission?: boolean;
/**
* Whether the command is enabled by default when the app is added to a guild
*
* If missing, this property should be assumed as `true`
* @deprecated Use `dm_permission` and/or `default_member_permissions` instead
*/
default_permission?: boolean;
/**

View File

@@ -53,6 +53,12 @@ export interface APIApplication {
* See https://discord.com/developers/docs/resources/user#user-object
*/
owner?: APIUser;
/**
* An empty string
*
* @deprecated This field will be removed in v11
*/
summary: string;
/**
* The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function
*

View File

@@ -16,6 +16,7 @@ import type {
GuildScheduledEventEntityType,
GuildScheduledEventStatus,
} from './guildScheduledEvent.ts';
import type { APIApplicationCommand } from './interactions.ts';
import type { APIRole } from './permissions.ts';
import type { StageInstancePrivacyLevel } from './stageInstance.ts';
import type { StickerFormatType } from './sticker.ts';
@@ -27,6 +28,12 @@ import type { Snowflake } from '../../globals.ts';
* https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure
*/
export interface APIAuditLog {
/**
* List of application commands found in the audit log
*
* See https://discord.com/developers/docs/interactions/application-commands#application-command-object
*/
application_commands: APIApplicationCommand[];
/**
* Webhooks found in the audit log
*
@@ -171,6 +178,8 @@ export enum AuditLogEvent {
ThreadCreate = 110,
ThreadUpdate,
ThreadDelete,
ApplicationCommandPermissionUpdate = 121,
}
/**
@@ -517,6 +526,12 @@ export type APIAuditLogChangeKeyPermissions = AuditLogChangeData<'permissions',
*/
export type APIAuditLogChangeKeyColor = AuditLogChangeData<'color', number>;
/**
* Represents a change where the key is a snowflake.
* Currently, the only known instance of this is returned when permissions for a command were updated (<insert name of object here>)
*/
export type APIAuditLogChangeKeySnowflake = AuditLogChangeData<Snowflake, unknown>;
/**
* Returned when a role's hoist status is changed
*/

View File

@@ -152,7 +152,10 @@ export interface GatewayActivity {
*/
timestamps?: GatewayActivityTimestamps;
sync_id?: string;
platform?: ActivityPlatform;
/**
* {@link ActivityPlatform}
*/
platform?: string;
/**
* Application id for the game
*/
@@ -208,10 +211,19 @@ export interface GatewayActivity {
buttons?: string[] | GatewayActivityButton[];
}
/**
* @unstable This enum is currently not documented by Discord but has known values which we will try to keep up to date.
* Values might be added or removed without a major version bump.
*/
export enum ActivityPlatform {
Desktop = 'desktop',
Samsung = 'samsung',
Xbox = 'xbox',
Samsung = 'samsung',
IOS = 'ios',
Android = 'android',
Embedded = 'embedded',
PS4 = 'ps4',
PS5 = 'ps5',
}
/**

View File

@@ -2,15 +2,11 @@
* Types extracted from https://discord.com/developers/docs/resources/guild
*/
import type { APIChannel } from './channel.ts';
import type { APIEmoji } from './emoji.ts';
import type { GatewayPresenceUpdate, PresenceUpdateStatus } from './gateway.ts';
import type { APIGuildScheduledEvent } from './guildScheduledEvent.ts';
import type { PresenceUpdateStatus } from './gateway.ts';
import type { APIRole } from './permissions.ts';
import type { APIStageInstance } from './stageInstance.ts';
import type { APISticker } from './sticker.ts';
import type { APIUser } from './user.ts';
import type { GatewayVoiceState } from './voice.ts';
import type { Permissions, Snowflake } from '../../globals.ts';
/**
@@ -196,64 +192,6 @@ export interface APIGuild extends APIPartialGuild {
* The id of the channel where Community guilds can display rules and/or guidelines
*/
rules_channel_id: Snowflake | null;
/**
* When this guild was joined at
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
joined_at?: string;
/**
* `true` if this is considered a large guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
large?: boolean;
/**
* Total number of members in this guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
member_count?: number;
/**
* States of members currently in voice channels; lacks the `guild_id` key
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/voice#voice-state-object
*/
voice_states?: Omit<GatewayVoiceState, 'guild_id'>[];
/**
* Users in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/guild#guild-member-object
*/
members?: APIGuildMember[];
/**
* Channels in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
channels?: APIChannel[];
/**
* Threads in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
threads?: APIChannel[];
/**
* Presences of the members in the guild, will only include non-offline members if the size is greater than `large_threshold`
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/topics/gateway#presence-update
*/
presences?: GatewayPresenceUpdate[];
/**
* The maximum number of presences for the guild (`null` is always returned, apart from the largest of guilds)
*/
@@ -320,14 +258,6 @@ export interface APIGuild extends APIPartialGuild {
* See https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level
*/
nsfw_level: GuildNSFWLevel;
/**
* The stage instances in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-stage-instance-structure
*/
stage_instances?: APIStageInstance[];
/**
* Custom guild stickers
*
@@ -338,14 +268,6 @@ export interface APIGuild extends APIPartialGuild {
* Whether the guild has the boost progress bar enabled.
*/
premium_progress_bar_enabled: boolean;
/**
* The scheduled events in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object
*/
guild_scheduled_events?: APIGuildScheduledEvent[];
/**
* The type of Student Hub the guild is
*/
@@ -536,14 +458,6 @@ export enum GuildFeature {
* Guild is able to set role icons
*/
RoleIcons = 'ROLE_ICONS',
/**
* Guild has access to the seven day archive time for threads
*/
SevenDayThreadArchive = 'SEVEN_DAY_THREAD_ARCHIVE',
/**
* Guild has access to the three day archive time for threads
*/
ThreeDayThreadArchive = 'THREE_DAY_THREAD_ARCHIVE',
/**
* Guild has enabled ticketed events
*/
@@ -715,7 +629,7 @@ export interface APIGuildIntegration {
/**
* Is this integration enabled
*/
enabled: boolean;
enabled?: boolean;
/**
* Is this integration syncing
*

View File

@@ -14,6 +14,10 @@ export enum OAuth2Scopes {
* See https://discord.com/developers/docs/resources/user#get-user-connections
*/
Connections = 'connections',
/**
* Allows your app to see information about the user's DMs and group DMs - requires Discord approval
*/
DMChannelsRead = 'dm_channels.read',
/**
* Enables [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) to return an `email`
*
@@ -69,6 +73,10 @@ export enum OAuth2Scopes {
* This generates a webhook that is returned in the oauth token response for authorization code grants
*/
WebhookIncoming = 'webhook.incoming',
/**
* Allows your app to connect to voice on user's behalf and see all the voice members - requires Discord approval
*/
Voice = 'voice',
/**
* Allows your app to upload/update builds for a user's applications - requires Discord approval
*/
@@ -111,4 +119,10 @@ export enum OAuth2Scopes {
* See https://discord.com/developers/docs/interactions/application-commands
*/
ApplicationsCommandsUpdate = 'applications.commands.update',
/**
* Allows your app to update permissions for its commands using a Bearer token - client credentials grant only
*
* See https://discord.com/developers/docs/interactions/application-commands
*/
ApplicationCommandsPermissionsUpdate = 'applications.commands.permissions.update',
}

View File

@@ -179,7 +179,8 @@ export enum RESTJSONErrorCodes {
CannotDeleteChannelRequiredForCommunityGuilds = 50074,
InvalidStickerSent = 50081,
CannotEditStickersWithinMessage = 50080,
InvalidStickerSent,
InvalidActionOnArchivedThread = 50083,
InvalidThreadNotificationSettings,
@@ -194,6 +195,8 @@ export enum RESTJSONErrorCodes {
RequestBodyContainsInvalidJSON = 50109,
YouDoNotHavePermissionToSendThisSticker = 50600,
TwoFactorAuthenticationIsRequired = 60003,
NoUsersWithDiscordTagExist = 80004,

View File

@@ -584,13 +584,22 @@ export type RESTPostAPIChannelMessagesThreadsJSONBody = AddUndefinedToPossiblyUn
/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody &
RESTPostAPIChannelMessageJSONBody;
export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody & {
/**
* First message in the forum thread
*/
message: RESTPostAPIChannelMessageJSONBody;
};
/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsFormDataBody = RESTPostAPIChannelMessageFormDataBody;
export type RESTPostAPIGuildForumThreadsFormDataBody = RESTPostAPIChannelMessagesThreadsJSONBody & {
/**
* First message in the forum thread
*/
message: string;
};
/**
* https://discord.com/developers/docs/resources/channel#start-thread-from-message

View File

@@ -41,7 +41,17 @@ export type APIGuildChannelResolvable = Exclude<APIChannel, APIDMChannel | APIGr
export type APIGuildCreatePartialChannel = StrictPartial<
DistributivePick<
APIGuildChannelResolvable,
'type' | 'topic' | 'nsfw' | 'bitrate' | 'user_limit' | 'rate_limit_per_user' | 'default_auto_archive_duration'
| 'type'
| 'topic'
| 'nsfw'
| 'bitrate'
| 'user_limit'
| 'rate_limit_per_user'
| 'default_auto_archive_duration'
| 'position'
| 'rtc_region'
| 'video_quality_mode'
| 'flags'
>
> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
@@ -331,7 +341,7 @@ export type RESTPatchAPIGuildChannelPositionsResult = never;
/**
* https://discord.com/developers/docs/resources/guild#list-active-threads
*/
export type RESTGetAPIGuildThreadsResult = Omit<APIThreadList, 'has_more'>;
export type RESTGetAPIGuildThreadsResult = APIThreadList;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-member
@@ -820,6 +830,9 @@ export type RESTPatchAPIGuildMemberVerificationJSONBody = AddUndefinedToPossibly
export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state
*/
export type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
@@ -835,6 +848,14 @@ export type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = AddUndefinedToPos
request_to_speak_timestamp?: string | null;
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state
*/
export type RESTPatchAPIGuildVoiceStateCurrentMemberResult = never;
/**
* https://discord.com/developers/docs/resources/guild#modify-user-voice-state
*/
export type RESTPatchAPIGuildVoiceStateUserJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
@@ -861,3 +882,8 @@ export type RESTPatchAPIGuildWelcomeScreenJSONBody = Nullable<StrictPartial<APIG
*/
enabled?: boolean | null;
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
*/
export type RESTPatchAPIGuildWelcomeScreenResult = APIGuildWelcomeScreen;

View File

@@ -37,7 +37,9 @@ type RESTPostAPIBaseApplicationCommandsJSONBody = AddUndefinedToPossiblyUndefine
| 'guild_id'
| 'name_localized'
| 'description_localized'
>
| 'default_member_permissions'
> &
Partial<Pick<APIApplicationCommand, 'default_member_permissions'>>
>;
/**
@@ -91,42 +93,50 @@ export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[];
/**
* https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands
*/
export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[];
export type RESTGetAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>[];
/**
* https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands
*/
export type RESTGetAPIApplicationGuildCommandResult = APIApplicationCommand;
export type RESTGetAPIApplicationGuildCommandResult = Omit<APIApplicationCommand, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
*/
export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody;
export type RESTPostAPIApplicationGuildCommandsJSONBody =
| Omit<RESTPostAPIChatInputApplicationCommandsJSONBody, 'dm_permission'>
| Omit<RESTPostAPIContextMenuApplicationCommandsJSONBody, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
*/
export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand;
export type RESTPostAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial<RESTPostAPIApplicationCommandsJSONBody>;
export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial<
| Omit<RESTPostAPIChatInputApplicationCommandsJSONBody, 'dm_permission'>
| Omit<RESTPostAPIContextMenuApplicationCommandsJSONBody, 'dm_permission'>
>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandResult = APIApplicationCommand;
export type RESTPatchAPIApplicationGuildCommandResult = Omit<APIApplicationCommand, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
*/
export type RESTPutAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[];
export type RESTPutAPIApplicationGuildCommandsJSONBody = (
| Omit<RESTPostAPIChatInputApplicationCommandsJSONBody, 'dm_permission'>
| Omit<RESTPostAPIContextMenuApplicationCommandsJSONBody, 'dm_permission'>
)[];
/**
* https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
*/
export type RESTPutAPIApplicationGuildCommandsResult = APIApplicationCommand[];
export type RESTPutAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>[];
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response

View File

@@ -598,13 +598,22 @@ export type RESTPostAPIChannelMessagesThreadsJSONBody = AddUndefinedToPossiblyUn
/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody &
RESTPostAPIChannelMessageJSONBody;
export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody & {
/**
* First message in the forum thread
*/
message: RESTPostAPIChannelMessageJSONBody;
};
/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsFormDataBody = RESTPostAPIChannelMessageFormDataBody;
export type RESTPostAPIGuildForumThreadsFormDataBody = RESTPostAPIChannelMessagesThreadsJSONBody & {
/**
* First message in the forum thread
*/
message: string;
};
/**
* https://discord.com/developers/docs/resources/channel#start-thread-from-message

View File

@@ -41,7 +41,17 @@ export type APIGuildChannelResolvable = Exclude<APIChannel, APIDMChannel | APIGr
export type APIGuildCreatePartialChannel = StrictPartial<
DistributivePick<
APIGuildChannelResolvable,
'type' | 'topic' | 'nsfw' | 'bitrate' | 'user_limit' | 'rate_limit_per_user' | 'default_auto_archive_duration'
| 'type'
| 'topic'
| 'nsfw'
| 'bitrate'
| 'user_limit'
| 'rate_limit_per_user'
| 'default_auto_archive_duration'
| 'position'
| 'rtc_region'
| 'video_quality_mode'
| 'flags'
>
> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
@@ -826,6 +836,9 @@ export type RESTPatchAPIGuildMemberVerificationJSONBody = AddUndefinedToPossibly
export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state
*/
export type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
@@ -841,6 +854,14 @@ export type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = AddUndefinedToPos
request_to_speak_timestamp?: string | null;
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state
*/
export type RESTPatchAPIGuildVoiceStateCurrentMemberResult = never;
/**
* https://discord.com/developers/docs/resources/guild#modify-user-voice-state
*/
export type RESTPatchAPIGuildVoiceStateUserJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
@@ -867,3 +888,8 @@ export type RESTPatchAPIGuildWelcomeScreenJSONBody = Nullable<StrictPartial<APIG
*/
enabled?: boolean | null;
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
*/
export type RESTPatchAPIGuildWelcomeScreenResult = APIGuildWelcomeScreen;

View File

@@ -37,7 +37,9 @@ type RESTPostAPIBaseApplicationCommandsJSONBody = AddUndefinedToPossiblyUndefine
| 'guild_id'
| 'name_localized'
| 'description_localized'
>
| 'default_member_permissions'
> &
Partial<Pick<APIApplicationCommand, 'default_member_permissions'>>
>;
/**
@@ -91,42 +93,50 @@ export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[];
/**
* https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands
*/
export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[];
export type RESTGetAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>[];
/**
* https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands
*/
export type RESTGetAPIApplicationGuildCommandResult = APIApplicationCommand;
export type RESTGetAPIApplicationGuildCommandResult = Omit<APIApplicationCommand, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
*/
export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody;
export type RESTPostAPIApplicationGuildCommandsJSONBody =
| Omit<RESTPostAPIChatInputApplicationCommandsJSONBody, 'dm_permission'>
| Omit<RESTPostAPIContextMenuApplicationCommandsJSONBody, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
*/
export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand;
export type RESTPostAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial<RESTPostAPIApplicationCommandsJSONBody>;
export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial<
| Omit<RESTPostAPIChatInputApplicationCommandsJSONBody, 'dm_permission'>
| Omit<RESTPostAPIContextMenuApplicationCommandsJSONBody, 'dm_permission'>
>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandResult = APIApplicationCommand;
export type RESTPatchAPIApplicationGuildCommandResult = Omit<APIApplicationCommand, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
*/
export type RESTPutAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[];
export type RESTPutAPIApplicationGuildCommandsJSONBody = (
| Omit<RESTPostAPIChatInputApplicationCommandsJSONBody, 'dm_permission'>
| Omit<RESTPostAPIContextMenuApplicationCommandsJSONBody, 'dm_permission'>
)[];
/**
* https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
*/
export type RESTPutAPIApplicationGuildCommandsResult = APIApplicationCommand[];
export type RESTPutAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>[];
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response

View File

@@ -3,6 +3,7 @@
*/
import type { Snowflake } from '../globals';
import type { GatewayPresenceUpdate } from '../payloads/v10/gateway';
import type {
APIApplication,
APIChannel,
@@ -195,6 +196,7 @@ export enum GatewayIntentBits {
* https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events
*/
export enum GatewayDispatchEvents {
ApplicationCommandPermissionsUpdate = 'APPLICATION_COMMAND_PERMISSIONS_UPDATE',
ChannelCreate = 'CHANNEL_CREATE',
ChannelDelete = 'CHANNEL_DELETE',
ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE',
@@ -500,15 +502,10 @@ export interface GatewayChannelPinsUpdateDispatchData {
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-update
*/
export type GatewayGuildModifyDispatch = DataPayload<
GatewayDispatchEvents.GuildCreate | GatewayDispatchEvents.GuildUpdate,
GatewayGuildModifyDispatchData
>;
export type GatewayGuildModifyDispatch = DataPayload<GatewayDispatchEvents.GuildUpdate, GatewayGuildModifyDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-update
*/
export type GatewayGuildModifyDispatchData = APIGuild;
@@ -516,12 +513,88 @@ export type GatewayGuildModifyDispatchData = APIGuild;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
*/
export type GatewayGuildCreateDispatch = GatewayGuildModifyDispatch;
export type GatewayGuildCreateDispatch = DataPayload<GatewayDispatchEvents.GuildCreate, GatewayGuildCreateDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-create-guild-create-extra-fields
*/
export type GatewayGuildCreateDispatchData = GatewayGuildModifyDispatchData;
export interface GatewayGuildCreateDispatchData extends APIGuild {
/**
* When this guild was joined at
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
joined_at: string;
/**
* `true` if this is considered a large guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
large: boolean;
/**
* Total number of members in this guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
member_count: number;
/**
* States of members currently in voice channels; lacks the `guild_id` key
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/voice#voice-state-object
*/
voice_states: Omit<GatewayVoiceState, 'guild_id'>[];
/**
* Users in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/guild#guild-member-object
*/
members: APIGuildMember[];
/**
* Channels in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
channels: APIChannel[];
/**
* Threads in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
threads: APIChannel[];
/**
* Presences of the members in the guild, will only include non-offline members if the size is greater than `large_threshold`
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/topics/gateway#presence-update
*/
presences: GatewayPresenceUpdate[];
/**
* The stage instances in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-stage-instance-structure
*/
stage_instances: APIStageInstance[];
/**
* The scheduled events in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object
*/
guild_scheduled_events: APIGuildScheduledEvent[];
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-update

View File

@@ -3,6 +3,7 @@
*/
import type { Snowflake } from '../globals';
import type { GatewayPresenceUpdate } from '../payloads/v9/gateway';
import type {
APIApplication,
APIChannel,
@@ -194,6 +195,7 @@ export enum GatewayIntentBits {
* https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events
*/
export enum GatewayDispatchEvents {
ApplicationCommandPermissionsUpdate = 'APPLICATION_COMMAND_PERMISSIONS_UPDATE',
ChannelCreate = 'CHANNEL_CREATE',
ChannelDelete = 'CHANNEL_DELETE',
ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE',
@@ -498,16 +500,11 @@ export interface GatewayChannelPinsUpdateDispatchData {
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-update
*/
export type GatewayGuildModifyDispatch = DataPayload<
GatewayDispatchEvents.GuildCreate | GatewayDispatchEvents.GuildUpdate,
GatewayGuildModifyDispatchData
>;
export type GatewayGuildModifyDispatch = DataPayload<GatewayDispatchEvents.GuildUpdate, GatewayGuildModifyDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-update
*/
export type GatewayGuildModifyDispatchData = APIGuild;
@@ -515,12 +512,88 @@ export type GatewayGuildModifyDispatchData = APIGuild;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
*/
export type GatewayGuildCreateDispatch = GatewayGuildModifyDispatch;
export type GatewayGuildCreateDispatch = DataPayload<GatewayDispatchEvents.GuildCreate, GatewayGuildCreateDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-create-guild-create-extra-fields
*/
export type GatewayGuildCreateDispatchData = GatewayGuildModifyDispatchData;
export interface GatewayGuildCreateDispatchData extends APIGuild {
/**
* When this guild was joined at
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
joined_at: string;
/**
* `true` if this is considered a large guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
large: boolean;
/**
* Total number of members in this guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
member_count: number;
/**
* States of members currently in voice channels; lacks the `guild_id` key
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/voice#voice-state-object
*/
voice_states: Omit<GatewayVoiceState, 'guild_id'>[];
/**
* Users in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/guild#guild-member-object
*/
members: APIGuildMember[];
/**
* Channels in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
channels: APIChannel[];
/**
* Threads in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
threads: APIChannel[];
/**
* Presences of the members in the guild, will only include non-offline members if the size is greater than `large_threshold`
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/topics/gateway#presence-update
*/
presences: GatewayPresenceUpdate[];
/**
* The stage instances in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-stage-instance-structure
*/
stage_instances: APIStageInstance[];
/**
* The scheduled events in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object
*/
guild_scheduled_events: APIGuildScheduledEvent[];
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-update

1836
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "discord-api-types",
"version": "0.31.2",
"version": "0.33.2",
"description": "Discord API typings that are kept up to date for use in bot library creation.",
"exports": {
"./globals": {
@@ -94,7 +94,7 @@
"build:deno": "node ./scripts/deno.mjs",
"build:node": "tsc && run-p esm:*",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"ci:pr": "run-s changelog lint build:deno",
"ci:pr": "run-s changelog lint build:deno && node ./scripts/bump-website-version.mjs",
"clean:deno": "rimraf deno/",
"clean:node": "rimraf {gateway,payloads,rest,rpc,voice,utils}/**/*.{js,mjs,d.ts,*map} {globals,v*}.{js,mjs,d.ts,*map}",
"clean": "run-p clean:*",
@@ -106,11 +106,11 @@
"esm:utils": "gen-esm-wrapper ./utils/index.js ./utils/index.mjs",
"esm:versions": "node ./scripts/versions.mjs",
"esm:voice": "gen-esm-wrapper ./voice/index.js ./voice/index.mjs",
"lint": "prettier --write . && eslint --fix --ext mjs,ts {gateway,payloads,rest,rpc,voice,utils}/**/*.ts {globals,v*}.ts scripts/**/*.{mjs,ts}",
"lint": "prettier --write . && eslint --fix --ext mjs,ts {gateway,payloads,rest,rpc,voice,utils}/**/*.ts {globals,v*}.ts scripts/**/*.mjs",
"postpublish": "run-s clean:node build:deno",
"prepare": "is-ci || husky install",
"prepublishOnly": "run-s clean test:lint build:node",
"test:lint": "prettier --check . && eslint --ext mjs,ts {gateway,payloads,rest,rpc,voice,utils}/**/*.ts {globals,v*}.ts scripts/**/*.{mjs,ts}",
"test:lint": "prettier --check . && eslint --ext mjs,ts {gateway,payloads,rest,rpc,voice,utils}/**/*.ts {globals,v*}.ts scripts/**/*.mjs",
"pretest:types": "tsc",
"test:types": "node ./scripts/run-tsd.mjs",
"posttest:types": "npm run clean:node"
@@ -128,32 +128,37 @@
"{globals,v*}.{js,js.map,d.ts,d.ts.map,mjs}"
],
"devDependencies": {
"@commitlint/cli": "^16.2.3",
"@commitlint/config-angular": "^16.2.3",
"@babel/runtime-corejs3": "^7.18.0",
"@commitlint/cli": "^17.0.0",
"@commitlint/config-angular": "^17.0.0",
"@favware/npm-deprecate": "^1.0.4",
"@octokit/action": "^3.18.0",
"@octokit/webhooks-types": "^5.5.1",
"@octokit/action": "^3.18.1",
"@octokit/webhooks-types": "^5.6.0",
"@sapphire/prettier-config": "^1.4.3",
"@types/conventional-recommended-bump": "^6.1.0",
"@types/node": "^17.0.23",
"@typescript-eslint/eslint-plugin": "^5.18.0",
"@typescript-eslint/parser": "^5.18.0",
"@types/node": "^17.0.35",
"@typescript-eslint/eslint-plugin": "^5.26.0",
"@typescript-eslint/parser": "^5.26.0",
"conventional-changelog-cli": "^2.2.2",
"conventional-recommended-bump": "^6.1.0",
"eslint": "^8.12.0",
"eslint": "^8.16.0",
"eslint-config-marine": "^9.4.1",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^2.7.1",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.30.0",
"eslint-plugin-react-hooks": "^4.5.0",
"gen-esm-wrapper": "^1.1.3",
"husky": "^7.0.4",
"husky": "^8.0.1",
"is-ci": "^3.0.1",
"lint-staged": "^12.3.7",
"lint-staged": "^12.4.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.2",
"pretty-quick": "^3.1.3",
"rimraf": "^3.0.2",
"tsd": "^0.20.0",
"typescript": "^4.6.3"
"typescript": "^4.6.4"
},
"repository": {
"type": "git",

View File

@@ -1,4 +1,4 @@
import type { LocaleString } from '../v10';
import type { LocaleString } from '../rest/common';
/**
* https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags

View File

@@ -5,7 +5,7 @@ import type { Snowflake } from '../../../../globals';
*/
export interface APIGuildApplicationCommandPermissions {
/**
* The id of the command
* The id of the command or the application id if that permission applies to all commands
*/
id: Snowflake;
/**
@@ -27,11 +27,11 @@ export interface APIGuildApplicationCommandPermissions {
*/
export interface APIApplicationCommandPermission {
/**
* The id of the role or user
* The id of the role, user or channel. Can also be a permission constant
*/
id: Snowflake;
/**
* Role or user
* Role, user or channel
*/
type: ApplicationCommandPermissionType;
/**
@@ -46,4 +46,13 @@ export interface APIApplicationCommandPermission {
export enum ApplicationCommandPermissionType {
Role = 1,
User,
Channel,
}
/**
* https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-constants
*/
export const APIApplicationCommandPermissionsConstant = {
Everyone: (guildId: string | bigint): Snowflake => String(guildId),
AllChannels: (guildId: string | bigint): Snowflake => String(BigInt(guildId) - 1n),
};

View File

@@ -70,10 +70,19 @@ export interface APIApplicationCommand {
* The parameters for the `CHAT_INPUT` command, max 25
*/
options?: APIApplicationCommandOption[];
/**
* Set of permissions represented as a bitset
*/
default_member_permissions: Permissions | null;
/**
* Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible
*/
dm_permission?: boolean;
/**
* Whether the command is enabled by default when the app is added to a guild
*
* If missing, this property should be assumed as `true`
* @deprecated Use `dm_permission` and/or `default_member_permissions` instead
*/
default_permission?: boolean;
/**

View File

@@ -53,6 +53,12 @@ export interface APIApplication {
* See https://discord.com/developers/docs/resources/user#user-object
*/
owner?: APIUser;
/**
* An empty string
*
* @deprecated This field will be removed in v11
*/
summary: string;
/**
* The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function
*

View File

@@ -16,6 +16,7 @@ import type {
GuildScheduledEventEntityType,
GuildScheduledEventStatus,
} from './guildScheduledEvent';
import type { APIApplicationCommand } from './interactions';
import type { APIRole } from './permissions';
import type { StageInstancePrivacyLevel } from './stageInstance';
import type { StickerFormatType } from './sticker';
@@ -27,6 +28,12 @@ import type { Snowflake } from '../../globals';
* https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure
*/
export interface APIAuditLog {
/**
* List of application commands found in the audit log
*
* See https://discord.com/developers/docs/interactions/application-commands#application-command-object
*/
application_commands: APIApplicationCommand[];
/**
* Webhooks found in the audit log
*
@@ -171,6 +178,8 @@ export enum AuditLogEvent {
ThreadCreate = 110,
ThreadUpdate,
ThreadDelete,
ApplicationCommandPermissionUpdate = 121,
}
/**
@@ -517,6 +526,12 @@ export type APIAuditLogChangeKeyPermissions = AuditLogChangeData<'permissions',
*/
export type APIAuditLogChangeKeyColor = AuditLogChangeData<'color', number>;
/**
* Represents a change where the key is a snowflake.
* Currently, the only known instance of this is returned when permissions for a command were updated (<insert name of object here>)
*/
export type APIAuditLogChangeKeySnowflake = AuditLogChangeData<Snowflake, unknown>;
/**
* Returned when a role's hoist status is changed
*/

View File

@@ -770,10 +770,6 @@ export interface APIThreadList {
* The members for the client user in each of the fetched threads
*/
members: APIThreadMember[];
/**
* Whether there are potentially additional threads
*/
has_more?: boolean;
}
/**

View File

@@ -127,6 +127,7 @@ export interface GatewayPresenceClientStatus {
export interface GatewayActivity {
/**
* The activity's id
* @unstable
*/
id: string;
/**
@@ -151,8 +152,16 @@ export interface GatewayActivity {
* Unix timestamps for start and/or end of the game
*/
timestamps?: GatewayActivityTimestamps;
/**
* The Spotify song id
* @unstable
*/
sync_id?: string;
platform?: ActivityPlatform;
/**
* The platform this activity is being done on
* @unstable You can use {@link ActivityPlatform} as a stepping stone, but this might be inaccurate
*/
platform?: string;
/**
* Application id for the game
*/
@@ -171,6 +180,9 @@ export interface GatewayActivity {
* See https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji
*/
emoji?: GatewayActivityEmoji;
/**
* @unstable
*/
session_id?: string;
/**
* Information for the current party of the player
@@ -208,10 +220,19 @@ export interface GatewayActivity {
buttons?: string[] | GatewayActivityButton[];
}
/**
* @unstable This enum is currently not documented by Discord but has known values which we will try to keep up to date.
* Values might be added or removed without a major version bump.
*/
export enum ActivityPlatform {
Desktop = 'desktop',
Samsung = 'samsung',
Xbox = 'xbox',
Samsung = 'samsung',
IOS = 'ios',
Android = 'android',
Embedded = 'embedded',
PS4 = 'ps4',
PS5 = 'ps5',
}
/**

View File

@@ -2,15 +2,11 @@
* Types extracted from https://discord.com/developers/docs/resources/guild
*/
import type { APIChannel } from './channel';
import type { APIEmoji } from './emoji';
import type { GatewayPresenceUpdate, PresenceUpdateStatus } from './gateway';
import type { APIGuildScheduledEvent } from './guildScheduledEvent';
import type { PresenceUpdateStatus } from './gateway';
import type { APIRole } from './permissions';
import type { APIStageInstance } from './stageInstance';
import type { APISticker } from './sticker';
import type { APIUser } from './user';
import type { GatewayVoiceState } from './voice';
import type { Permissions, Snowflake } from '../../globals';
/**
@@ -196,64 +192,6 @@ export interface APIGuild extends APIPartialGuild {
* The id of the channel where Community guilds can display rules and/or guidelines
*/
rules_channel_id: Snowflake | null;
/**
* When this guild was joined at
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
joined_at?: string;
/**
* `true` if this is considered a large guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
large?: boolean;
/**
* Total number of members in this guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
member_count?: number;
/**
* States of members currently in voice channels; lacks the `guild_id` key
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/voice#voice-state-object
*/
voice_states?: Omit<GatewayVoiceState, 'guild_id'>[];
/**
* Users in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/guild#guild-member-object
*/
members?: APIGuildMember[];
/**
* Channels in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
channels?: APIChannel[];
/**
* Threads in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
threads?: APIChannel[];
/**
* Presences of the members in the guild, will only include non-offline members if the size is greater than `large_threshold`
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/topics/gateway#presence-update
*/
presences?: GatewayPresenceUpdate[];
/**
* The maximum number of presences for the guild (`null` is always returned, apart from the largest of guilds)
*/
@@ -320,14 +258,6 @@ export interface APIGuild extends APIPartialGuild {
* See https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level
*/
nsfw_level: GuildNSFWLevel;
/**
* The stage instances in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-stage-instance-structure
*/
stage_instances?: APIStageInstance[];
/**
* Custom guild stickers
*
@@ -338,14 +268,6 @@ export interface APIGuild extends APIPartialGuild {
* Whether the guild has the boost progress bar enabled.
*/
premium_progress_bar_enabled: boolean;
/**
* The scheduled events in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object
*/
guild_scheduled_events?: APIGuildScheduledEvent[];
/**
* The type of Student Hub the guild is
*/
@@ -536,14 +458,6 @@ export enum GuildFeature {
* Guild is able to set role icons
*/
RoleIcons = 'ROLE_ICONS',
/**
* Guild has access to the seven day archive time for threads
*/
SevenDayThreadArchive = 'SEVEN_DAY_THREAD_ARCHIVE',
/**
* Guild has access to the three day archive time for threads
*/
ThreeDayThreadArchive = 'THREE_DAY_THREAD_ARCHIVE',
/**
* Guild has enabled ticketed events
*/
@@ -715,7 +629,7 @@ export interface APIGuildIntegration {
/**
* Is this integration enabled
*/
enabled: boolean;
enabled?: boolean;
/**
* Is this integration syncing
*

View File

@@ -14,6 +14,10 @@ export enum OAuth2Scopes {
* See https://discord.com/developers/docs/resources/user#get-user-connections
*/
Connections = 'connections',
/**
* Allows your app to see information about the user's DMs and group DMs - requires Discord approval
*/
DMChannelsRead = 'dm_channels.read',
/**
* Enables [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) to return an `email`
*
@@ -69,6 +73,10 @@ export enum OAuth2Scopes {
* This generates a webhook that is returned in the oauth token response for authorization code grants
*/
WebhookIncoming = 'webhook.incoming',
/**
* Allows your app to connect to voice on user's behalf and see all the voice members - requires Discord approval
*/
Voice = 'voice',
/**
* Allows your app to upload/update builds for a user's applications - requires Discord approval
*/
@@ -111,4 +119,10 @@ export enum OAuth2Scopes {
* See https://discord.com/developers/docs/interactions/application-commands
*/
ApplicationsCommandsUpdate = 'applications.commands.update',
/**
* Allows your app to update permissions for its commands using a Bearer token - client credentials grant only
*
* See https://discord.com/developers/docs/interactions/application-commands
*/
ApplicationCommandsPermissionsUpdate = 'applications.commands.permissions.update',
}

View File

@@ -5,7 +5,7 @@ import type { Snowflake } from '../../../../globals';
*/
export interface APIGuildApplicationCommandPermissions {
/**
* The id of the command
* The id of the command or the application id if that permission applies to all commands
*/
id: Snowflake;
/**
@@ -27,11 +27,11 @@ export interface APIGuildApplicationCommandPermissions {
*/
export interface APIApplicationCommandPermission {
/**
* The id of the role or user
* The id of the role, user or channel. Can also be a permission constant
*/
id: Snowflake;
/**
* Role or user
* Role, user or channel
*/
type: ApplicationCommandPermissionType;
/**
@@ -46,4 +46,13 @@ export interface APIApplicationCommandPermission {
export enum ApplicationCommandPermissionType {
Role = 1,
User,
Channel,
}
/**
* https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-constants
*/
export const APIApplicationCommandPermissionsConstant = {
Everyone: (guildId: string | bigint): Snowflake => String(guildId),
AllChannels: (guildId: string | bigint): Snowflake => String(BigInt(guildId) - 1n),
};

View File

@@ -70,10 +70,19 @@ export interface APIApplicationCommand {
* The parameters for the `CHAT_INPUT` command, max 25
*/
options?: APIApplicationCommandOption[];
/**
* Set of permissions represented as a bitset
*/
default_member_permissions: Permissions | null;
/**
* Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible
*/
dm_permission?: boolean;
/**
* Whether the command is enabled by default when the app is added to a guild
*
* If missing, this property should be assumed as `true`
* @deprecated Use `dm_permission` and/or `default_member_permissions` instead
*/
default_permission?: boolean;
/**

View File

@@ -53,6 +53,12 @@ export interface APIApplication {
* See https://discord.com/developers/docs/resources/user#user-object
*/
owner?: APIUser;
/**
* An empty string
*
* @deprecated This field will be removed in v11
*/
summary: string;
/**
* The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function
*

View File

@@ -16,6 +16,7 @@ import type {
GuildScheduledEventEntityType,
GuildScheduledEventStatus,
} from './guildScheduledEvent';
import type { APIApplicationCommand } from './interactions';
import type { APIRole } from './permissions';
import type { StageInstancePrivacyLevel } from './stageInstance';
import type { StickerFormatType } from './sticker';
@@ -27,6 +28,12 @@ import type { Snowflake } from '../../globals';
* https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure
*/
export interface APIAuditLog {
/**
* List of application commands found in the audit log
*
* See https://discord.com/developers/docs/interactions/application-commands#application-command-object
*/
application_commands: APIApplicationCommand[];
/**
* Webhooks found in the audit log
*
@@ -171,6 +178,8 @@ export enum AuditLogEvent {
ThreadCreate = 110,
ThreadUpdate,
ThreadDelete,
ApplicationCommandPermissionUpdate = 121,
}
/**
@@ -517,6 +526,12 @@ export type APIAuditLogChangeKeyPermissions = AuditLogChangeData<'permissions',
*/
export type APIAuditLogChangeKeyColor = AuditLogChangeData<'color', number>;
/**
* Represents a change where the key is a snowflake.
* Currently, the only known instance of this is returned when permissions for a command were updated (<insert name of object here>)
*/
export type APIAuditLogChangeKeySnowflake = AuditLogChangeData<Snowflake, unknown>;
/**
* Returned when a role's hoist status is changed
*/

View File

@@ -152,7 +152,10 @@ export interface GatewayActivity {
*/
timestamps?: GatewayActivityTimestamps;
sync_id?: string;
platform?: ActivityPlatform;
/**
* {@link ActivityPlatform}
*/
platform?: string;
/**
* Application id for the game
*/
@@ -208,10 +211,19 @@ export interface GatewayActivity {
buttons?: string[] | GatewayActivityButton[];
}
/**
* @unstable This enum is currently not documented by Discord but has known values which we will try to keep up to date.
* Values might be added or removed without a major version bump.
*/
export enum ActivityPlatform {
Desktop = 'desktop',
Samsung = 'samsung',
Xbox = 'xbox',
Samsung = 'samsung',
IOS = 'ios',
Android = 'android',
Embedded = 'embedded',
PS4 = 'ps4',
PS5 = 'ps5',
}
/**

View File

@@ -2,15 +2,11 @@
* Types extracted from https://discord.com/developers/docs/resources/guild
*/
import type { APIChannel } from './channel';
import type { APIEmoji } from './emoji';
import type { GatewayPresenceUpdate, PresenceUpdateStatus } from './gateway';
import type { APIGuildScheduledEvent } from './guildScheduledEvent';
import type { PresenceUpdateStatus } from './gateway';
import type { APIRole } from './permissions';
import type { APIStageInstance } from './stageInstance';
import type { APISticker } from './sticker';
import type { APIUser } from './user';
import type { GatewayVoiceState } from './voice';
import type { Permissions, Snowflake } from '../../globals';
/**
@@ -196,64 +192,6 @@ export interface APIGuild extends APIPartialGuild {
* The id of the channel where Community guilds can display rules and/or guidelines
*/
rules_channel_id: Snowflake | null;
/**
* When this guild was joined at
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
joined_at?: string;
/**
* `true` if this is considered a large guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
large?: boolean;
/**
* Total number of members in this guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*/
member_count?: number;
/**
* States of members currently in voice channels; lacks the `guild_id` key
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/voice#voice-state-object
*/
voice_states?: Omit<GatewayVoiceState, 'guild_id'>[];
/**
* Users in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/guild#guild-member-object
*/
members?: APIGuildMember[];
/**
* Channels in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
channels?: APIChannel[];
/**
* Threads in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
threads?: APIChannel[];
/**
* Presences of the members in the guild, will only include non-offline members if the size is greater than `large_threshold`
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/topics/gateway#presence-update
*/
presences?: GatewayPresenceUpdate[];
/**
* The maximum number of presences for the guild (`null` is always returned, apart from the largest of guilds)
*/
@@ -320,14 +258,6 @@ export interface APIGuild extends APIPartialGuild {
* See https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level
*/
nsfw_level: GuildNSFWLevel;
/**
* The stage instances in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-stage-instance-structure
*/
stage_instances?: APIStageInstance[];
/**
* Custom guild stickers
*
@@ -338,14 +268,6 @@ export interface APIGuild extends APIPartialGuild {
* Whether the guild has the boost progress bar enabled.
*/
premium_progress_bar_enabled: boolean;
/**
* The scheduled events in the guild
*
* **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#guild-create) event**
*
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object
*/
guild_scheduled_events?: APIGuildScheduledEvent[];
/**
* The type of Student Hub the guild is
*/
@@ -536,14 +458,6 @@ export enum GuildFeature {
* Guild is able to set role icons
*/
RoleIcons = 'ROLE_ICONS',
/**
* Guild has access to the seven day archive time for threads
*/
SevenDayThreadArchive = 'SEVEN_DAY_THREAD_ARCHIVE',
/**
* Guild has access to the three day archive time for threads
*/
ThreeDayThreadArchive = 'THREE_DAY_THREAD_ARCHIVE',
/**
* Guild has enabled ticketed events
*/
@@ -715,7 +629,7 @@ export interface APIGuildIntegration {
/**
* Is this integration enabled
*/
enabled: boolean;
enabled?: boolean;
/**
* Is this integration syncing
*

View File

@@ -14,6 +14,10 @@ export enum OAuth2Scopes {
* See https://discord.com/developers/docs/resources/user#get-user-connections
*/
Connections = 'connections',
/**
* Allows your app to see information about the user's DMs and group DMs - requires Discord approval
*/
DMChannelsRead = 'dm_channels.read',
/**
* Enables [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) to return an `email`
*
@@ -69,6 +73,10 @@ export enum OAuth2Scopes {
* This generates a webhook that is returned in the oauth token response for authorization code grants
*/
WebhookIncoming = 'webhook.incoming',
/**
* Allows your app to connect to voice on user's behalf and see all the voice members - requires Discord approval
*/
Voice = 'voice',
/**
* Allows your app to upload/update builds for a user's applications - requires Discord approval
*/
@@ -111,4 +119,10 @@ export enum OAuth2Scopes {
* See https://discord.com/developers/docs/interactions/application-commands
*/
ApplicationsCommandsUpdate = 'applications.commands.update',
/**
* Allows your app to update permissions for its commands using a Bearer token - client credentials grant only
*
* See https://discord.com/developers/docs/interactions/application-commands
*/
ApplicationCommandsPermissionsUpdate = 'applications.commands.permissions.update',
}

View File

@@ -179,7 +179,8 @@ export enum RESTJSONErrorCodes {
CannotDeleteChannelRequiredForCommunityGuilds = 50074,
InvalidStickerSent = 50081,
CannotEditStickersWithinMessage = 50080,
InvalidStickerSent,
InvalidActionOnArchivedThread = 50083,
InvalidThreadNotificationSettings,
@@ -194,6 +195,8 @@ export enum RESTJSONErrorCodes {
RequestBodyContainsInvalidJSON = 50109,
YouDoNotHavePermissionToSendThisSticker = 50600,
TwoFactorAuthenticationIsRequired = 60003,
NoUsersWithDiscordTagExist = 80004,

View File

@@ -584,13 +584,22 @@ export type RESTPostAPIChannelMessagesThreadsJSONBody = AddUndefinedToPossiblyUn
/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody &
RESTPostAPIChannelMessageJSONBody;
export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody & {
/**
* First message in the forum thread
*/
message: RESTPostAPIChannelMessageJSONBody;
};
/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsFormDataBody = RESTPostAPIChannelMessageFormDataBody;
export type RESTPostAPIGuildForumThreadsFormDataBody = RESTPostAPIChannelMessagesThreadsJSONBody & {
/**
* First message in the forum thread
*/
message: string;
};
/**
* https://discord.com/developers/docs/resources/channel#start-thread-from-message

View File

@@ -41,7 +41,17 @@ export type APIGuildChannelResolvable = Exclude<APIChannel, APIDMChannel | APIGr
export type APIGuildCreatePartialChannel = StrictPartial<
DistributivePick<
APIGuildChannelResolvable,
'type' | 'topic' | 'nsfw' | 'bitrate' | 'user_limit' | 'rate_limit_per_user' | 'default_auto_archive_duration'
| 'type'
| 'topic'
| 'nsfw'
| 'bitrate'
| 'user_limit'
| 'rate_limit_per_user'
| 'default_auto_archive_duration'
| 'position'
| 'rtc_region'
| 'video_quality_mode'
| 'flags'
>
> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
@@ -331,7 +341,7 @@ export type RESTPatchAPIGuildChannelPositionsResult = never;
/**
* https://discord.com/developers/docs/resources/guild#list-active-threads
*/
export type RESTGetAPIGuildThreadsResult = Omit<APIThreadList, 'has_more'>;
export type RESTGetAPIGuildThreadsResult = APIThreadList;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-member
@@ -820,6 +830,9 @@ export type RESTPatchAPIGuildMemberVerificationJSONBody = AddUndefinedToPossibly
export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state
*/
export type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
@@ -835,6 +848,14 @@ export type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = AddUndefinedToPos
request_to_speak_timestamp?: string | null;
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state
*/
export type RESTPatchAPIGuildVoiceStateCurrentMemberResult = never;
/**
* https://discord.com/developers/docs/resources/guild#modify-user-voice-state
*/
export type RESTPatchAPIGuildVoiceStateUserJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
@@ -861,3 +882,8 @@ export type RESTPatchAPIGuildWelcomeScreenJSONBody = Nullable<StrictPartial<APIG
*/
enabled?: boolean | null;
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
*/
export type RESTPatchAPIGuildWelcomeScreenResult = APIGuildWelcomeScreen;

View File

@@ -37,7 +37,9 @@ type RESTPostAPIBaseApplicationCommandsJSONBody = AddUndefinedToPossiblyUndefine
| 'guild_id'
| 'name_localized'
| 'description_localized'
>
| 'default_member_permissions'
> &
Partial<Pick<APIApplicationCommand, 'default_member_permissions'>>
>;
/**
@@ -91,42 +93,50 @@ export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[];
/**
* https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands
*/
export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[];
export type RESTGetAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>[];
/**
* https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands
*/
export type RESTGetAPIApplicationGuildCommandResult = APIApplicationCommand;
export type RESTGetAPIApplicationGuildCommandResult = Omit<APIApplicationCommand, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
*/
export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody;
export type RESTPostAPIApplicationGuildCommandsJSONBody =
| Omit<RESTPostAPIChatInputApplicationCommandsJSONBody, 'dm_permission'>
| Omit<RESTPostAPIContextMenuApplicationCommandsJSONBody, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
*/
export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand;
export type RESTPostAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial<RESTPostAPIApplicationCommandsJSONBody>;
export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial<
| Omit<RESTPostAPIChatInputApplicationCommandsJSONBody, 'dm_permission'>
| Omit<RESTPostAPIContextMenuApplicationCommandsJSONBody, 'dm_permission'>
>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandResult = APIApplicationCommand;
export type RESTPatchAPIApplicationGuildCommandResult = Omit<APIApplicationCommand, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
*/
export type RESTPutAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[];
export type RESTPutAPIApplicationGuildCommandsJSONBody = (
| Omit<RESTPostAPIChatInputApplicationCommandsJSONBody, 'dm_permission'>
| Omit<RESTPostAPIContextMenuApplicationCommandsJSONBody, 'dm_permission'>
)[];
/**
* https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
*/
export type RESTPutAPIApplicationGuildCommandsResult = APIApplicationCommand[];
export type RESTPutAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>[];
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response

View File

@@ -598,13 +598,22 @@ export type RESTPostAPIChannelMessagesThreadsJSONBody = AddUndefinedToPossiblyUn
/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody &
RESTPostAPIChannelMessageJSONBody;
export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody & {
/**
* First message in the forum thread
*/
message: RESTPostAPIChannelMessageJSONBody;
};
/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsFormDataBody = RESTPostAPIChannelMessageFormDataBody;
export type RESTPostAPIGuildForumThreadsFormDataBody = RESTPostAPIChannelMessagesThreadsJSONBody & {
/**
* First message in the forum thread
*/
message: string;
};
/**
* https://discord.com/developers/docs/resources/channel#start-thread-from-message

View File

@@ -41,7 +41,17 @@ export type APIGuildChannelResolvable = Exclude<APIChannel, APIDMChannel | APIGr
export type APIGuildCreatePartialChannel = StrictPartial<
DistributivePick<
APIGuildChannelResolvable,
'type' | 'topic' | 'nsfw' | 'bitrate' | 'user_limit' | 'rate_limit_per_user' | 'default_auto_archive_duration'
| 'type'
| 'topic'
| 'nsfw'
| 'bitrate'
| 'user_limit'
| 'rate_limit_per_user'
| 'default_auto_archive_duration'
| 'position'
| 'rtc_region'
| 'video_quality_mode'
| 'flags'
>
> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
@@ -826,6 +836,9 @@ export type RESTPatchAPIGuildMemberVerificationJSONBody = AddUndefinedToPossibly
export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state
*/
export type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
@@ -841,6 +854,14 @@ export type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = AddUndefinedToPos
request_to_speak_timestamp?: string | null;
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state
*/
export type RESTPatchAPIGuildVoiceStateCurrentMemberResult = never;
/**
* https://discord.com/developers/docs/resources/guild#modify-user-voice-state
*/
export type RESTPatchAPIGuildVoiceStateUserJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
@@ -867,3 +888,8 @@ export type RESTPatchAPIGuildWelcomeScreenJSONBody = Nullable<StrictPartial<APIG
*/
enabled?: boolean | null;
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
*/
export type RESTPatchAPIGuildWelcomeScreenResult = APIGuildWelcomeScreen;

View File

@@ -37,7 +37,9 @@ type RESTPostAPIBaseApplicationCommandsJSONBody = AddUndefinedToPossiblyUndefine
| 'guild_id'
| 'name_localized'
| 'description_localized'
>
| 'default_member_permissions'
> &
Partial<Pick<APIApplicationCommand, 'default_member_permissions'>>
>;
/**
@@ -91,42 +93,50 @@ export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[];
/**
* https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands
*/
export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[];
export type RESTGetAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>[];
/**
* https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands
*/
export type RESTGetAPIApplicationGuildCommandResult = APIApplicationCommand;
export type RESTGetAPIApplicationGuildCommandResult = Omit<APIApplicationCommand, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
*/
export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody;
export type RESTPostAPIApplicationGuildCommandsJSONBody =
| Omit<RESTPostAPIChatInputApplicationCommandsJSONBody, 'dm_permission'>
| Omit<RESTPostAPIContextMenuApplicationCommandsJSONBody, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
*/
export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand;
export type RESTPostAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial<RESTPostAPIApplicationCommandsJSONBody>;
export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial<
| Omit<RESTPostAPIChatInputApplicationCommandsJSONBody, 'dm_permission'>
| Omit<RESTPostAPIContextMenuApplicationCommandsJSONBody, 'dm_permission'>
>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandResult = APIApplicationCommand;
export type RESTPatchAPIApplicationGuildCommandResult = Omit<APIApplicationCommand, 'dm_permission'>;
/**
* https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
*/
export type RESTPutAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[];
export type RESTPutAPIApplicationGuildCommandsJSONBody = (
| Omit<RESTPostAPIChatInputApplicationCommandsJSONBody, 'dm_permission'>
| Omit<RESTPostAPIContextMenuApplicationCommandsJSONBody, 'dm_permission'>
)[];
/**
* https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
*/
export type RESTPutAPIApplicationGuildCommandsResult = APIApplicationCommand[];
export type RESTPutAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>[];
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response

View File

@@ -5,6 +5,10 @@ import { Octokit } from '@octokit/action';
const packageJson = JSON.parse(await readFile(new URL('../../package.json', import.meta.url), { encoding: 'utf8' }));
const octokit = new Octokit();
const [OWNER, REPOSITORY] = process.env.GITHUB_REPOSITORY.split('/');
const prPattern = new RegExp(
`\\(\\[#(?<prNumber>\\d+)\\]\\(https:\\/\\/github\\.com\\/${OWNER}\\/${REPOSITORY}\\/(?:issues|pulls)\\/(?:\\d+)\\)\\)`,
'gi',
);
console.log('👀 Getting the previous release version');
const previousReleases = await octokit.repos.listReleases({
@@ -19,6 +23,8 @@ console.log('👀 Previous release version:', previousRelease?.tag_name);
const releaseChangelog = [];
const changelogContent = await readFile(new URL('../../CHANGELOG.md', import.meta.url), { encoding: 'utf8' });
let contentToParseAndAdd = '';
if (previousRelease) {
// find difference between previous release and current version
const maybeMinorIndex = changelogContent.indexOf(`## [${previousRelease.tag_name}](https://github.com`);
@@ -26,14 +32,32 @@ if (previousRelease) {
if (maybeMinorIndex === -1) {
// find major version
const maybeMajorIndex = changelogContent.indexOf(`# [${previousRelease.tag_name}](https://github.com`);
releaseChangelog.push(changelogContent.slice(0, maybeMajorIndex));
contentToParseAndAdd = changelogContent.slice(0, maybeMajorIndex);
} else {
releaseChangelog.push(changelogContent.slice(0, maybeMinorIndex));
contentToParseAndAdd = changelogContent.slice(0, maybeMinorIndex);
}
} else {
releaseChangelog.push(changelogContent);
contentToParseAndAdd = changelogContent;
}
for (const [input, prNumber] of contentToParseAndAdd.matchAll(prPattern)) {
try {
const prData = await octokit.pulls.get({
owner: OWNER,
repo: REPOSITORY,
pull_number: Number(prNumber),
});
const replaced = input.replace('))', `) by @${prData.data.user?.login ?? 'ghost'})`);
contentToParseAndAdd = contentToParseAndAdd.replace(input, replaced);
} catch (err) {
console.error(`Failed to fetch PR #${prNumber}`, err);
}
}
releaseChangelog.push(contentToParseAndAdd);
const { data } = await octokit.repos.generateReleaseNotes({
owner: OWNER,
repo: REPOSITORY,

View File

@@ -0,0 +1,19 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
import { execSync } from 'node:child_process';
import { readFile, writeFile } from 'node:fs/promises';
const cwd = new URL('../website/', import.meta.url);
const json = JSON.parse(await readFile(new URL('../package.json', import.meta.url), { encoding: 'utf8' }));
console.log(`⌛ Creating website version for ${json.version}`);
execSync(`npm run docusaurus docs:version ${json.version}`, { cwd, encoding: 'utf8' });
execSync(`npm run docusaurus api:version ${json.version}`, { cwd, encoding: 'utf8' });
const bigJsonPath = new URL(`../website/versioned_docs/version-${json.version}/api-typedoc.json`, import.meta.url);
const parsed = JSON.parse(await readFile(bigJsonPath, { encoding: 'utf8' }));
await writeFile(bigJsonPath, JSON.stringify(parsed));
console.log(`✅ Done! Website version created for ${json.version}`);

View File

@@ -17,6 +17,7 @@
"voice/**/*.ts",
"scripts",
"deno",
"tests/**/*.ts"
"tests/**/*.ts",
"website"
]
}

22
website/.editorconfig Normal file
View File

@@ -0,0 +1,22 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{js,mjs,ts}]
indent_size = 4
indent_style = tab
block_comment_start = /*
block_comment = *
block_comment_end = */
[*.{yml,yaml}]
indent_size = 2
indent_style = space
[*.{md,rmd,mkd,mkdn,mdwn,mdown,markdown,litcoffee}]
tab_width = 4
trim_trailing_whitespace = false

13
website/.eslintignore Normal file
View File

@@ -0,0 +1,13 @@
# Node modules
node_modules/
# Submodules
projects/
# Generated data
docs/Documentation/
.docusaurus/
src/index.d.ts
docs/Guide/code/

141
website/.eslintrc Normal file
View File

@@ -0,0 +1,141 @@
{
"root": true,
"extends": ["marine/prettier/react", "plugin:import/typescript"],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
},
"jsx": true,
"project": "./tsconfig.eslint.json"
},
"plugins": ["import", "jsx-a11y", "react", "react-hooks"],
"settings": {
"react": {
"version": "detect"
}
},
"overrides": [
{
"files": ["docusaurus.config.js", "babel.config.js", "sidebars.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-require-imports": "off"
}
}
],
"rules": {
"no-extra-label": "warn",
"no-iterator": "warn",
"no-label-var": "warn",
"no-labels": [
"warn",
{
"allowLoop": true,
"allowSwitch": true
}
],
"no-lone-blocks": "warn",
"no-loop-func": "warn",
"no-mixed-operators": [
"warn",
{
"groups": [
["&", "|", "^", "~", "<<", ">>", ">>>"],
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
["&&", "||"],
["in", "instanceof"]
],
"allowSamePrecedence": false
}
],
"no-multi-str": "warn",
"rest-spread-spacing": ["warn", "never"],
"no-restricted-properties": [
"error",
{
"object": "require",
"property": "ensure",
"message": "Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting"
},
{
"object": "System",
"property": "import",
"message": "Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting"
}
],
"getter-return": "warn",
"import/first": "error",
"import/no-amd": "error",
"import/no-webpack-loader-syntax": "error",
"react/forbid-foreign-prop-types": [
"warn",
{
"allowInPropTypes": true
}
],
"react/jsx-no-comment-textnodes": "warn",
"react/jsx-no-duplicate-props": "warn",
"react/jsx-no-target-blank": "warn",
"react/jsx-no-undef": "error",
"react/jsx-pascal-case": [
"warn",
{
"allowAllCaps": true,
"ignore": []
}
],
"react/jsx-uses-react": "warn",
"react/jsx-uses-vars": "warn",
"react/no-children-prop": "warn",
"react/no-access-state-in-setstate": "warn",
"react/no-danger": "error",
"react/no-danger-with-children": "warn",
"react/no-direct-mutation-state": "warn",
"react/no-is-mounted": "warn",
"react/no-this-in-sfc": "warn",
"react/no-typos": "error",
"react/react-in-jsx-scope": "error",
"react/require-render-return": "error",
"react/style-prop-object": "warn",
"react/void-dom-elements-no-children": "warn",
"react/jsx-filename-extension": [
"error",
{
"extensions": [".jsx", ".tsx"]
}
],
"jsx-a11y/accessible-emoji": "warn",
"jsx-a11y/alt-text": "warn",
"jsx-a11y/anchor-has-content": "warn",
"jsx-a11y/anchor-is-valid": [
"warn",
{
"aspects": ["noHref", "invalidHref"]
}
],
"jsx-a11y/aria-activedescendant-has-tabindex": "warn",
"jsx-a11y/aria-props": "warn",
"jsx-a11y/aria-proptypes": "warn",
"jsx-a11y/aria-role": [
"warn",
{
"ignoreNonDOM": true
}
],
"jsx-a11y/aria-unsupported-elements": "warn",
"jsx-a11y/heading-has-content": "warn",
"jsx-a11y/iframe-has-title": "warn",
"jsx-a11y/img-redundant-alt": "warn",
"jsx-a11y/no-access-key": "warn",
"jsx-a11y/no-distracting-elements": "warn",
"jsx-a11y/no-redundant-roles": "warn",
"jsx-a11y/role-has-required-aria-props": "warn",
"jsx-a11y/role-supports-aria-props": "warn",
"jsx-a11y/scope": "warn",
"react-hooks/exhaustive-deps": "warn",
"react-hooks/rules-of-hooks": "error"
}
}

33
website/.gitignore vendored Normal file
View File

@@ -0,0 +1,33 @@
# Dependencies
node_modules/
.pnp/
# Yarn files
.yarn/install-state.gz
.yarn/build-state.yml
# Production
build/
# Generated Files
.docusaurus/
.cache-loader/
docs/Documentation/
tsconfig.tsbuildinfo
# misc
.DS_Store
Thumbs.db
# Local env vars
.env
# IDE Settings
.idea/
.vs/
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*.log

View File

@@ -0,0 +1,14 @@
{
"config": {
"default": false,
"MD001": true,
"MD003": true,
"MD009": true,
"MD011": true,
"MD012": true,
"MD013": {
"line_length": 120
}
},
"globs": ["docs/**/*.{md,mdx}"]
}

10
website/.prettierignore Normal file
View File

@@ -0,0 +1,10 @@
# Node modules
node_modules/
# Generated data
.docusaurus/
# Versioned json
versioned_sidebars/
versioned_docs/
versions.json

17
website/.prettierrc.js Normal file
View File

@@ -0,0 +1,17 @@
const sapphirePrettierConfig = require('@sapphire/prettier-config');
module.exports = {
...sapphirePrettierConfig,
overrides: [
...sapphirePrettierConfig.overrides,
{
files: ['README.md', 'docs/**/*.mdx', 'docs/**/*.md'],
options: {
tabWidth: 2,
useTabs: false,
printWidth: 120,
proseWrap: 'always'
}
}
]
};

13
website/.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,13 @@
{
"recommendations": [
"bierner.github-markdown-preview",
"christian-kohler.path-intellisense",
"davidanson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"mdickin.markdown-shortcuts",
"silvenon.mdx",
"streetsidesoftware.code-spell-checker",
"usernamehw.errorlens"
]
}

19
website/.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,19 @@
{
"editor.detectIndentation": true,
"files.eol": "\n",
"files.associations": {
"*.mdx": "markdown"
},
"cSpell.language": "en-US",
"cSpell.maxNumberOfProblems": 8,
"cSpell.numSuggestions": 24,
"search.exclude": {
"**/.docusaurus/": true,
"**/.git/": true,
"**/.yarn": true,
"**/*.code-search": true,
"**/bower_components": true,
"**/node_modules": true,
"**/projects/": true
}
}

24
website/LICENSE.md Normal file
View File

@@ -0,0 +1,24 @@
# The MIT License (MIT)
Copyright © `2020` `The Sapphire Community and its contributors`
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.

27
website/README.md Normal file
View File

@@ -0,0 +1,27 @@
<div align="center">
# Discord API Types Website
**Source code for the Discord API Types website.**
_Code is forked from the Sapphire Community's Website under the MIT license_
[![GitHub](https://img.shields.io/github/license/sapphiredev/website)](https://github.com/discordjs/discord-api-types/blob/main/website/LICENSE.md)
</div>
## Running locally
After forking/cloning this repo to a folder locally:
1. Install dependencies with `npm ci`.
2. Run `npm run start` to start the dev server
## Special thanks
This project is being hosted by the amazing team at [Vercel]. We use their service to ensure you always get the latest
version of the documentation, as well as being able to preview builds internally. Thank you [Vercel]!
[![Vercel](./static/powered-by-vercel.svg)][vercel]
[vercel]: https://vercel.com?utm_source=sapphiredev&utm_campaign=oss

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Facebook, Inc. and its affiliates.
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.

3
website/babel.config.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')]
};

View File

@@ -0,0 +1,263 @@
---
id: contributing_to_discord-api-types
title: How to Contribute
sidebar_position: 1
---
So, you'd like to contribute to `discord-api-types` but don't know where to start or what to do? Here are some of the
things you need to keep in mind before opening a pull request!
:::tip Before you begin
We recommend you contribute either through locally editing the files on your desktop (which means also installing
[`npm`](https://www.npmjs.com/) dependencies as this will ensure not only a consistent code style, but also that the
`deno` types stay in sync automatically) or through a service like
[`GitHub Codespaces`](https://github.com/features/codespaces).
:::
:::info Still can't figure it out?
No problem! We await you with open hands in our [`Discord Server`](https://discord.gg/djs) in the `#discord-api-types`
channel (under the `Miscellaneous` category)
:::
### Install npm dependencies first
One of the most crucial steps is installing [`npm`](https://www.npmjs.com/) dependencies via `npm ci`. This ensures that
linting can be done, and it also sets up the `git` hooks for building the `deno` types and automatically
formatting/linting the code when you commit it.
If you forget to install [`npm`](https://www.npmjs.com/) dependencies, or are doing the contributions through other
means (like directly from GitHub web), you might see a comment like this one being sent as a review to your pull
request:
![An image showing the style of comment the automatic deno checker reports](./images/deno_types_out_of_sync.png)
The easiest way to solve this is to run the `build:deno` script (`npm run build:deno`) and pushing the results.
### Figure out if the update you want to contribute respects our rules about documentation
:::danger
We will not document client-only / client related types. If you plan on contributing, make sure the types you want to
document can be used by bots and are _intended_ for usage by bots. This is a hard rule that will never change.
:::
Not every single update to the API is valid to be documented here. Our main stance for documentation is that properties
must be known and documented on [`Discord's API Documentation repository`](https://github.com/discord/discord-api-docs),
must be mentioned in an open pull request or must have received the green light to be used.
With that aside, there are times where documentation for certain types is not approved/merged by Discord on the grounds
that `it isn't helpful for bots` (or similar), but it would actually benefit bot developers to have it documented (one
good example is the UserFlags `SPAMMER` flag). As such, if you think your update should still be merged, please propose
it and we will be handled on a case by case basis. If approved, your update will be documented with an `@unstable` tag.
It will also not be subject to the same versioning rules as the rest of the types.
### Figure out what API versions need to receive the update
`discord-api-types` has multiple API versions in the repository, some of which may be considered `deprecated` or
`discontinued` as we keep them till the version is completely dead before removing them. This is a good time to figure
out which API versions need to be updated, and you can use the table below to guide you.
You can also check [`Discord's API versioning table`](https://discord.com/developers/docs/reference#api-versioning) if
you want to be 1000% sure.
| **API Version** | **Should receive updates** |
| :-------------: | :------------------------: |
| 10 | Yes |
| 9 | Yes |
| 8 | No |
| 7 | No |
| 6 | No |
If the version you want to contribute to is not listed above (for instance if a new API version rolls out) or if the
version you want to contribute to is for a different part of the API (for instance `voice`), feel free to submit it and
we will review it accordingly.
### Figure out where exactly are the files you need to modify to make the update
The file structure might seem confusing at first, especially if it's your first time contributing, but we're here to
guide you through it.
When you clone the repository for the first time, you'll see a folder structure like this (we've not mentioned some
tooling specific files like `.eslintrc.json` to keep the structure clean). We've highlighted the important folders you
need to keep in mind when contributing.
```bash {5,7-9,12-13,15-19}
├── deno
├── gateway
├── node_modules (once you ran `npm ci`)
├── payloads
├── rest
├── rpc
├── scripts
├── tests
├── utils
├── voice
├── website
├── globals.ts
├── v6.ts
├── v8.ts
├── v9.ts
├── v10.ts
└── package.json
```
#### `deno`
This folder stores the [`deno`](https://deno.land/) compatible typings for Discord's API.
:::danger
This folder should not be manually modified. Any manual changes will be overwritten by the `build:deno` script.
Any changes that need to be done to this folder need to be done through the `scripts/deno.mjs` file.
:::
#### `gateway`
This folder holds types that are strictly received from
[`Discord's gateway`](https://discord.com/developers/docs/topics/gateway). It stores the gateway version the types are
for, the intents and opcodes, and any data that can be received/sent through the gateway.
Each file in the folder represents a gateway version. It references types from the versioned [`payloads`](#payloads)
folder unless the payloads come _only_ through the gateway. There is also a `common.ts` file which represents shared
types across all versions, as well as an `index.ts` file that exports the recommended gateway version's types.
:::info
Types created here must start with the `Gateway` prefix (for instance `GatewayGuildCreateDispatchData` which is an
extension of the `APIGuild` type with extra fields received only through the gateway).
:::
#### `payloads`
This folder holds the bulk of type definitions for Discord's APIs. Each API version receives its own folder. Inside of
each folder there is always an `index.ts` file that exports every type available in that version, as well as the common
types that can be found in `payloads/common.ts`. At the root of the `payloads` folder is also an `index.ts` file which
exports the recommended API version's types.
Inside of each versioned folder, the files are defined from the structure in
[`Discord's API Documentation`](https://discord.dev), under the `Resources` category. Depending on the complexity of the
resource, you may opt for splitting it up into multiple files. If you want to do so, please create a folder named
`_{resource_name}` where the `resource_name` is the same name as the resource you're splitting up (a good example is the
`_interactions` folder which stores all the types for interactions in a neater structure), and create a
`{resource_name}.ts` file which exports everything from that folder). If you feel like you need to split it up even
more, just repeat the same structure of creating an `_{file_name}` folder and exporting everything from it in the
`{file_name}.ts` file (you can see an example
[here](https://github.com/discordjs/discord-api-types/tree/85802f1/payloads/v10/_interactions)).
:::info
Types created here must start with the `API` prefix (for instance `APIUser`), **except** for enums, which should have a
normal name (for instance `UserFlags`).
:::
#### `rest`
This folder holds all the types that are related to Discord's REST API. Just like [`payloads`](#payloads), it is split
into folders that have an `index.ts` file. from the structure in [`Discord's API Documentation`](https://discord.dev),
under the `Resources` category.
:::info
Types created here must start with the `REST` prefix (for instance `RESTGetAPIUserResult`) unless they are objects or
enums (for instance `Routes`).
They must also follow the following structure: `REST{http_method}{type_name}{Query|(JSON|FormData)|Result}`, where:
- `http_method` is the PascalCase HTTP method name (for instance `Get`, `Post`, and so on)
- `type_name` is the actual name of the type it returns (for instance `APIUser`)
- `Query|(JSON|FormData)Body|Result` should be used depending on what the route takes or returns
- If a route doesn't take in any parameters, be it query, JSON or FormData, it shouldn't define any of those types
- A route should always define a `Result` type, and should reference an `API*` type unless the data returned is only
received through a REST call
- If a route returns a `204 No Content` response, it should define a `Result` type with `never` as its value (this
does not account for errors)
This structure should be followed whenever possible, however that might not always be doable. Specifically, types for
OAuth2 may not follow the structure exactly, but should aim to follow it as much as possible.
:::
#### `rpc`
This folder holds types that are strictly related to
[`Discord's RPC API`](https://discord.com/developers/docs/topics/rpc). Just like [`gateway`](#gateway), each RPC API
version receives its own file.
:::info
Types created here must start with the `RPC` prefix (for instance `RPCErrorCodes`).
:::
#### `scripts`
This folder holds the module's scripts that empower our Continuous Integration / Deployment pipelines, as well as other
miscellaneous scripts we might need. There's really not much to say about these really...
#### `tests`
This folder holds tests for certain complex types that the mdule might have, and is especially useful for validating
unions.
:::info
Files created here **must** end in `.test-d.ts`, as otherwise they will not be picked up by
[`tsd`](https://www.npmjs.com/package/tsd).
:::
#### `utils`
This folder holds certain utility functions which can be used while working with some complicated types (for instance
for more complicated unions). Each API version gets its own file with utility functions, but a folder can be created if
a lot of methods are created.
:::info
The `internals.ts` file stores types that are strictly used inside the module to help build out our strict types. These
types should never be exported from the module.
:::
#### `voice`
This folder holds types that are strictly related to
[`Discord's Voice API`](https://discord.com/developers/docs/topics/voice-connections). It follows the same folder
structure as [`gateway`](#gateway).
:::info
Types in this folder must start with the `Voice` prefix (for instance `VoiceOpcodes`).
:::
#### `website`
This folder holds...well...this very site you are reading this page from! For the most part, you do not need to alter
its contents, except if you're contributing a new API version to the module.
To add the new version to this very website, edit the `docusaurus.config.js` file, and in the `plugins` array, for the
`docusaurus-plugin-typedoc-api` plugin, you need to add an entry similar to the ones already present.
#### `globals.ts`
This file stores types that are present regardless of the API version you use.
#### `v*.ts`
These files export everything from the previously mentioned folders that match the version the file is named after. It
serves as the entry point for importing types from the module (for example by importing `discord-api-types/v10`).
#### `package.json`
This is the entry point of the package for [`npm`](https://www.npmjs.com/). You won't need to edit this file unless
you're adding a new API version, in which case you should follow the same structure as seen in the `exports` field.

View File

@@ -0,0 +1,167 @@
---
id: introduction_to_discord-api-types
title: Introduction
sidebar_position: 0
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
<div align="center">
<img src="/svgs/logo_long_blurple.svg" className="markdown__logo" />
[![Discord server](https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white)](https://discord-api-types.dev/discord)
[![Patreon Donate](https://img.shields.io/badge/patreon-donate-brightgreen.svg?label=Donate%20with%20Patreon&logo=patreon&colorB=F96854&link=https://www.patreon.com/vladfrangu)](https://www.patreon.com/vladfrangu)
[![Ko-fi Donate](https://img.shields.io/badge/kofi-donate-brightgreen.svg?label=Donate%20with%20Ko-fi&logo=ko-fi&colorB=F16061&link=https://ko-fi.com/wolfgalvlad&logoColor=FFFFFF)](https://ko-fi.com/wolfgalvlad)
[![GitHub Sponsors](https://img.shields.io/badge/patreon-donate-brightgreen.svg?label=Sponsor%20through%20GitHub&logo=github&colorB=F96854&link=https://github.com/sponsors/vladfrangu)](https://github.com/sponsors/vladfrangu)
[![npm version](https://img.shields.io/npm/v/discord-api-types?color=crimson&label=NPM%20Version&logo=npm)](https://www.npmjs.com/package/discord-api-types)
[![npm downloads](https://img.shields.io/npm/dt/discord-api-types.svg?label=NPM%20Downloads&logo=npm)](https://www.npmjs.com/package/discord-api-types)
[![deno](https://img.shields.io/npm/v/discord-api-types?color=blue&label=deno&logo=deno)](https://deno.land/x/discord_api_types)
</div>
## About
Discord API Types is a community-maintained project that brings API types for Discord's REST, Gateway and Voice APIs.
## Installation
Install with [`npm`](https://www.npmjs.com/) / [`yarn`](https://yarnpkg.com) / [`pnpm`](https://pnpm.js.org/):
```bash npm2yarn2pnpm
npm install discord-api-types
```
### Usage
You can only import this module by specifying the API version you want to target. Append `/v*` to the import path, where
the `*` represents the API version. Below are some examples
<Tabs groupId="ts2esm2cjs">
<TabItem value="javascript" label="JavaScript">
```typescript showLineNumbers
/**
* @type {import('discord-api-types/v10').APIUser}
*/
```
</TabItem>
<TabItem value="esm" label="ESM">
```typescript showLineNumbers
/**
* @type {import('discord-api-types/v10').APIUser}
*/
```
</TabItem>
<TabItem value="typescript" label="TypeScript">
```typescript showLineNumbers
import { type APIUser } from 'discord-api-types/v10';
```
</TabItem>
</Tabs>
:::info
You may also import just certain parts of the module that you need. The possible values are: `globals`, `gateway`,
`gateway/v*`, `payloads`, `payloads/v*`, `rest`, `rest/v*`, `rpc`, `rpc/v*`, `utils`, `utils/v*`, `voice`, and
`voice/v*`. Below is an example of importing directly from the gateway submodule
```typescript ts2esm2cjs
import { GatewayVersion } from 'discord-api-types/gateway/v10';
console.log(`Let's connect to wss://gateway.discord.gg/?v=${GatewayVersion}`);
```
> _**Note:** The `v*` exports (`discord-api-types/v*`) include the appropriate version of `gateway`, `payloads`, `rest`,
> `rpc`, and `utils` you specified, alongside the `globals` exports_
:::
### Deno
We also provide typings compatible with the [deno](https://deno.land/) runtime. Here are 3 examples of how you can
import them:
<Tabs>
<TabItem value="github" label="From GitHub">
```typescript showLineNumbers
// Importing a specific API version
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v10.ts';
```
</TabItem>
<TabItem value="deno" label="From deno.land/x" default>
```typescript showLineNumbers
// Importing a specific API version
import { APIUser } from 'https://deno.land/x/discord_api_types/v10.ts';
```
</TabItem>
<TabItem value="skypack" label="From skypack.dev">
```typescript showLineNumbers
// Importing a specific API version
import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v10?dts';
```
</TabItem>
</Tabs>
## Project Structure
The exports of each API version is split into three main parts:
- Everything exported with the `API` prefix represents a payload you may get from the REST API _or_ the Gateway.
- Everything exported with the `Gateway` prefix represents data that ONLY comes from or is directly related to the
Gateway.
- Everything exported with the `REST` prefix represents data that ONLY comes from or is directly related to the REST
API.
- For endpoint options, they will follow the following structure:
`REST<HTTP Method><Type><Query|(JSON|FormData)Body|Result>` where the type represents what it will return.
- For example, `RESTPostAPIChannelMessageJSONBody` or `RESTGetAPIGatewayBotInfoResult`.
- Some exported types (specifically OAuth2 related ones) may not respect this entire structure due to the nature of
the fields. They will start with either `RESTOAuth2` or with something similar to `REST<HTTP Method>OAuth2`
- If a type ends with `Result`, then it represents the expected result by calling its accompanying route.
- Types that are exported as `never` usually mean the result will be a `204 No Content`, so you can safely ignore
it. This does **not** account for errors.
- Anything else that is miscellaneous will be exported based on what it represents (for example the `REST` route
object).
- There may be types exported that are identical for all versions. These will be exported as is and can be found in the
`globals` file. They will still be prefixed accordingly as described above.
:::danger A note about how types are documented
This package will add types only for known and documented properties that are present in Discord's
[API Documentation repository](https://github.com/discord/discord-api-docs), that are mentioned in an open pull request,
or known through other means _and have received the green light to be used_. Anything else will not be documented (for
example client only types).
With that aside, we may allow certain types that are not documented in the
[API Documentation repository](https://github.com/discord/discord-api-docs) on a case by case basis. They will be
documented with an `@unstable` tag and are not subject with the same versioning rules.
:::

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

View File

@@ -0,0 +1,261 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
const { join } = require('path');
const { npm2yarn2pnpm } = require('@sapphire/docusaurus-plugin-npm2yarn2pnpm');
const { ts2esm2cjs } = require('@sapphire/docusaurus-plugin-ts2esm2cjs');
const lightCodeTheme = require('prism-react-renderer/themes/github');
const darkCodeTheme = require('prism-react-renderer/themes/vsDark');
/** @type {string[]} */
const versions = require('./versions.json');
const Description = "discord-api-types is a simple Node/Deno module that brings up to date typings for Discord's API";
const BaseUrl = 'https://discord-api-types.dev';
const Email = 'vlad@discord-api-types.dev';
const Title = 'discord-api-types documentation';
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'discord-api-types documentation',
url: BaseUrl,
baseUrl: '/',
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'throw',
onDuplicateRoutes: 'throw',
favicon: '/favicon.ico',
tagline: Description,
organizationName: 'discordjs',
projectName: 'discord-api-types',
themes: [],
plugins: [
'docusaurus-plugin-sass',
[
'@docusaurus/plugin-pwa',
{
offlineModeActivationStrategies: ['appInstalled', 'standalone', 'queryString'],
pwaHead: [
{
tagName: 'link',
rel: 'icon',
href: '/android-chrome-192x192.png'
},
{
tagName: 'link',
rel: 'manifest',
href: '/manifest.webmanifest'
},
{
tagName: 'meta',
name: 'theme-color',
content: '#2563EB'
}
]
}
],
[
'docusaurus-plugin-typedoc-api',
/** @type {Parameters<import('docusaurus-plugin-typedoc-api')['default']>[1]} */ ({
projectRoot: join(__dirname, '../'),
packages: [
{
path: './',
entry: {
globals: { path: 'globals.ts', label: 'Global Types' },
'gateway/common': { path: 'gateway/common.ts', label: 'Gateway - Common Types' },
'payloads/common': { path: 'payloads/common.ts', label: 'Payloads - Common Types' },
'rest/common': { path: 'rest/common.ts', label: 'REST - Common Types' },
'rpc/common': { path: 'rpc/common.ts', label: 'RPC - Common Types' },
v6: { path: 'v6.ts', label: 'API v6 - Deprecated' },
v8: { path: 'v8.ts', label: 'API v8 - Deprecated' },
v9: { path: 'v9.ts', label: 'API v9' },
v10: { path: 'v10.ts', label: 'API v10' },
'rpc/v8': { path: 'rpc/v8.ts', label: 'RPC v8' },
'rpc/v9': { path: 'rpc/v9.ts', label: 'RPC v9' },
'rpc/v10': { path: 'rpc/v10.ts', label: 'RPC v10' },
'voice/v4': { path: 'voice/v4.ts', label: 'Voice v4' },
'utils/v8': { path: 'utils/v8.ts', label: 'Utils v8' },
'utils/v9': { path: 'utils/v9.ts', label: 'Utils v9' },
'utils/v10': { path: 'utils/v10.ts', label: 'Utils v10' }
},
slug: 'discord-api-types'
}
]
})
]
],
presets: [
[
'@docusaurus/preset-classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
sidebarPath: require.resolve('./sidebars.js'),
showLastUpdateAuthor: false,
showLastUpdateTime: false,
remarkPlugins: [npm2yarn2pnpm, ts2esm2cjs]
},
blog: false,
theme: {
customCss: [
require.resolve('./src/css/custom.scss'),
require.resolve('./src/css/tippy-discord.css'),
require.resolve('./src/css/discordjs.scss')
]
}
})
]
],
themeConfig:
/** @type {Partial<import('@docusaurus/preset-classic').ThemeConfig>} */
({
image: 'https://discord-api-types.dev/opengraph.png',
colorMode: {
defaultMode: 'dark',
respectPrefersColorScheme: true
},
metadata: [
// Tags from realfavicongenerator
{ name: 'apple-mobile-web-app-title', content: Title },
{ name: 'application-name', content: Title },
{ name: 'msapplication-TileColor', content: '#2563EB' },
{ name: 'msapplication-TileImage', content: '/mstile-144x144.png' },
{ name: 'theme-color', content: '#2563EB' },
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
{ name: 'apple-mobile-web-app-status-bar-style', content: 'black' },
{ name: 'audience', content: 'all' },
{ name: 'author', content: `Vlad Frangu, ${Email}` },
{ name: 'coverage', content: 'Worldwide' },
{ name: 'description', content: Description },
{ name: 'designer', content: `Vlad Frangu, ${Email}` },
{ name: 'distribution', content: 'Global' },
{ name: 'googlebot', content: 'index,follow' },
{ name: 'HandheldFriendly', content: 'True' },
{ name: 'identifier-URL', content: BaseUrl },
{ name: 'keywords', content: 'discord, bot, discord api, documentation, guide, discord-api-types' },
{ name: 'msapplication-config', content: '/browserconfig.xml' },
{ name: 'owner', content: `Vlad Frangu, ${Email}` },
{ name: 'rating', content: 'safe for kids' },
{ name: 'reply-to', content: Email },
{ name: 'revisit-after', content: '7 days' },
{ name: 'robots', content: 'archive,follow,imageindex,index,odp,snippet,translate' },
{ name: 'shortlink', content: BaseUrl },
{ name: 'subject', content: 'Documentation website for discord-api-types' },
{ name: 'summary', content: Description },
{ name: 'target', content: 'all' },
{ name: 'twitter:card', content: 'summary_large_image' },
{ name: 'twitter:creator', content: '@WolfgalVlad' },
{ name: 'twitter:site', content: '@WolfgalVlad' },
{ name: 'twitter:title', content: 'discord-api-types - Imagine typings' },
{ name: 'twitter:description', content: Description },
{ name: 'url', content: BaseUrl },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ property: 'og:description', content: Description },
{ property: 'og:email', content: Email },
{ property: 'og:image:alt', content: 'OpenGraphImage' },
{ property: 'og:image:height', content: '512' },
{ property: 'og:image:width', content: '1024' },
{ property: 'og:locale', content: 'en_US' },
{ property: 'og:site_name', content: Title },
{ property: 'og:title', content: 'discord-api-types - Imagine typings' },
{ property: 'og:type', content: 'article' },
{ property: 'og:url', content: BaseUrl }
],
navbar: {
items: [
{
to: '/',
label: 'discord-api-types',
position: 'left',
activeBaseRegex: '^/$'
},
{
to: 'docs/introduction_to_discord-api-types',
label: 'Introduction to the module',
position: 'left'
},
{
type: 'dropdown',
to: 'api',
label: 'API',
position: 'left',
items: [
{ label: versions.length === 0 ? 'Development Time' : 'next 🚧', to: versions.length === 0 ? 'api' : 'api/next' },
...versions.map((version, i) => ({
label: version,
to: i === 0 ? 'api' : `api/${version}`
}))
]
},
// Right
{
href: 'https://github.com/discordjs/discord-api-types',
position: 'right',
className: 'header-github-link',
'aria-label': 'GitHub repository',
label: 'GitHub'
}
]
},
footer: {
style: 'dark',
logo: {
alt: 'Powered By Vercel',
src: '/powered-by-vercel.svg',
href: 'https://vercel.com/?utm_source=sapphiredev&utm_campaign=oss'
},
links: [
{
title: 'Donate',
items: [
{
label: 'Ko-fi',
href: 'https://discord-api-types.dev/kofi'
},
{
label: 'Patreon',
href: 'https://discord-api-types.dev/patreon'
},
{
label: 'GitHub Sponsors',
href: 'https://discord-api-types.dev/sponsor'
}
]
},
{
title: 'Our Platforms',
items: [
{
label: 'Discord Server',
href: 'https://discord-api-types.dev/discord'
},
{
label: 'GitHub Organization',
href: 'https://discord-api-types.dev/ghorg'
}
]
}
],
copyright: `Copyright © 2021 - ${new Date().getFullYear()} The discord.js Community and its contributors.`
},
prism: {
defaultLanguage: 'typescript',
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
additionalLanguages: ['powershell', 'batch']
}
// algolia: {
// appId: 'TO_BE_DONE',
// apiKey: 'TO_BE_DONE',
// indexName: 'TO_BE_DONE',
// contextualSearch: false
// }
})
};
module.exports = config;

30509
website/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

103
website/package.json Normal file
View File

@@ -0,0 +1,103 @@
{
"name": "discord-api-types-website",
"version": "1.0.0",
"description": "Website for discord-api-types, hosted on https://discord-api-types.dev",
"author": "Vlad Frangu <kingdgrizzle@gmail.com>",
"license": "MIT",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
"start": "npm run clean && docusaurus start",
"build": "npm run clean && docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"typecheck": "tsc",
"lint": "eslint src --ext mjs,ts --fix",
"lint:no-fix": "eslint src --ext mjs,ts --fix",
"lint:md": "markdownlint-cli2-fix",
"lint:md-no-fix": "markdownlint-cli2",
"clean": "node scripts/clean.mjs",
"format": "prettier --write \"{src,static,scripts,docs}/**/*.{js,jsx,ts,tsx,css,scss,json,md,mdx,yml}\"",
"format:check": "prettier --check \"{src,static,scripts,docs}/**/*.{js,jsx,ts,tsx,css,scss,json,md,mdx,yml}\"",
"test:lint": "run-s lint:no-fix format:check lint:md-no-fix",
"vercel-build": "npm run build"
},
"dependencies": {
"@docusaurus/core": "2.0.0-beta.20",
"@docusaurus/plugin-pwa": "2.0.0-beta.20",
"@docusaurus/preset-classic": "2.0.0-beta.20",
"@docusaurus/theme-search-algolia": "2.0.0-beta.20",
"@heroicons/react": "^1.0.6",
"@mdx-js/react": "^1.6.22",
"@sapphire/docusaurus-plugin-npm2yarn2pnpm": "^1.1.0",
"@sapphire/docusaurus-plugin-ts2esm2cjs": "^1.1.0",
"@svgr/webpack": "^6.2.1",
"@tippyjs/react": "^4.2.6",
"clsx": "^1.1.1",
"docusaurus-plugin-sass": "^0.2.2",
"docusaurus-plugin-typedoc-api": "^1.11.0",
"prism-react-renderer": "^1.3.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"sass": "^1.52.1",
"swr": "^1.3.0"
},
"devDependencies": {
"@commitlint/cli": "^17.0.1",
"@commitlint/config-conventional": "^17.0.0",
"@docusaurus/module-type-aliases": "2.0.0-beta.20",
"@sapphire/prettier-config": "^1.4.3",
"@sapphire/ts-config": "^3.3.4",
"@types/node": "^17.0.36",
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.5",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"cross-env": "^7.0.3",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.16.0",
"lint-staged": "^12.4.3",
"markdownlint": "^0.25.1",
"markdownlint-cli2": "^0.4.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.2",
"pretty-quick": "^3.1.3",
"replace-in-file": "^6.3.5",
"rimraf": "^3.0.2",
"typedoc": "^0.22.16",
"typedoc-plugin-djs-links": "^1.0.4",
"typedoc-plugin-markdown": "^3.12.1",
"typedoc-plugin-mdn-links": "^1.0.6",
"typescript": "^4.7.2"
},
"browserslist": {
"production": [
">0.5%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"homepage": "https://discord-api-types.dev",
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"lint-staged": {
"*.{mjs,js,jsx,ts,tsx}": "eslint --fix --ext mjs,js,jsx,ts,tsx"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}

17
website/scripts/clean.mjs Normal file
View File

@@ -0,0 +1,17 @@
import { rm } from 'node:fs/promises';
const rootDir = new URL('../', import.meta.url);
const documentationDir = new URL('docs/Documentation/', rootDir);
const docusaurusOutputDir = new URL('.docusaurus/', rootDir);
const nodeModulesCacheDir = new URL('node_modules/.cache/', rootDir);
const buildDir = new URL('build/', rootDir);
/** @type {import('node:fs').RmOptions} */
const rmOptions = { recursive: true, force: true };
await Promise.all([
rm(docusaurusOutputDir, rmOptions), //
rm(documentationDir, rmOptions),
rm(nodeModulesCacheDir, rmOptions),
rm(buildDir, rmOptions)
]);

8
website/sidebars.js Normal file
View File

@@ -0,0 +1,8 @@
module.exports = {
sidebar: [
{
type: 'autogenerated',
dirName: '.'
}
]
};

View File

@@ -0,0 +1,28 @@
.loadingSkeleton {
width: 315px;
height: 210px;
cursor: progress;
animation: loading 1.5s infinite;
}
.lightLoadingSkeleton {
background: linear-gradient(0.25turn, transparent, #fff, transparent), linear-gradient(#eee, #eee), linear-gradient(#eee, #eee),
linear-gradient(#eee, #eee), linear-gradient(#eee, #eee), linear-gradient(#eee, #eee);
background-repeat: no-repeat;
background-size: 315px 210px, 315px 30px, 315px 30px, 315px 30px, 315px 30px, 315px 30px;
background-position: -315px 0, 0 0, 0 45px, 0 90px, 0 135px, 0 180px;
}
.darkLoadingSkeleton {
background: linear-gradient(0.25turn, transparent, #444, transparent), linear-gradient(#333, #333), linear-gradient(#333, #333),
linear-gradient(#333, #333), linear-gradient(#333, #333), linear-gradient(#333, #333);
background-repeat: no-repeat;
background-size: 315px 210px, 315px 30px, 315px 30px, 315px 30px, 315px 30px, 315px 30px;
background-position: -315px 0, 0 0, 0 45px, 0 90px, 0 135px, 0 180px;
}
@keyframes loading {
to {
background-position: 315px 0, 0 0, 0 45px, 0 90px, 0 135px, 0 180px;
}
}

View File

@@ -0,0 +1,20 @@
import { useColorMode } from '@docusaurus/theme-common';
import clsx from 'clsx';
import React, { CSSProperties, FC, memo } from 'react';
import styles from './LoadingSkeleton.module.css';
const LoadingSkeleton: FC<CSSProperties> = (props) => {
const { colorMode } = useColorMode();
return (
<div
className={clsx(styles.loadingSkeleton, {
[styles.lightLoadingSkeleton]: colorMode !== 'dark',
[styles.darkLoadingSkeleton]: colorMode === 'dark'
})}
style={props}
/>
);
};
export default memo(LoadingSkeleton);

View File

@@ -0,0 +1,18 @@
.linkIcon {
height: 15px;
margin-left: 2px;
margin-right: 8px;
}
.linkIconNoMarginRight {
margin-right: unset;
}
.link {
display: flex;
align-items: center;
}
.block {
display: block;
}

View File

@@ -0,0 +1,21 @@
import { ExternalLinkIcon } from '@heroicons/react/outline';
import React, { FC, ReactNode } from 'react';
import styles from './Link.module.css';
interface Props {
linkName: string;
href: string;
description: ReactNode;
}
const OptionalPackageLink: FC<Props> = ({ description, href, linkName }) => (
<span className={styles.block}>
<a href={href} className={styles.link}>
<strong>{linkName}</strong>
<ExternalLinkIcon className={styles.linkIcon} />
</a>
{description}
</span>
);
export default OptionalPackageLink;

View File

@@ -0,0 +1,31 @@
import CodeBlock from '@theme/CodeBlock';
import TabItem from '@theme/TabItem';
import Tabs from '@theme/Tabs';
import React, { FC } from 'react';
interface CodeblockProps {
readonly content: string;
readonly title?: string;
}
interface Props {
readonly jsCodeblockProps: CodeblockProps;
readonly esmCodeblockProps: CodeblockProps;
readonly tsCodeblockProps: CodeblockProps;
}
const RawContentCodeTabs: FC<Props> = ({ esmCodeblockProps, jsCodeblockProps, tsCodeblockProps }) => (
<Tabs groupId="language-choice">
<TabItem value="javascript" label="JavaScript" default>
<CodeBlock className="javascript">{jsCodeblockProps.content}</CodeBlock>
</TabItem>
<TabItem value="ESM" label="ESM">
<CodeBlock className="javascript">{esmCodeblockProps.content}</CodeBlock>
</TabItem>
<TabItem value="typescript" label="TypeScript">
<CodeBlock className="typescript">{tsCodeblockProps.content}</CodeBlock>
</TabItem>
</Tabs>
);
export default RawContentCodeTabs;

View File

@@ -0,0 +1,19 @@
import { ExternalLinkIcon } from '@heroicons/react/outline';
import clsx from 'clsx';
import React, { FC } from 'react';
import styles from './Link.module.css';
interface Props {
linkName: string;
href: string;
noRightMargin: boolean;
}
const SimpleLink: FC<Props> = ({ href, linkName, noRightMargin = false }) => (
<a href={href} className={styles.link}>
{linkName}
<ExternalLinkIcon className={clsx(styles.linkIcon, { [styles.linkIconNoMarginRight]: noRightMargin })} />
</a>
);
export default SimpleLink;

View File

@@ -0,0 +1,5 @@
@media only screen and (max-width: 1024px) {
.feature {
margin-bottom: 2rem;
}
}

View File

@@ -0,0 +1,15 @@
import clsx from 'clsx';
import React, { FC, memo } from 'react';
import styles from './Feature.module.css';
import type { FeatureItem } from './Types';
const Feature: FC<FeatureItem> = ({ title, description }) => (
<div className={clsx('col', 'col--4', styles.feature)}>
<div className="text--left padding-horiz--md">
<h3>{title}</h3>
<div>{description}</div>
</div>
</div>
);
export default memo(Feature);

View File

@@ -0,0 +1,15 @@
.stars {
list-style-type: '✨ ';
}
.forks {
list-style-type: '🤖 ';
}
.contributors {
list-style-type: '👥 ';
}
.downloads {
list-style-type: '📥 ';
}

View File

@@ -0,0 +1,43 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
import useIsBrowser from '@docusaurus/useIsBrowser';
import { formatNumber } from '@site/src/utils/Intl';
import React, { FC, memo } from 'react';
import useSWR from 'swr';
import styles from './Statistics.module.css';
import type { ContributorsData, NpmData, RepoData } from './Types';
const Statistics: FC = () => {
const isBrowser = useIsBrowser();
const { data: repoData } = useSWR<RepoData>('https://api.github.com/repos/discordjs/discord-api-types', {
suspense: isBrowser
});
const { data: contributorsData } = useSWR<ContributorsData[]>('https://api.github.com/repos/discordjs/discord-api-types/contributors', {
suspense: isBrowser
});
const { data: npmData } = useSWR<NpmData>('https://api.npmjs.org/downloads/range/2020-01-01:2100-12-31/discord-api-types', {
suspense: isBrowser
});
return (
<ul>
{npmData && (
<li className={styles.downloads}>
{formatNumber(npmData.downloads.reduce((acc: number, curr) => (acc += curr.downloads), 0))}+ downloads
</li>
)}
{repoData && (
<>
<li className={styles.stars}>{formatNumber(repoData['stargazers_count'])}+ stars</li>
<li className={styles.forks}>{formatNumber(repoData['forks_count'])}+ forks</li>
</>
)}
{contributorsData && <li className={styles.contributors}>{formatNumber(contributorsData.length)}+ contributors</li>}
</ul>
);
};
export default memo(Statistics);

View File

@@ -0,0 +1,24 @@
import BrowserOnly from '@docusaurus/BrowserOnly';
import clsx from 'clsx';
import React, { FC, memo, Suspense } from 'react';
import Statistics from './Statistics';
import LoadingSkeleton from '../../Common/LoadingSkeleton';
const StatisticsFeature: FC = () => (
<div className={clsx('col col--4')}>
<div className="text--left padding-horiz--md">
<h3>Statistics</h3>
<div>
<BrowserOnly fallback={<LoadingSkeleton />}>
{() => (
<Suspense fallback={<LoadingSkeleton />}>
<Statistics />
</Suspense>
)}
</BrowserOnly>
</div>
</div>
</div>
);
export default memo(StatisticsFeature);

View File

@@ -0,0 +1,43 @@
import type { ReactNode } from 'react';
export interface FeatureItem {
title: string;
description: ReactNode;
}
export interface NpmData {
start: string;
end: string;
package: string;
downloads: Array<{
downloads: number;
day: string;
}>;
}
export interface RepoData {
forks_count: number;
stargazers_count: number;
}
export interface ContributorsData {
avatar_url: string;
contributions: number;
events_url: string;
followers_url: string;
following_url: string;
gists_url: string;
gravatar_id: string;
html_url: string;
id: number;
login: string;
node_id: string;
organizations_url: string;
received_events_url: string;
repos_url: string;
site_admin: false;
starred_url: string;
subscriptions_url: string;
type: string;
url: string;
}

View File

@@ -0,0 +1,28 @@
import Head from '@docusaurus/Head';
import React, { FC, memo } from 'react';
const HeadTags: FC = () => (
<Head>
<meta httpEquiv="Content-Type" content="text/html; charset=UTF-8" />
<meta httpEquiv="Expires" content="1y" />
<meta httpEquiv="Pragma" content="1y" />
<meta httpEquiv="Cache-Control" content="1y" />
<meta httpEquiv="Page-Enter" content="RevealTrans(Duration=2.0,Transition=2)" />
<meta httpEquiv="Page-Exit" content="RevealTrans(Duration=3.0,Transition=12)" />
<link rel="canonical" href="https://discord-api-types.dev" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;700&display=swap" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="192x192" href="/android-chrome-192x192.png" />
<link rel="icon" type="image/png" sizes="194x194" href="/android-chrome-194x194.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="manifest" href="/manifest.webmanifest" />
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#23529B" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="apple-touch-startup-image" href="/apple-startup.png" />
</Head>
);
export default memo(HeadTags);

View File

@@ -0,0 +1,33 @@
.heroBanner {
padding: 4rem 0;
text-align: center;
position: relative;
overflow: hidden;
}
@media screen and (max-width: 966px) {
.heroBanner {
padding: 2rem;
}
}
.logo {
margin-top: -4rem;
margin-bottom: -4rem;
max-height: 24rem;
}
.fontSemiTitle {
font-size: 2.5rem;
}
@media screen and (max-width: 966px) {
.logo {
padding-top: 4rem;
padding-bottom: 4rem;
}
.fontSemiTitle {
font-size: 1.5rem;
}
}

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