Compare commits

...

50 Commits

Author SHA1 Message Date
Vlad Frangu
5723cc04bf chore(release): 0.22.0 🎉 (#177) 2021-08-01 00:51:03 +03:00
Vlad Frangu
f93b6be252 chore(ApplicationCommandOptionType): casing changes for subcommands (#175)
BREAKING CHANGE: This renames `SubCommand` to `Subcommand`, and `SubCommandGroup` to `SubcommandGroup`
2021-08-01 00:48:14 +03:00
Vlad Frangu
b75b05f0d5 fix(MessageComponent): correct type for emoji (#176) 2021-08-01 00:47:15 +03:00
Advaith
47100bcf2c feat: thread updates (#167)
* feat: thread updates

* feat: update Routes

BREAKING CHANGE: `Routes#channelJoinedArchivedThreads` is now spelled right (from `Routes#channelJoinedArhivedThreads`)
2021-07-31 23:54:06 +03:00
ckohen
a93235c9df fix(Gateway): thread list sync now sends an array as documented (#174)
BREAKING CHANGE: `GatewayThreadListSync#members` is now an array of APIThreadMember instead of a Record of GatewayThreadListSyncMember
2021-07-31 23:52:27 +03:00
Vlad Frangu
b1589545e9 chore(release): 0.21.0 🎉 (#173) 2021-07-31 02:14:54 +03:00
Vlad Frangu
647905e16b revert: fix: change resolved index types to string (#172)
This reverts commit d338409410.
2021-07-31 02:10:57 +03:00
Noel
f2995073e0 feat(Globals): revert template bigint type to string type (#171)
BREAKING CHANGE: The type for Snowflake and Permissions is reverted from the `${bigint}` template type back to a normal string type
2021-07-31 02:05:50 +03:00
Advaith
6f15e537df feat(ApplicationCommandOptionType): add Number (10) (#153) 2021-07-26 22:12:54 +03:00
Advaith
d338409410 fix: change resolved index types to string (#169) 2021-07-26 22:12:35 +03:00
Advaith
ef2a0aeb07 fix: export APIPingInteraction (#168) 2021-07-26 08:49:31 +03:00
Vlad Frangu
ab1951b7b9 chore(release): 0.20.2 🎉 (#165) 2021-07-21 12:57:08 +03:00
Vlad Frangu
ff75eb3f5d fix(APIInteraction): bring back Ping type (#164)
* fix(APIInteraction): bring back Ping type

* fix(APIPingInteraction): there be no data here!
2021-07-21 12:52:28 +03:00
Vlad Frangu
f0f44e6db4 chore(release): 0.20.1 🎉 (#163) 2021-07-20 14:52:22 +03:00
Advaith
f99f07f72e feat(Interactions): add interaction response and followup route (#162) 2021-07-20 14:04:09 +03:00
Vlad Frangu
b9d61aed90 chore(release): 0.20.0 🎉 (#161) 2021-07-20 10:33:35 +03:00
Advaith
d009554cae chore: Add more missing stuff (#160)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

BREAKING CHANGE: `GatewayGuildMemberUpdateDispatchData#joined_at` is properly marked as nullable now

BREAKING CHANGE: In v9, `thread_id` was incorrectly placed in `RESTPostAPIWebhookWithTokenJSONBody` and has been moved to `RESTPostAPIWebhookWithTokenQuery`
2021-07-20 10:25:51 +03:00
Advaith
8dbeca0fc9 feat(RESTJSONErrorCodes): add sticker errors (#155)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-07-20 01:46:12 +03:00
Advaith
5dccc6b2a3 feat(PermissionFlagsBits): add UseExternalStickers (1n << 37n) (#154) 2021-07-20 01:29:03 +03:00
Antonio Román
323e531a77 refactor: change xID to xId (#159)
BREAKING CHANGE: All types that contained the `ID` word in them have had it renamed to `Id` (ex: `APIButtonComponentWithCustomID` is now `APIButtonComponentWithCustomId`)
2021-07-20 01:17:39 +03:00
Advaith
634f64d4ce refactor: rename isStyledButton to isInteractionButton (#158)
BREAKING CHANGE: The `isStyledButton` util has been renamed to `isInteractionButton`
2021-07-20 00:43:48 +03:00
Vlad Frangu
ecaf52008b chore(release): 0.19.0 🎉 (#157) 2021-07-19 22:10:57 +03:00
Vlad Frangu
86e0736726 chore: Get up to date *again* (#156)
Co-authored-by: monbrey <rsm999@uowmail.edu.au>

* Added `DiscordCertifiedModerator` flag to UserFlags

* Updated types for Message Components
  * Added `disabled` to APISelectMenuCompponent
  * Cleaned up Buttons types, making them stricter based on the `style` you provide

BREAKING CHANGE: `APISelectOption` has been renamed to `APISelectMenuOption`

BREAKING CHANGE: APISelectMenuOption#default is now properly marked as optional

* Updated OAuth2 Application types

BREAKING CHANGE: `APIApplication#owner` is now marked as optional, per the docs

* Correct APIAuditLogChangeKeyNick's key

BREAKING CHANGE: This renames APIAuditLogChangeKeyNick's key from `mute` to `nick`

* Add `application_id` to APIMessage
* Correct type of `id` and `user_id` in APIThreadMember

BREAKING CHANGE: The type of `id` and `user_id` in APIThreadMember are now marked as optional; read the TSDoc for when it's actually optional

* Correctly version API route in RouteBases

BREAKING CHANGE: This changes the `RouteBases.api` to be versioned based on the API version you're importing. **Make sure to update your code to handle that**

* Added new guild features
ref: 4d36e533cf

* Cleaned up interaction types

BREAKING CHANGE: While this shouldn't be necessary, this is a warning that types for interactions HAVE changed and you may need to update your code. For the most part, the types *should* be the same, more accurate and strictly typed. You will also see that every type of interaction has a Guild/DM counterpart exported (ex: APIApplicationCommandGuildInteraction vs APIApplicationCommandInteraction, where the former has all the guild properties, while the latter has all properties that depend on context marked as optional).

* Add TSD testing support in CI
This is mostly useful for testing unions of types

* Add message property to MessageComponent interactions
2021-07-19 22:00:20 +03:00
모메MoMe
ca933ae84d fix(RESTPostAPIWebhookWithTokenJSONBody): add missing components (#152) 2021-07-18 18:51:25 +03:00
Advaith
4a836293d5 feat(Stickers): sticker packs, sticker routes, and guild stickers (#145)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-07-07 17:07:32 +03:00
Shubham Parihar
836e8fb294 feat: add stage instance related typings to audit logs (#151) 2021-07-03 20:25:45 +03:00
Vlad Frangu
c5b6091c43 chore: deprecate old @next versions (#150) 2021-07-03 17:55:04 +03:00
Shubham Parihar
5256ac7f97 feat(APIGuild): add nsfw_level (#149) 2021-07-03 16:46:45 +03:00
ckohen
f393ba520d feat(Threads): add typed thread creation (#148)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-06-24 12:30:56 +03:00
Shubham Parihar
e36ef9e1d2 feat: add typings for stage instance (#144) 2021-06-24 12:12:03 +03:00
ckohen
dd12c6ac99 fix(FormattingPatterns): fix StyledTimestamp (#147) 2021-06-24 12:09:22 +03:00
monbrey
036bb035c9 feat(Interactions): components and component interactions (#132)
Co-authored-by: nearlySplat <splatterxl@outlook.ie>
Co-authored-by: Advaith <advaithj1@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2021-06-19 21:18:10 +03:00
ckohen
16eae7eafe feat(FormattingPatterns): add timestamp (#146)
Co-authored-by: Antonio Román <kyradiscord@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-06-19 21:15:10 +03:00
ckohen
13d483ef2e feat(Channel): add embeds to post / patch (#143)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2021-06-16 01:51:43 +03:00
ckohen
d2b6276119 feat(Threads): add default auto archive and minor tweaks (#142) 2021-06-15 15:36:39 +03:00
Vlad Frangu
8627c9d219 fix: fix autopublish CD (#140) 2021-06-05 16:09:13 +03:00
Vlad Frangu
72043a2645 chore: add automatic npm deploys (#139) 2021-06-05 15:29:16 +03:00
ckohen
d1498c3ce2 feat: api v9 and threads (#133)
* feat: api v9 and threads

* fix: address review comments
2021-06-02 10:06:40 +03:00
Carter
7b47fc9680 feat(RESTErrors): add types for rest errors (#122)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2021-05-26 00:14:56 +03:00
Vlad Frangu
c4e69c9ce3 chore: don't install huskies in CI 2021-05-26 00:13:36 +03:00
Vlad Frangu
ca6612e0a4 chore(RESTErrorCodes): correct casing for OAuth
BREAKING CHANGE: This properly capitalizes certain error codes with the right OAuth capitalization
2021-05-22 16:25:41 +03:00
Vlad Frangu
63e5e8b7ab chore: update all the deps
build: deno build for 8111146265bbfe527daabfe852292d9c0803d8be
2021-05-22 13:54:42 +03:00
Vlad Frangu
8fdf8c4453 chore(Husky): update to Husky v6 (#135) 2021-05-22 13:43:52 +03:00
Vlad Frangu
f0b2766d5b fix(RESTOAuth2): correct casing of OAuth (#134)
BREAKING CHANGE: `RESTGetAPIOauth2CurrentApplicationResult` and `RESTGetAPIOauth2CurrentAuthorizationResult` have been renamed to `RESTGetAPIOAuth2CurrentApplicationResult ` and `RESTGetAPIOAuth2CurrentAuthorizationResult`, to correct the casing of `OAuth`

build: deno build for 03c88f5a49ba74ea87a35efb27cb75c2e4d0aa44

chore: fix Actions

build: deno build for d5a7b8d8ceee1530f941da7c1e2d6281cf1ea3ba
2021-05-22 13:07:24 +03:00
Jan
aa5e26d92b refactor(Enums): make property casing consistent (#131)
BREAKING CHANGE: Enum keys have been normalized, and they are all PascalCased now (for API v8 and above). API v6 did not receive these changes.
2021-05-11 23:58:27 +03:00
Vlad Frangu
557b969f35 chore(release): 0.18.1 🎉 (#130) 2021-05-03 23:34:40 +03:00
Jan
bd638b97e5 feat: add new interfaces for interaction-related structures (#129) 2021-05-03 23:19:17 +03:00
Advaith
44b956ad85 fix(APIInvite): expires_at is nullable (#128) 2021-04-30 19:58:16 +03:00
Advaith
82ca0ce5c4 feat(APIInvite): add expires_at field and with_expiration param (#127) 2021-04-30 19:32:24 +03:00
Advaith
91afb0bb49 feat(ApplicationCommandOptionType): add MENTIONABLE (9) (#126) 2021-04-28 20:42:22 +03:00
185 changed files with 26379 additions and 3027 deletions

View File

@@ -14,10 +14,10 @@ jobs:
- name: Checkout Project
uses: actions/checkout@v2
- name: Use Node.js 14
- name: Use Node.js v16
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 16
- name: Install Dependencies
run: npm ci
@@ -40,10 +40,10 @@ jobs:
- name: Checkout Project
uses: actions/checkout@v2
- name: Use Node.js 14
- name: Use Node.js v16
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 16
- name: Install Dependencies
run: npm ci
@@ -61,3 +61,25 @@ jobs:
git add --all .
git commit -m "build: deno build for ${GITHUB_SHA}" || true
git push || true
tsd:
name: TSD checks
runs-on: ubuntu-latest
needs: testing
if: needs.testing.result == 'success'
steps:
- name: Checkout Project
uses: actions/checkout@v2
- name: Use Node.js v16
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install Dependencies
run: npm ci
- name: Run TSD
run: npm run test:types

42
.github/workflows/publish-next.yml vendored Normal file
View File

@@ -0,0 +1,42 @@
name: Publish next
on:
workflow_dispatch:
schedule:
- cron: '0 */12 * * *'
jobs:
publish:
name: Publish to npm
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install Node v16
uses: actions/setup-node@v2
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Bump version
run: npx standard-version
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: Deprecate old versions
run: npm deprecate discord-api-types@"~$(jq --raw-output '.version' package.json)-next" "No longer supported. Install the latest @next release" || true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: Publish new version
run: |
npm version --git-tag-version=false $(jq --raw-output '.version' package.json)-next.$(git rev-parse --short HEAD).$(date +%s)
npm publish --tag next || true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

1
.husky/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
_

4
.husky/commit-msg Normal file
View File

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

4
.husky/pre-commit Normal file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install pretty-quick --staged && npx --no-install lint-staged && npm run build:deno && git add deno

View File

@@ -1,4 +1,4 @@
{
"files.eol": "\n",
"typescript.tsdk": "node_modules/typescript/lib"
"files.eol": "\n",
"typescript.tsdk": "node_modules/typescript/lib"
}

View File

@@ -1,3 +1,154 @@
# [0.22.0](https://github.com/discordjs/discord-api-types/compare/0.21.0...0.22.0) (2021-07-31)
### Bug Fixes
- **Gateway:** thread list sync now sends an array as documented ([#174](https://github.com/discordjs/discord-api-types/issues/174)) ([a93235c](https://github.com/discordjs/discord-api-types/commit/a93235c9df2bc36a337c03e8ba08986e6e377483))
- **MessageComponent:** correct type for emoji ([#176](https://github.com/discordjs/discord-api-types/issues/176)) ([b75b05f](https://github.com/discordjs/discord-api-types/commit/b75b05f0d50014335fefc8bb8969d519ed0076d3))
### chore
- **ApplicationCommandOptionType:** casing changes for subcommands ([#175](https://github.com/discordjs/discord-api-types/issues/175)) ([f93b6be](https://github.com/discordjs/discord-api-types/commit/f93b6be2528c80f8dc038282a7d6ddb3c4685c2f))
### Features
- thread updates ([#167](https://github.com/discordjs/discord-api-types/issues/167)) ([47100bc](https://github.com/discordjs/discord-api-types/commit/47100bcf2c154146baecb359e1c00ecca9939ffa))
### BREAKING CHANGES
- **ApplicationCommandOptionType:** This renames `SubCommand` to `Subcommand`, and `SubCommandGroup` to `SubcommandGroup`
- `Routes#channelJoinedArchivedThreads` is now spelled right (from `Routes#channelJoinedArhivedThreads`)
- **Gateway:** `GatewayThreadListSync#members` is now an array of APIThreadMember instead of a Record of GatewayThreadListSyncMember
# [0.21.0](https://github.com/discordjs/discord-api-types/compare/0.20.1...0.21.0) (2021-07-30)
### Bug Fixes
- change resolved index types to string ([#169](https://github.com/discordjs/discord-api-types/issues/169)) ([d338409](https://github.com/discordjs/discord-api-types/commit/d338409410854cc1f97f9903fdc2565e1f45e778))
- export APIPingInteraction ([#168](https://github.com/discordjs/discord-api-types/issues/168)) ([ef2a0ae](https://github.com/discordjs/discord-api-types/commit/ef2a0aeb07cdd04b47e6cb0d40dd8a1b2a77b491))
- **APIInteraction:** bring back Ping type ([#164](https://github.com/discordjs/discord-api-types/issues/164)) ([ff75eb3](https://github.com/discordjs/discord-api-types/commit/ff75eb3f5dfd7597968c26133d125cfe40ee5838))
### Features
- **ApplicationCommandOptionType:** add Number (10) ([#153](https://github.com/discordjs/discord-api-types/issues/153)) ([6f15e53](https://github.com/discordjs/discord-api-types/commit/6f15e537dfee5bda383572cd725c05246c97ca62))
- **Globals:** revert template bigint type to string type ([#171](https://github.com/discordjs/discord-api-types/issues/171)) ([f299507](https://github.com/discordjs/discord-api-types/commit/f2995073e033b050ab459c42b480e626f3f6ae8e))
### Reverts
- fix: change resolved index types to string ([#172](https://github.com/discordjs/discord-api-types/issues/172)) ([647905e](https://github.com/discordjs/discord-api-types/commit/647905e16bfeb689e644695657ac5f05920c0c4c))
### BREAKING CHANGES
- **Globals:** The type for Snowflake and Permissions is reverted from the `${bigint}` template type back to a normal string type
## [0.20.2](https://github.com/discordjs/discord-api-types/compare/0.21.0...0.20.2) (2021-07-21)
### Bug Fixes
- **APIInteraction:** bring back Ping type ([#164](https://github.com/discordjs/discord-api-types/issues/164)) ([ff75eb3](https://github.com/discordjs/discord-api-types/commit/ff75eb3f5dfd7597968c26133d125cfe40ee5838))
## [0.20.1](https://github.com/discordjs/discord-api-types/compare/0.20.0...0.20.1) (2021-07-20)
### Features
- **Interactions:** add interaction response and followup route ([#162](https://github.com/discordjs/discord-api-types/issues/162)) ([f99f07f](https://github.com/discordjs/discord-api-types/commit/f99f07f72e95a9537a955eb942b52e345c1067d6))
# [0.20.0](https://github.com/discordjs/discord-api-types/compare/0.19.0...0.20.0) (2021-07-20)
### chore
- Add more missing stuff ([#160](https://github.com/discordjs/discord-api-types/issues/160)) ([d009554](https://github.com/discordjs/discord-api-types/commit/d009554caed6c738c4a801f00806ab7cc4ac7e16))
### Code Refactoring
- change `xID` to `xId` ([#159](https://github.com/discordjs/discord-api-types/issues/159)) ([323e531](https://github.com/discordjs/discord-api-types/commit/323e531a77aa75397ee1ce59f0db35b08b80b606))
- rename `isStyledButton` to `isInteractionButton` ([#158](https://github.com/discordjs/discord-api-types/issues/158)) ([634f64d](https://github.com/discordjs/discord-api-types/commit/634f64d4ce143bd0a6b9ccf0ffb1241c21550958))
### Features
- **PermissionFlagsBits:** add `UseExternalStickers` (1n << 37n) ([#154](https://github.com/discordjs/discord-api-types/issues/154)) ([5dccc6b](https://github.com/discordjs/discord-api-types/commit/5dccc6b2a3711e14d499ee9a2122403a80da99fe))
- **RESTJSONErrorCodes:** add sticker errors ([#155](https://github.com/discordjs/discord-api-types/issues/155)) ([8dbeca0](https://github.com/discordjs/discord-api-types/commit/8dbeca0fc91cafef59eb8ee30bcfee9ab14a422c))
### BREAKING CHANGES
- `GatewayGuildMemberUpdateDispatchData#joined_at` is properly marked as nullable now
- In v9, `thread_id` was incorrectly placed in `RESTPostAPIWebhookWithTokenJSONBody` and has been moved to `RESTPostAPIWebhookWithTokenQuery`
- All types that contained the `ID` word in them have had it renamed to `Id` (ex: `APIButtonComponentWithCustomID` is now `APIButtonComponentWithCustomId`)
- The `isStyledButton` util has been renamed to `isInteractionButton`
# [0.19.0](https://github.com/discordjs/discord-api-types/compare/0.18.1...0.19.0) (2021-07-19)
### Bug Fixes
- **FormattingPatterns:** fix StyledTimestamp ([#147](https://github.com/discordjs/discord-api-types/issues/147)) ([dd12c6a](https://github.com/discordjs/discord-api-types/commit/dd12c6ac9902d1b300a167f0acd9fba5192aaa91))
- **RESTOAuth2:** correct casing of `OAuth` ([#134](https://github.com/discordjs/discord-api-types/issues/134)) ([f0b2766](https://github.com/discordjs/discord-api-types/commit/f0b2766d5b55bd9b8b8ba9c506a868dafcdca568))
- **RESTPostAPIWebhookWithTokenJSONBody:** add missing components ([#152](https://github.com/discordjs/discord-api-types/issues/152)) ([ca933ae](https://github.com/discordjs/discord-api-types/commit/ca933ae84d54456f0a443e5e8bd10b7613271f62))
- fix autopublish CD ([#140](https://github.com/discordjs/discord-api-types/issues/140)) ([8627c9d](https://github.com/discordjs/discord-api-types/commit/8627c9d2195aaa0a97de2fdf9f64ba0c0ff6db02))
### chore
- Get up to date _again_ ([#156](https://github.com/discordjs/discord-api-types/issues/156)) ([86e0736](https://github.com/discordjs/discord-api-types/commit/86e0736726fb4ef13736510fa6d69f20383d5ea5))
- **RESTErrorCodes:** correct casing for OAuth ([ca6612e](https://github.com/discordjs/discord-api-types/commit/ca6612e0a4f313731009a37a81c3a0834e6a0cd8))
### Code Refactoring
- **Enums:** make property casing consistent ([#131](https://github.com/discordjs/discord-api-types/issues/131)) ([aa5e26d](https://github.com/discordjs/discord-api-types/commit/aa5e26d92b587bf9b4fc33e038a6d3c8586597c2))
### Features
- **Stickers:** sticker packs, sticker routes, and guild stickers ([#145](https://github.com/discordjs/discord-api-types/issues/145)) ([4a83629](https://github.com/discordjs/discord-api-types/commit/4a836293d5224a6cad19c50bc074a9ef9b0f0af4))
- add stage instance related typings to audit logs ([#151](https://github.com/discordjs/discord-api-types/issues/151)) ([836e8fb](https://github.com/discordjs/discord-api-types/commit/836e8fb29491f8df72c0caf2eb5c05ed2bda3191))
- **APIGuild:** add `nsfw_level` ([#149](https://github.com/discordjs/discord-api-types/issues/149)) ([5256ac7](https://github.com/discordjs/discord-api-types/commit/5256ac7f97d35200f1676721a80ad0f57d05cab7))
- **Channel:** add embeds to post / patch ([#143](https://github.com/discordjs/discord-api-types/issues/143)) ([13d483e](https://github.com/discordjs/discord-api-types/commit/13d483ef2e53373438e8b03fed681232626b2670))
- **FormattingPatterns:** add timestamp ([#146](https://github.com/discordjs/discord-api-types/issues/146)) ([16eae7e](https://github.com/discordjs/discord-api-types/commit/16eae7eafe9ef6001f664a30c0f78d6982d2e54c))
- **RESTErrors:** add types for rest errors ([#122](https://github.com/discordjs/discord-api-types/issues/122)) ([7b47fc9](https://github.com/discordjs/discord-api-types/commit/7b47fc96809aed2b28e15064f308651b08a5b74d))
- **Threads:** add typed thread creation ([#148](https://github.com/discordjs/discord-api-types/issues/148)) ([f393ba5](https://github.com/discordjs/discord-api-types/commit/f393ba520d7d6d2aacaca7b3ca5d355fab614f6e))
- add typings for stage instance ([#144](https://github.com/discordjs/discord-api-types/issues/144)) ([e36ef9e](https://github.com/discordjs/discord-api-types/commit/e36ef9e1d225d8e8c849c3198e628202eedbd20b))
- **Interactions:** components and component interactions ([#132](https://github.com/discordjs/discord-api-types/issues/132)) ([036bb03](https://github.com/discordjs/discord-api-types/commit/036bb035c9d6ddf780bab5af4884861d08f04d24))
- **Threads:** add default auto archive and minor tweaks ([#142](https://github.com/discordjs/discord-api-types/issues/142)) ([d2b6276](https://github.com/discordjs/discord-api-types/commit/d2b62761194064b38e38045a72ee8b38c920ada6))
- api v9 and threads ([#133](https://github.com/discordjs/discord-api-types/issues/133)) ([d1498c3](https://github.com/discordjs/discord-api-types/commit/d1498c3ce2eaea11c9946726ef758f7de489253b))
### BREAKING CHANGES
- `APISelectOption` has been renamed to `APISelectMenuOption`
- APISelectMenuOption#default is now properly marked as optional
- Updated OAuth2 Application types
- `APIApplication#owner` is now marked as optional, per the docs
- Correct APIAuditLogChangeKeyNick's key
- This renames APIAuditLogChangeKeyNick's key from `mute` to `nick`
- Add `application_id` to APIMessage
- Correct type of `id` and `user_id` in APIThreadMember
- The type of `id` and `user_id` in APIThreadMember are now marked as optional; read the TSDoc for when it's actually optional
- Correctly version API route in RouteBases
- This changes the `RouteBases.api` to be versioned based on the API version you're importing. **Make sure to update your code to handle that**
- Added new guild features
ref: https://github.com/discordjs/discord-api-types/pull/156/commits/4d36e533cffecbcce13e968a7803e5a68e021106
- Cleaned up interaction types
- While this shouldn't be necessary, this is a warning that types for interactions HAVE changed and you may need to update your code. For the most part, the types _should_ be the same, more accurate and strictly typed. You will also see that every type of interaction has a Guild/DM counterpart exported (ex: APIApplicationCommandGuildInteraction vs APIApplicationCommandInteraction, where the former has all the guild properties, while the latter has all properties that depend on context marked as optional).
- Add message property to MessageComponent interactions
- **RESTErrorCodes:** This properly capitalizes certain error codes with the right OAuth capitalization
- **RESTOAuth2:** `RESTGetAPIOauth2CurrentApplicationResult` and `RESTGetAPIOauth2CurrentAuthorizationResult` have been renamed to `RESTGetAPIOAuth2CurrentApplicationResult ` and `RESTGetAPIOAuth2CurrentAuthorizationResult`, to correct the casing of `OAuth`
- **Enums:** Enum keys have been normalized, and they are all PascalCased now (for API v8 and above). API v6 did not receive these changes.
## [0.18.1](https://github.com/discordjs/discord-api-types/compare/0.18.0...0.18.1) (2021-05-03)
### Bug Fixes
- **APIInvite:** `expires_at` is nullable ([#128](https://github.com/discordjs/discord-api-types/issues/128)) ([44b956a](https://github.com/discordjs/discord-api-types/commit/44b956ad858a457e7671ced38529b433b02efbde))
### Features
- add new interfaces for interaction-related structures ([#129](https://github.com/discordjs/discord-api-types/issues/129)) ([bd638b9](https://github.com/discordjs/discord-api-types/commit/bd638b97e5d26abd8a4f1edbd0f56ddc7d3a30a0))
- **APIInvite:** add `expires_at` field and `with_expiration` param ([#127](https://github.com/discordjs/discord-api-types/issues/127)) ([82ca0ce](https://github.com/discordjs/discord-api-types/commit/82ca0ce5c44ad2e93b3c4875baa82720ea8dd221))
- **ApplicationCommandOptionType:** add `MENTIONABLE` (9) ([#126](https://github.com/discordjs/discord-api-types/issues/126)) ([91afb0b](https://github.com/discordjs/discord-api-types/commit/91afb0bb49015c02b6000c27d07e703011dc540d))
# [0.18.0](https://github.com/discordjs/discord-api-types/compare/0.16.0...0.18.0) (2021-04-18)
### Bug Fixes

View File

@@ -24,23 +24,23 @@ pnpm add discord-api-types
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
```js
const { APIUser } = require('discord-api-types/v8');
const { APIUser } = require('discord-api-types/v9');
```
```ts
// TypeScript/ES Module support
import { APIUser } from 'discord-api-types/v8';
import { APIUser } from 'discord-api-types/v9';
```
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 are some examples
```js
const { GatewayVersion } = require('discord-api-types/gateway/v8');
const { GatewayVersion } = require('discord-api-types/gateway/v9');
```
```ts
// TypeScript/ES Module support
import { GatewayVersion } from 'discord-api-types/gateway/v8';
import { GatewayVersion } from 'discord-api-types/gateway/v9';
```
> _**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_
@@ -53,21 +53,21 @@ We also provide typings compatible with the [deno](https://deno.land/) runtime.
```ts
// Importing a specific API version
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v8.ts';
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v9.ts';
```
2. From [deno.land/x](https://deno.land/x)
```ts
// Importing a specific API version
import { APIUser } from 'https://deno.land/x/discord_api_types/v8.ts';
import { APIUser } from 'https://deno.land/x/discord_api_types/v9.ts';
```
3. From [skypack.dev](https://www.skypack.dev/)
```ts
// Importing a specific API version
import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v8?dts';
import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v9?dts';
```
## Project Structure

View File

@@ -1,3 +1,154 @@
# [0.22.0](https://github.com/discordjs/discord-api-types/compare/0.21.0...0.22.0) (2021-07-31)
### Bug Fixes
- **Gateway:** thread list sync now sends an array as documented ([#174](https://github.com/discordjs/discord-api-types/issues/174)) ([a93235c](https://github.com/discordjs/discord-api-types/commit/a93235c9df2bc36a337c03e8ba08986e6e377483))
- **MessageComponent:** correct type for emoji ([#176](https://github.com/discordjs/discord-api-types/issues/176)) ([b75b05f](https://github.com/discordjs/discord-api-types/commit/b75b05f0d50014335fefc8bb8969d519ed0076d3))
### chore
- **ApplicationCommandOptionType:** casing changes for subcommands ([#175](https://github.com/discordjs/discord-api-types/issues/175)) ([f93b6be](https://github.com/discordjs/discord-api-types/commit/f93b6be2528c80f8dc038282a7d6ddb3c4685c2f))
### Features
- thread updates ([#167](https://github.com/discordjs/discord-api-types/issues/167)) ([47100bc](https://github.com/discordjs/discord-api-types/commit/47100bcf2c154146baecb359e1c00ecca9939ffa))
### BREAKING CHANGES
- **ApplicationCommandOptionType:** This renames `SubCommand` to `Subcommand`, and `SubCommandGroup` to `SubcommandGroup`
- `Routes#channelJoinedArchivedThreads` is now spelled right (from `Routes#channelJoinedArhivedThreads`)
- **Gateway:** `GatewayThreadListSync#members` is now an array of APIThreadMember instead of a Record of GatewayThreadListSyncMember
# [0.21.0](https://github.com/discordjs/discord-api-types/compare/0.20.1...0.21.0) (2021-07-30)
### Bug Fixes
- change resolved index types to string ([#169](https://github.com/discordjs/discord-api-types/issues/169)) ([d338409](https://github.com/discordjs/discord-api-types/commit/d338409410854cc1f97f9903fdc2565e1f45e778))
- export APIPingInteraction ([#168](https://github.com/discordjs/discord-api-types/issues/168)) ([ef2a0ae](https://github.com/discordjs/discord-api-types/commit/ef2a0aeb07cdd04b47e6cb0d40dd8a1b2a77b491))
- **APIInteraction:** bring back Ping type ([#164](https://github.com/discordjs/discord-api-types/issues/164)) ([ff75eb3](https://github.com/discordjs/discord-api-types/commit/ff75eb3f5dfd7597968c26133d125cfe40ee5838))
### Features
- **ApplicationCommandOptionType:** add Number (10) ([#153](https://github.com/discordjs/discord-api-types/issues/153)) ([6f15e53](https://github.com/discordjs/discord-api-types/commit/6f15e537dfee5bda383572cd725c05246c97ca62))
- **Globals:** revert template bigint type to string type ([#171](https://github.com/discordjs/discord-api-types/issues/171)) ([f299507](https://github.com/discordjs/discord-api-types/commit/f2995073e033b050ab459c42b480e626f3f6ae8e))
### Reverts
- fix: change resolved index types to string ([#172](https://github.com/discordjs/discord-api-types/issues/172)) ([647905e](https://github.com/discordjs/discord-api-types/commit/647905e16bfeb689e644695657ac5f05920c0c4c))
### BREAKING CHANGES
- **Globals:** The type for Snowflake and Permissions is reverted from the `${bigint}` template type back to a normal string type
## [0.20.2](https://github.com/discordjs/discord-api-types/compare/0.21.0...0.20.2) (2021-07-21)
### Bug Fixes
- **APIInteraction:** bring back Ping type ([#164](https://github.com/discordjs/discord-api-types/issues/164)) ([ff75eb3](https://github.com/discordjs/discord-api-types/commit/ff75eb3f5dfd7597968c26133d125cfe40ee5838))
## [0.20.1](https://github.com/discordjs/discord-api-types/compare/0.20.0...0.20.1) (2021-07-20)
### Features
- **Interactions:** add interaction response and followup route ([#162](https://github.com/discordjs/discord-api-types/issues/162)) ([f99f07f](https://github.com/discordjs/discord-api-types/commit/f99f07f72e95a9537a955eb942b52e345c1067d6))
# [0.20.0](https://github.com/discordjs/discord-api-types/compare/0.19.0...0.20.0) (2021-07-20)
### chore
- Add more missing stuff ([#160](https://github.com/discordjs/discord-api-types/issues/160)) ([d009554](https://github.com/discordjs/discord-api-types/commit/d009554caed6c738c4a801f00806ab7cc4ac7e16))
### Code Refactoring
- change `xID` to `xId` ([#159](https://github.com/discordjs/discord-api-types/issues/159)) ([323e531](https://github.com/discordjs/discord-api-types/commit/323e531a77aa75397ee1ce59f0db35b08b80b606))
- rename `isStyledButton` to `isInteractionButton` ([#158](https://github.com/discordjs/discord-api-types/issues/158)) ([634f64d](https://github.com/discordjs/discord-api-types/commit/634f64d4ce143bd0a6b9ccf0ffb1241c21550958))
### Features
- **PermissionFlagsBits:** add `UseExternalStickers` (1n << 37n) ([#154](https://github.com/discordjs/discord-api-types/issues/154)) ([5dccc6b](https://github.com/discordjs/discord-api-types/commit/5dccc6b2a3711e14d499ee9a2122403a80da99fe))
- **RESTJSONErrorCodes:** add sticker errors ([#155](https://github.com/discordjs/discord-api-types/issues/155)) ([8dbeca0](https://github.com/discordjs/discord-api-types/commit/8dbeca0fc91cafef59eb8ee30bcfee9ab14a422c))
### BREAKING CHANGES
- `GatewayGuildMemberUpdateDispatchData#joined_at` is properly marked as nullable now
- In v9, `thread_id` was incorrectly placed in `RESTPostAPIWebhookWithTokenJSONBody` and has been moved to `RESTPostAPIWebhookWithTokenQuery`
- All types that contained the `ID` word in them have had it renamed to `Id` (ex: `APIButtonComponentWithCustomID` is now `APIButtonComponentWithCustomId`)
- The `isStyledButton` util has been renamed to `isInteractionButton`
# [0.19.0](https://github.com/discordjs/discord-api-types/compare/0.18.1...0.19.0) (2021-07-19)
### Bug Fixes
- **FormattingPatterns:** fix StyledTimestamp ([#147](https://github.com/discordjs/discord-api-types/issues/147)) ([dd12c6a](https://github.com/discordjs/discord-api-types/commit/dd12c6ac9902d1b300a167f0acd9fba5192aaa91))
- **RESTOAuth2:** correct casing of `OAuth` ([#134](https://github.com/discordjs/discord-api-types/issues/134)) ([f0b2766](https://github.com/discordjs/discord-api-types/commit/f0b2766d5b55bd9b8b8ba9c506a868dafcdca568))
- **RESTPostAPIWebhookWithTokenJSONBody:** add missing components ([#152](https://github.com/discordjs/discord-api-types/issues/152)) ([ca933ae](https://github.com/discordjs/discord-api-types/commit/ca933ae84d54456f0a443e5e8bd10b7613271f62))
- fix autopublish CD ([#140](https://github.com/discordjs/discord-api-types/issues/140)) ([8627c9d](https://github.com/discordjs/discord-api-types/commit/8627c9d2195aaa0a97de2fdf9f64ba0c0ff6db02))
### chore
- Get up to date _again_ ([#156](https://github.com/discordjs/discord-api-types/issues/156)) ([86e0736](https://github.com/discordjs/discord-api-types/commit/86e0736726fb4ef13736510fa6d69f20383d5ea5))
- **RESTErrorCodes:** correct casing for OAuth ([ca6612e](https://github.com/discordjs/discord-api-types/commit/ca6612e0a4f313731009a37a81c3a0834e6a0cd8))
### Code Refactoring
- **Enums:** make property casing consistent ([#131](https://github.com/discordjs/discord-api-types/issues/131)) ([aa5e26d](https://github.com/discordjs/discord-api-types/commit/aa5e26d92b587bf9b4fc33e038a6d3c8586597c2))
### Features
- **Stickers:** sticker packs, sticker routes, and guild stickers ([#145](https://github.com/discordjs/discord-api-types/issues/145)) ([4a83629](https://github.com/discordjs/discord-api-types/commit/4a836293d5224a6cad19c50bc074a9ef9b0f0af4))
- add stage instance related typings to audit logs ([#151](https://github.com/discordjs/discord-api-types/issues/151)) ([836e8fb](https://github.com/discordjs/discord-api-types/commit/836e8fb29491f8df72c0caf2eb5c05ed2bda3191))
- **APIGuild:** add `nsfw_level` ([#149](https://github.com/discordjs/discord-api-types/issues/149)) ([5256ac7](https://github.com/discordjs/discord-api-types/commit/5256ac7f97d35200f1676721a80ad0f57d05cab7))
- **Channel:** add embeds to post / patch ([#143](https://github.com/discordjs/discord-api-types/issues/143)) ([13d483e](https://github.com/discordjs/discord-api-types/commit/13d483ef2e53373438e8b03fed681232626b2670))
- **FormattingPatterns:** add timestamp ([#146](https://github.com/discordjs/discord-api-types/issues/146)) ([16eae7e](https://github.com/discordjs/discord-api-types/commit/16eae7eafe9ef6001f664a30c0f78d6982d2e54c))
- **RESTErrors:** add types for rest errors ([#122](https://github.com/discordjs/discord-api-types/issues/122)) ([7b47fc9](https://github.com/discordjs/discord-api-types/commit/7b47fc96809aed2b28e15064f308651b08a5b74d))
- **Threads:** add typed thread creation ([#148](https://github.com/discordjs/discord-api-types/issues/148)) ([f393ba5](https://github.com/discordjs/discord-api-types/commit/f393ba520d7d6d2aacaca7b3ca5d355fab614f6e))
- add typings for stage instance ([#144](https://github.com/discordjs/discord-api-types/issues/144)) ([e36ef9e](https://github.com/discordjs/discord-api-types/commit/e36ef9e1d225d8e8c849c3198e628202eedbd20b))
- **Interactions:** components and component interactions ([#132](https://github.com/discordjs/discord-api-types/issues/132)) ([036bb03](https://github.com/discordjs/discord-api-types/commit/036bb035c9d6ddf780bab5af4884861d08f04d24))
- **Threads:** add default auto archive and minor tweaks ([#142](https://github.com/discordjs/discord-api-types/issues/142)) ([d2b6276](https://github.com/discordjs/discord-api-types/commit/d2b62761194064b38e38045a72ee8b38c920ada6))
- api v9 and threads ([#133](https://github.com/discordjs/discord-api-types/issues/133)) ([d1498c3](https://github.com/discordjs/discord-api-types/commit/d1498c3ce2eaea11c9946726ef758f7de489253b))
### BREAKING CHANGES
- `APISelectOption` has been renamed to `APISelectMenuOption`
- APISelectMenuOption#default is now properly marked as optional
- Updated OAuth2 Application types
- `APIApplication#owner` is now marked as optional, per the docs
- Correct APIAuditLogChangeKeyNick's key
- This renames APIAuditLogChangeKeyNick's key from `mute` to `nick`
- Add `application_id` to APIMessage
- Correct type of `id` and `user_id` in APIThreadMember
- The type of `id` and `user_id` in APIThreadMember are now marked as optional; read the TSDoc for when it's actually optional
- Correctly version API route in RouteBases
- This changes the `RouteBases.api` to be versioned based on the API version you're importing. **Make sure to update your code to handle that**
- Added new guild features
ref: https://github.com/discordjs/discord-api-types/pull/156/commits/4d36e533cffecbcce13e968a7803e5a68e021106
- Cleaned up interaction types
- While this shouldn't be necessary, this is a warning that types for interactions HAVE changed and you may need to update your code. For the most part, the types _should_ be the same, more accurate and strictly typed. You will also see that every type of interaction has a Guild/DM counterpart exported (ex: APIApplicationCommandGuildInteraction vs APIApplicationCommandInteraction, where the former has all the guild properties, while the latter has all properties that depend on context marked as optional).
- Add message property to MessageComponent interactions
- **RESTErrorCodes:** This properly capitalizes certain error codes with the right OAuth capitalization
- **RESTOAuth2:** `RESTGetAPIOauth2CurrentApplicationResult` and `RESTGetAPIOauth2CurrentAuthorizationResult` have been renamed to `RESTGetAPIOAuth2CurrentApplicationResult ` and `RESTGetAPIOAuth2CurrentAuthorizationResult`, to correct the casing of `OAuth`
- **Enums:** Enum keys have been normalized, and they are all PascalCased now (for API v8 and above). API v6 did not receive these changes.
## [0.18.1](https://github.com/discordjs/discord-api-types/compare/0.18.0...0.18.1) (2021-05-03)
### Bug Fixes
- **APIInvite:** `expires_at` is nullable ([#128](https://github.com/discordjs/discord-api-types/issues/128)) ([44b956a](https://github.com/discordjs/discord-api-types/commit/44b956ad858a457e7671ced38529b433b02efbde))
### Features
- add new interfaces for interaction-related structures ([#129](https://github.com/discordjs/discord-api-types/issues/129)) ([bd638b9](https://github.com/discordjs/discord-api-types/commit/bd638b97e5d26abd8a4f1edbd0f56ddc7d3a30a0))
- **APIInvite:** add `expires_at` field and `with_expiration` param ([#127](https://github.com/discordjs/discord-api-types/issues/127)) ([82ca0ce](https://github.com/discordjs/discord-api-types/commit/82ca0ce5c44ad2e93b3c4875baa82720ea8dd221))
- **ApplicationCommandOptionType:** add `MENTIONABLE` (9) ([#126](https://github.com/discordjs/discord-api-types/issues/126)) ([91afb0b](https://github.com/discordjs/discord-api-types/commit/91afb0bb49015c02b6000c27d07e703011dc540d))
# [0.18.0](https://github.com/discordjs/discord-api-types/compare/0.16.0...0.18.0) (2021-04-18)
### Bug Fixes

View File

@@ -24,23 +24,23 @@ pnpm add discord-api-types
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
```js
const { APIUser } = require('discord-api-types/v8');
const { APIUser } = require('discord-api-types/v9');
```
```ts
// TypeScript/ES Module support
import { APIUser } from 'discord-api-types/v8';
import { APIUser } from 'discord-api-types/v9';
```
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 are some examples
```js
const { GatewayVersion } = require('discord-api-types/gateway/v8');
const { GatewayVersion } = require('discord-api-types/gateway/v9');
```
```ts
// TypeScript/ES Module support
import { GatewayVersion } from 'discord-api-types/gateway/v8';
import { GatewayVersion } from 'discord-api-types/gateway/v9';
```
> _**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_
@@ -53,21 +53,21 @@ We also provide typings compatible with the [deno](https://deno.land/) runtime.
```ts
// Importing a specific API version
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v8.ts';
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v9.ts';
```
2. From [deno.land/x](https://deno.land/x)
```ts
// Importing a specific API version
import { APIUser } from 'https://deno.land/x/discord_api_types/v8.ts';
import { APIUser } from 'https://deno.land/x/discord_api_types/v9.ts';
```
3. From [skypack.dev](https://www.skypack.dev/)
```ts
// Importing a specific API version
import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v8?dts';
import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v9?dts';
```
## Project Structure

View File

@@ -1,4 +1,4 @@
// This file exports all the types available in the recommended gateway version
// Thereby, things MAY break in the future. Try sticking to imports from a specific version
export * from './v8.ts';
export * from './v9.ts';

View File

@@ -13,7 +13,10 @@ import type {
APIGuildIntegration,
APIGuildMember,
APIMessage,
APIMessageComponentInteraction,
APIRole,
APIStageInstance,
APISticker,
APIUnavailableGuild,
APIUser,
GatewayActivity,
@@ -22,6 +25,7 @@ import type {
InviteTargetType,
PresenceUpdateStatus,
} from '../payloads/v8/mod.ts';
import type { Nullable } from '../utils/internals.ts';
export * from './common.ts';
@@ -30,7 +34,7 @@ export const GatewayVersion = '8';
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes
*/
export enum GatewayOPCodes {
export enum GatewayOpcodes {
/**
* An event was dispatched
*/
@@ -91,7 +95,7 @@ export enum GatewayCloseCodes {
*
* See https://discord.com/developers/docs/topics/gateway#payloads-and-opcodes
*/
UnknownOpCode,
UnknownOpcode,
/**
* You sent an invalid payload to us. Don't do that!
*
@@ -165,21 +169,21 @@ export enum GatewayCloseCodes {
* https://discord.com/developers/docs/topics/gateway#list-of-intents
*/
export enum GatewayIntentBits {
GUILDS = 1 << 0,
GUILD_MEMBERS = 1 << 1,
GUILD_BANS = 1 << 2,
GUILD_EMOJIS = 1 << 3,
GUILD_INTEGRATIONS = 1 << 4,
GUILD_WEBHOOKS = 1 << 5,
GUILD_INVITES = 1 << 6,
GUILD_VOICE_STATES = 1 << 7,
GUILD_PRESENCES = 1 << 8,
GUILD_MESSAGES = 1 << 9,
GUILD_MESSAGE_REACTIONS = 1 << 10,
GUILD_MESSAGE_TYPING = 1 << 11,
DIRECT_MESSAGES = 1 << 12,
DIRECT_MESSAGE_REACTIONS = 1 << 13,
DIRECT_MESSAGE_TYPING = 1 << 14,
Guilds = 1 << 0,
GuildMembers = 1 << 1,
GuildBans = 1 << 2,
GuildEmojisAndStickers = 1 << 3,
GuildIntegrations = 1 << 4,
GuildWebhooks = 1 << 5,
GuildInvites = 1 << 6,
GuildVoiceStates = 1 << 7,
GuildPresences = 1 << 8,
GuildMessages = 1 << 9,
GuildMessageReactions = 1 << 10,
GuildMessageTyping = 1 << 11,
DirectMessages = 1 << 12,
DirectMessageReactions = 1 << 13,
DirectMessageTyping = 1 << 14,
}
/**
@@ -206,6 +210,7 @@ export enum GatewayDispatchEvents {
GuildRoleCreate = 'GUILD_ROLE_CREATE',
GuildRoleDelete = 'GUILD_ROLE_DELETE',
GuildRoleUpdate = 'GUILD_ROLE_UPDATE',
GuildStickersUpdate = 'GUILD_STICKERS_UPDATE',
GuildUpdate = 'GUILD_UPDATE',
IntegrationCreate = 'INTEGRATION_CREATE',
IntegrationDelete = 'INTEGRATION_DELETE',
@@ -222,6 +227,9 @@ export enum GatewayDispatchEvents {
MessageReactionRemoveEmoji = 'MESSAGE_REACTION_REMOVE_EMOJI',
MessageUpdate = 'MESSAGE_UPDATE',
PresenceUpdate = 'PRESENCE_UPDATE',
StageInstanceCreate = 'STAGE_INSTANCE_CREATE',
StageInstanceDelete = 'STAGE_INSTANCE_DELETE',
StageInstanceUpdate = 'STAGE_INSTANCE_UPDATE',
Ready = 'READY',
Resumed = 'RESUMED',
TypingStart = 'TYPING_START',
@@ -261,6 +269,7 @@ export type GatewayDispatchPayload =
| GatewayGuildModifyDispatch
| GatewayGuildRoleDeleteDispatch
| GatewayGuildRoleModifyDispatch
| GatewayGuildStickersUpdateDispatch
| GatewayIntegrationCreateDispatch
| GatewayIntegrationDeleteDispatch
| GatewayIntegrationUpdateDispatch
@@ -276,6 +285,9 @@ export type GatewayDispatchPayload =
| GatewayMessageReactionRemoveEmojiDispatch
| GatewayMessageUpdateDispatch
| GatewayPresenceUpdateDispatch
| GatewayStageInstanceCreateDispatch
| GatewayStageInstanceDeleteDispatch
| GatewayStageInstanceUpdateDispatch
| GatewayReadyDispatch
| GatewayResumedDispatch
| GatewayTypingStartDispatch
@@ -303,9 +315,7 @@ export type GatewayApplicationCommandModifyDispatch = DataPayload<
* https://discord.com/developers/docs/topics/gateway#application-command-update
* https://discord.com/developers/docs/topics/gateway#application-command-delete
*/
export interface GatewayApplicationCommandModifyDispatchData extends APIApplicationCommand {
guild_id?: string;
}
export type GatewayApplicationCommandModifyDispatchData = APIApplicationCommand;
/**
* https://discord.com/developers/docs/topics/gateway#application-command-create
@@ -341,7 +351,7 @@ export type GatewayApplicationCommandDeleteDispatchData = GatewayApplicationComm
* https://discord.com/developers/docs/topics/gateway#hello
*/
export interface GatewayHello extends NonDispatchPayload {
op: GatewayOPCodes.Hello;
op: GatewayOpcodes.Hello;
d: GatewayHelloData;
}
@@ -359,7 +369,7 @@ export interface GatewayHelloData {
* https://discord.com/developers/docs/topics/gateway#heartbeating
*/
export interface GatewayHeartbeatRequest extends NonDispatchPayload {
op: GatewayOPCodes.Heartbeat;
op: GatewayOpcodes.Heartbeat;
d: never;
}
@@ -367,7 +377,7 @@ export interface GatewayHeartbeatRequest extends NonDispatchPayload {
* https://discord.com/developers/docs/topics/gateway#heartbeating-example-gateway-heartbeat-ack
*/
export interface GatewayHeartbeatAck extends NonDispatchPayload {
op: GatewayOPCodes.HeartbeatAck;
op: GatewayOpcodes.HeartbeatAck;
d: never;
}
@@ -375,7 +385,7 @@ export interface GatewayHeartbeatAck extends NonDispatchPayload {
* https://discord.com/developers/docs/topics/gateway#invalid-session
*/
export interface GatewayInvalidSession extends NonDispatchPayload {
op: GatewayOPCodes.InvalidSession;
op: GatewayOpcodes.InvalidSession;
d: GatewayInvalidSessionData;
}
@@ -388,7 +398,7 @@ export type GatewayInvalidSessionData = boolean;
* https://discord.com/developers/docs/topics/gateway#reconnect
*/
export interface GatewayReconnect extends NonDispatchPayload {
op: GatewayOPCodes.Reconnect;
op: GatewayOpcodes.Reconnect;
d: never;
}
@@ -432,7 +442,7 @@ export interface GatewayReadyDispatchData {
/**
* Contains `id` and `flags`
*
* See https://discord.com/developers/docs/topics/oauth2#application-object
* See https://discord.com/developers/docs/resources/application#application-object
*/
application: Pick<APIApplication, 'id' | 'flags'>;
}
@@ -630,6 +640,30 @@ export interface GatewayGuildEmojisUpdateDispatchData {
emojis: APIEmoji[];
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-stickers-update
*/
export type GatewayGuildStickersUpdateDispatch = DataPayload<
GatewayDispatchEvents.GuildStickersUpdate,
GatewayGuildStickersUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-stickers-update
*/
export interface GatewayGuildStickersUpdateDispatchData {
/**
* ID of the guild
*/
guild_id: Snowflake;
/**
* Array of stickers
*
* See https://discord.com/developers/docs/resources/sticker#sticker-object
*/
stickers: APISticker[];
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-integrations-update
*/
@@ -701,9 +735,10 @@ export type GatewayGuildMemberUpdateDispatch = DataPayload<
/**
* https://discord.com/developers/docs/topics/gateway#guild-member-update
*/
export type GatewayGuildMemberUpdateDispatchData = Omit<APIGuildMember, 'deaf' | 'mute' | 'user'> &
export type GatewayGuildMemberUpdateDispatchData = Omit<APIGuildMember, 'deaf' | 'mute' | 'user' | 'joined_at'> &
Partial<Pick<APIGuildMember, 'deaf' | 'mute'>> &
Required<Pick<APIGuildMember, 'user'>> & {
Required<Pick<APIGuildMember, 'user'>> &
Nullable<Pick<APIGuildMember, 'joined_at'>> & {
/**
* The id of the guild
*/
@@ -889,7 +924,7 @@ export type GatewayInteractionCreateDispatch = DataPayload<
/**
* https://discord.com/developers/docs/topics/gateway#interaction-create
*/
export type GatewayInteractionCreateDispatchData = APIApplicationCommandInteraction;
export type GatewayInteractionCreateDispatchData = APIApplicationCommandInteraction | APIMessageComponentInteraction;
/**
* https://discord.com/developers/docs/topics/gateway#invite-create
@@ -1134,6 +1169,45 @@ export type GatewayPresenceUpdateDispatch = DataPayload<
*/
export type GatewayPresenceUpdateDispatchData = RawGatewayPresenceUpdate;
/**
* https://discord.com/developers/docs/topics/gateway#stage-instance-create
*/
export type GatewayStageInstanceCreateDispatch = DataPayload<
GatewayDispatchEvents.StageInstanceCreate,
GatewayStageInstanceCreateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#stage-instance-create
*/
export type GatewayStageInstanceCreateDispatchData = APIStageInstance;
/**
* https://discord.com/developers/docs/topics/gateway#stage-instance-delete
*/
export type GatewayStageInstanceDeleteDispatch = DataPayload<
GatewayDispatchEvents.StageInstanceDelete,
GatewayStageInstanceDeleteDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#stage-instance-delete
*/
export type GatewayStageInstanceDeleteDispatchData = APIStageInstance;
/**
* https://discord.com/developers/docs/topics/gateway#stage-instance-update
*/
export type GatewayStageInstanceUpdateDispatch = DataPayload<
GatewayDispatchEvents.StageInstanceUpdate,
GatewayStageInstanceUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#stage-instance-update
*/
export type GatewayStageInstanceUpdateDispatchData = APIStageInstance;
/**
* https://discord.com/developers/docs/topics/gateway#typing-start
*/
@@ -1250,7 +1324,7 @@ export interface GatewayWebhooksUpdateDispatchData {
* https://discord.com/developers/docs/topics/gateway#heartbeating
*/
export interface GatewayHeartbeat {
op: GatewayOPCodes.Heartbeat;
op: GatewayOpcodes.Heartbeat;
d: GatewayHeartbeatData;
}
@@ -1263,7 +1337,7 @@ export type GatewayHeartbeatData = number | null;
* https://discord.com/developers/docs/topics/gateway#identify
*/
export interface GatewayIdentify {
op: GatewayOPCodes.Identify;
op: GatewayOpcodes.Identify;
d: GatewayIdentifyData;
}
@@ -1303,7 +1377,7 @@ export interface GatewayIdentifyData {
/**
* Presence structure for initial presence information
*
* See https://discord.com/developers/docs/topics/gateway#update-status
* See https://discord.com/developers/docs/topics/gateway#update-presence
*/
presence?: GatewayPresenceUpdateData;
/**
@@ -1336,7 +1410,7 @@ export interface GatewayIdentifyProperties {
* https://discord.com/developers/docs/topics/gateway#resume
*/
export interface GatewayResume {
op: GatewayOPCodes.Resume;
op: GatewayOpcodes.Resume;
d: GatewayResumeData;
}
@@ -1362,7 +1436,7 @@ export interface GatewayResumeData {
* https://discord.com/developers/docs/topics/gateway#request-guild-members
*/
export interface GatewayRequestGuildMembers {
op: GatewayOPCodes.RequestGuildMembers;
op: GatewayOpcodes.RequestGuildMembers;
d: GatewayRequestGuildMembersData;
}
@@ -1405,7 +1479,7 @@ export interface GatewayRequestGuildMembersData {
* https://discord.com/developers/docs/topics/gateway#update-voice-state
*/
export interface GatewayVoiceStateUpdate {
op: GatewayOPCodes.VoiceStateUpdate;
op: GatewayOpcodes.VoiceStateUpdate;
d: GatewayVoiceStateUpdateData;
}
@@ -1432,15 +1506,15 @@ export interface GatewayVoiceStateUpdateData {
}
/**
* https://discord.com/developers/docs/topics/gateway#update-status
* https://discord.com/developers/docs/topics/gateway#update-presence
*/
export interface GatewayUpdatePresence {
op: GatewayOPCodes.PresenceUpdate;
op: GatewayOpcodes.PresenceUpdate;
d: GatewayPresenceUpdateData;
}
/**
* https://discord.com/developers/docs/topics/gateway#update-status-gateway-status-update-structure
* https://discord.com/developers/docs/topics/gateway#update-presence-gateway-presence-update-structure
*/
export interface GatewayPresenceUpdateData {
/**
@@ -1456,7 +1530,7 @@ export interface GatewayPresenceUpdateData {
/**
* The user's new status
*
* See https://discord.com/developers/docs/topics/gateway#update-status-status-types
* See https://discord.com/developers/docs/topics/gateway#update-presence-status-types
*/
status: PresenceUpdateStatus;
/**
@@ -1477,7 +1551,7 @@ interface BasePayload {
/**
* Opcode for the payload
*/
op: GatewayOPCodes;
op: GatewayOpcodes;
/**
* Event data
*/
@@ -1495,7 +1569,7 @@ interface BasePayload {
type NonDispatchPayload = Omit<BasePayload, 't'>;
interface DataPayload<Event extends GatewayDispatchEvents, D = unknown> extends BasePayload {
op: GatewayOPCodes.Dispatch;
op: GatewayOpcodes.Dispatch;
t: Event;
d: D;
}

1717
deno/gateway/v9.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,13 @@
/**
* https://discord.com/developers/docs/reference#snowflakes
*/
export type Snowflake = `${bigint}`;
export type Snowflake = string;
/**
* https://discord.com/developers/docs/topics/permissions
* @internal
*/
export type Permissions = `${bigint}`;
export type Permissions = string;
/**
* https://discord.com/developers/docs/reference#message-formatting-formats
@@ -61,6 +61,24 @@ export const FormattingPatterns = {
* The `name` and `id` group properties are present on the `exec` result of this expression
*/
StaticEmoji: /<:(?<name>\w{2,32}):(?<id>\d{17,20})>/,
/**
* Regular expression for matching a timestamp, either default or custom styled
*
* The `timestamp` and `style` group properties are present on the `exec` result of this expression
*/
Timestamp: /<t:(?<timestamp>-?\d{1,13})(:(?<style>[tTdDfFR]))?>/,
/**
* Regular expression for matching strictly default styled timestamps
*
* The `timestamp` group property is present on the `exec` result of this expression
*/
DefaultStyledTimestamp: /<t:(?<timestamp>-?\d{1,13})>/,
/**
* Regular expression for matching strictly custom styled timestamps
*
* The `timestamp` and `style` group properties are present on the `exec` result of this expression
*/
StyledTimestamp: /<t:(?<timestamp>-?\d{1,13}):(?<style>[tTdDfFR])>/,
} as const;
/**

View File

@@ -1,4 +1,4 @@
// This file exports all the payloads available in the recommended API version
// Thereby, things MAY break in the future. Try sticking to imports from a specific version
export * from './v8/mod.ts';
export * from './v9/mod.ts';

View File

@@ -0,0 +1,101 @@
import type { Permissions, Snowflake } from '../../../globals.ts';
import type { InteractionType } from '../../v8.ts';
import type { APIMessage } from '../channel.ts';
import type { APIGuildMember } from '../guild.ts';
import type { APIUser } from '../user.ts';
/**
* https://discord.com/developers/docs/interactions/slash-commands#message-interaction-object-message-interaction-structure
*/
export interface APIMessageInteraction {
/**
* ID of the interaction
*/
id: Snowflake;
/**
* The type of interaction
*/
type: InteractionType;
/**
* The name of the ApplicationCommand
*/
name: string;
/**
* The user who invoked the interaction
*/
user: APIUser;
}
/**
* https://discord.com/developers/docs/resources/guild#guild-member-object
*/
export interface APIInteractionGuildMember extends APIGuildMember {
permissions: Permissions;
user: APIUser;
}
// INTERACTIONS RECEIVED
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object
*/
export interface APIBaseInteraction<Type extends InteractionType, Data extends unknown> {
/**
* ID of the interaction
*/
id: Snowflake;
/**
* ID of the application this interaction is for
*/
application_id: Snowflake;
/**
* The type of interaction
*/
type: Type;
/**
* The command data payload
*/
data?: Data;
/**
* The guild it was sent from
*/
guild_id?: Snowflake;
/**
* The channel it was sent from
*/
channel_id?: Snowflake;
/**
* Guild member data for the invoking user, including permissions
*
* **This is only sent when an interaction is invoked in a guild**
*/
member?: APIInteractionGuildMember;
/**
* User object for the invoking user, if invoked in a DM
*/
user?: APIUser;
/**
* A continuation token for responding to the interaction
*/
token: string;
/**
* Read-only property, always `1`
*/
version: 1;
/**
* For components, the message they were attached to
*/
message?: APIMessage;
}
export type APIDMInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
Original,
'member' | 'guild_id'
> &
Required<Pick<Original, 'user'>>;
export type APIGuildInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
Original,
'user'
> &
Required<Pick<Original, 'member' | 'guild_id'>>;

View File

@@ -0,0 +1,38 @@
import type { ComponentType } from '../channel.ts';
import type { APIBaseInteraction, InteractionType } from '../interactions.ts';
import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts';
export type APIMessageComponentInteraction = APIBaseInteraction<
InteractionType.MessageComponent,
APIMessageComponentInteractionData
> &
Required<
Pick<
APIBaseInteraction<InteractionType.MessageComponent, APIMessageComponentInteractionData>,
'channel_id' | 'data' | 'message'
>
>;
export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData;
export interface APIMessageComponentBaseInteractionData<CType extends ComponentType> {
/**
* The `custom_id` of the component
*/
custom_id: string;
/**
* The type of the component
*/
component_type: CType;
}
export type APIMessageButtonInteractionData = APIMessageComponentBaseInteractionData<ComponentType.Button>;
export interface APIMessageSelectMenuInteractionData
extends APIMessageComponentBaseInteractionData<ComponentType.SelectMenu> {
values: string[];
}
export type APIMessageComponentDMInteraction = APIDMInteractionWrapper<APIMessageComponentInteraction>;
export type APIMessageComponentGuildInteraction = APIGuildInteractionWrapper<APIMessageComponentInteraction>;

View File

@@ -0,0 +1,4 @@
import type { APIBaseInteraction } from './base.ts';
import type { InteractionType } from './responses.ts';
export type APIPingInteraction = APIBaseInteraction<InteractionType.Ping, never>;

View File

@@ -0,0 +1,78 @@
import type { MessageFlags } from '../mod.ts';
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v8.ts';
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type
*/
export enum InteractionType {
Ping = 1,
ApplicationCommand,
MessageComponent,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object
*/
export type APIInteractionResponse =
| APIInteractionResponsePong
| APIInteractionResponseChannelMessageWithSource
| APIInteractionResponseDeferredChannelMessageWithSource
| APIInteractionResponseDeferredMessageUpdate
| APIInteractionResponseUpdateMessage;
export interface APIInteractionResponsePong {
type: InteractionResponseType.Pong;
}
export interface APIInteractionResponseChannelMessageWithSource {
type: InteractionResponseType.ChannelMessageWithSource;
data: APIInteractionResponseCallbackData;
}
export interface APIInteractionResponseDeferredChannelMessageWithSource {
type: InteractionResponseType.DeferredChannelMessageWithSource;
data?: Pick<APIInteractionResponseCallbackData, 'flags'>;
}
export interface APIInteractionResponseDeferredMessageUpdate {
type: InteractionResponseType.DeferredMessageUpdate;
}
export interface APIInteractionResponseUpdateMessage {
type: InteractionResponseType.UpdateMessage;
data?: APIInteractionResponseCallbackData;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-callback-type
*/
export enum InteractionResponseType {
/**
* ACK a `Ping`
*/
Pong = 1,
/**
* Respond to an interaction with a message
*/
ChannelMessageWithSource = 4,
/**
* ACK an interaction and edit to a response later, the user sees a loading state
*/
DeferredChannelMessageWithSource,
/**
* ACK a button interaction and update it to a loading state
*/
DeferredMessageUpdate,
/**
* ACK a button interaction and edit the message to which the button was attached
*/
UpdateMessage,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-application-command-callback-data-structure
*/
export type APIInteractionResponseCallbackData = Omit<
RESTPostAPIWebhookWithTokenJSONBody,
'username' | 'avatar_url'
> & { flags?: MessageFlags };

View File

@@ -0,0 +1,283 @@
import type { APIRole, APIUser } from '../mod.ts';
import type { Permissions, Snowflake } from '../../../globals.ts';
import type { APIPartialChannel } from '../channel.ts';
import type { APIGuildMember } from '../guild.ts';
import type { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts';
import type { InteractionType } from './responses.ts';
/**
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object
*/
export interface APIApplicationCommand {
/**
* Unique id of the command
*/
id: Snowflake;
/**
* Unique id of the parent application
*/
application_id: Snowflake;
/**
* Guild id of the command, if not global
*/
guild_id?: Snowflake;
/**
* 1-32 character name matching `^[\w-]{1,32}$`
*/
name: string;
/**
* 1-100 character description
*/
description: string;
/**
* The parameters for the command
*/
options?: APIApplicationCommandOption[];
/**
* Whether the command is enabled by default when the app is added to a guild
*
* If missing, this property should be assumed as `true`
*/
default_permission?: boolean;
}
interface APIApplicationCommandOptionBase {
type:
| ApplicationCommandOptionType.Boolean
| ApplicationCommandOptionType.User
| ApplicationCommandOptionType.Channel
| ApplicationCommandOptionType.Role
| ApplicationCommandOptionType.Mentionable;
name: string;
description: string;
default?: boolean;
required?: boolean;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-structure
*/
export type APIApplicationCommandOption =
| APIApplicationCommandArgumentOptions
| APIApplicationCommandSubCommandOptions
| APIApplicationCommandOptionBase;
/**
* This type is exported as a way to make it stricter for you when you're writing your commands
*
* If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters
*/
export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
type: ApplicationCommandOptionType.Subcommand | ApplicationCommandOptionType.SubcommandGroup;
options?: APIApplicationCommandOption[];
}
/**
* This type is exported as a way to make it stricter for you when you're writing your commands
*
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
* but they can have a `choices` one
*/
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
type:
| ApplicationCommandOptionType.String
| ApplicationCommandOptionType.Integer
| ApplicationCommandOptionType.Number;
choices?: APIApplicationCommandOptionChoice[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-type
*/
export enum ApplicationCommandOptionType {
Subcommand = 1,
SubcommandGroup,
String,
Integer,
Boolean,
User,
Channel,
Role,
Mentionable,
Number,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-choice-structure
*/
export interface APIApplicationCommandOptionChoice {
name: string;
value: string | number;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-structure
*/
export interface APIApplicationCommandInteractionData {
id: Snowflake;
name: string;
options?: APIApplicationCommandInteractionDataOption[];
resolved?: {
users?: Record<Snowflake, APIUser>;
roles?: Record<Snowflake, APIRole>;
members?: Record<Snowflake, APIInteractionDataResolvedGuildMember>;
channels?: Record<Snowflake, APIInteractionDataResolvedChannel>;
};
}
/**
* https://discord.com/developers/docs/resources/channel#channel-object
*/
export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
permissions: Permissions;
}
/**
* https://discord.com/developers/docs/resources/guild#guild-member-object
*/
export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {
permissions: Permissions;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-application-command-interaction-data-option-structure
*/
export type APIApplicationCommandInteractionDataOption =
| ApplicationCommandInteractionDataOptionSubCommand
| ApplicationCommandInteractionDataOptionSubCommandGroup
| APIApplicationCommandInteractionDataOptionWithValues;
export interface ApplicationCommandInteractionDataOptionSubCommand {
name: string;
type: ApplicationCommandOptionType.Subcommand;
options: APIApplicationCommandInteractionDataOptionWithValues[];
}
export interface ApplicationCommandInteractionDataOptionSubCommandGroup {
name: string;
type: ApplicationCommandOptionType.SubcommandGroup;
options: ApplicationCommandInteractionDataOptionSubCommand[];
}
export type APIApplicationCommandInteractionDataOptionWithValues =
| ApplicationCommandInteractionDataOptionString
| ApplicationCommandInteractionDataOptionRole
| ApplicationCommandInteractionDataOptionChannel
| ApplicationCommandInteractionDataOptionUser
| ApplicationCommandInteractionDataOptionMentionable
| ApplicationCommandInteractionDataOptionInteger
| ApplicationCommandInteractionDataOptionNumber
| ApplicationCommandInteractionDataOptionBoolean;
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
ApplicationCommandOptionType.String,
string
>;
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
ApplicationCommandOptionType.Role,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase<
ApplicationCommandOptionType.Channel,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase<
ApplicationCommandOptionType.User,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionMentionable = InteractionDataOptionBase<
ApplicationCommandOptionType.Mentionable,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
ApplicationCommandOptionType.Integer,
number
>;
export type ApplicationCommandInteractionDataOptionNumber = InteractionDataOptionBase<
ApplicationCommandOptionType.Number,
number
>;
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
ApplicationCommandOptionType.Boolean,
boolean
>;
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
name: string;
type: T;
value: D;
}
// PERMISSIONS
/**
* https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-guild-application-command-permissions-structure
*/
export interface APIGuildApplicationCommandPermissions {
/**
* The id of the command
*/
id: Snowflake;
/**
* The id of the application the command belongs to
*/
application_id: Snowflake;
/**
* The id of the guild
*/
guild_id: Snowflake;
/**
* The permissions for the command in the guild
*/
permissions: APIApplicationCommandPermission[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-application-command-permissions-structure
*/
export interface APIApplicationCommandPermission {
/**
* The id of the role or user
*/
id: Snowflake;
/**
* Role or user
*/
type: ApplicationCommandPermissionType;
/**
* `true` to allow, `false`, to disallow
*/
permission: boolean;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype
*/
export enum ApplicationCommandPermissionType {
Role = 1,
User,
}
// INTERACTIONS
export type APIApplicationCommandInteraction = APIBaseInteraction<
InteractionType.ApplicationCommand,
APIApplicationCommandInteractionData
> &
Required<
Pick<
APIBaseInteraction<InteractionType.ApplicationCommand, APIApplicationCommandInteractionData>,
'channel_id' | 'data'
>
>;
export type APIApplicationCommandDMInteraction = APIDMInteractionWrapper<APIApplicationCommandInteraction>;
export type APIApplicationCommandGuildInteraction = APIGuildInteractionWrapper<APIApplicationCommandInteraction>;

View File

@@ -0,0 +1,109 @@
/**
* Types extracted from https://discord.com/developers/docs/resources/application
*/
import type { Snowflake } from '../../globals.ts';
import type { APITeam } from './teams.ts';
import type { APIUser } from './user.ts';
/**
* https://discord.com/developers/docs/resources/application#application-object
*/
export interface APIApplication {
/**
* The id of the app
*/
id: Snowflake;
/**
* The name of the app
*/
name: string;
/**
* The icon hash of the app
*/
icon: string | null;
/**
* The description of the app
*/
description: string;
/**
* An array of rpc origin urls, if rpc is enabled
*/
rpc_origins?: string[];
/**
* When `false` only app owner can join the app's bot to guilds
*/
bot_public: boolean;
/**
* When `true` the app's bot will only join upon completion of the full oauth2 code grant flow
*/
bot_require_code_grant: boolean;
/**
* The url of the application's terms of service
*/
terms_of_service_url?: string;
/**
* The url of the application's privacy policy
*/
privacy_policy_url?: string;
/**
* Partial user object containing info on the owner of the application
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
owner?: APIUser;
/**
* If this application is a game sold on Discord, this field will be the summary field for the store page
* of its primary sku
*/
summary: string;
/**
* The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function
*
* See https://discord.com/developers/docs/game-sdk/applications#get-ticket
*/
verify_key: string;
/**
* The team this application belongs to
*
* See https://discord.com/developers/docs/topics/teams#data-models-team-object
*/
team: APITeam | null;
/**
* If this application is a game sold on Discord, this field will be the guild to which it has been linked
*/
guild_id?: Snowflake;
/**
* If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists
*/
primary_sku_id?: Snowflake;
/**
* If this application is a game sold on Discord, this field will be the URL slug that links to the store page
*/
slug?: string;
/**
* If this application is a game sold on Discord, this field will be the hash of the image on store embeds
*/
cover_image?: string;
/**
* The application's public flags
*
* See https://discord.com/developers/docs/resources/application#application-object-application-flags
*/
flags: ApplicationFlags;
}
/**
* https://discord.com/developers/docs/resources/application#application-object-application-flags
*/
export enum ApplicationFlags {
ManagedEmoji = 1 << 2,
GroupDMCreate = 1 << 4,
RPCHasConnected = 1 << 11,
GatewayPresence = 1 << 12,
GatewayPresenceLimited = 1 << 13,
GatewayGuildMembers = 1 << 14,
GatewayGuildMembersLimited = 1 << 15,
VerificationPendingGuildLimit = 1 << 16,
Embedded = 1 << 17,
}

View File

@@ -3,7 +3,7 @@
*/
import type { Snowflake } from '../../globals.ts';
import type { APIOverwrite, ChannelType } from './channel.ts';
import type { APIOverwrite } from './channel.ts';
import type {
APIGuildIntegration,
GuildDefaultMessageNotifications,
@@ -13,8 +13,10 @@ import type {
IntegrationExpireBehavior,
} from './guild.ts';
import type { APIRole } from './permissions.ts';
import type { StickerFormatType } from './sticker.ts';
import type { APIUser } from './user.ts';
import type { APIWebhook } from './webhook.ts';
import type { StageInstancePrivacyLevel } from './stageInstance.ts';
/**
* https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure
@@ -92,49 +94,56 @@ export interface APIAuditLogEntry {
* https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events
*/
export enum AuditLogEvent {
GUILD_UPDATE = 1,
GuildUpdate = 1,
CHANNEL_CREATE = 10,
CHANNEL_UPDATE,
CHANNEL_DELETE,
CHANNEL_OVERWRITE_CREATE,
CHANNEL_OVERWRITE_UPDATE,
CHANNEL_OVERWRITE_DELETE,
ChannelCreate = 10,
ChannelUpdate,
ChannelDelete,
ChannelOverwriteCreate,
ChannelOverwriteUpdate,
ChannelOverwriteDelete,
MEMBER_KICK = 20,
MEMBER_PRUNE,
MEMBER_BAN_ADD,
MEMBER_BAN_REMOVE,
MEMBER_UPDATE,
MEMBER_ROLE_UPDATE,
MEMBER_MOVE,
MEMBER_DISCONNECT,
BOT_ADD,
MemberKick = 20,
MemberPrune,
MemberBanAdd,
MemberBanRemove,
MemberUpdate,
MemberRoleUpdate,
MemberMove,
MemberDisconnect,
BotAdd,
ROLE_CREATE = 30,
ROLE_UPDATE,
ROLE_DELETE,
RoleCreate = 30,
RoleUpdate,
RoleDelete,
INVITE_CREATE = 40,
INVITE_UPDATE,
INVITE_DELETE,
InviteCreate = 40,
InviteUpdate,
InviteDelete,
WEBHOOK_CREATE = 50,
WEBHOOK_UPDATE,
WEBHOOK_DELETE,
WebhookCreate = 50,
WebhookUpdate,
WebhookDelete,
EMOJI_CREATE = 60,
EMOJI_UPDATE,
EMOJI_DELETE,
EmojiCreate = 60,
EmojiUpdate,
EmojiDelete,
MESSAGE_DELETE = 72,
MESSAGE_BULK_DELETE,
MESSAGE_PIN,
MESSAGE_UNPIN,
MessageDelete = 72,
MessageBulkDelete,
MessagePin,
MessageUnpin,
INTEGRATION_CREATE = 80,
INTEGRATION_UPDATE,
INTEGRATION_DELETE,
IntegrationCreate = 80,
IntegrationUpdate,
IntegrationDelete,
StageInstanceCreate,
StageInstanceUpdate,
StageInstanceDelete,
StickerCreate = 90,
StickerUpdate,
StickerDelete,
}
/**
@@ -164,6 +173,9 @@ export interface APIAuditLogOptions {
* - MESSAGE_PIN
* - MESSAGE_UNPIN
* - MESSAGE_DELETE
* - STAGE_INSTANCE_CREATE
* - STAGE_INSTANCE_UPDATE
* - STAGE_INSTANCE_DELETE
*/
channel_id?: Snowflake;
@@ -237,13 +249,13 @@ export type APIAuditLogChange =
| APIAuditLogChangeKeySplashHash
| APIAuditLogChangeKeyDiscoverySplashHash
| APIAuditLogChangeKeyBannerHash
| APIAuditLogChangeKeyOwnerID
| APIAuditLogChangeKeyOwnerId
| APIAuditLogChangeKeyRegion
| APIAuditLogChangeKeyPreferredLocale
| APIAuditLogChangeKeyAFKChannelID
| APIAuditLogChangeKeyAFKChannelId
| APIAuditLogChangeKeyAFKTimeout
| APIAuditLogChangeKeyRulesChannelID
| APIAuditLogChangeKeyPublicUpdatesChannelID
| APIAuditLogChangeKeyRulesChannelId
| APIAuditLogChangeKeyPublicUpdatesChannelId
| APIAuditLogChangeKeyMFALevel
| APIAuditLogChangeKeyVerificationLevel
| APIAuditLogChangeKeyExplicitContentFilter
@@ -253,14 +265,14 @@ export type APIAuditLogChange =
| APIAuditLogChangeKey$Remove
| APIAuditLogChangeKeyPruneDeleteDays
| APIAuditLogChangeKeyWidgetEnabled
| APIAuditLogChangeKeyWidgetChannelID
| APIAuditLogChangeKeySystemChannelID
| APIAuditLogChangeKeyWidgetChannelId
| APIAuditLogChangeKeySystemChannelId
| APIAuditLogChangeKeyPosition
| APIAuditLogChangeKeyTopic
| APIAuditLogChangeKeyBitrate
| APIAuditLogChangeKeyPermissionOverwrites
| APIAuditLogChangeKeyNSFW
| APIAuditLogChangeKeyApplicationID
| APIAuditLogChangeKeyApplicationId
| APIAuditLogChangeKeyRateLimitPerUser
| APIAuditLogChangeKeyPermissions
| APIAuditLogChangeKeyColor
@@ -269,8 +281,8 @@ export type APIAuditLogChange =
| APIAuditLogChangeKeyAllow
| APIAuditLogChangeKeyDeny
| APIAuditLogChangeKeyCode
| APIAuditLogChangeKeyChannelID
| APIAuditLogChangeKeyInviterID
| APIAuditLogChangeKeyChannelId
| APIAuditLogChangeKeyInviterId
| APIAuditLogChangeKeyMaxUses
| APIAuditLogChangeKeyUses
| APIAuditLogChangeKeyMaxAge
@@ -279,20 +291,26 @@ export type APIAuditLogChange =
| APIAuditLogChangeKeyMute
| APIAuditLogChangeKeyNick
| APIAuditLogChangeKeyAvatarHash
| APIAuditLogChangeKeyID
| APIAuditLogChangeKeyId
| APIAuditLogChangeKeyType
| APIAuditLogChangeKeyEnableEmoticons
| APIAuditLogChangeKeyExpireBehavior
| APIAuditLogChangeKeyExpireGracePeriod
| APIAuditLogChangeKeyUserLimit;
| APIAuditLogChangeKeyUserLimit
| APIAuditLogChangeKeyPrivacyLevel
| APIAuditLogChangeKeyTags
| APIAuditLogChangeKeyFormatType
| APIAuditLogChangeKeyAsset
| APIAuditLogChangeKeyAvailable
| APIAuditLogChangeKeyGuildId;
/**
* Returned when a guild's name is changed
* Returned when an entity's name is changed
*/
export type APIAuditLogChangeKeyName = AuditLogChangeData<'name', string>;
/**
* Returned when a guild's description is changed
* Returned when a guild's or sticker's description is changed
*/
export type APIAuditLogChangeKeyDescription = AuditLogChangeData<'description', string>;
@@ -319,7 +337,7 @@ export type APIAuditLogChangeKeyBannerHash = AuditLogChangeData<'banner_hash', s
/**
* Returned when a guild's owner_id is changed
*/
export type APIAuditLogChangeKeyOwnerID = AuditLogChangeData<'owner_id', Snowflake>;
export type APIAuditLogChangeKeyOwnerId = AuditLogChangeData<'owner_id', Snowflake>;
/**
* Returned when a guild's region is changed
@@ -334,7 +352,7 @@ export type APIAuditLogChangeKeyPreferredLocale = AuditLogChangeData<'preferred_
/**
* Returned when a guild's afk_channel_id is changed
*/
export type APIAuditLogChangeKeyAFKChannelID = AuditLogChangeData<'afk_channel_id', Snowflake>;
export type APIAuditLogChangeKeyAFKChannelId = AuditLogChangeData<'afk_channel_id', Snowflake>;
/**
* Returned when a guild's afk_timeout is changed
@@ -344,12 +362,12 @@ export type APIAuditLogChangeKeyAFKTimeout = AuditLogChangeData<'afk_timeout', n
/**
* Returned when a guild's rules_channel_id is changed
*/
export type APIAuditLogChangeKeyRulesChannelID = AuditLogChangeData<'rules_channel_id', string>;
export type APIAuditLogChangeKeyRulesChannelId = AuditLogChangeData<'rules_channel_id', string>;
/**
* Returned when a guild's public_updates_channel_id is changed
*/
export type APIAuditLogChangeKeyPublicUpdatesChannelID = AuditLogChangeData<'public_updates_channel_id', string>;
export type APIAuditLogChangeKeyPublicUpdatesChannelId = AuditLogChangeData<'public_updates_channel_id', string>;
/**
* Returned when a guild's mfa_level is changed
@@ -405,12 +423,12 @@ export type APIAuditLogChangeKeyWidgetEnabled = AuditLogChangeData<'widget_enabl
/**
* Returned when a guild's widget_channel_id is changed
*/
export type APIAuditLogChangeKeyWidgetChannelID = AuditLogChangeData<'widget_channel_id', Snowflake>;
export type APIAuditLogChangeKeyWidgetChannelId = AuditLogChangeData<'widget_channel_id', Snowflake>;
/**
* Returned when a guild's system_channel_id is changed
*/
export type APIAuditLogChangeKeySystemChannelID = AuditLogChangeData<'system_channel_id', Snowflake>;
export type APIAuditLogChangeKeySystemChannelId = AuditLogChangeData<'system_channel_id', Snowflake>;
/**
* Returned when a channel's position is changed
@@ -440,7 +458,7 @@ export type APIAuditLogChangeKeyNSFW = AuditLogChangeData<'nsfw', boolean>;
/**
* The application ID of the added or removed Webhook or Bot
*/
export type APIAuditLogChangeKeyApplicationID = AuditLogChangeData<'application_id', Snowflake>;
export type APIAuditLogChangeKeyApplicationId = AuditLogChangeData<'application_id', Snowflake>;
/**
* Returned when a channel's amount of seconds a user has to wait before sending another message
@@ -486,12 +504,12 @@ export type APIAuditLogChangeKeyCode = AuditLogChangeData<'code', string>;
/**
* Returned when an invite's channel_id is changed
*/
export type APIAuditLogChangeKeyChannelID = AuditLogChangeData<'channel_id', Snowflake>;
export type APIAuditLogChangeKeyChannelId = AuditLogChangeData<'channel_id', Snowflake>;
/**
* Returned when an invite's inviter_id is changed
*/
export type APIAuditLogChangeKeyInviterID = AuditLogChangeData<'inviter_id', Snowflake>;
export type APIAuditLogChangeKeyInviterId = AuditLogChangeData<'inviter_id', Snowflake>;
/**
* Returned when an invite's max_uses is changed
@@ -526,7 +544,7 @@ export type APIAuditLogChangeKeyMute = AuditLogChangeData<'mute', boolean>;
/**
* Returned when a user's nick is changed
*/
export type APIAuditLogChangeKeyNick = AuditLogChangeData<'mute', boolean>;
export type APIAuditLogChangeKeyNick = AuditLogChangeData<'nick', boolean>;
/**
* Returned when a user's avatar_hash is changed
@@ -536,12 +554,12 @@ export type APIAuditLogChangeKeyAvatarHash = AuditLogChangeData<'avatar_hash', s
/**
* The ID of the changed entity - sometimes used in conjunction with other keys
*/
export type APIAuditLogChangeKeyID = AuditLogChangeData<'id', Snowflake>;
export type APIAuditLogChangeKeyId = AuditLogChangeData<'id', Snowflake>;
/**
* The type of entity created
*/
export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', ChannelType | string>;
export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', number | string>;
/**
* Returned when an integration's enable_emoticons is changed
@@ -563,6 +581,36 @@ export type APIAuditLogChangeKeyExpireGracePeriod = AuditLogChangeData<'expire_g
*/
export type APIAuditLogChangeKeyUserLimit = AuditLogChangeData<'user_limit', number>;
/**
* Returned when privacy level of a stage instance is changed
*/
export type APIAuditLogChangeKeyPrivacyLevel = AuditLogChangeData<'privacy_level', StageInstancePrivacyLevel>;
/**
* Returned when a sticker's related emoji is changed
*/
export type APIAuditLogChangeKeyTags = AuditLogChangeData<'tags', string>;
/**
* Returned when a sticker's format_type is changed
*/
export type APIAuditLogChangeKeyFormatType = AuditLogChangeData<'format_type', StickerFormatType>;
/**
* Empty string
*/
export type APIAuditLogChangeKeyAsset = AuditLogChangeData<'asset', ''>;
/**
* Returned when a sticker's availability is changed
*/
export type APIAuditLogChangeKeyAvailable = AuditLogChangeData<'available', boolean>;
/**
* Returned when a sticker's guild_id is changed
*/
export type APIAuditLogChangeKeyGuildId = AuditLogChangeData<'guild_id', Snowflake>;
interface AuditLogChangeData<K extends string, D extends unknown> {
key: K;
/**

View File

@@ -6,8 +6,9 @@ import type { Permissions, Snowflake } from '../../globals.ts';
import type { APIPartialEmoji } from './emoji.ts';
import type { APIGuildMember } from './guild.ts';
import type { APIMessageInteraction } from './interactions.ts';
import { APIApplication } from './oauth2.ts';
import type { APIApplication } from './application.ts';
import type { APIRole } from './permissions.ts';
import type { APISticker, APIStickerItem } from './sticker.ts';
import type { APIUser } from './user.ts';
/**
@@ -121,7 +122,7 @@ export enum ChannelType {
/**
* A text channel within a guild
*/
GUILD_TEXT,
GuildText,
/**
* A direct message between users
*/
@@ -129,46 +130,46 @@ export enum ChannelType {
/**
* A voice channel within a guild
*/
GUILD_VOICE,
GuildVoice,
/**
* A direct message between multiple users
*/
GROUP_DM,
GroupDM,
/**
* An organizational category that contains up to 50 channels
*
* See https://support.discord.com/hc/en-us/articles/115001580171-Channel-Categories-101
*/
GUILD_CATEGORY,
GuildCategory,
/**
* A channel that users can follow and crosspost into their own guild
*
* See https://support.discord.com/hc/en-us/articles/360032008192
*/
GUILD_NEWS,
GuildNews,
/**
* A channel in which game developers can sell their game on Discord
*
* See https://discord.com/developers/docs/game-and-server-management/special-channels
*/
GUILD_STORE,
GuildStore,
/**
* A voice channel for hosting events with an audience
*
* See https://support.discord.com/hc/en-us/articles/1500005513722
*/
GUILD_STAGE_VOICE = 13,
GuildStageVoice = 13,
}
export enum VideoQualityMode {
/**
* Discord chooses the quality for optimal performance
*/
AUTO = 1,
Auto = 1,
/**
* 720p
*/
FULL,
Full,
}
/**
@@ -305,7 +306,11 @@ export interface APIMessage {
*/
application?: Partial<APIApplication>;
/**
* Reference data sent with crossposted messages and replies
* If the message is a response to an Interaction, this is the id of the interaction's application
*/
application_id?: Snowflake;
/**
* Reference data sent with crossposted messages, replies, pins, and thread starter messages
*
* See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
*/
@@ -318,12 +323,6 @@ export interface APIMessage {
* See https://en.wikipedia.org/wiki/Bit_field
*/
flags?: MessageFlags;
/**
* The stickers sent with the message (bots currently can only receive messages with stickers, not send)
*
* See https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure
*/
stickers?: APISticker[];
/**
* The message associated with the `message_reference`
*
@@ -342,32 +341,49 @@ export interface APIMessage {
* Sent if the message is a response to an Interaction
*/
interaction?: APIMessageInteraction;
/**
* Sent if the message contains components like buttons, action rows, or other interactive components
*/
components?: APIActionRowComponent[];
/**
* Sent if the message contains stickers
*
* See https://discord.com/developers/docs/resources/sticker#sticker-item-object
*/
sticker_items?: APIStickerItem[];
/**
* The stickers sent with the message
*
* See https://discord.com/developers/docs/resources/sticker#sticker-object
* @deprecated Use `sticker_items` instead
*/
stickers?: APISticker[];
}
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-types
*/
export enum MessageType {
DEFAULT,
RECIPIENT_ADD,
RECIPIENT_REMOVE,
CALL,
CHANNEL_NAME_CHANGE,
CHANNEL_ICON_CHANGE,
CHANNEL_PINNED_MESSAGE,
GUILD_MEMBER_JOIN,
USER_PREMIUM_GUILD_SUBSCRIPTION,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3,
CHANNEL_FOLLOW_ADD,
GUILD_DISCOVERY_DISQUALIFIED = 14,
GUILD_DISCOVERY_REQUALIFIED,
GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING,
GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING,
REPLY = 19,
APPLICATION_COMMAND,
GUILD_INVITE_REMINDER = 22,
Default,
RecipientAdd,
RecipientRemove,
Call,
ChannelNameChange,
ChannelIconChange,
ChannelPinnedMessage,
GuildMemberJoin,
UserPremiumGuildSubscription,
UserPremiumGuildSubscriptionTier1,
UserPremiumGuildSubscriptionTier2,
UserPremiumGuildSubscriptionTier3,
ChannelFollowAdd,
GuildDiscoveryDisqualified = 14,
GuildDiscoveryRequalified,
GuildDiscoveryGracePeriodInitialWarning,
GuildDiscoveryGracePeriodFinalWarning,
Reply = 19,
ApplicationCommand,
GuildInviteReminder = 22,
}
/**
@@ -410,10 +426,10 @@ export interface APIMessageReference {
* https://discord.com/developers/docs/resources/channel#message-object-message-activity-types
*/
export enum MessageActivityType {
JOIN = 1,
SPECTATE,
LISTEN,
JOIN_REQUEST = 5,
Join = 1,
Spectate,
Listen,
JoinRequest = 5,
}
/**
@@ -423,76 +439,31 @@ export enum MessageFlags {
/**
* This message has been published to subscribed channels (via Channel Following)
*/
CROSSPOSTED = 1 << 0,
Crossposted = 1 << 0,
/**
* This message originated from a message in another channel (via Channel Following)
*/
IS_CROSSPOST = 1 << 1,
IsCrosspost = 1 << 1,
/**
* Do not include any embeds when serializing this message
*/
SUPPRESS_EMBEDS = 1 << 2,
SuppressEmbeds = 1 << 2,
/**
* The source message for this crosspost has been deleted (via Channel Following)
*/
SOURCE_MESSAGE_DELETED = 1 << 3,
SourceMessageDeleted = 1 << 3,
/**
* This message came from the urgent message system
*/
URGENT = 1 << 4,
Urgent = 1 << 4,
/**
* This message is only visible to the user who invoked the Interaction
*/
EPHEMERAL = 1 << 6,
Ephemeral = 1 << 6,
/**
* This message is an Interaction Response and the bot is "thinking"
*/
LOADING = 1 << 7,
}
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure
*/
export interface APISticker {
/**
* ID of the sticker
*/
id: Snowflake;
/**
* ID of the pack the sticker is from
*/
pack_id: Snowflake;
/**
* Name of the sticker
*/
name: string;
/**
* Description of the sticker
*/
description: string;
/**
* A comma-separated list of tags for the sticker
*/
tags?: string;
/**
* Sticker asset hash
*/
asset: string;
/**
* Type of sticker format
*
* See https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types
*/
format_type: StickerFormatType;
}
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types
*/
export enum StickerFormatType {
PNG = 1,
APNG,
LOTTIE,
Loading = 1 << 7,
}
/**
@@ -589,7 +560,7 @@ export interface APIEmbed {
/**
* Description of embed
*
* Length limit: 2048 characters
* Length limit: 4096 characters
*/
description?: string;
/**
@@ -670,7 +641,7 @@ export enum EmbedType {
/**
* Animated gif image embed rendered as a video embed
*/
GifV = 'gifv',
GIFV = 'gifv',
/**
* Article embed
*/
@@ -930,3 +901,175 @@ export interface APIAllowedMentions {
*/
replied_user?: boolean;
}
/**
* https://discord.com/developers/docs/interactions/message-components#component-object
*/
export interface APIBaseMessageComponent<T extends ComponentType> {
/**
* The type of the component
*/
type: T;
}
/**
* https://discord.com/developers/docs/interactions/message-components#component-types
*/
export enum ComponentType {
/**
* Action Row component
*/
ActionRow = 1,
/**
* Button component
*/
Button,
/**
* Select Menu component
*/
SelectMenu,
}
/**
* https://discord.com/developers/docs/interactions/message-components#action-rows
*/
export interface APIActionRowComponent extends APIBaseMessageComponent<ComponentType.ActionRow> {
/**
* The components in the ActionRow
*/
components: Exclude<APIMessageComponent, APIActionRowComponent>[];
}
/**
* https://discord.com/developers/docs/interactions/message-components#buttons
*/
interface APIButtonComponentBase<Style extends ButtonStyle> extends APIBaseMessageComponent<ComponentType.Button> {
/**
* The label to be displayed on the button
*/
label?: string;
/**
* The style of the button
*/
style: Style;
/**
* The emoji to display to the left of the text
*/
emoji?: APIMessageComponentEmoji;
/**
* The status of the button
*/
disabled?: boolean;
}
export interface APIMessageComponentEmoji {
/**
* Emoji id
*/
id?: Snowflake;
/**
* Emoji name
*/
name?: string;
/**
* Whether this emoji is animated
*/
animated?: boolean;
}
export interface APIButtonComponentWithCustomId
extends APIButtonComponentBase<
ButtonStyle.Primary | ButtonStyle.Secondary | ButtonStyle.Success | ButtonStyle.Danger
> {
/**
* The custom_id to be sent in the interaction when clicked
*/
custom_id: string;
}
export interface APIButtonComponentWithURL extends APIButtonComponentBase<ButtonStyle.Link> {
/**
* The URL to direct users to when clicked for Link buttons
*/
url: string;
}
export type APIButtonComponent = APIButtonComponentWithCustomId | APIButtonComponentWithURL;
/**
* https://discord.com/developers/docs/interactions/message-components#button-object-button-styles
*/
export enum ButtonStyle {
Primary = 1,
Secondary,
Success,
Danger,
Link,
}
/**
* https://discord.com/developers/docs/interactions/message-components#select-menus
*/
export interface APISelectMenuComponent extends APIBaseMessageComponent<ComponentType.SelectMenu> {
/**
* A developer-defined identifier for the select menu, max 100 characters
*/
custom_id: string;
/**
* The choices in the select, max 25
*/
options: APISelectMenuOption[];
/**
* Custom placeholder text if nothing is selected, max 100 characters
*/
placeholder?: string;
/**
* The minimum number of items that must be chosen; min 0, max 25
*
* @default 1
*/
min_values?: number;
/**
* The maximum number of items that can be chosen; max 25
*
* @default 1
*/
max_values?: number;
/**
* Disable the select
*
* @default false
*/
disabled?: boolean;
}
/**
* https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure
*/
export interface APISelectMenuOption {
/**
* The user-facing name of the option (max 25 chars)
*/
label: string;
/**
* The dev-defined value of the option (max 100 chars)
*/
value: string;
/**
* An additional description of the option (max 50 chars)
*/
description?: string;
/**
* The emoji to display to the left of the option
*/
emoji?: APIMessageComponentEmoji;
/**
* Whether this option should be already-selected by default
*/
default?: boolean;
}
/**
* https://discord.com/developers/docs/interactions/message-components#message-components
*/
export type APIMessageComponent = APIActionRowComponent | APIButtonComponent | APISelectMenuComponent;

View File

@@ -292,12 +292,12 @@ export type GatewayActivitySecrets = Partial<Record<'join' | 'spectate' | 'match
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags
*/
export enum ActivityFlags {
INSTANCE = 1 << 0,
JOIN = 1 << 1,
SPECTATE = 1 << 2,
JOIN_REQUEST = 1 << 3,
SYNC = 1 << 4,
PLAY = 1 << 5,
Instance = 1 << 0,
Join = 1 << 1,
Spectate = 1 << 2,
JoinRequest = 1 << 3,
Sync = 1 << 4,
Play = 1 << 5,
}
export interface GatewayActivityButton {

View File

@@ -7,6 +7,8 @@ import type { APIChannel } from './channel.ts';
import type { APIEmoji } from './emoji.ts';
import type { GatewayPresenceUpdate, 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';
@@ -244,7 +246,7 @@ export interface APIGuild extends APIPartialGuild {
*/
presences?: GatewayPresenceUpdate[];
/**
* The maximum number of presences for the guild (the default value, currently 25000, is in effect when `null` is returned)
* The maximum number of presences for the guild (`null` is always returned, apart from the largest of guilds)
*/
max_presences?: number | null;
/**
@@ -304,36 +306,60 @@ export interface APIGuild extends APIPartialGuild {
*/
welcome_screen?: APIGuildWelcomeScreen;
/**
* `true` if this guild is designated as NSFW
* The nsfw level of the guild
*
* See https://support.discord.com/hc/en-us/articles/1500005389362-NSFW-Server-Designation
* See https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level
*/
nsfw: boolean;
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
*
* See https://discord.com/developers/docs/resources/sticker#sticker-object
*/
stickers: APISticker[];
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
*/
export enum GuildDefaultMessageNotifications {
ALL_MESSAGES,
ONLY_MENTIONS,
AllMessages,
OnlyMentions,
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level
*/
export enum GuildExplicitContentFilter {
DISABLED,
MEMBERS_WITHOUT_ROLES,
ALL_MEMBERS,
Disabled,
MembersWithoutRoles,
AllMembers,
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-mfa-level
*/
export enum GuildMFALevel {
NONE,
ELEVATED,
None,
Elevated,
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level
*/
export enum GuildNSFWLevel {
Default,
Explicit,
Safe,
AgeRestricted,
}
/**
@@ -343,33 +369,33 @@ export enum GuildVerificationLevel {
/**
* Unrestricted
*/
NONE,
None,
/**
* Must have verified email on account
*/
LOW,
Low,
/**
* Must be registered on Discord for longer than 5 minutes
*/
MEDIUM,
Medium,
/**
* Must be a member of the guild for longer than 10 minutes
*/
HIGH,
High,
/**
* Must have a verified phone number
*/
VERY_HIGH,
VeryHigh,
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-premium-tier
*/
export enum GuildPremiumTier {
NONE,
TIER_1,
TIER_2,
TIER_3,
None,
Tier1,
Tier2,
Tier3,
}
/**
@@ -379,15 +405,15 @@ export enum GuildSystemChannelFlags {
/**
* Suppress member join notifications
*/
SUPPRESS_JOIN_NOTIFICATIONS = 1 << 0,
SuppressJoinNotifications = 1 << 0,
/**
* Suppress server boost notifications
*/
SUPPRESS_PREMIUM_SUBSCRIPTIONS = 1 << 1,
SuppressPremiumSubscriptions = 1 << 1,
/**
* Suppress server setup tips
*/
SUPPRESS_GUILD_REMINDER_NOTIFICATIONS = 1 << 2,
SuppressGuildReminderNotifications = 1 << 2,
}
/**
@@ -397,64 +423,88 @@ export enum GuildFeature {
/**
* Guild has access to set an animated guild icon
*/
ANIMATED_ICON = 'ANIMATED_ICON',
AnimatedIcon = 'ANIMATED_ICON',
/**
* Guild has access to set a guild banner image
*/
BANNER = 'BANNER',
Banner = 'BANNER',
/**
* Guild has access to use commerce features (i.e. create store channels)
*/
COMMERCE = 'COMMERCE',
Commerce = 'COMMERCE',
/**
* Guild can enable welcome screen, Membership Screening and discovery, and receives community updates
*/
COMMUNITY = 'COMMUNITY',
Community = 'COMMUNITY',
/**
* Guild is able to be discovered in the directory
*/
DISCOVERABLE = 'DISCOVERABLE',
Discoverable = 'DISCOVERABLE',
/**
* Guild is able to be featured in the directory
*/
FEATURABLE = 'FEATURABLE',
Featurable = 'FEATURABLE',
/**
* Guild has access to set an invite splash background
*/
INVITE_SPLASH = 'INVITE_SPLASH',
InviteSplash = 'INVITE_SPLASH',
/**
* Guild has access to create news channels
*/
NEWS = 'NEWS',
News = 'NEWS',
/**
* Guild is partnered
*/
PARTNERED = 'PARTNERED',
RELAY_ENABLED = 'RELAY_ENABLED',
Partnered = 'PARTNERED',
RelayEnabled = 'RELAY_ENABLED',
/**
* Guild has access to set a vanity URL
*/
VANITY_URL = 'VANITY_URL',
VanityURL = 'VANITY_URL',
/**
* Guild is verified
*/
VERIFIED = 'VERIFIED',
Verified = 'VERIFIED',
/**
* Guild has access to set 384kbps bitrate in voice (previously VIP voice servers)
*/
VIP_REGIONS = 'VIP_REGIONS',
VIPRegions = 'VIP_REGIONS',
/**
* Guild has enabled the welcome screen
*/
WELCOME_SCREEN_ENABLED = 'WELCOME_SCREEN_ENABLED',
WelcomeScreenEnabled = 'WELCOME_SCREEN_ENABLED',
/**
* Guild has enabled Membership Screening
*/
MEMBER_VERIFICATION_GATE_ENABLED = 'MEMBER_VERIFICATION_GATE_ENABLED',
MemberVerificationGateEnabled = 'MEMBER_VERIFICATION_GATE_ENABLED',
/**
* Guild can be previewed before joining via Membership Screening or the directory
*/
PREVIEW_ENABLED = 'PREVIEW_ENABLED',
PreviewEnabled = 'PREVIEW_ENABLED',
/**
* Guild has enabled ticketed events
*/
TicketedEventsEnabled = 'TICKETED_EVENTS_ENABLED',
/**
* Guild has enabled monetization
*/
MonetizationEnabled = 'MONETIZATION_ENABLED',
/**
* Guild has increased custom sticker slots
*/
MoreStickers = 'MORE_STICKERS',
/**
* Guild has access to the three day archive time for threads
*/
ThreeDayThreadArchive = 'THREE_DAY_THREAD_ARCHIVE',
/**
* Guild has access to the seven day archive time for threads
*/
SevenDayThreadArchive = 'SEVEN_DAY_THREAD_ARCHIVE',
/**
* Guild has access to create private threads
*/
PrivateThreads = 'PRIVATE_THREADS',
}
/**
@@ -872,5 +922,5 @@ export enum MembershipScreeningFieldType {
/**
* Server Rules
*/
TERMS = 'TERMS',
Terms = 'TERMS',
}

View File

@@ -1,396 +1,23 @@
import type { Permissions, Snowflake } from '../../globals.ts';
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../rest/v8/mod.ts';
import type { APIGuildMember, APIPartialChannel, APIRole, APIUser, MessageFlags } from './mod.ts';
import type {
APIMessageComponentDMInteraction,
APIMessageComponentGuildInteraction,
APIMessageComponentInteraction,
} from './_interactions/messageComponents.ts';
import type { APIPingInteraction } from './_interactions/ping.ts';
import type {
APIApplicationCommandDMInteraction,
APIApplicationCommandGuildInteraction,
APIApplicationCommandInteraction,
} from './_interactions/slashCommands.ts';
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
*/
export interface APIApplicationCommand {
/**
* Unique id of the command
*/
id: Snowflake;
/**
* Unique id of the parent application
*/
application_id: Snowflake;
/**
* 1-32 character name matching `^[\w-]{1,32}$`
*/
name: string;
/**
* 1-100 character description
*/
description: string;
/**
* The parameters for the command
*/
options?: APIApplicationCommandOption[];
/**
* Whether the command is enabled by default when the app is added to a guild
*
* If missing, this property should be assumed as `true`
*/
default_permission?: boolean;
}
export * from './_interactions/base.ts';
export * from './_interactions/messageComponents.ts';
export * from './_interactions/ping.ts';
export * from './_interactions/responses.ts';
export * from './_interactions/slashCommands.ts';
interface APIApplicationCommandOptionBase {
type:
| ApplicationCommandOptionType.BOOLEAN
| ApplicationCommandOptionType.USER
| ApplicationCommandOptionType.CHANNEL
| ApplicationCommandOptionType.ROLE;
name: string;
description: string;
default?: boolean;
required?: boolean;
}
export type APIInteraction = APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction;
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption
*/
export type APIApplicationCommandOption =
| APIApplicationCommandArgumentOptions
| APIApplicationCommandSubCommandOptions
| APIApplicationCommandOptionBase;
export type APIDMInteraction = APIApplicationCommandDMInteraction | APIMessageComponentDMInteraction;
/**
* This type is exported as a way to make it stricter for you when you're writing your commands
*
* If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters
*/
export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
type: ApplicationCommandOptionType.SUB_COMMAND | ApplicationCommandOptionType.SUB_COMMAND_GROUP;
options?: APIApplicationCommandOption[];
}
/**
* This type is exported as a way to make it stricter for you when you're writing your commands
*
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
* but they can have a `choices` one
*/
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
type: ApplicationCommandOptionType.STRING | ApplicationCommandOptionType.INTEGER;
choices?: APIApplicationCommandOptionChoice[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype
*/
export enum ApplicationCommandOptionType {
SUB_COMMAND = 1,
SUB_COMMAND_GROUP,
STRING,
INTEGER,
BOOLEAN,
USER,
CHANNEL,
ROLE,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice
*/
export interface APIApplicationCommandOptionChoice {
name: string;
value: string | number;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction
*/
export interface APIBaseInteraction {
/**
* ID of the interaction
*/
id: Snowflake;
/**
* ID of the application this interaction is for
*/
application_id: Snowflake;
/**
* The type of interaction
*/
type: InteractionType;
/**
* The command data payload
*/
data?: APIApplicationCommandInteractionData;
/**
* The channel it was sent from
*/
channel_id?: Snowflake;
/**
* A continuation token for responding to the interaction
*/
token: string;
/**
* Read-only property, always `1`
*/
version: 1;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction
*/
export interface APIGuildInteraction extends APIBaseInteraction {
/**
* The guild it was sent from
*
* In the case of an `APIDMInteraction`, this will not be present
*/
guild_id: Snowflake;
/**
* Guild member data for the invoking user, including permissions
*/
member: APIGuildMember & { permissions: Permissions; user: APIUser };
channel_id: Snowflake;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction
*/
export interface APIDMInteraction extends APIBaseInteraction {
/**
* User object for the invoking user, if invoked in a DM
*/
user: APIUser;
channel_id: Snowflake;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction
*/
export type APIInteraction = APIGuildInteraction | APIDMInteraction;
/**
* Like APIGuildInteraction, only with the `data` property always present
*
* @see APIGuildInteraction
*/
export type APIApplicationCommandGuildInteraction = Required<APIGuildInteraction>;
/**
* Like APIDMInteraction, only with the `data` property always present
*
* @see APIDMInteraction
*/
export type APIApplicationCommandDMInteraction = Required<APIDMInteraction>;
/**
* Like APIInteraction, only with the `data` property always present
*
* @see APIInteraction
*/
export type APIApplicationCommandInteraction =
| APIApplicationCommandGuildInteraction
| APIApplicationCommandDMInteraction;
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype
*/
export enum InteractionType {
Ping = 1,
ApplicationCommand,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#guildapplicationcommandpermissions
*/
export interface APIGuildApplicationCommandPermissions {
/**
* The id of the command
*/
id: Snowflake;
/**
* The id of the application the command belongs to
*/
application_id: Snowflake;
/**
* The id of the guild
*/
guild_id: Snowflake;
/**
* The permissions for the command in the guild
*/
permissions: APIApplicationCommandPermission[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissions
*/
export interface APIApplicationCommandPermission {
/**
* The id of the role or user
*/
id: Snowflake;
/**
* Role or user
*/
type: ApplicationCommandPermissionType;
/**
* `true` to allow, `false`, to disallow
*/
permission: boolean;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype
*/
export enum ApplicationCommandPermissionType {
ROLE = 1,
USER,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata
*/
export interface APIApplicationCommandInteractionData {
id: Snowflake;
name: string;
options?: APIApplicationCommandInteractionDataOption[];
resolved?: {
users?: Record<string, APIUser>;
roles?: Record<string, APIRole>;
members?: Record<string, Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> & { permissions: Permissions }>;
channels?: Record<string, Required<APIPartialChannel> & { permissions: Permissions }>;
};
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption
*/
export type APIApplicationCommandInteractionDataOption =
| ApplicationCommandInteractionDataOptionSubCommand
| ApplicationCommandInteractionDataOptionSubCommandGroup
| APIApplicationCommandInteractionDataOptionWithValues;
export interface ApplicationCommandInteractionDataOptionSubCommand {
name: string;
type: ApplicationCommandOptionType.SUB_COMMAND;
options: APIApplicationCommandInteractionDataOptionWithValues[];
}
export interface ApplicationCommandInteractionDataOptionSubCommandGroup {
name: string;
type: ApplicationCommandOptionType.SUB_COMMAND_GROUP;
options: ApplicationCommandInteractionDataOptionSubCommand[];
}
export type APIApplicationCommandInteractionDataOptionWithValues =
| ApplicationCommandInteractionDataOptionString
| ApplicationCommandInteractionDataOptionRole
| ApplicationCommandInteractionDataOptionChannel
| ApplicationCommandInteractionDataOptionUser
| ApplicationCommandInteractionDataOptionInteger
| ApplicationCommandInteractionDataOptionBoolean;
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
ApplicationCommandOptionType.STRING,
string
>;
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
ApplicationCommandOptionType.ROLE,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase<
ApplicationCommandOptionType.CHANNEL,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase<
ApplicationCommandOptionType.USER,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
ApplicationCommandOptionType.INTEGER,
number
>;
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
ApplicationCommandOptionType.BOOLEAN,
boolean
>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response
*/
export type APIInteractionResponse =
| APIInteractionResponsePong
| APIInteractionResponseChannelMessageWithSource
| APIInteractionResponseDeferredChannelMessageWithSource;
export interface APIInteractionResponsePong {
type: InteractionResponseType.Pong;
}
export interface APIInteractionResponseChannelMessageWithSource {
type: InteractionResponseType.ChannelMessageWithSource;
data: APIInteractionApplicationCommandCallbackData;
}
export interface APIInteractionResponseDeferredChannelMessageWithSource {
type: InteractionResponseType.DeferredChannelMessageWithSource;
data?: Pick<APIInteractionApplicationCommandCallbackData, 'flags'>;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionresponsetype
*/
export enum InteractionResponseType {
/**
* ACK a `Ping`
*/
Pong = 1,
/**
* Respond to an interaction with a message
*/
ChannelMessageWithSource = 4,
/**
* ACK an interaction and edit to a response later, the user sees a loading state
*/
DeferredChannelMessageWithSource,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata
*/
export type APIInteractionApplicationCommandCallbackData = Omit<
RESTPostAPIWebhookWithTokenJSONBody,
'username' | 'avatar_url'
> & { flags?: MessageFlags };
/**
* https://discord.com/developers/docs/interactions/slash-commands#messageinteraction
*/
export interface APIMessageInteraction {
/**
* ID of the interaction
*/
id: Snowflake;
/**
* The type of interaction
*/
type: InteractionType;
/**
* The name of the ApplicationCommand
*/
name: string;
/**
* The user who invoked the interaction
*/
user: APIUser;
}
/**
* @internal
*/
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
name: string;
type: T;
value: D;
}
export type APIGuildInteraction = APIApplicationCommandGuildInteraction | APIMessageComponentGuildInteraction;

View File

@@ -4,7 +4,8 @@
import type { APIPartialChannel } from './channel.ts';
import type { APIPartialGuild } from './guild.ts';
import type { APIApplication } from './oauth2.ts';
import type { APIApplication } from './application.ts';
import type { APIInviteStageInstance } from './stageInstance.ts';
import type { APIUser } from './user.ts';
/**
@@ -59,14 +60,22 @@ export interface APIInvite {
* Approximate count of total members, returned from the `GET /invites/<code>` endpoint when `with_counts` is `true`
*/
approximate_member_count?: number;
/**
* The expiration date of this invite, returned from the `GET /invites/<code>` endpoint when `with_expiration` is `true`
*/
expires_at?: string | null;
/**
* The stage instance data if there is a public stage instance in the stage channel this invite is for
*/
stage_instance?: APIInviteStageInstance;
}
/**
* https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types
*/
export enum InviteTargetType {
STREAM = 1,
EMBEDDED_APPLICATION,
Stream = 1,
EmbeddedApplication,
}
/**

View File

@@ -1,3 +1,4 @@
export * from './application.ts';
export * from './auditLog.ts';
export * from './channel.ts';
export * from './emoji.ts';
@@ -7,6 +8,8 @@ export * from './interactions.ts';
export * from './invite.ts';
export * from './oauth2.ts';
export * from './permissions.ts';
export * from './stageInstance.ts';
export * from './sticker.ts';
export * from './teams.ts';
export * from './template.ts';
export * from './user.ts';

View File

@@ -2,107 +2,6 @@
* Types extracted from https://discord.com/developers/docs/topics/oauth2
*/
import type { Snowflake } from '../../globals.ts';
import type { APITeam } from './teams.ts';
import type { APIUser } from './user.ts';
/**
* https://discord.com/developers/docs/topics/oauth2#get-current-application-information-response-structure
*/
export interface APIApplication {
/**
* The id of the app
*/
id: Snowflake;
/**
* The name of the app
*/
name: string;
/**
* The icon hash of the app
*/
icon: string | null;
/**
* The description of the app
*/
description: string;
/**
* An array of rpc origin urls, if rpc is enabled
*/
rpc_origins?: string[];
/**
* When `false` only app owner can join the app's bot to guilds
*/
bot_public: boolean;
/**
* When `true` the app's bot will only join upon completion of the full oauth2 code grant flow
*/
bot_require_code_grant: boolean;
/**
* The url of the application's terms of service
*/
terms_of_service_url?: string;
/**
* The url of the application's privacy policy
*/
privacy_policy_url?: string;
/**
* Partial user object containing info on the owner of the application
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
owner: APIUser;
/**
* If this application is a game sold on Discord, this field will be the summary field for the store page
* of its primary sku
*/
summary: string;
/**
* The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function
*
* See https://discord.com/developers/docs/game-sdk/applications#get-ticket
*/
verify_key: string;
/**
* The team this application belongs to
*
* See https://discord.com/developers/docs/topics/teams#data-models-team-object
*/
team: APITeam | null;
/**
* If this application is a game sold on Discord, this field will be the guild to which it has been linked
*/
guild_id?: Snowflake;
/**
* If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists
*/
primary_sku_id?: Snowflake;
/**
* If this application is a game sold on Discord, this field will be the URL slug that links to the store page
*/
slug?: string;
/**
* If this application is a game sold on Discord, this field will be the hash of the image on store embeds
*/
cover_image?: string;
/**
* The application's public flags
*/
flags: ApplicationFlags;
}
export enum ApplicationFlags {
ManagedEmoji = 1 << 2,
GroupDMCreate = 1 << 4,
RPCHasConnected = 1 << 11,
GatewayPresence = 1 << 12,
GatewayPresenceLimited = 1 << 13,
GatewayGuildMembers = 1 << 14,
GatewayGuildMembersLimited = 1 << 15,
VerificationPendingGuildLimit = 1 << 16,
Embedded = 1 << 17,
}
export enum OAuth2Scopes {
/**
* For oauth2 bots, this puts the bot in the user's selected guild by default
@@ -153,11 +52,11 @@ export enum OAuth2Scopes {
*/
MessagesRead = 'messages.read',
/**
* For local rpc server access, this allows you to control a user's local Discord client - whitelist only
* For local rpc server access, this allows you to control a user's local Discord client - requires Discord approval
*/
RPC = 'rpc',
/**
* For local rpc server api access, this allows you to receive notifications pushed out to the user - whitelist only
* For local rpc server api access, this allows you to receive notifications pushed out to the user - requires Discord approval
*/
RPCNotificationsRead = 'rpc.notifications.read',
/**
@@ -165,7 +64,7 @@ export enum OAuth2Scopes {
*/
WebhookIncoming = 'webhook.incoming',
/**
* Allows your app to upload/update builds for a user's applications - whitelist only
* Allows your app to upload/update builds for a user's applications - requires Discord approval
*/
ApplicationsBuildsUpload = 'applications.builds.upload',
/**
@@ -181,27 +80,27 @@ export enum OAuth2Scopes {
*/
ApplicationsEntitlements = 'applications.entitlements',
/**
* Allows your app to know a user's friends and implicit relationships - whitelist only
* Allows your app to know a user's friends and implicit relationships - requires Discord approval
*/
RelationshipsRead = 'relationships.read',
/**
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list - whitelist only
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list - requires Discord approval
*/
ActivitiesRead = 'activities.read',
/**
* Allows your app to update a user's activity - whitelist only (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
* Allows your app to update a user's activity - requires Discord approval (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
*
* See https://discord.com/developers/docs/game-sdk/activities
*/
ActivitiesWrite = 'activities.write',
/**
* Allows your app to create Slash Commands in the authorized guild
* Allows your app to use Slash Commands in a guild
*
* See https://discord.com/developers/docs/interactions/slash-commands
*/
ApplicationsCommands = 'applications.commands',
/**
* Allows your app to update Slash Commands via this bearer token
* Allows your app to update its Slash Commands via this bearer token - client credentials grant only
*
* See https://discord.com/developers/docs/interactions/slash-commands
*/

View File

@@ -12,39 +12,40 @@ import type { Permissions, Snowflake } from '../../globals.ts';
* replicate them in some way
*/
export const PermissionFlagsBits = {
CREATE_INSTANT_INVITE: 1n << 0n,
KICK_MEMBERS: 1n << 1n,
BAN_MEMBERS: 1n << 2n,
ADMINISTRATOR: 1n << 3n,
MANAGE_CHANNELS: 1n << 4n,
MANAGE_GUILD: 1n << 5n,
ADD_REACTIONS: 1n << 6n,
VIEW_AUDIT_LOG: 1n << 7n,
PRIORITY_SPEAKER: 1n << 8n,
STREAM: 1n << 9n,
VIEW_CHANNEL: 1n << 10n,
SEND_MESSAGES: 1n << 11n,
SEND_TTS_MESSAGES: 1n << 12n,
MANAGE_MESSAGES: 1n << 13n,
EMBED_LINKS: 1n << 14n,
ATTACH_FILES: 1n << 15n,
READ_MESSAGE_HISTORY: 1n << 16n,
MENTION_EVERYONE: 1n << 17n,
USE_EXTERNAL_EMOJIS: 1n << 18n,
VIEW_GUILD_INSIGHTS: 1n << 19n,
CONNECT: 1n << 20n,
SPEAK: 1n << 21n,
MUTE_MEMBERS: 1n << 22n,
DEAFEN_MEMBERS: 1n << 23n,
MOVE_MEMBERS: 1n << 24n,
USE_VAD: 1n << 25n,
CHANGE_NICKNAME: 1n << 26n,
MANAGE_NICKNAMES: 1n << 27n,
MANAGE_ROLES: 1n << 28n,
MANAGE_WEBHOOKS: 1n << 29n,
MANAGE_EMOJIS: 1n << 30n,
USE_SLASH_COMMANDS: 1n << 31n,
REQUEST_TO_SPEAK: 1n << 32n,
CreateInstantInvite: 1n << 0n,
KickMembers: 1n << 1n,
BanMembers: 1n << 2n,
Administrator: 1n << 3n,
ManageChannels: 1n << 4n,
ManageGuild: 1n << 5n,
AddReactions: 1n << 6n,
ViewAuditLog: 1n << 7n,
PrioritySpeaker: 1n << 8n,
Stream: 1n << 9n,
ViewChannel: 1n << 10n,
SendMessages: 1n << 11n,
SendTTSMessages: 1n << 12n,
ManageMessages: 1n << 13n,
EmbedLinks: 1n << 14n,
AttachFiles: 1n << 15n,
ReadMessageHistory: 1n << 16n,
MentionEveryone: 1n << 17n,
UseExternalEmojis: 1n << 18n,
ViewGuildInsights: 1n << 19n,
Connect: 1n << 20n,
Speak: 1n << 21n,
MuteMembers: 1n << 22n,
DeafenMembers: 1n << 23n,
MoveMembers: 1n << 24n,
UseVAD: 1n << 25n,
ChangeNickname: 1n << 26n,
ManageNicknames: 1n << 27n,
ManageRoles: 1n << 28n,
ManageWebhooks: 1n << 29n,
ManageEmojisAndStickers: 1n << 30n,
UseSlashCommands: 1n << 31n,
RequestToSpeak: 1n << 32n,
UseExternalStickers: 1n << 37n,
} as const;
/**

View File

@@ -0,0 +1,72 @@
import type { Snowflake } from '../../globals.ts';
import type { APIGuildMember } from './guild.ts';
/**
* https://discord.com/developers/docs/resources/stage-instance#stage-instance-object
*/
export interface APIStageInstance {
/**
* The id of the stage instance
*/
id: Snowflake;
/**
* The guild id of the associated stage channel
*/
guild_id: Snowflake;
/**
* The id of the associated stage channel
*/
channel_id: Snowflake;
/**
* The topic of the stage instance (1-120 characters)
*/
topic: string;
/**
* The privacy level of the stage instance
*
* See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level
*/
privacy_level: StageInstancePrivacyLevel;
/**
* Whether or not stage discovery is disabled
*/
discoverable_disabled: boolean;
}
/**
* https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level
*/
export enum StageInstancePrivacyLevel {
/**
* The stage instance is visible publicly, such as on stage discovery
*/
Public = 1,
/**
* The stage instance is visible to only guild members
*/
GuildOnly,
}
/**
* https://discord.com/developers/docs/resources/invite#invite-stage-instance-object-invite-stage-instance-structure
*/
export interface APIInviteStageInstance {
/**
* The topic of the stage instance (1-120 characters)
*/
topic: string;
/**
* The number of users in the stage
*/
participant_count: number;
/**
* The number of users speaking in the stage
*/
speaker_count: number;
/**
* The members speaking in the stage
*
* See https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-structure
*/
members: APIGuildMember[];
}

127
deno/payloads/v8/sticker.ts Normal file
View File

@@ -0,0 +1,127 @@
/**
* Types extracted from https://discord.com/developers/docs/resources/sticker
*/
import type { Snowflake } from '../../globals.ts';
import type { APIUser } from './user.ts';
/**
* https://discord.com/developers/docs/resources/sticker#sticker-object
*/
export interface APISticker {
/**
* ID of the sticker
*/
id: Snowflake;
/**
* For standard stickers, ID of the pack the sticker is from
*/
pack_id?: Snowflake;
/**
* Name of the sticker
*/
name: string;
/**
* Description of the sticker
*/
description: string | null;
/**
* For guild stickers, the Discord name of a unicode emoji representing the sticker's expression. for standard stickers, a comma-separated list of related expressions.
*/
tags: string;
/**
* Previously the sticker asset hash, now an empty string
* @deprecated
*/
asset: '';
/**
* Type of sticker
*
* See https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types
*/
type: StickerType;
/**
* Type of sticker format
*
* See https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types
*/
format_type: StickerFormatType;
/**
* Whether this guild sticker can be used, may be false due to loss of Server Boosts
*/
available?: boolean;
/**
* ID of the guild that owns this sticker
*/
guild_id?: Snowflake;
/**
* The user that uploaded the guild sticker
*/
user?: APIUser;
/**
* The standard sticker's sort order within its pack
*/
sort_value?: number;
}
/**
* https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types
*/
export enum StickerType {
/**
* An official sticker in a pack, part of Nitro or in a removed purchasable pack
*/
Standard = 1,
/**
* A sticker uploaded to a Boosted guild for the guild's members
*/
Guild,
}
/**
* https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types
*/
export enum StickerFormatType {
PNG = 1,
APNG,
Lottie,
}
/**
* https://discord.com/developers/docs/resources/sticker#sticker-item-object
*/
export type APIStickerItem = Pick<APISticker, 'id' | 'name' | 'format_type'>;
/**
* https://discord.com/developers/docs/resources/sticker#sticker-object
*/
export interface APIStickerPack {
/**
* ID of the sticker pack
*/
id: Snowflake;
/**
* The stickers in the pack
*/
stickers: APISticker[];
/**
* Name of the sticker pack
*/
name: string;
/**
* ID of the pack's SKU
*/
sku_id: Snowflake;
/**
* ID of a sticker in the pack which is shown as the pack's icon
*/
cover_sticker_id?: Snowflake;
/**
* Description of the sticker pack
*/
description: string;
/**
* ID of the sticker pack's banner image
*/
banner_asset_id: Snowflake;
}

View File

@@ -21,6 +21,10 @@ export interface APITeam {
* The members of the team
*/
members: APITeamMember[];
/**
* The name of the team
*/
name: string;
/**
* The user id of the current team owner
*/
@@ -57,6 +61,6 @@ export interface APITeamMember {
* https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum
*/
export enum TeamMemberMembershipState {
INVITED = 1,
ACCEPTED,
Invited = 1,
Accepted,
}

View File

@@ -88,6 +88,7 @@ export enum UserFlags {
BugHunterLevel2 = 1 << 14,
VerifiedBot = 1 << 16,
EarlyVerifiedBotDeveloper = 1 << 17,
DiscordCertifiedModerator = 1 << 18,
}
/**

View File

@@ -72,4 +72,8 @@ export enum WebhookType {
* Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels
*/
ChannelFollower,
/**
* Application webhooks are webhooks used with Interactions
*/
Application,
}

View File

@@ -0,0 +1,101 @@
import type { Permissions, Snowflake } from '../../../globals.ts';
import type { InteractionType } from '../../v9.ts';
import type { APIMessage } from '../channel.ts';
import type { APIGuildMember } from '../guild.ts';
import type { APIUser } from '../user.ts';
/**
* https://discord.com/developers/docs/interactions/slash-commands#message-interaction-object-message-interaction-structure
*/
export interface APIMessageInteraction {
/**
* ID of the interaction
*/
id: Snowflake;
/**
* The type of interaction
*/
type: InteractionType;
/**
* The name of the ApplicationCommand
*/
name: string;
/**
* The user who invoked the interaction
*/
user: APIUser;
}
/**
* https://discord.com/developers/docs/resources/guild#guild-member-object
*/
export interface APIInteractionGuildMember extends APIGuildMember {
permissions: Permissions;
user: APIUser;
}
// INTERACTIONS RECEIVED
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object
*/
export interface APIBaseInteraction<Type extends InteractionType, Data extends unknown> {
/**
* ID of the interaction
*/
id: Snowflake;
/**
* ID of the application this interaction is for
*/
application_id: Snowflake;
/**
* The type of interaction
*/
type: Type;
/**
* The command data payload
*/
data?: Data;
/**
* The guild it was sent from
*/
guild_id?: Snowflake;
/**
* The channel it was sent from
*/
channel_id?: Snowflake;
/**
* Guild member data for the invoking user, including permissions
*
* **This is only sent when an interaction is invoked in a guild**
*/
member?: APIInteractionGuildMember;
/**
* User object for the invoking user, if invoked in a DM
*/
user?: APIUser;
/**
* A continuation token for responding to the interaction
*/
token: string;
/**
* Read-only property, always `1`
*/
version: 1;
/**
* For components, the message they were attached to
*/
message?: APIMessage;
}
export type APIDMInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
Original,
'member' | 'guild_id'
> &
Required<Pick<Original, 'user'>>;
export type APIGuildInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
Original,
'user'
> &
Required<Pick<Original, 'member' | 'guild_id'>>;

View File

@@ -0,0 +1,38 @@
import type { ComponentType } from '../channel.ts';
import type { APIBaseInteraction, InteractionType } from '../interactions.ts';
import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts';
export type APIMessageComponentInteraction = APIBaseInteraction<
InteractionType.MessageComponent,
APIMessageComponentInteractionData
> &
Required<
Pick<
APIBaseInteraction<InteractionType.MessageComponent, APIMessageComponentInteractionData>,
'channel_id' | 'data' | 'message'
>
>;
export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData;
export interface APIMessageComponentBaseInteractionData<CType extends ComponentType> {
/**
* The `custom_id` of the component
*/
custom_id: string;
/**
* The type of the component
*/
component_type: CType;
}
export type APIMessageButtonInteractionData = APIMessageComponentBaseInteractionData<ComponentType.Button>;
export interface APIMessageSelectMenuInteractionData
extends APIMessageComponentBaseInteractionData<ComponentType.SelectMenu> {
values: string[];
}
export type APIMessageComponentDMInteraction = APIDMInteractionWrapper<APIMessageComponentInteraction>;
export type APIMessageComponentGuildInteraction = APIGuildInteractionWrapper<APIMessageComponentInteraction>;

View File

@@ -0,0 +1,4 @@
import type { APIBaseInteraction } from './base.ts';
import type { InteractionType } from './responses.ts';
export type APIPingInteraction = APIBaseInteraction<InteractionType.Ping, never>;

View File

@@ -0,0 +1,78 @@
import type { MessageFlags } from '../mod.ts';
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9.ts';
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type
*/
export enum InteractionType {
Ping = 1,
ApplicationCommand,
MessageComponent,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object
*/
export type APIInteractionResponse =
| APIInteractionResponsePong
| APIInteractionResponseChannelMessageWithSource
| APIInteractionResponseDeferredChannelMessageWithSource
| APIInteractionResponseDeferredMessageUpdate
| APIInteractionResponseUpdateMessage;
export interface APIInteractionResponsePong {
type: InteractionResponseType.Pong;
}
export interface APIInteractionResponseChannelMessageWithSource {
type: InteractionResponseType.ChannelMessageWithSource;
data: APIInteractionResponseCallbackData;
}
export interface APIInteractionResponseDeferredChannelMessageWithSource {
type: InteractionResponseType.DeferredChannelMessageWithSource;
data?: Pick<APIInteractionResponseCallbackData, 'flags'>;
}
export interface APIInteractionResponseDeferredMessageUpdate {
type: InteractionResponseType.DeferredMessageUpdate;
}
export interface APIInteractionResponseUpdateMessage {
type: InteractionResponseType.UpdateMessage;
data?: APIInteractionResponseCallbackData;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-callback-type
*/
export enum InteractionResponseType {
/**
* ACK a `Ping`
*/
Pong = 1,
/**
* Respond to an interaction with a message
*/
ChannelMessageWithSource = 4,
/**
* ACK an interaction and edit to a response later, the user sees a loading state
*/
DeferredChannelMessageWithSource,
/**
* ACK a button interaction and update it to a loading state
*/
DeferredMessageUpdate,
/**
* ACK a button interaction and edit the message to which the button was attached
*/
UpdateMessage,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-application-command-callback-data-structure
*/
export type APIInteractionResponseCallbackData = Omit<
RESTPostAPIWebhookWithTokenJSONBody,
'username' | 'avatar_url'
> & { flags?: MessageFlags };

View File

@@ -0,0 +1,283 @@
import type { APIRole, APIUser } from '../mod.ts';
import type { Permissions, Snowflake } from '../../../globals.ts';
import type { APIPartialChannel } from '../channel.ts';
import type { APIGuildMember } from '../guild.ts';
import type { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts';
import type { InteractionType } from './responses.ts';
/**
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object
*/
export interface APIApplicationCommand {
/**
* Unique id of the command
*/
id: Snowflake;
/**
* Unique id of the parent application
*/
application_id: Snowflake;
/**
* Guild id of the command, if not global
*/
guild_id?: Snowflake;
/**
* 1-32 character name matching `^[\w-]{1,32}$`
*/
name: string;
/**
* 1-100 character description
*/
description: string;
/**
* The parameters for the command
*/
options?: APIApplicationCommandOption[];
/**
* Whether the command is enabled by default when the app is added to a guild
*
* If missing, this property should be assumed as `true`
*/
default_permission?: boolean;
}
interface APIApplicationCommandOptionBase {
type:
| ApplicationCommandOptionType.Boolean
| ApplicationCommandOptionType.User
| ApplicationCommandOptionType.Channel
| ApplicationCommandOptionType.Role
| ApplicationCommandOptionType.Mentionable;
name: string;
description: string;
default?: boolean;
required?: boolean;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-structure
*/
export type APIApplicationCommandOption =
| APIApplicationCommandArgumentOptions
| APIApplicationCommandSubCommandOptions
| APIApplicationCommandOptionBase;
/**
* This type is exported as a way to make it stricter for you when you're writing your commands
*
* If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters
*/
export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
type: ApplicationCommandOptionType.Subcommand | ApplicationCommandOptionType.SubcommandGroup;
options?: APIApplicationCommandOption[];
}
/**
* This type is exported as a way to make it stricter for you when you're writing your commands
*
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
* but they can have a `choices` one
*/
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
type:
| ApplicationCommandOptionType.String
| ApplicationCommandOptionType.Integer
| ApplicationCommandOptionType.Number;
choices?: APIApplicationCommandOptionChoice[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-type
*/
export enum ApplicationCommandOptionType {
Subcommand = 1,
SubcommandGroup,
String,
Integer,
Boolean,
User,
Channel,
Role,
Mentionable,
Number,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-choice-structure
*/
export interface APIApplicationCommandOptionChoice {
name: string;
value: string | number;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-structure
*/
export interface APIApplicationCommandInteractionData {
id: Snowflake;
name: string;
options?: APIApplicationCommandInteractionDataOption[];
resolved?: {
users?: Record<Snowflake, APIUser>;
roles?: Record<Snowflake, APIRole>;
members?: Record<Snowflake, APIInteractionDataResolvedGuildMember>;
channels?: Record<Snowflake, APIInteractionDataResolvedChannel>;
};
}
/**
* https://discord.com/developers/docs/resources/channel#channel-object
*/
export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
permissions: Permissions;
}
/**
* https://discord.com/developers/docs/resources/guild#guild-member-object
*/
export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {
permissions: Permissions;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-application-command-interaction-data-option-structure
*/
export type APIApplicationCommandInteractionDataOption =
| ApplicationCommandInteractionDataOptionSubCommand
| ApplicationCommandInteractionDataOptionSubCommandGroup
| APIApplicationCommandInteractionDataOptionWithValues;
export interface ApplicationCommandInteractionDataOptionSubCommand {
name: string;
type: ApplicationCommandOptionType.Subcommand;
options: APIApplicationCommandInteractionDataOptionWithValues[];
}
export interface ApplicationCommandInteractionDataOptionSubCommandGroup {
name: string;
type: ApplicationCommandOptionType.SubcommandGroup;
options: ApplicationCommandInteractionDataOptionSubCommand[];
}
export type APIApplicationCommandInteractionDataOptionWithValues =
| ApplicationCommandInteractionDataOptionString
| ApplicationCommandInteractionDataOptionRole
| ApplicationCommandInteractionDataOptionChannel
| ApplicationCommandInteractionDataOptionUser
| ApplicationCommandInteractionDataOptionMentionable
| ApplicationCommandInteractionDataOptionInteger
| ApplicationCommandInteractionDataOptionNumber
| ApplicationCommandInteractionDataOptionBoolean;
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
ApplicationCommandOptionType.String,
string
>;
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
ApplicationCommandOptionType.Role,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase<
ApplicationCommandOptionType.Channel,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase<
ApplicationCommandOptionType.User,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionMentionable = InteractionDataOptionBase<
ApplicationCommandOptionType.Mentionable,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
ApplicationCommandOptionType.Integer,
number
>;
export type ApplicationCommandInteractionDataOptionNumber = InteractionDataOptionBase<
ApplicationCommandOptionType.Number,
number
>;
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
ApplicationCommandOptionType.Boolean,
boolean
>;
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
name: string;
type: T;
value: D;
}
// PERMISSIONS
/**
* https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-guild-application-command-permissions-structure
*/
export interface APIGuildApplicationCommandPermissions {
/**
* The id of the command
*/
id: Snowflake;
/**
* The id of the application the command belongs to
*/
application_id: Snowflake;
/**
* The id of the guild
*/
guild_id: Snowflake;
/**
* The permissions for the command in the guild
*/
permissions: APIApplicationCommandPermission[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-application-command-permissions-structure
*/
export interface APIApplicationCommandPermission {
/**
* The id of the role or user
*/
id: Snowflake;
/**
* Role or user
*/
type: ApplicationCommandPermissionType;
/**
* `true` to allow, `false`, to disallow
*/
permission: boolean;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype
*/
export enum ApplicationCommandPermissionType {
Role = 1,
User,
}
// INTERACTIONS
export type APIApplicationCommandInteraction = APIBaseInteraction<
InteractionType.ApplicationCommand,
APIApplicationCommandInteractionData
> &
Required<
Pick<
APIBaseInteraction<InteractionType.ApplicationCommand, APIApplicationCommandInteractionData>,
'channel_id' | 'data'
>
>;
export type APIApplicationCommandDMInteraction = APIDMInteractionWrapper<APIApplicationCommandInteraction>;
export type APIApplicationCommandGuildInteraction = APIGuildInteractionWrapper<APIApplicationCommandInteraction>;

View File

@@ -0,0 +1,109 @@
/**
* Types extracted from https://discord.com/developers/docs/resources/application
*/
import type { Snowflake } from '../../globals.ts';
import type { APITeam } from './teams.ts';
import type { APIUser } from './user.ts';
/**
* https://discord.com/developers/docs/resources/application#application-object
*/
export interface APIApplication {
/**
* The id of the app
*/
id: Snowflake;
/**
* The name of the app
*/
name: string;
/**
* The icon hash of the app
*/
icon: string | null;
/**
* The description of the app
*/
description: string;
/**
* An array of rpc origin urls, if rpc is enabled
*/
rpc_origins?: string[];
/**
* When `false` only app owner can join the app's bot to guilds
*/
bot_public: boolean;
/**
* When `true` the app's bot will only join upon completion of the full oauth2 code grant flow
*/
bot_require_code_grant: boolean;
/**
* The url of the application's terms of service
*/
terms_of_service_url?: string;
/**
* The url of the application's privacy policy
*/
privacy_policy_url?: string;
/**
* Partial user object containing info on the owner of the application
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
owner?: APIUser;
/**
* If this application is a game sold on Discord, this field will be the summary field for the store page
* of its primary sku
*/
summary: string;
/**
* The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function
*
* See https://discord.com/developers/docs/game-sdk/applications#get-ticket
*/
verify_key: string;
/**
* The team this application belongs to
*
* See https://discord.com/developers/docs/topics/teams#data-models-team-object
*/
team: APITeam | null;
/**
* If this application is a game sold on Discord, this field will be the guild to which it has been linked
*/
guild_id?: Snowflake;
/**
* If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists
*/
primary_sku_id?: Snowflake;
/**
* If this application is a game sold on Discord, this field will be the URL slug that links to the store page
*/
slug?: string;
/**
* If this application is a game sold on Discord, this field will be the hash of the image on store embeds
*/
cover_image?: string;
/**
* The application's public flags
*
* See https://discord.com/developers/docs/resources/application#application-object-application-flags
*/
flags: ApplicationFlags;
}
/**
* https://discord.com/developers/docs/resources/application#application-object-application-flags
*/
export enum ApplicationFlags {
ManagedEmoji = 1 << 2,
GroupDMCreate = 1 << 4,
RPCHasConnected = 1 << 11,
GatewayPresence = 1 << 12,
GatewayPresenceLimited = 1 << 13,
GatewayGuildMembers = 1 << 14,
GatewayGuildMembersLimited = 1 << 15,
VerificationPendingGuildLimit = 1 << 16,
Embedded = 1 << 17,
}

View File

@@ -0,0 +1,663 @@
/**
* Types extracted from https://discord.com/developers/docs/resources/audit-log
*/
import type { Snowflake } from '../../globals.ts';
import type { APIChannel, APIOverwrite } from './channel.ts';
import type {
APIGuildIntegration,
GuildDefaultMessageNotifications,
GuildExplicitContentFilter,
GuildMFALevel,
GuildVerificationLevel,
IntegrationExpireBehavior,
} from './guild.ts';
import type { APIRole } from './permissions.ts';
import type { StickerFormatType } from './sticker.ts';
import type { APIUser } from './user.ts';
import type { APIWebhook } from './webhook.ts';
import type { StageInstancePrivacyLevel } from './stageInstance.ts';
/**
* https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure
*/
export interface APIAuditLog {
/**
* Webhooks found in the audit log
*
* See https://discord.com/developers/docs/resources/webhook#webhook-object
*/
webhooks: APIWebhook[];
/**
* Users found in the audit log
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
users: APIUser[];
/**
* Audit log entries
*
* See https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object
*/
audit_log_entries: APIAuditLogEntry[];
/**
* Partial integration objects
*
* See https://discord.com/developers/docs/resources/guild#integration-object
*/
integrations: APIGuildIntegration[];
/**
* Threads found in the audit log
*
* Threads referenced in THREAD_CREATE and THREAD_UPDATE events are included in the threads map, since archived threads might not be kept in memory by clients.
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
threads: APIChannel[];
}
/**
* https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure
*/
export interface APIAuditLogEntry {
/**
* ID of the affected entity (webhook, user, role, etc.)
*/
target_id: string | null;
/**
* Changes made to the `target_id`
*
* See https://discord.com/developers/docs/resources/audit-log#audit-log-change-object
*/
changes?: APIAuditLogChange[];
/**
* The user who made the changes
*
* This can be `null` in some cases (webhooks deleting themselves by using their own token, for example)
*/
user_id: Snowflake | null;
/**
* ID of the entry
*/
id: Snowflake;
/**
* Type of action that occurred
*
* See https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events
*/
action_type: AuditLogEvent;
/**
* Additional info for certain action types
*
* See https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info
*/
options?: APIAuditLogOptions;
/**
* The reason for the change (0-512 characters)
*/
reason?: string;
}
/**
* https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events
*/
export enum AuditLogEvent {
GuildUpdate = 1,
ChannelCreate = 10,
ChannelUpdate,
ChannelDelete,
ChannelOverwriteCreate,
ChannelOverwriteUpdate,
ChannelOverwriteDelete,
MemberKick = 20,
MemberPrune,
MemberBanAdd,
MemberBanRemove,
MemberUpdate,
MemberRoleUpdate,
MemberMove,
MemberDisconnect,
BotAdd,
RoleCreate = 30,
RoleUpdate,
RoleDelete,
InviteCreate = 40,
InviteUpdate,
InviteDelete,
WebhookCreate = 50,
WebhookUpdate,
WebhookDelete,
EmojiCreate = 60,
EmojiUpdate,
EmojiDelete,
MessageDelete = 72,
MessageBulkDelete,
MessagePin,
MessageUnpin,
IntegrationCreate = 80,
IntegrationUpdate,
IntegrationDelete,
StageInstanceCreate,
StageInstanceUpdate,
StageInstanceDelete,
StickerCreate = 90,
StickerUpdate,
StickerDelete,
ThreadCreate = 110,
ThreadUpdate,
ThreadDelete,
}
/**
* https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info
*/
export interface APIAuditLogOptions {
/**
* Number of days after which inactive members were kicked
*
* Present from:
* - MEMBER_PRUNE
*/
delete_member_days?: string;
/**
* Number of members removed by the prune
*
* Present from:
* - MEMBER_PRUNE
*/
members_removed?: string;
/**
* Channel in which the entities were targeted
*
* Present from:
* - MEMBER_MOVE
* - MESSAGE_PIN
* - MESSAGE_UNPIN
* - MESSAGE_DELETE
* - STAGE_INSTANCE_CREATE
* - STAGE_INSTANCE_UPDATE
* - STAGE_INSTANCE_DELETE
*/
channel_id?: Snowflake;
/**
* ID of the message that was targeted
*
* Present from:
* - MESSAGE_PIN
* - MESSAGE_UNPIN
*/
message_id?: Snowflake;
/**
* Number of entities that were targeted
*
* Present from:
* - MESSAGE_DELETE
* - MESSAGE_BULK_DELETE
* - MEMBER_DISCONNECT
* - MEMBER_MOVE
*/
count?: string;
/**
* ID of the overwritten entity
*
* Present from:
* - CHANNEL_OVERWRITE_CREATE
* - CHANNEL_OVERWRITE_UPDATE
* - CHANNEL_OVERWRITE_DELETE
*/
id?: Snowflake;
/**
* Type of overwritten entity - "0" for "role" or "1" for "member"
*
* Present from:
* - CHANNEL_OVERWRITE_CREATE
* - CHANNEL_OVERWRITE_UPDATE
* - CHANNEL_OVERWRITE_DELETE
*
* {@link AuditLogOptionsType}
*/
type?: AuditLogOptionsType;
/**
* Name of the role
*
* Present from:
* - CHANNEL_OVERWRITE_CREATE
* - CHANNEL_OVERWRITE_UPDATE
* - CHANNEL_OVERWRITE_DELETE
*
* **Present only if the {@link APIAuditLogOptions#type entry type} is "0"**
*/
role_name?: string;
}
export enum AuditLogOptionsType {
Role = '0',
Member = '1',
}
/**
* https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure
*/
export type APIAuditLogChange =
| APIAuditLogChangeKeyName
| APIAuditLogChangeKeyDescription
| APIAuditLogChangeKeyIconHash
| APIAuditLogChangeKeySplashHash
| APIAuditLogChangeKeyDiscoverySplashHash
| APIAuditLogChangeKeyBannerHash
| APIAuditLogChangeKeyOwnerId
| APIAuditLogChangeKeyRegion
| APIAuditLogChangeKeyPreferredLocale
| APIAuditLogChangeKeyAFKChannelId
| APIAuditLogChangeKeyAFKTimeout
| APIAuditLogChangeKeyRulesChannelId
| APIAuditLogChangeKeyPublicUpdatesChannelId
| APIAuditLogChangeKeyMFALevel
| APIAuditLogChangeKeyVerificationLevel
| APIAuditLogChangeKeyExplicitContentFilter
| APIAuditLogChangeKeyDefaultMessageNotifications
| APIAuditLogChangeKeyVanityURLCode
| APIAuditLogChangeKey$Add
| APIAuditLogChangeKey$Remove
| APIAuditLogChangeKeyPruneDeleteDays
| APIAuditLogChangeKeyWidgetEnabled
| APIAuditLogChangeKeyWidgetChannelId
| APIAuditLogChangeKeySystemChannelId
| APIAuditLogChangeKeyPosition
| APIAuditLogChangeKeyTopic
| APIAuditLogChangeKeyBitrate
| APIAuditLogChangeKeyPermissionOverwrites
| APIAuditLogChangeKeyNSFW
| APIAuditLogChangeKeyApplicationId
| APIAuditLogChangeKeyRateLimitPerUser
| APIAuditLogChangeKeyPermissions
| APIAuditLogChangeKeyColor
| APIAuditLogChangeKeyHoist
| APIAuditLogChangeKeyMentionable
| APIAuditLogChangeKeyAllow
| APIAuditLogChangeKeyDeny
| APIAuditLogChangeKeyCode
| APIAuditLogChangeKeyChannelId
| APIAuditLogChangeKeyInviterId
| APIAuditLogChangeKeyMaxUses
| APIAuditLogChangeKeyUses
| APIAuditLogChangeKeyMaxAge
| APIAuditLogChangeKeyTemporary
| APIAuditLogChangeKeyDeaf
| APIAuditLogChangeKeyMute
| APIAuditLogChangeKeyNick
| APIAuditLogChangeKeyAvatarHash
| APIAuditLogChangeKeyId
| APIAuditLogChangeKeyType
| APIAuditLogChangeKeyEnableEmoticons
| APIAuditLogChangeKeyExpireBehavior
| APIAuditLogChangeKeyExpireGracePeriod
| APIAuditLogChangeKeyUserLimit
| APIAuditLogChangeKeyPrivacyLevel
| APIAuditLogChangeKeyTags
| APIAuditLogChangeKeyFormatType
| APIAuditLogChangeKeyAsset
| APIAuditLogChangeKeyAvailable
| APIAuditLogChangeKeyGuildId
| APIAuditLogChangeKeyArchived
| APIAuditLogChangeKeyLocked
| APIAuditLogChangeKeyAutoArchiveDuration
| APIAuditLogChangeKeyDefaultAutoArchiveDuration;
/**
* Returned when an entity's name is changed
*/
export type APIAuditLogChangeKeyName = AuditLogChangeData<'name', string>;
/**
* Returned when a guild's or sticker's description is changed
*/
export type APIAuditLogChangeKeyDescription = AuditLogChangeData<'description', string>;
/**
* Returned when a guild's icon is changed
*/
export type APIAuditLogChangeKeyIconHash = AuditLogChangeData<'icon_hash', string>;
/**
* Returned when a guild's splash is changed
*/
export type APIAuditLogChangeKeySplashHash = AuditLogChangeData<'splash_hash', string>;
/**
* Returned when a guild's discovery splash is changed
*/
export type APIAuditLogChangeKeyDiscoverySplashHash = AuditLogChangeData<'discovery_splash_hash', string>;
/**
* Returned when a guild's banner hash is changed
*/
export type APIAuditLogChangeKeyBannerHash = AuditLogChangeData<'banner_hash', string>;
/**
* Returned when a guild's owner_id is changed
*/
export type APIAuditLogChangeKeyOwnerId = AuditLogChangeData<'owner_id', Snowflake>;
/**
* Returned when a guild's region is changed
*/
export type APIAuditLogChangeKeyRegion = AuditLogChangeData<'region', string>;
/**
* Returned when a guild's preferred_locale is changed
*/
export type APIAuditLogChangeKeyPreferredLocale = AuditLogChangeData<'preferred_locale', string>;
/**
* Returned when a guild's afk_channel_id is changed
*/
export type APIAuditLogChangeKeyAFKChannelId = AuditLogChangeData<'afk_channel_id', Snowflake>;
/**
* Returned when a guild's afk_timeout is changed
*/
export type APIAuditLogChangeKeyAFKTimeout = AuditLogChangeData<'afk_timeout', number>;
/**
* Returned when a guild's rules_channel_id is changed
*/
export type APIAuditLogChangeKeyRulesChannelId = AuditLogChangeData<'rules_channel_id', string>;
/**
* Returned when a guild's public_updates_channel_id is changed
*/
export type APIAuditLogChangeKeyPublicUpdatesChannelId = AuditLogChangeData<'public_updates_channel_id', string>;
/**
* Returned when a guild's mfa_level is changed
*/
export type APIAuditLogChangeKeyMFALevel = AuditLogChangeData<'mfa_level', GuildMFALevel>;
/**
* Returned when a guild's verification_level is changed
*/
export type APIAuditLogChangeKeyVerificationLevel = AuditLogChangeData<'verification_level', GuildVerificationLevel>;
/**
* Returned when a guild's explicit_content_filter is changed
*/
export type APIAuditLogChangeKeyExplicitContentFilter = AuditLogChangeData<
'explicit_content_filter',
GuildExplicitContentFilter
>;
/**
* Returned when a guild's default_message_notifications is changed
*/
export type APIAuditLogChangeKeyDefaultMessageNotifications = AuditLogChangeData<
'default_message_notifications',
GuildDefaultMessageNotifications
>;
/**
* Returned when a guild's vanity_url_code is changed
*/
export type APIAuditLogChangeKeyVanityURLCode = AuditLogChangeData<'vanity_url_code', string>;
/**
* Returned when new role(s) are added
*/
export type APIAuditLogChangeKey$Add = AuditLogChangeData<'$add', APIRole[]>;
/**
* Returned when role(s) are removed
*/
export type APIAuditLogChangeKey$Remove = AuditLogChangeData<'$remove', APIRole[]>;
/**
* Returned when there is a change in number of days after which inactive and role-unassigned members are kicked
*/
export type APIAuditLogChangeKeyPruneDeleteDays = AuditLogChangeData<'prune_delete_days', number>;
/**
* Returned when a guild's widget is enabled
*/
export type APIAuditLogChangeKeyWidgetEnabled = AuditLogChangeData<'widget_enabled', boolean>;
/**
* Returned when a guild's widget_channel_id is changed
*/
export type APIAuditLogChangeKeyWidgetChannelId = AuditLogChangeData<'widget_channel_id', Snowflake>;
/**
* Returned when a guild's system_channel_id is changed
*/
export type APIAuditLogChangeKeySystemChannelId = AuditLogChangeData<'system_channel_id', Snowflake>;
/**
* Returned when a channel's position is changed
*/
export type APIAuditLogChangeKeyPosition = AuditLogChangeData<'position', number>;
/**
* Returned when a channel's topic is changed
*/
export type APIAuditLogChangeKeyTopic = AuditLogChangeData<'topic', string>;
/**
* Returned when a voice channel's bitrate is changed
*/
export type APIAuditLogChangeKeyBitrate = AuditLogChangeData<'bitrate', number>;
/**
* Returned when a channel's permission overwrites is changed
*/
export type APIAuditLogChangeKeyPermissionOverwrites = AuditLogChangeData<'permission_overwrites', APIOverwrite[]>;
/**
* Returned when a channel's NSFW restriction is changed
*/
export type APIAuditLogChangeKeyNSFW = AuditLogChangeData<'nsfw', boolean>;
/**
* The application ID of the added or removed Webhook or Bot
*/
export type APIAuditLogChangeKeyApplicationId = AuditLogChangeData<'application_id', Snowflake>;
/**
* Returned when a channel's amount of seconds a user has to wait before sending another message
* is changed
*/
export type APIAuditLogChangeKeyRateLimitPerUser = AuditLogChangeData<'rate_limit_per_user', number>;
/**
* Returned when a permission bitfield is changed
*/
export type APIAuditLogChangeKeyPermissions = AuditLogChangeData<'permissions', string>;
/**
* Returned when a role's color is changed
*/
export type APIAuditLogChangeKeyColor = AuditLogChangeData<'color', number>;
/**
* Returned when a role's hoist status is changed
*/
export type APIAuditLogChangeKeyHoist = AuditLogChangeData<'hoist', boolean>;
/**
* Returned when a role's mentionable status is changed
*/
export type APIAuditLogChangeKeyMentionable = AuditLogChangeData<'mentionable', boolean>;
/**
* Returned when an overwrite's allowed permissions bitfield is changed
*/
export type APIAuditLogChangeKeyAllow = AuditLogChangeData<'allow', string>;
/**
* Returned when an overwrite's denied permissions bitfield is changed
*/
export type APIAuditLogChangeKeyDeny = AuditLogChangeData<'deny', string>;
/**
* Returned when an invite's code is changed
*/
export type APIAuditLogChangeKeyCode = AuditLogChangeData<'code', string>;
/**
* Returned when an invite's channel_id is changed
*/
export type APIAuditLogChangeKeyChannelId = AuditLogChangeData<'channel_id', Snowflake>;
/**
* Returned when an invite's inviter_id is changed
*/
export type APIAuditLogChangeKeyInviterId = AuditLogChangeData<'inviter_id', Snowflake>;
/**
* Returned when an invite's max_uses is changed
*/
export type APIAuditLogChangeKeyMaxUses = AuditLogChangeData<'max_uses', number>;
/**
* Returned when an invite's uses is changed
*/
export type APIAuditLogChangeKeyUses = AuditLogChangeData<'uses', number>;
/**
* Returned when an invite's max_age is changed
*/
export type APIAuditLogChangeKeyMaxAge = AuditLogChangeData<'max_age', number>;
/**
* Returned when an invite's temporary status is changed
*/
export type APIAuditLogChangeKeyTemporary = AuditLogChangeData<'temporary', boolean>;
/**
* Returned when a user's deaf status is changed
*/
export type APIAuditLogChangeKeyDeaf = AuditLogChangeData<'deaf', boolean>;
/**
* Returned when a user's mute status is changed
*/
export type APIAuditLogChangeKeyMute = AuditLogChangeData<'mute', boolean>;
/**
* Returned when a user's nick is changed
*/
export type APIAuditLogChangeKeyNick = AuditLogChangeData<'nick', boolean>;
/**
* Returned when a user's avatar_hash is changed
*/
export type APIAuditLogChangeKeyAvatarHash = AuditLogChangeData<'avatar_hash', string>;
/**
* The ID of the changed entity - sometimes used in conjunction with other keys
*/
export type APIAuditLogChangeKeyId = AuditLogChangeData<'id', Snowflake>;
/**
* The type of entity created
*/
export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', number | string>;
/**
* Returned when an integration's enable_emoticons is changed
*/
export type APIAuditLogChangeKeyEnableEmoticons = AuditLogChangeData<'enable_emoticons', boolean>;
/**
* Returned when an integration's expire_behavior is changed
*/
export type APIAuditLogChangeKeyExpireBehavior = AuditLogChangeData<'expire_behavior', IntegrationExpireBehavior>;
/**
* Returned when an integration's expire_grace_period is changed
*/
export type APIAuditLogChangeKeyExpireGracePeriod = AuditLogChangeData<'expire_grace_period', number>;
/**
* Returned when a voice channel's user_limit is changed
*/
export type APIAuditLogChangeKeyUserLimit = AuditLogChangeData<'user_limit', number>;
/**
* Returned when privacy level of a stage instance is changed
*/
export type APIAuditLogChangeKeyPrivacyLevel = AuditLogChangeData<'privacy_level', StageInstancePrivacyLevel>;
/**
* Returned when a sticker's related emoji is changed
*/
export type APIAuditLogChangeKeyTags = AuditLogChangeData<'tags', string>;
/**
* Returned when a sticker's format_type is changed
*/
export type APIAuditLogChangeKeyFormatType = AuditLogChangeData<'format_type', StickerFormatType>;
/**
* Empty string
*/
export type APIAuditLogChangeKeyAsset = AuditLogChangeData<'asset', ''>;
/**
* Returned when a sticker's availability is changed
*/
export type APIAuditLogChangeKeyAvailable = AuditLogChangeData<'available', boolean>;
/**
* Returned when a sticker's guild_id is changed
*/
export type APIAuditLogChangeKeyGuildId = AuditLogChangeData<'guild_id', Snowflake>;
/*
* Returned when a thread's archive status is changed
*/
export type APIAuditLogChangeKeyArchived = AuditLogChangeData<'archived', boolean>;
/*
* Returned when a thread's lock status is changed
*/
export type APIAuditLogChangeKeyLocked = AuditLogChangeData<'locked', boolean>;
/*
* Returned when a thread's auto archive duration is changed
*/
export type APIAuditLogChangeKeyAutoArchiveDuration = AuditLogChangeData<'auto_archive_duration', number>;
/*
* Returned when a channel's default auto archive duration for newly created threads is changed
*/
export type APIAuditLogChangeKeyDefaultAutoArchiveDuration = AuditLogChangeData<
'default_auto_archive_duration',
number
>;
interface AuditLogChangeData<K extends string, D extends unknown> {
key: K;
/**
* The new value
*
* If `new_value` is not present in the change object, while `old_value` is,
* that means the property that was changed has been reset, or set to `null`
*/
new_value?: D;
old_value?: D;
}

1200
deno/payloads/v9/channel.ts Normal file

File diff suppressed because it is too large Load Diff

51
deno/payloads/v9/emoji.ts Normal file
View File

@@ -0,0 +1,51 @@
/**
* Types extracted from https://discord.com/developers/docs/resources/emoji
*/
import type { Snowflake } from '../../globals.ts';
import type { APIRole } from './permissions.ts';
import type { APIUser } from './user.ts';
/**
* Not documented but mentioned
*/
export interface APIPartialEmoji {
/**
* Emoji id
*/
id: Snowflake | null;
/**
* Emoji name (can be null only in reaction emoji objects)
*/
name: string | null;
/**
* Whether this emoji is animated
*/
animated?: boolean;
}
/**
* https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure
*/
export interface APIEmoji extends APIPartialEmoji {
/**
* Roles this emoji is whitelisted to
*/
roles?: APIRole['id'][];
/**
* User that created this emoji
*/
user?: APIUser;
/**
* Whether this emoji must be wrapped in colons
*/
require_colons?: boolean;
/**
* Whether this emoji is managed
*/
managed?: boolean;
/**
* Whether this emoji can be used, may be false due to loss of Server Boosts
*/
available?: boolean;
}

361
deno/payloads/v9/gateway.ts Normal file
View File

@@ -0,0 +1,361 @@
/**
* Types extracted from https://discord.com/developers/docs/topics/gateway
*/
import type { Snowflake } from '../../globals.ts';
import type { APIChannel, APIThreadMember } from './channel.ts';
import type { APIEmoji } from './emoji.ts';
import type { APIUser } from './user.ts';
/**
* https://discord.com/developers/docs/topics/gateway#get-gateway
*/
export interface APIGatewayInfo {
/**
* The WSS URL that can be used for connecting to the gateway
*/
url: string;
}
/**
* https://discord.com/developers/docs/topics/gateway#get-gateway-bot
*/
export interface APIGatewayBotInfo extends APIGatewayInfo {
/**
* The recommended number of shards to use when connecting
*
* See https://discord.com/developers/docs/topics/gateway#sharding
*/
shards: number;
/**
* Information on the current session start limit
*
* See https://discord.com/developers/docs/topics/gateway#session-start-limit-object
*/
session_start_limit: APIGatewaySessionStartLimit;
}
/**
* https://discord.com/developers/docs/topics/gateway#session-start-limit-object
*/
export interface APIGatewaySessionStartLimit {
/**
* The total number of session starts the current user is allowed
*/
total: number;
/**
* The remaining number of session starts the current user is allowed
*/
remaining: number;
/**
* The number of milliseconds after which the limit resets
*/
reset_after: number;
/**
* The number of identify requests allowed per 5 seconds
*/
max_concurrency: number;
}
/**
* https://discord.com/developers/docs/topics/gateway#presence-update-presence-update-event-fields
*/
export interface GatewayPresenceUpdate {
/**
* The user presence is being updated for
*
* **The user object within this event can be partial, the only field which must be sent is the `id` field,
* everything else is optional.**
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
user: Partial<APIUser> & Pick<APIUser, 'id'>;
/**
* ID of the guild
*/
guild_id: Snowflake;
/**
* Either "idle", "dnd", "online", or "offline"
*/
status?: PresenceUpdateStatus;
/**
* User's current activities
*
* See https://discord.com/developers/docs/topics/gateway#activity-object
*/
activities?: GatewayActivity[];
/**
* User's platform-dependent status
*
* See https://discord.com/developers/docs/topics/gateway#client-status-object
*/
client_status?: GatewayPresenceClientStatus;
}
export enum PresenceUpdateStatus {
Online = 'online',
DoNotDisturb = 'dnd',
Idle = 'idle',
/**
* Invisible and shown as offline
*/
Invisible = 'invisible',
Offline = 'offline',
}
/**
* https://discord.com/developers/docs/topics/gateway#client-status-object
*/
export interface GatewayPresenceClientStatus {
/**
* The user's status set for an active desktop (Windows, Linux, Mac) application session
*/
desktop?: PresenceUpdateStatus;
/**
* The user's status set for an active mobile (iOS, Android) application session
*/
mobile?: PresenceUpdateStatus;
/**
* The user's status set for an active web (browser, bot account) application session
*/
web?: PresenceUpdateStatus;
}
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-structure
*/
export interface GatewayActivity {
/**
* The activity's id
*/
id: string;
/**
* The activity's name
*/
name: string;
/**
* Activity type
*
* See https://discord.com/developers/docs/topics/gateway#activity-object-activity-types
*/
type: ActivityType;
/**
* Stream url, is validated when type is `1`
*/
url?: string | null;
/**
* Unix timestamp of when the activity was added to the user's session
*/
created_at: number;
/**
* Unix timestamps for start and/or end of the game
*/
timestamps?: GatewayActivityTimestamps;
sync_id?: string;
platform?: ActivityPlatform;
/**
* Application id for the game
*/
application_id?: Snowflake;
/**
* What the player is currently doing
*/
details?: string | null;
/**
* The user's current party status
*/
state?: string | null;
/**
* The emoji used for a custom status
*
* See https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji
*/
emoji?: GatewayActivityEmoji;
session_id?: string;
/**
* Information for the current party of the player
*
* See https://discord.com/developers/docs/topics/gateway#activity-object-activity-party
*/
party?: GatewayActivityParty;
/**
* Images for the presence and their hover texts
*
* See https://discord.com/developers/docs/topics/gateway#activity-object-activity-assets
*/
assets?: GatewayActivityAssets;
/**
* Secrets for Rich Presence joining and spectating
*
* See https://discord.com/developers/docs/topics/gateway#activity-object-activity-secrets
*/
secrets?: GatewayActivitySecrets;
/**
* Whether or not the activity is an instanced game session
*/
instance?: boolean;
/**
* Activity flags `OR`d together, describes what the payload includes
*
* See https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
flags?: ActivityFlags;
/**
* The custom buttons shown in the Rich Presence (max 2)
*/
buttons?: string[] | GatewayActivityButton[];
}
export enum ActivityPlatform {
Desktop = 'desktop',
Samsung = 'samsung',
Xbox = 'xbox',
}
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-types
*/
export enum ActivityType {
/**
* Playing {game}
*/
Game,
/**
* Streaming {details}
*/
Streaming,
/**
* Listening to {name}
*/
Listening,
/**
* Watching {details}
*/
Watching,
/**
* {emoji} {details}
*/
Custom,
/**
* Competing in {name}
*/
Competing,
}
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-timestamps
*/
export interface GatewayActivityTimestamps {
/**
* Unix time (in milliseconds) of when the activity started
*/
start?: number;
/**
* Unix time (in milliseconds) of when the activity ends
*/
end?: number;
}
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji
*/
export type GatewayActivityEmoji = Partial<Pick<APIEmoji, 'id' | 'animated'>> & Pick<APIEmoji, 'name'>;
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-party
*/
export interface GatewayActivityParty {
/**
* The id of the party
*/
id?: string;
/**
* Used to show the party's current and maximum size
*/
size?: [current_size: number, max_size: number];
}
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-assets
*/
export type GatewayActivityAssets = Partial<
Record<'large_image' | 'large_text' | 'small_image' | 'small_text', string>
>;
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-secrets
*/
export type GatewayActivitySecrets = Partial<Record<'join' | 'spectate' | 'match', string>>;
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags
*/
export enum ActivityFlags {
Instance = 1 << 0,
Join = 1 << 1,
Spectate = 1 << 2,
JoinRequest = 1 << 3,
Sync = 1 << 4,
Play = 1 << 5,
}
export interface GatewayActivityButton {
/**
* The text shown on the button (1-32 characters)
*/
label: string;
/**
* The url opened when clicking the button (1-512 characters)
*/
url: string;
}
/**
* https://discord.com/developers/docs/topics/gateway#thread-list-sync-thread-list-sync-event-fields
*/
export interface GatewayThreadListSync {
/**
* ID of the guild
*/
guild_id: Snowflake;
/**
* The ids of all the parent channels whose threads are being synced, otherwise the entire guild
*/
channel_ids?: Snowflake[];
/**
* Array of the synced threads
*/
threads: APIChannel[];
/**
* The member objects for the client user in each joined thread that was synced
*/
members: APIThreadMember[];
}
/**
* https://discord.com/developers/docs/topics/gateway#thread-members-update-thread-members-update-event-fields
*/
export interface GatewayThreadMembersUpdate {
/**
* The id of the thread for which members are being synced
*/
id: Snowflake;
/**
* The id of the guild that the thread is in
*/
guild_id: Snowflake;
/**
* The approximate member count of the thread, does not count above 50 even if there are more members
*/
member_count: number;
/**
* The members that were added to the thread
*/
added_members?: APIThreadMember[];
/**
* The ids of the members that were removed from the thread
*/
removed_member_ids?: Snowflake[];
}

934
deno/payloads/v9/guild.ts Normal file
View File

@@ -0,0 +1,934 @@
/**
* Types extracted from https://discord.com/developers/docs/resources/guild
*/
import type { Permissions, Snowflake } from '../../globals.ts';
import type { APIChannel } from './channel.ts';
import type { APIEmoji } from './emoji.ts';
import type { GatewayPresenceUpdate, 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';
/**
* https://discord.com/developers/docs/resources/guild#unavailable-guild-object
*/
export interface APIUnavailableGuild {
/**
* Guild id
*/
id: Snowflake;
/**
* `true` if this guild is unavailable due to an outage
*/
unavailable: boolean;
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-guild-structure
*/
export interface APIPartialGuild extends Omit<APIUnavailableGuild, 'unavailable'>, Pick<APIGuild, 'welcome_screen'> {
/**
* Guild name (2-100 characters, excluding trailing and leading whitespace)
*/
name: string;
/**
* Icon hash
*
* See https://discord.com/developers/docs/reference#image-formatting
*/
icon: string | null;
/**
* Splash hash
*
* See https://discord.com/developers/docs/reference#image-formatting
*/
splash: string | null;
/**
* Banner hash
*
* See https://discord.com/developers/docs/reference#image-formatting
*/
banner?: string | null;
/**
* The description for the guild, if the guild is discoverable
*/
description?: string | null;
/**
* Enabled guild features
*
* See https://discord.com/developers/docs/resources/guild#guild-object-guild-features
*/
features?: GuildFeature[];
/**
* Verification level required for the guild
*
* See https://discord.com/developers/docs/resources/guild#guild-object-verification-level
*/
verification_level?: GuildVerificationLevel;
/**
* The vanity url code for the guild
*/
vanity_url_code?: string | null;
/**
* `true` if this guild is unavailable due to an outage
*/
unavailable?: boolean;
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-guild-structure
*/
export interface APIGuild extends APIPartialGuild {
/**
* Icon hash, returned when in the template object
*
* See https://discord.com/developers/docs/reference#image-formatting
*/
icon_hash?: string | null;
/**
* Discovery splash hash; only present for guilds with the "DISCOVERABLE" feature
*
* See https://discord.com/developers/docs/reference#image-formatting
*/
discovery_splash: string | null;
/**
* `true` if the user is the owner of the guild
*
* **This field is only received from https://discord.com/developers/docs/resources/user#get-current-user-guilds**
*/
owner?: boolean;
/**
* ID of owner
*/
owner_id: Snowflake;
/**
* Total permissions for the user in the guild (excludes overrides)
*
* **This field is only received from https://discord.com/developers/docs/resources/user#get-current-user-guilds**
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
permissions?: Permissions;
/**
* Voice region id for the guild
*
* See https://discord.com/developers/docs/resources/voice#voice-region-object
* @deprecated This field has been deprecated in favor of `rtc_region` on the channel.
*/
region: string;
/**
* ID of afk channel
*/
afk_channel_id: Snowflake | null;
/**
* afk timeout in seconds
*/
afk_timeout: number;
/**
* `true` if the guild widget is enabled
*/
widget_enabled?: boolean;
/**
* The channel id that the widget will generate an invite to, or `null` if set to no invite
*/
widget_channel_id?: Snowflake | null;
/**
* Verification level required for the guild
*
* See https://discord.com/developers/docs/resources/guild#guild-object-verification-level
*/
verification_level: GuildVerificationLevel;
/**
* Default message notifications level
*
* See https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
*/
default_message_notifications: GuildDefaultMessageNotifications;
/**
* Explicit content filter level
*
* See https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level
*/
explicit_content_filter: GuildExplicitContentFilter;
/**
* Roles in the guild
*
* See https://discord.com/developers/docs/topics/permissions#role-object
*/
roles: APIRole[];
/**
* Custom guild emojis
*
* See https://discord.com/developers/docs/resources/emoji#emoji-object
*/
emojis: APIEmoji[];
/**
* Enabled guild features
*
* See https://discord.com/developers/docs/resources/guild#guild-object-guild-features
*/
features: GuildFeature[];
/**
* Required MFA level for the guild
*
* See https://discord.com/developers/docs/resources/guild#guild-object-mfa-level
*/
mfa_level: GuildMFALevel;
/**
* Application id of the guild creator if it is bot-created
*/
application_id: Snowflake | null;
/**
* The id of the channel where guild notices such as welcome messages and boost events are posted
*/
system_channel_id: Snowflake | null;
/**
* System channel flags
*
* See https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags
*/
system_channel_flags: GuildSystemChannelFlags;
/**
* 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)
*/
max_presences?: number | null;
/**
* The maximum number of members for the guild
*/
max_members?: number;
/**
* The vanity url code for the guild
*/
vanity_url_code: string | null;
/**
* The description for the guild, if the guild is discoverable
*/
description: string | null;
/**
* Banner hash
*
* See https://discord.com/developers/docs/reference#image-formatting
*/
banner: string | null;
/**
* Premium tier (Server Boost level)
*
* See https://discord.com/developers/docs/resources/guild#guild-object-premium-tier
*/
premium_tier: GuildPremiumTier;
/**
* The number of boosts this guild currently has
*/
premium_subscription_count?: number;
/**
* The preferred locale of a Community guild; used in guild discovery and notices from Discord; defaults to "en-US"
*
* @default "en-US"
*/
preferred_locale: string;
/**
* The id of the channel where admins and moderators of Community guilds receive notices from Discord
*/
public_updates_channel_id: Snowflake | null;
/**
* The maximum amount of users in a video channel
*/
max_video_channel_users?: number;
/**
* **This field is only received from https://discord.com/developers/docs/resources/guild#get-guild with the `with_counts` query parameter set to `true`**
*/
approximate_member_count?: number;
/**
* **This field is only received from https://discord.com/developers/docs/resources/guild#get-guild with the `with_counts` query parameter set to `true`**
*/
approximate_presence_count?: number;
/**
* The welcome screen of a Community guild, shown to new members
*
* Returned in the invite object
*/
welcome_screen?: APIGuildWelcomeScreen;
/**
* The nsfw level of the guild
*
* 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
*
* See https://discord.com/developers/docs/resources/sticker#sticker-object
*/
stickers: APISticker[];
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
*/
export enum GuildDefaultMessageNotifications {
AllMessages,
OnlyMentions,
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level
*/
export enum GuildExplicitContentFilter {
Disabled,
MembersWithoutRoles,
AllMembers,
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-mfa-level
*/
export enum GuildMFALevel {
None,
Elevated,
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level
*/
export enum GuildNSFWLevel {
Default,
Explicit,
Safe,
AgeRestricted,
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-verification-level
*/
export enum GuildVerificationLevel {
/**
* Unrestricted
*/
None,
/**
* Must have verified email on account
*/
Low,
/**
* Must be registered on Discord for longer than 5 minutes
*/
Medium,
/**
* Must be a member of the guild for longer than 10 minutes
*/
High,
/**
* Must have a verified phone number
*/
VeryHigh,
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-premium-tier
*/
export enum GuildPremiumTier {
None,
Tier1,
Tier2,
Tier3,
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags
*/
export enum GuildSystemChannelFlags {
/**
* Suppress member join notifications
*/
SuppressJoinNotifications = 1 << 0,
/**
* Suppress server boost notifications
*/
SuppressPremiumSubscriptions = 1 << 1,
/**
* Suppress server setup tips
*/
SuppressGuildReminderNotifications = 1 << 2,
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-guild-features
*/
export enum GuildFeature {
/**
* Guild has access to set an animated guild icon
*/
AnimatedIcon = 'ANIMATED_ICON',
/**
* Guild has access to set a guild banner image
*/
Banner = 'BANNER',
/**
* Guild has access to use commerce features (i.e. create store channels)
*/
Commerce = 'COMMERCE',
/**
* Guild can enable welcome screen, Membership Screening and discovery, and receives community updates
*/
Community = 'COMMUNITY',
/**
* Guild is able to be discovered in the directory
*/
Discoverable = 'DISCOVERABLE',
/**
* Guild is able to be featured in the directory
*/
Featurable = 'FEATURABLE',
/**
* Guild has access to set an invite splash background
*/
InviteSplash = 'INVITE_SPLASH',
/**
* Guild has access to create news channels
*/
News = 'NEWS',
/**
* Guild is partnered
*/
Partnered = 'PARTNERED',
RelayEnabled = 'RELAY_ENABLED',
/**
* Guild has access to set a vanity URL
*/
VanityURL = 'VANITY_URL',
/**
* Guild is verified
*/
Verified = 'VERIFIED',
/**
* Guild has access to set 384kbps bitrate in voice (previously VIP voice servers)
*/
VIPRegions = 'VIP_REGIONS',
/**
* Guild has enabled the welcome screen
*/
WelcomeScreenEnabled = 'WELCOME_SCREEN_ENABLED',
/**
* Guild has enabled Membership Screening
*/
MemberVerificationGateEnabled = 'MEMBER_VERIFICATION_GATE_ENABLED',
/**
* Guild can be previewed before joining via Membership Screening or the directory
*/
PreviewEnabled = 'PREVIEW_ENABLED',
/**
* Guild has enabled ticketed events
*/
TicketedEventsEnabled = 'TICKETED_EVENTS_ENABLED',
/**
* Guild has enabled monetization
*/
MonetizationEnabled = 'MONETIZATION_ENABLED',
/**
* Guild has increased custom sticker slots
*/
MoreStickers = 'MORE_STICKERS',
/**
* Guild has access to the three day archive time for threads
*/
ThreeDayThreadArchive = 'THREE_DAY_THREAD_ARCHIVE',
/**
* Guild has access to the seven day archive time for threads
*/
SevenDayThreadArchive = 'SEVEN_DAY_THREAD_ARCHIVE',
/**
* Guild has access to create private threads
*/
PrivateThreads = 'PRIVATE_THREADS',
}
/**
* https://discord.com/developers/docs/resources/guild#guild-preview-object
*/
export interface APIGuildPreview {
/**
* Guild id
*/
id: Snowflake;
/**
* Guild name (2-100 characters)
*/
name: string;
/**
* Icon hash
*
* See https://discord.com/developers/docs/reference#image-formatting
*/
icon: string | null;
/**
* Splash hash
*
* See https://discord.com/developers/docs/reference#image-formatting
*/
splash: string | null;
/**
* Discovery splash hash; only present for guilds with the "DISCOVERABLE" feature
*
* See https://discord.com/developers/docs/reference#image-formatting
*/
discovery_splash: string | null;
/**
* Custom guild emojis
*
* See https://discord.com/developers/docs/resources/emoji#emoji-object
*/
emojis: APIEmoji[];
/**
* Enabled guild features
*
* See https://discord.com/developers/docs/resources/guild#guild-object-guild-features
*/
features: GuildFeature[];
/**
* Approximate number of members in this guild
*/
approximate_member_count: number;
/**
* Approximate number of online members in this guild
*/
approximate_presence_count: number;
/**
* The description for the guild
*/
description: string;
}
/**
* https://discord.com/developers/docs/resources/guild#guild-widget-object
*/
export interface APIGuildWidgetSettings {
/**
* Whether the widget is enabled
*/
enabled: boolean;
/**
* The widget channel id
*/
channel_id: Snowflake | null;
}
/**
* https://discord.com/developers/docs/resources/guild#guild-member-object
*/
export interface APIGuildMember {
/**
* The user this guild member represents
*
* **This field won't be included in the member object attached to `MESSAGE_CREATE` and `MESSAGE_UPDATE` gateway events.**
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
user?: APIUser;
/**
* This users guild nickname
*/
nick?: string | null;
/**
* Array of role object ids
*
* See https://discord.com/developers/docs/topics/permissions#role-object
*/
roles: Snowflake[];
/**
* When the user joined the guild
*/
joined_at: string;
/**
* When the user started boosting the guild
*
* See https://support.discord.com/hc/en-us/articles/360028038352-Server-Boosting-
*/
premium_since?: string | null;
/**
* Whether the user is deafened in voice channels
*/
deaf: boolean;
/**
* Whether the user is muted in voice channels
*/
mute: boolean;
/**
* Whether the user has not yet passed the guild's Membership Screening requirements
*
* *If this field is not present, it can be assumed as `false`.*
*/
pending?: boolean;
}
/**
* https://discord.com/developers/docs/resources/guild#integration-object
*/
export interface APIGuildIntegration {
/**
* Integration id
*/
id: Snowflake;
/**
* Integration name
*/
name: string;
/**
* Integration type
*/
type: APIGuildInteractionType;
/**
* Is this integration enabled
*/
enabled: boolean;
/**
* Is this integration syncing
*
* **This field is not provided for `discord` bot integrations.**
*/
syncing?: boolean;
/**
* ID that this integration uses for "subscribers"
*
* **This field is not provided for `discord` bot integrations.**
*/
role_id?: Snowflake;
/**
* Whether emoticons should be synced for this integration (`twitch` only currently)
*
* **This field is not provided for `discord` bot integrations.**
*/
enable_emoticons?: boolean;
/**
* The behavior of expiring subscribers
*
* **This field is not provided for `discord` bot integrations.**
*
* See https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
*/
expire_behavior?: IntegrationExpireBehavior;
/**
* The grace period (in days) before expiring subscribers
*
* **This field is not provided for `discord` bot integrations.**
*/
expire_grace_period?: number;
/**
* User for this integration
*
* **This field is not provided for `discord` bot integrations.**
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
user?: APIUser;
/**
* Integration account information
*
* See https://discord.com/developers/docs/resources/guild#integration-account-object
*/
account: APIIntegrationAccount;
/**
* When this integration was last synced
*
* **This field is not provided for `discord` bot integrations.**
*/
synced_at?: string;
/**
* How many subscribers this integration has
*
* **This field is not provided for `discord` bot integrations.**
*/
subscriber_count?: number;
/**
* Has this integration been revoked
*
* **This field is not provided for `discord` bot integrations.**
*/
revoked?: boolean;
/**
* The bot/OAuth2 application for discord integrations
*
* See https://discord.com/developers/docs/resources/guild#integration-application-object
*
* **This field is not provided for `discord` bot integrations.**
*/
application?: APIGuildIntegrationApplication;
}
export type APIGuildInteractionType = 'twitch' | 'youtube' | 'discord';
/**
* https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
*/
export enum IntegrationExpireBehavior {
RemoveRole,
Kick,
}
/**
* https://discord.com/developers/docs/resources/guild#integration-account-object
*/
export interface APIIntegrationAccount {
/**
* ID of the account
*/
id: string;
/**
* Name of the account
*/
name: string;
}
/**
* https://discord.com/developers/docs/resources/guild#integration-application-object
*/
export interface APIGuildIntegrationApplication {
/**
* The id of the app
*/
id: Snowflake;
/**
* The name of the app
*/
name: string;
/**
* The icon hash of the app
*
* See https://discord.com/developers/docs/reference#image-formatting
*/
icon: string | null;
/**
* The description of the app
*/
description: string;
/**
* The summary of the app
*/
summary: string;
/**
* The bot associated with this application
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
bot?: APIUser;
}
/**
* https://discord.com/developers/docs/resources/guild#ban-object
*/
export interface APIBan {
/**
* The reason for the ban
*/
reason: string | null;
/**
* The banned user
*/
user: APIUser;
}
/**
* https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget
*/
export interface APIGuildWidget {
id: Snowflake;
name: string;
instant_invite: string | null;
channels: APIGuildWidgetChannel[];
members: APIGuildWidgetMember[];
presence_count: number;
}
/**
* https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget
*/
export interface APIGuildWidgetChannel {
id: Snowflake;
name: string;
position: number;
}
/**
* https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget
*/
export interface APIGuildWidgetMember {
id: string;
username: string;
discriminator: string;
avatar: string | null;
status: PresenceUpdateStatus;
activity?: { name: string };
avatar_url: string;
}
/**
* https://discord.com/developers/docs/resources/guild#get-guild-widget-image-widget-style-options
*/
export enum GuildWidgetStyle {
/**
* Shield style widget with Discord icon and guild members online count
*/
Shield = 'shield',
/**
* Large image with guild icon, name and online count. "POWERED BY DISCORD" as the footer of the widget
*/
Banner1 = 'banner1',
/**
* Smaller widget style with guild icon, name and online count. Split on the right with Discord logo
*/
Banner2 = 'banner2',
/**
* Large image with guild icon, name and online count. In the footer, Discord logo on the left and "Chat Now" on the right
*/
Banner3 = 'banner3',
/**
* Large Discord logo at the top of the widget. Guild icon, name and online count in the middle portion of the widget
* and a "JOIN MY SERVER" button at the bottom
*/
Banner4 = 'banner4',
}
export interface APIGuildWelcomeScreen {
/**
* The welcome screen short message
*/
description: string | null;
/**
* Array of suggested channels
*/
welcome_channels: APIGuildWelcomeScreenChannel[];
}
export interface APIGuildWelcomeScreenChannel {
/**
* The channel id that is suggested
*/
channel_id: Snowflake;
/**
* The description shown for the channel
*/
description: string;
/**
* The emoji id of the emoji that is shown on the left of the channel
*/
emoji_id: Snowflake | null;
/**
* The emoji name of the emoji that is shown on the left of the channel
*/
emoji_name: string | null;
}
export interface APIGuildMembershipScreening {
/**
* When the fields were last updated
*/
version: string;
/**
* The steps in the screening form
*/
form_fields: APIGuildMembershipScreeningField[];
/**
* The server description shown in the screening form
*/
description: string | null;
}
// TODO: make this a union based on the type in the future, when new types are added
export interface APIGuildMembershipScreeningField {
/**
* The type of field
*/
field_type: MembershipScreeningFieldType;
/**
* The title of the field
*/
label: string;
/**
* The list of rules
*/
values?: string[];
/**
* Whether the user has to fill out this field
*/
required: boolean;
}
export enum MembershipScreeningFieldType {
/**
* Server Rules
*/
Terms = 'TERMS',
}

View File

@@ -0,0 +1,23 @@
import type {
APIMessageComponentDMInteraction,
APIMessageComponentGuildInteraction,
APIMessageComponentInteraction,
} from './_interactions/messageComponents.ts';
import type { APIPingInteraction } from './_interactions/ping.ts';
import type {
APIApplicationCommandDMInteraction,
APIApplicationCommandGuildInteraction,
APIApplicationCommandInteraction,
} from './_interactions/slashCommands.ts';
export * from './_interactions/base.ts';
export * from './_interactions/messageComponents.ts';
export * from './_interactions/ping.ts';
export * from './_interactions/responses.ts';
export * from './_interactions/slashCommands.ts';
export type APIInteraction = APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction;
export type APIDMInteraction = APIApplicationCommandDMInteraction | APIMessageComponentDMInteraction;
export type APIGuildInteraction = APIApplicationCommandGuildInteraction | APIMessageComponentGuildInteraction;

105
deno/payloads/v9/invite.ts Normal file
View File

@@ -0,0 +1,105 @@
/**
* Types extracted from https://discord.com/developers/docs/resources/invite
*/
import type { APIPartialChannel } from './channel.ts';
import type { APIPartialGuild } from './guild.ts';
import type { APIApplication } from './application.ts';
import type { APIInviteStageInstance } from './stageInstance.ts';
import type { APIUser } from './user.ts';
/**
* https://discord.com/developers/docs/resources/invite#invite-object
*/
export interface APIInvite {
/**
* The invite code (unique ID)
*/
code: string;
/**
* The guild this invite is for
*
* See https://discord.com/developers/docs/resources/guild#guild-object
*/
guild?: APIPartialGuild;
/**
* The channel this invite is for
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
channel: Required<APIPartialChannel>;
/**
* The user who created the invite
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
inviter?: APIUser;
/**
* The type of target for this voice channel invite
*
* See https://discord.com/developers/docs/resources/invite#invite-object-target-user-types
*/
target_type?: InviteTargetType;
/**
* The user whose stream to display for this voice channel stream invite
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
target_user?: APIUser;
/**
* The embedded application to open for this voice channel embedded application invite
*
* See https://discord.com/developers/docs/topics/oauth2#application
*/
target_application?: Partial<APIApplication>;
/**
* Approximate count of online members, returned from the `GET /invites/<code>` endpoint when `with_counts` is `true`
*/
approximate_presence_count?: number;
/**
* Approximate count of total members, returned from the `GET /invites/<code>` endpoint when `with_counts` is `true`
*/
approximate_member_count?: number;
/**
* The expiration date of this invite, returned from the `GET /invites/<code>` endpoint when `with_expiration` is `true`
*/
expires_at?: string | null;
/**
* The stage instance data if there is a public stage instance in the stage channel this invite is for
*/
stage_instance?: APIInviteStageInstance;
}
/**
* https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types
*/
export enum InviteTargetType {
Stream = 1,
EmbeddedApplication,
}
/**
* https://discord.com/developers/docs/resources/invite#invite-metadata-object
*/
export interface APIExtendedInvite extends APIInvite {
/**
* Number of times this invite has been used
*/
uses: number;
/**
* Max number of times this invite can be used
*/
max_uses: number;
/**
* Duration (in seconds) after which the invite expires
*/
max_age: number;
/**
* Whether this invite only grants temporary membership
*/
temporary: boolean;
/**
* When this invite was created
*/
created_at: string;
}

17
deno/payloads/v9/mod.ts Normal file
View File

@@ -0,0 +1,17 @@
export * from './application.ts';
export * from './auditLog.ts';
export * from './channel.ts';
export * from './emoji.ts';
export * from './gateway.ts';
export * from './guild.ts';
export * from './interactions.ts';
export * from './invite.ts';
export * from './oauth2.ts';
export * from './permissions.ts';
export * from './stageInstance.ts';
export * from './sticker.ts';
export * from './teams.ts';
export * from './template.ts';
export * from './user.ts';
export * from './voice.ts';
export * from './webhook.ts';

108
deno/payloads/v9/oauth2.ts Normal file
View File

@@ -0,0 +1,108 @@
/**
* Types extracted from https://discord.com/developers/docs/topics/oauth2
*/
export enum OAuth2Scopes {
/**
* For oauth2 bots, this puts the bot in the user's selected guild by default
*/
Bot = 'bot',
/**
* Allows [/users/@me/connections](https://discord.com/developers/docs/resources/user#get-user-connections)
* to return linked third-party accounts
*
* See https://discord.com/developers/docs/resources/user#get-user-connections
*/
Connections = 'connections',
/**
* Enables [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) to return an `email`
*
* See https://discord.com/developers/docs/resources/user#get-current-user
*/
Email = 'email',
/**
* Allows [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) without `email`
*
* See https://discord.com/developers/docs/resources/user#get-current-user
*/
Identify = 'identify',
/**
* Allows [/users/@me/guilds](https://discord.com/developers/docs/resources/user#get-current-user-guilds)
* to return basic information about all of a user's guilds
*
* See https://discord.com/developers/docs/resources/user#get-current-user-guilds
*/
Guilds = 'guilds',
/**
* Allows [/guilds/{guild.id}/members/{user.id}](https://discord.com/developers/docs/resources/guild#add-guild-member)
* to be used for joining users to a guild
*
* See https://discord.com/developers/docs/resources/guild#add-guild-member
*/
GuildsJoin = 'guilds.join',
/**
* Allows your app to join users to a group dm
*
* See https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
*/
GroupDMJoins = 'gdm.join',
/**
* For local rpc server api access, this allows you to read messages from all client channels
* (otherwise restricted to channels/guilds your app creates)
*/
MessagesRead = 'messages.read',
/**
* For local rpc server access, this allows you to control a user's local Discord client - requires Discord approval
*/
RPC = 'rpc',
/**
* For local rpc server api access, this allows you to receive notifications pushed out to the user - requires Discord approval
*/
RPCNotificationsRead = 'rpc.notifications.read',
/**
* This generates a webhook that is returned in the oauth token response for authorization code grants
*/
WebhookIncoming = 'webhook.incoming',
/**
* Allows your app to upload/update builds for a user's applications - requires Discord approval
*/
ApplicationsBuildsUpload = 'applications.builds.upload',
/**
* Allows your app to read build data for a user's applications
*/
ApplicationsBuildsRead = 'applications.builds.read',
/**
* Allows your app to read and update store data (SKUs, store listings, achievements, etc.) for a user's applications
*/
ApplicationsStoreUpdate = 'applications.store.update',
/**
* Allows your app to read entitlements for a user's applications
*/
ApplicationsEntitlements = 'applications.entitlements',
/**
* Allows your app to know a user's friends and implicit relationships - requires Discord approval
*/
RelationshipsRead = 'relationships.read',
/**
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list - requires Discord approval
*/
ActivitiesRead = 'activities.read',
/**
* Allows your app to update a user's activity - requires Discord approval (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
*
* See https://discord.com/developers/docs/game-sdk/activities
*/
ActivitiesWrite = 'activities.write',
/**
* Allows your app to use Slash Commands in a guild
*
* See https://discord.com/developers/docs/interactions/slash-commands
*/
ApplicationsCommands = 'applications.commands',
/**
* Allows your app to update its Slash Commands via this bearer token - client credentials grant only
*
* See https://discord.com/developers/docs/interactions/slash-commands
*/
ApplicationsCommandsUpdate = 'applications.commands.update',
}

View File

@@ -0,0 +1,120 @@
/**
* Types extracted from https://discord.com/developers/docs/topics/permissions
*/
import type { Permissions, Snowflake } from '../../globals.ts';
/**
* https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags
*
* These flags are exported as `BigInt`s and NOT numbers. Wrapping them in `Number()`
* may cause issues, try to use BigInts as much as possible or modules that can
* replicate them in some way
*/
export const PermissionFlagsBits = {
CreateInstantInvite: 1n << 0n,
KickMembers: 1n << 1n,
BanMembers: 1n << 2n,
Administrator: 1n << 3n,
ManageChannels: 1n << 4n,
ManageGuild: 1n << 5n,
AddReactions: 1n << 6n,
ViewAuditLog: 1n << 7n,
PrioritySpeaker: 1n << 8n,
Stream: 1n << 9n,
ViewChannel: 1n << 10n,
SendMessages: 1n << 11n,
SendTTSMessages: 1n << 12n,
ManageMessages: 1n << 13n,
EmbedLinks: 1n << 14n,
AttachFiles: 1n << 15n,
ReadMessageHistory: 1n << 16n,
MentionEveryone: 1n << 17n,
UseExternalEmojis: 1n << 18n,
ViewGuildInsights: 1n << 19n,
Connect: 1n << 20n,
Speak: 1n << 21n,
MuteMembers: 1n << 22n,
DeafenMembers: 1n << 23n,
MoveMembers: 1n << 24n,
UseVAD: 1n << 25n,
ChangeNickname: 1n << 26n,
ManageNicknames: 1n << 27n,
ManageRoles: 1n << 28n,
ManageWebhooks: 1n << 29n,
ManageEmojisAndStickers: 1n << 30n,
UseSlashCommands: 1n << 31n,
RequestToSpeak: 1n << 32n,
ManageThreads: 1n << 34n,
UsePublicThreads: 1n << 35n,
UsePrivateThreads: 1n << 36n,
UseExternalStickers: 1n << 37n,
} as const;
/**
* Freeze the object of bits, preventing any modifications to it
* @internal
*/
Object.freeze(PermissionFlagsBits);
/**
* https://discord.com/developers/docs/topics/permissions#role-object
*/
export interface APIRole {
/**
* Role id
*/
id: Snowflake;
/**
* Role name
*/
name: string;
/**
* Integer representation of hexadecimal color code
*/
color: number;
/**
* If this role is pinned in the user listing
*/
hoist: boolean;
/**
* Position of this role
*/
position: number;
/**
* Permission bit set
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
permissions: Permissions;
/**
* Whether this role is managed by an integration
*/
managed: boolean;
/**
* Whether this role is mentionable
*/
mentionable: boolean;
/**
* The tags this role has
*/
tags?: APIRoleTags;
}
/**
* https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure
*/
export interface APIRoleTags {
/**
* The id of the bot this role belongs to
*/
bot_id?: Snowflake;
/**
* Whether this is the guild's premium subscriber role
*/
premium_subscriber?: null;
/**
* The id of the integration this role belongs to
*/
integration_id?: Snowflake;
}

View File

@@ -0,0 +1,72 @@
import type { Snowflake } from '../../globals.ts';
import type { APIGuildMember } from './guild.ts';
/**
* https://discord.com/developers/docs/resources/stage-instance#stage-instance-object
*/
export interface APIStageInstance {
/**
* The id of the stage instance
*/
id: Snowflake;
/**
* The guild id of the associated stage channel
*/
guild_id: Snowflake;
/**
* The id of the associated stage channel
*/
channel_id: Snowflake;
/**
* The topic of the stage instance (1-120 characters)
*/
topic: string;
/**
* The privacy level of the stage instance
*
* See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level
*/
privacy_level: StageInstancePrivacyLevel;
/**
* Whether or not stage discovery is disabled
*/
discoverable_disabled: boolean;
}
/**
* https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level
*/
export enum StageInstancePrivacyLevel {
/**
* The stage instance is visible publicly, such as on stage discovery
*/
Public = 1,
/**
* The stage instance is visible to only guild members
*/
GuildOnly,
}
/**
* https://discord.com/developers/docs/resources/invite#invite-stage-instance-object-invite-stage-instance-structure
*/
export interface APIInviteStageInstance {
/**
* The topic of the stage instance (1-120 characters)
*/
topic: string;
/**
* The number of users in the stage
*/
participant_count: number;
/**
* The number of users speaking in the stage
*/
speaker_count: number;
/**
* The members speaking in the stage
*
* See https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-structure
*/
members: APIGuildMember[];
}

127
deno/payloads/v9/sticker.ts Normal file
View File

@@ -0,0 +1,127 @@
/**
* Types extracted from https://discord.com/developers/docs/resources/sticker
*/
import type { Snowflake } from '../../globals.ts';
import type { APIUser } from './user.ts';
/**
* https://discord.com/developers/docs/resources/sticker#sticker-object
*/
export interface APISticker {
/**
* ID of the sticker
*/
id: Snowflake;
/**
* For standard stickers, ID of the pack the sticker is from
*/
pack_id?: Snowflake;
/**
* Name of the sticker
*/
name: string;
/**
* Description of the sticker
*/
description: string | null;
/**
* For guild stickers, the Discord name of a unicode emoji representing the sticker's expression. for standard stickers, a comma-separated list of related expressions.
*/
tags: string;
/**
* Previously the sticker asset hash, now an empty string
* @deprecated
*/
asset: '';
/**
* Type of sticker
*
* See https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types
*/
type: StickerType;
/**
* Type of sticker format
*
* See https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types
*/
format_type: StickerFormatType;
/**
* Whether this guild sticker can be used, may be false due to loss of Server Boosts
*/
available?: boolean;
/**
* ID of the guild that owns this sticker
*/
guild_id?: Snowflake;
/**
* The user that uploaded the guild sticker
*/
user?: APIUser;
/**
* The standard sticker's sort order within its pack
*/
sort_value?: number;
}
/**
* https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types
*/
export enum StickerType {
/**
* An official sticker in a pack, part of Nitro or in a removed purchasable pack
*/
Standard = 1,
/**
* A sticker uploaded to a Boosted guild for the guild's members
*/
Guild,
}
/**
* https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types
*/
export enum StickerFormatType {
PNG = 1,
APNG,
Lottie,
}
/**
* https://discord.com/developers/docs/resources/sticker#sticker-item-object
*/
export type APIStickerItem = Pick<APISticker, 'id' | 'name' | 'format_type'>;
/**
* https://discord.com/developers/docs/resources/sticker#sticker-object
*/
export interface APIStickerPack {
/**
* ID of the sticker pack
*/
id: Snowflake;
/**
* The stickers in the pack
*/
stickers: APISticker[];
/**
* Name of the sticker pack
*/
name: string;
/**
* ID of the pack's SKU
*/
sku_id: Snowflake;
/**
* ID of a sticker in the pack which is shown as the pack's icon
*/
cover_sticker_id?: Snowflake;
/**
* Description of the sticker pack
*/
description: string;
/**
* ID of the sticker pack's banner image
*/
banner_asset_id: Snowflake;
}

66
deno/payloads/v9/teams.ts Normal file
View File

@@ -0,0 +1,66 @@
/**
* Types extracted from https://discord.com/developers/docs/topics/teams
*/
import type { Snowflake } from '../../globals.ts';
import type { APIUser } from './user.ts';
/**
* https://discord.com/developers/docs/topics/teams#data-models-team-object
*/
export interface APITeam {
/**
* A hash of the image of the team's icon
*/
icon: string | null;
/**
* The unique id of the team
*/
id: Snowflake;
/**
* The members of the team
*/
members: APITeamMember[];
/**
* The name of the team
*/
name: string;
/**
* The user id of the current team owner
*/
owner_user_id: Snowflake;
}
/**
* https://discord.com/developers/docs/topics/teams#data-models-team-members-object
*/
export interface APITeamMember {
/**
* The user's membership state on the team
*
* See https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum
*/
membership_state: TeamMemberMembershipState;
/**
* Will always be `["*"]`
*/
permissions: ['*'];
/**
* The id of the parent team of which they are a member
*/
team_id: Snowflake;
/**
* The avatar, discriminator, id, and username of the user
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
user: APIUser;
}
/**
* https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum
*/
export enum TeamMemberMembershipState {
Invited = 1,
Accepted,
}

View File

@@ -0,0 +1,65 @@
/**
* Types extracted from https://discord.com/developers/docs/resources/template
*/
import type { Snowflake } from '../../globals.ts';
import type { RESTPostAPIGuildsJSONBody } from '../../rest/v9/mod.ts';
import type { APIUser } from './user.ts';
/**
* https://discord.com/developers/docs/resources/template#template-object
*/
export interface APITemplate {
/**
* The template code (unique ID)
*/
code: string;
/**
* Template name
*/
name: string;
/**
* The description for the template
*/
description: string | null;
/**
* Number of times this template has been used
*/
usage_count: number;
/**
* The ID of the user who created the template
*/
creator_id: Snowflake;
/**
* The user who created the template
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
creator: APIUser;
/**
* When this template was created
*/
created_at: string;
/**
* When this template was last synced to the source guild
*/
updated_at: string;
/**
* The ID of the guild this template is based on
*/
source_guild_id: Snowflake;
/**
* The guild snapshot this template contains
*/
serialized_source_guild: APITemplateSerializedSourceGuild;
/**
* Whether the template has unsynced changes
*/
is_dirty: boolean | null;
}
export interface APITemplateSerializedSourceGuild extends Omit<RESTPostAPIGuildsJSONBody, 'icon'> {
description: string | null;
preferred_locale: string;
icon_hash: string | null;
}

158
deno/payloads/v9/user.ts Normal file
View File

@@ -0,0 +1,158 @@
/**
* Types extracted from https://discord.com/developers/docs/resources/user
*/
import type { Snowflake } from '../../globals.ts';
import type { APIGuildIntegration } from './guild.ts';
/**
* https://discord.com/developers/docs/resources/user#user-object
*/
export interface APIUser {
/**
* The user's id
*/
id: Snowflake;
/**
* The user's username, not unique across the platform
*/
username: string;
/**
* The user's 4-digit discord-tag
*/
discriminator: string;
/**
* The user's avatar hash
*
* See https://discord.com/developers/docs/reference#image-formatting
*/
avatar: string | null;
/**
* Whether the user belongs to an OAuth2 application
*/
bot?: boolean;
/**
* Whether the user is an Official Discord System user (part of the urgent message system)
*/
system?: boolean;
/**
* Whether the user has two factor enabled on their account
*/
mfa_enabled?: boolean;
/**
* The user's chosen language option
*/
locale?: string;
/**
* Whether the email on this account has been verified
*/
verified?: boolean;
/**
* The user's email
*/
email?: string | null;
/**
* The flags on a user's account
*
* See https://discord.com/developers/docs/resources/user#user-object-user-flags
*/
flags?: UserFlags;
/**
* The type of Nitro subscription on a user's account
*
* See https://discord.com/developers/docs/resources/user#user-object-premium-types
*/
premium_type?: UserPremiumType;
/**
* The public flags on a user's account
*
* See https://discord.com/developers/docs/resources/user#user-object-user-flags
*/
public_flags?: UserFlags;
}
/**
* https://discord.com/developers/docs/resources/user#user-object-user-flags
*/
export enum UserFlags {
None = 0,
DiscordEmployee = 1 << 0,
PartneredServerOwner = 1 << 1,
DiscordHypeSquadEvents = 1 << 2,
BugHunterLevel1 = 1 << 3,
HypeSquadHouseBravery = 1 << 6,
HypeSquadHouseBrilliance = 1 << 7,
HypeSquadHouseBalance = 1 << 8,
EarlySupporter = 1 << 9,
TeamUser = 1 << 10,
BugHunterLevel2 = 1 << 14,
VerifiedBot = 1 << 16,
EarlyVerifiedBotDeveloper = 1 << 17,
DiscordCertifiedModerator = 1 << 18,
}
/**
* https://discord.com/developers/docs/resources/user#user-object-premium-types
*/
export enum UserPremiumType {
None,
NitroClassic,
Nitro,
}
/**
* https://discord.com/developers/docs/resources/user#connection-object
*/
export interface APIConnection {
/**
* ID of the connection account
*/
id: string;
/**
* The username of the connection account
*/
name: string;
/**
* The service of the connection
*/
type: string;
/**
* Whether the connection is revoked
*/
revoked?: boolean;
/**
* An array of partial server integrations
*
* See https://discord.com/developers/docs/resources/guild#integration-object
*/
integrations?: Partial<APIGuildIntegration>[];
/**
* Whether the connection is verified
*/
verified: boolean;
/**
* Whether friend sync is enabled for this connection
*/
friend_sync: boolean;
/**
* Whether activities related to this connection will be shown in presence updates
*/
show_activity: boolean;
/**
* Visibility of this connection
*
* See https://discord.com/developers/docs/resources/user#connection-object-visibility-types
*/
visibility: ConnectionVisibility;
}
export enum ConnectionVisibility {
/**
* Invisible to everyone except the user themselves
*/
None,
/**
* Visible to everyone
*/
Everyone,
}

96
deno/payloads/v9/voice.ts Normal file
View File

@@ -0,0 +1,96 @@
/**
* Types extracted from https://discord.com/developers/docs/resources/voice
*/
import type { Snowflake } from '../../globals.ts';
import type { APIGuildMember } from './guild.ts';
/**
* https://discord.com/developers/docs/resources/voice#voice-state-object
*/
export interface GatewayVoiceState {
/**
* The guild id this voice state is for
*/
guild_id?: Snowflake;
/**
* The channel id this user is connected to
*/
channel_id: Snowflake | null;
/**
* The user id this voice state is for
*/
user_id: Snowflake;
/**
* The guild member this voice state is for
*
* See https://discord.com/developers/docs/resources/guild#guild-member-object
*/
member?: APIGuildMember;
/**
* The session id for this voice state
*/
session_id: string;
/**
* Whether this user is deafened by the server
*/
deaf: boolean;
/**
* Whether this user is muted by the server
*/
mute: boolean;
/**
* Whether this user is locally deafened
*/
self_deaf: boolean;
/**
* Whether this user is locally muted
*/
self_mute: boolean;
/**
* Whether this user is streaming using "Go Live"
*/
self_stream?: boolean;
/**
* Whether this user's camera is enabled
*/
self_video: boolean;
/**
* Whether this user is muted by the current user
*/
suppress: boolean;
/**
* The time at which the user requested to speak
*/
request_to_speak_timestamp: string | null;
}
/**
* https://discord.com/developers/docs/resources/voice#voice-region-object
*/
export interface APIVoiceRegion {
/**
* Unique ID for the region
*/
id: string;
/**
* Name of the region
*/
name: string;
/**
* `true` if this is a vip-only server
*/
vip: boolean;
/**
* `true` for a single server that is closest to the current user's client
*/
optimal: boolean;
/**
* Whether this is a deprecated voice region (avoid switching to these)
*/
deprecated: boolean;
/**
* Whether this is a custom voice region (used for events/etc)
*/
custom: boolean;
}

View File

@@ -0,0 +1,79 @@
/**
* Types extracted from https://discord.com/developers/docs/resources/webhook
*/
import type { Snowflake } from '../../globals.ts';
import type { APIPartialChannel, APIPartialGuild, APIUser } from './mod.ts';
/**
* https://discord.com/developers/docs/resources/webhook#webhook-object
*/
export interface APIWebhook {
/**
* The id of the webhook
*/
id: Snowflake;
/**
* The type of the webhook
*
* See https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types
*/
type: WebhookType;
/**
* The guild id this webhook is for
*/
guild_id?: Snowflake;
/**
* The channel id this webhook is for
*/
channel_id: Snowflake;
/**
* The user this webhook was created by (not returned when getting a webhook with its token)
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
user?: APIUser;
/**
* The default name of the webhook
*/
name: string | null;
/**
* The default avatar of the webhook
*/
avatar: string | null;
/**
* The secure token of the webhook (returned for Incoming Webhooks)
*/
token?: string;
/**
* The bot/OAuth2 application that created this webhook
*/
application_id: Snowflake | null;
/**
* The guild of the channel that this webhook is following (returned for Channel Follower Webhooks)
*/
source_guild?: APIPartialGuild;
/**
* The channel that this webhook is following (returned for Channel Follower Webhooks)
*/
source_channel?: APIPartialChannel;
/**
* The url used for executing the webhook (returned by the webhooks OAuth2 flow)
*/
url?: string;
}
export enum WebhookType {
/**
* Incoming Webhooks can post messages to channels with a generated token
*/
Incoming = 1,
/**
* Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels
*/
ChannelFollower,
/**
* Application webhooks are webhooks used with Interactions
*/
Application,
}

View File

@@ -19,6 +19,9 @@ export enum RESTJSONErrorCodes {
UnknownUser,
UnknownEmoji,
UnknownWebhook,
UnknownWebhookService,
UnknownSession = 10020,
UnknownBan = 10026,
UnknownSKU,
@@ -27,28 +30,52 @@ export enum RESTJSONErrorCodes {
UnknownBuild,
UnknownLobby,
UnknownBranch,
UnknownStoreDirectoryLayout,
UnknownRedistributable = 10036,
UnknownGiftCode = 10038,
UnknownGuildTemplate = 10057,
UnknownDiscoverableServerCategory = 10059,
UnknownSticker,
UnknownInteraction = 10062,
UnknownApplicationCommand,
UnknownApplicationCommandPermissions = 10066,
UnknownStageInstance,
UnknownGuildMemberVerificationForm,
UnknownGuildWelcomeScreen,
BotsCannotUseThisEndpoint = 20001,
OnlyBotsCanUseThisEndpoint,
ExplicitContentCannotBeSentToTheDesiredRecipient = 20009,
NotAuthorizedToPerformThisActionOnThisApplication = 20012,
ActionCannotBePerformedDueToSlowmodeRateLimit = 20016,
OnlyTheOwnerOfThisAccountCanPerformThisAction = 20018,
AnnouncementEditLimitExceeded = 20022,
ChannelSendRateLimit = 20028,
StageTopicServerNameServerDescriptionOrChannelNamesContainDisallowedWords = 20031,
GuildPremiumSubscriptionLevelTooLow = 20035,
MaximumNumberOfGuildsReached = 30001,
MaximumNumberOfFriendsReached,
MaximumNumberOfPinsReachedForTheChannel,
MaximumNumberOfGuildRolesReached = 30005,
MaximumNumberOfRecipientsReached,
MaximumNumberOfGuildRolesReached,
MaximumNumberOfWebhooksReached = 30007,
MaximumNumberOfEmojisReached,
MaximumNumberOfReactionsReached = 30010,
@@ -57,16 +84,33 @@ export enum RESTJSONErrorCodes {
MaximumNumberOfAttachmentsInAMessageReached = 30015,
MaximumNumberOfInvitesReached,
MaximumNumberOfAnimatedEmojisReached = 30018,
MaximumNumberOfServerMembersReached,
MaximumNumberOfServerCategoriesReached = 30030,
GuildAlreadyHasTemplate = 30031,
MaximumThreadParticipants = 30033,
MaximumNumberOfNonGuildMemberBansHasBeenExceeded = 30035,
MaximumNumberOfBanFetchesHasBeenReached = 30037,
MaximumNumberOfStickersReached = 30039,
Unauthorized = 40001,
VerifyYourAccount,
OpeningDirectMessagesTooFast,
RequestEntityTooLarge = 40005,
FeatureTemporarilyDisabledServerSide,
UserBannedFromThisGuild,
ThisMessageWasAlreadyCrossposted = 40033,
TargetUserIsNotConnectedToVoice = 40032,
ThisMessageWasAlreadyCrossposted,
ApplicationCommandWithThatNameAlreadyExists = 40041,
MissingAccess = 50001,
InvalidAccountType,
@@ -77,9 +121,9 @@ export enum RESTJSONErrorCodes {
CannotSendMessagesToThisUser,
CannotSendMessagesInVoiceChannel,
ChannelVerificationLevelTooHighForYouToGainAccess,
Oauth2ApplicationDoesNotHaveBot,
Oauth2ApplicationLimitReached,
InvalidOauth2State,
OAuth2ApplicationDoesNotHaveBot,
OAuth2ApplicationLimitReached,
InvalidOAuth2State,
MissingPermissions,
InvalidToken,
NoteWasTooLong,
@@ -90,9 +134,10 @@ export enum RESTJSONErrorCodes {
CannotExecuteActionOnSystemMessage,
CannotExecuteActionOnThisChannelType = 50024,
InvalidOauth2AccessToken,
InvalidOAuth2AccessToken,
InvalidWebhookToken = 50027,
InvalidRole,
InvalidRecipients = 50033,
OneOfTheMessagesProvidedWasTooOldForBulkDelete,
@@ -101,13 +146,39 @@ export enum RESTJSONErrorCodes {
InvalidAPIVersion = 50041,
FileUploadedExceedsMaximumSize = 50045,
InvalidFileUploaded,
CannotSelfRedeemThisGift = 50070,
CannotDeleteChannelRequiredForCommunityGuilds = 50074,
InvalidStickerSent = 50081,
InvalidActionOnArchivedThread = 50083,
InvalidThreadNotificationSettings,
ParameterEarlierThanCreation,
TwoFactorAuthenticationIsRequired = 60003,
NoUsersWithDiscordTagExist = 80004,
ReactionWasBlocked = 90001,
APIResourceOverloaded = 130000,
TheStageIsAlreadyOpen = 150006,
ThreadAlreadyCreatedForMessage = 160004,
ThreadLocked,
MaximumActiveThreads,
MaximumActiveAnnouncementThreads,
InvalidJSONForUploadedLottieFile = 170001,
UploadedLottiesCannotContainRasterizedImages,
StickerMaximumFramerateExceeded,
StickerFrameCountExceedsMaximumOf1000Frames,
LottieAnimationMaximumDimensionsExceeded,
StickerFramerateIsTooSmallOrTooLarge,
StickerAnimationDurationExceedsMaximumOf5Seconds,
}

View File

@@ -1,4 +1,4 @@
// This file exports all the types available in the recommended API version
// Thereby, things MAY break in the future. Try sticking to imports from a specific version
export * from './v8/mod.ts';
export * from './v9/mod.ts';

View File

@@ -177,5 +177,5 @@ export interface RESTPostOAuth2AccessTokenWithBotAndWebhookIncomingScopeResult {
/**
* @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8.
*/
export type RESTPostOAuth2AccessTokenWithBotAndGuildsAndWebhookIncomingScopeResult = RESTPostOAuth2AccessTokenWithBotAndGuildsScopeResult &
RESTPostOAuth2AccessTokenWithBotAndWebhookIncomingScopeResult;
export type RESTPostOAuth2AccessTokenWithBotAndGuildsAndWebhookIncomingScopeResult =
RESTPostOAuth2AccessTokenWithBotAndGuildsScopeResult & RESTPostOAuth2AccessTokenWithBotAndWebhookIncomingScopeResult;

View File

@@ -1,6 +1,8 @@
import type { Permissions, Snowflake } from '../../globals.ts';
import type {
APIActionRowComponent,
APIAllowedMentions,
APIAttachment,
APIChannel,
APIEmbed,
APIExtendedInvite,
@@ -26,7 +28,7 @@ export type RESTGetAPIChannelResult = APIChannel;
*/
export interface RESTPatchAPIChannelJSONBody {
/**
* 2-100 character channel name
* 1-100 character channel name
*
* Channel types: all
*/
@@ -38,7 +40,7 @@ export interface RESTPatchAPIChannelJSONBody {
*
* Channel types: text, news
*/
type?: ChannelType.GUILD_NEWS | ChannelType.GUILD_TEXT;
type?: ChannelType.GuildNews | ChannelType.GuildText;
/**
* The position of the channel in the left-hand listing
*
@@ -176,6 +178,12 @@ export interface RESTPostAPIChannelMessageJSONBody {
* `true` if this is a TTS message
*/
tts?: boolean;
/**
* Embedded `rich` content (up to 6000 characters)
*
* See https://discord.com/developers/docs/resources/channel#embed-object
*/
embeds?: APIEmbed[];
/**
* Embedded `rich` content
*
@@ -194,6 +202,18 @@ export interface RESTPostAPIChannelMessageJSONBody {
* See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
*/
message_reference?: APIMessageReferenceSend;
/**
* The components to include with the message
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent[];
/**
* IDs of up to 3 stickers in the server to send in the message
*
* See https://discord.com/developers/docs/resources/sticker#sticker-object
*/
sticker_ids?: [Snowflake] | [Snowflake, Snowflake] | [Snowflake, Snowflake, Snowflake];
}
/**
@@ -281,8 +301,17 @@ export interface RESTPatchAPIChannelMessageJSONBody {
* The new message contents (up to 2000 characters)
*/
content?: string | null;
/**
* Embedded `rich` content (up to 6000 characters)
*
* See https://discord.com/developers/docs/resources/channel#embed-object
*/
embeds?: APIEmbed[] | null;
/**
* Embedded `rich` content
*
* See https://discord.com/developers/docs/resources/channel#embed-object
* @deprecated Use `embeds` instead
*/
embed?: APIEmbed | null;
/**
@@ -290,14 +319,50 @@ export interface RESTPatchAPIChannelMessageJSONBody {
*
* When specifying flags, ensure to include all previously set flags/bits
* in addition to ones that you are modifying
*
* See https://discord.com/developers/docs/resources/channel#message-object-message-flags
*/
flags?: MessageFlags | null;
/**
* Allowed mentions for the message
*
* See https://discord.com/developers/docs/resources/channel#allowed-mentions-object
*/
allowed_mentions?: APIAllowedMentions | null;
/**
* Attached files to keep
*
* See https://discord.com/developers/docs/resources/channel#attachment-object
*/
attachments?: APIAttachment[] | null;
/**
* The components to include with the message
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent[] | null;
}
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/
export type RESTPatchAPIChannelMessageFormDataBody =
| {
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPatchAPIChannelMessageJSONBody & {
/**
* The file contents
*/
file: unknown;
});
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/

View File

@@ -20,6 +20,7 @@ import type {
GuildVerificationLevel,
GuildWidgetStyle,
} from '../../payloads/v8/mod.ts';
import type { Nullable } from '../../utils/internals.ts';
import type { RESTPutAPIChannelPermissionJSONBody } from './channel.ts';
export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionJSONBody {
@@ -774,7 +775,3 @@ export interface RESTPatchAPIGuildWelcomeScreenJSONBody extends Nullable<Partial
*/
enabled?: boolean | null;
}
type Nullable<T> = {
[P in keyof T]: T[P] | null;
};

View File

@@ -3,7 +3,16 @@ import type {
APIApplicationCommandPermission,
APIGuildApplicationCommandPermissions,
APIInteractionResponse,
APIInteractionResponseCallbackData,
} from '../../payloads/v8/mod.ts';
import type {
RESTDeleteAPIWebhookWithTokenMessageResult,
RESTGetAPIWebhookWithTokenMessageResult,
RESTPatchAPIWebhookWithTokenMessageFormDataBody,
RESTPatchAPIWebhookWithTokenMessageJSONBody,
RESTPatchAPIWebhookWithTokenMessageResult,
RESTPostAPIWebhookWithTokenWaitResult,
} from './webhook.ts';
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-global-application-commands
@@ -111,6 +120,87 @@ export type RESTPostAPIInteractionCallbackFormDataBody =
file: unknown;
});
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-original-interaction-response
*/
export type RESTGetAPIInteractionOriginalResponseResult = RESTGetAPIWebhookWithTokenMessageResult;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response
*/
export type RESTPatchAPIInteractionOriginalResponseJSONBody = RESTPatchAPIWebhookWithTokenMessageJSONBody;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response
*/
export type RESTPatchAPIInteractionOriginalResponseFormDataBody = RESTPatchAPIWebhookWithTokenMessageFormDataBody;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response
*/
export type RESTPatchAPIInteractionOriginalResponseResult = RESTPatchAPIWebhookWithTokenMessageResult;
/**
* https://discord.com/developers/docs/interactions/slash-commands#delete-original-interaction-response
*/
export type RESTDeleteAPIInteractionOriginalResponseResult = RESTDeleteAPIWebhookWithTokenMessageResult;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-followup-message
*/
export type RESTPostAPIInteractionFollowupJSONBody = APIInteractionResponseCallbackData;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-followup-message
*/
export type RESTPostAPIInteractionFollowupFormDataBody =
| {
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPostAPIInteractionFollowupJSONBody & {
/**
* The file contents
*/
file: unknown;
});
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-followup-message
*/
export type RESTPostAPIInteractionFollowupResult = RESTPostAPIWebhookWithTokenWaitResult;
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-followup-message
*/
export type RESTGetAPIInteractionFollowupResult = RESTGetAPIWebhookWithTokenMessageResult;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message
*/
export type RESTPatchAPIInteractionFollowupJSONBody = RESTPatchAPIWebhookWithTokenMessageJSONBody;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message
*/
export type RESTPatchAPIInteractionFollowupFormDataBody = RESTPatchAPIWebhookWithTokenMessageFormDataBody;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message
*/
export type RESTPatchAPIInteractionFollowupResult = RESTPatchAPIWebhookWithTokenMessageResult;
/**
* https://discord.com/developers/docs/interactions/slash-commands#delete-followup-message
*/
export type RESTDeleteAPIInteractionFollowupResult = RESTDeleteAPIWebhookWithTokenMessageResult;
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command-permissions
*/

View File

@@ -8,6 +8,10 @@ export interface RESTGetAPIInviteQuery {
* Whether the invite should contain approximate member counts
*/
with_counts?: boolean;
/**
* Whether the invite should contain the expiration date
*/
with_expiration?: boolean;
}
export type RESTGetAPIInviteResult = APIInvite;

View File

@@ -10,6 +10,8 @@ export * from './guild.ts';
export * from './interactions.ts';
export * from './invite.ts';
export * from './oauth2.ts';
export * from './stageInstance.ts';
export * from './sticker.ts';
export * from './template.ts';
export * from './user.ts';
export * from './voice.ts';
@@ -22,8 +24,8 @@ export const Routes = {
* Route for:
* - GET `/guilds/{guild.id}/audit-logs`
*/
guildAuditLog(guildID: Snowflake) {
return `/guilds/${guildID}/audit-logs` as const;
guildAuditLog(guildId: Snowflake) {
return `/guilds/${guildId}/audit-logs` as const;
},
/**
@@ -32,8 +34,8 @@ export const Routes = {
* - PATCH `/channels/{channel.id}`
* - DELETE `/channels/{channel.id}`
*/
channel(channelID: Snowflake) {
return `/channels/${channelID}` as const;
channel(channelId: Snowflake) {
return `/channels/${channelId}` as const;
},
/**
@@ -41,8 +43,8 @@ export const Routes = {
* - GET `/channels/{channel.id}/messages`
* - POST `/channels/{channel.id}/messages`
*/
channelMessages(channelID: Snowflake) {
return `/channels/${channelID}/messages` as const;
channelMessages(channelId: Snowflake) {
return `/channels/${channelId}/messages` as const;
},
/**
@@ -51,16 +53,16 @@ export const Routes = {
* - PATCH `/channels/{channel.id}/messages/{message.id}`
* - DELETE `/channels/{channel.id}/messages/{message.id}`
*/
channelMessage(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}` as const;
channelMessage(channelId: Snowflake, messageId: Snowflake) {
return `/channels/${channelId}/messages/${messageId}` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/messages/{message.id}/crosspost`
*/
channelMessageCrosspost(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}/crosspost` as const;
channelMessageCrosspost(channelId: Snowflake, messageId: Snowflake) {
return `/channels/${channelId}/messages/${messageId}/crosspost` as const;
},
/**
@@ -70,8 +72,8 @@ export const Routes = {
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageOwnReaction(channelID: Snowflake, messageID: Snowflake, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me` as const;
channelMessageOwnReaction(channelId: Snowflake, messageId: Snowflake, emoji: string) {
return `/channels/${channelId}/messages/${messageId}/reactions/${emoji}/@me` as const;
},
/**
@@ -80,8 +82,8 @@ export const Routes = {
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageUserReaction(channelID: Snowflake, messageID: Snowflake, emoji: string, userID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}` as const;
channelMessageUserReaction(channelId: Snowflake, messageId: Snowflake, emoji: string, userId: Snowflake) {
return `/channels/${channelId}/messages/${messageId}/reactions/${emoji}/${userId}` as const;
},
/**
@@ -91,24 +93,24 @@ export const Routes = {
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageReaction(channelID: Snowflake, messageID: Snowflake, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}` as const;
channelMessageReaction(channelId: Snowflake, messageId: Snowflake, emoji: string) {
return `/channels/${channelId}/messages/${messageId}/reactions/${emoji}` as const;
},
/**
* Route for:
* - DELETE `/channels/{channel.id}/messages/{message.id}/reactions`
*/
channelMessageAllReactions(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}/reactions` as const;
channelMessageAllReactions(channelId: Snowflake, messageId: Snowflake) {
return `/channels/${channelId}/messages/${messageId}/reactions` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/messages/bulk-delete`
*/
channelBulkDelete(channelID: Snowflake) {
return `/channels/${channelID}/messages/bulk-delete` as const;
channelBulkDelete(channelId: Snowflake) {
return `/channels/${channelId}/messages/bulk-delete` as const;
},
/**
@@ -116,8 +118,8 @@ export const Routes = {
* - PUT `/channels/{channel.id}/permissions/{overwrite.id}`
* - DELETE `/channels/{channel.id}/permissions/{overwrite.id}`
*/
channelPermission(channelID: Snowflake, overwriteID: Snowflake) {
return `/channels/${channelID}/permissions/${overwriteID}` as const;
channelPermission(channelId: Snowflake, overwriteId: Snowflake) {
return `/channels/${channelId}/permissions/${overwriteId}` as const;
},
/**
@@ -125,32 +127,32 @@ export const Routes = {
* - GET `/channels/{channel.id}/invites`
* - POST `/channels/{channel.id}/invites`
*/
channelInvites(channelID: Snowflake) {
return `/channels/${channelID}/invites` as const;
channelInvites(channelId: Snowflake) {
return `/channels/${channelId}/invites` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/followers`
*/
channelFollowers(channelID: Snowflake) {
return `/channels/${channelID}/followers` as const;
channelFollowers(channelId: Snowflake) {
return `/channels/${channelId}/followers` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/typing`
*/
channelTyping(channelID: Snowflake) {
return `/channels/${channelID}/typing` as const;
channelTyping(channelId: Snowflake) {
return `/channels/${channelId}/typing` as const;
},
/**
* Route for:
* - GET `/channels/{channel.id}/pins`
*/
channelPins(channelID: Snowflake) {
return `/channels/${channelID}/pins` as const;
channelPins(channelId: Snowflake) {
return `/channels/${channelId}/pins` as const;
},
/**
@@ -158,8 +160,8 @@ export const Routes = {
* - PUT `/channels/{channel.id}/pins/{message.id}`
* - DELETE `/channels/{channel.id}/pins/{message.id}`
*/
channelPin(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/pins/${messageID}` as const;
channelPin(channelId: Snowflake, messageId: Snowflake) {
return `/channels/${channelId}/pins/${messageId}` as const;
},
/**
@@ -167,8 +169,8 @@ export const Routes = {
* - PUT `/channels/{channel.id}/recipients/{user.id}`
* - DELETE `/channels/{channel.id}/recipients/{user.id}`
*/
channelRecipient(channelID: Snowflake, userID: Snowflake) {
return `/channels/${channelID}/recipients/${userID}` as const;
channelRecipient(channelId: Snowflake, userId: Snowflake) {
return `/channels/${channelId}/recipients/${userId}` as const;
},
/**
@@ -176,8 +178,8 @@ export const Routes = {
* - GET `/guilds/{guild.id}/emojis`
* - POST `/guilds/{guild.id}/emojis`
*/
guildEmojis(guildID: Snowflake) {
return `/guilds/${guildID}/emojis` as const;
guildEmojis(guildId: Snowflake) {
return `/guilds/${guildId}/emojis` as const;
},
/**
@@ -186,8 +188,8 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/emojis/{emoji.id}`
* - DELETE `/guilds/{guild.id}/emojis/{emoji.id}`
*/
guildEmoji(guildID: Snowflake, emojiID: Snowflake) {
return `/guilds/${guildID}/emojis/${emojiID}` as const;
guildEmoji(guildId: Snowflake, emojiId: Snowflake) {
return `/guilds/${guildId}/emojis/${emojiId}` as const;
},
/**
@@ -204,16 +206,16 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}`
* - DELETE `/guilds/{guild.id}`
*/
guild(guildID: Snowflake) {
return `/guilds/${guildID}` as const;
guild(guildId: Snowflake) {
return `/guilds/${guildId}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/preview`
*/
guildPreview(guildID: Snowflake) {
return `/guilds/${guildID}/preview` as const;
guildPreview(guildId: Snowflake) {
return `/guilds/${guildId}/preview` as const;
},
/**
@@ -222,8 +224,8 @@ export const Routes = {
* - POST `/guilds/{guild.id}/channels`
* - PATCH `/guilds/{guild.id}/channels`
*/
guildChannels(guildID: Snowflake) {
return `/guilds/${guildID}/channels` as const;
guildChannels(guildId: Snowflake) {
return `/guilds/${guildId}/channels` as const;
},
/**
@@ -233,32 +235,32 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/members/{user.id}`
* - DELETE `/guilds/{guild.id}/members/{user.id}`
*/
guildMember(guildID: Snowflake, userID: Snowflake) {
return `/guilds/${guildID}/members/${userID}` as const;
guildMember(guildId: Snowflake, userId: Snowflake) {
return `/guilds/${guildId}/members/${userId}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/members`
*/
guildMembers(guildID: Snowflake) {
return `/guilds/${guildID}/members` as const;
guildMembers(guildId: Snowflake) {
return `/guilds/${guildId}/members` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/members/search`
*/
guildMembersSearch(guildID: Snowflake) {
return `/guilds/${guildID}/members/search` as const;
guildMembersSearch(guildId: Snowflake) {
return `/guilds/${guildId}/members/search` as const;
},
/**
* Route for:
* - PATCH `/guilds/{guild.id}/members/@me/nick`
*/
guildCurrentMemberNickname(guildID: Snowflake) {
return `/guilds/${guildID}/members/@me/nick` as const;
guildCurrentMemberNickname(guildId: Snowflake) {
return `/guilds/${guildId}/members/@me/nick` as const;
},
/**
@@ -266,16 +268,16 @@ export const Routes = {
* - PUT `/guilds/{guild.id}/members/{user.id}/roles/{role.id}`
* - DELETE `/guilds/{guild.id}/members/{user.id}/roles/{role.id}`
*/
guildMemberRole(guildID: Snowflake, memberID: Snowflake, roleID: Snowflake) {
return `/guilds/${guildID}/members/${memberID}/roles/${roleID}` as const;
guildMemberRole(guildId: Snowflake, memberId: Snowflake, roleId: Snowflake) {
return `/guilds/${guildId}/members/${memberId}/roles/${roleId}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/bans`
*/
guildBans(guildID: Snowflake) {
return `/guilds/${guildID}/bans` as const;
guildBans(guildId: Snowflake) {
return `/guilds/${guildId}/bans` as const;
},
/**
@@ -284,8 +286,8 @@ export const Routes = {
* - PUT `/guilds/{guild.id}/bans/{user.id}`
* - DELETE `/guilds/{guild.id}/bans/{user.id}`
*/
guildBan(guildID: Snowflake, userID: Snowflake) {
return `/guilds/${guildID}/bans/${userID}` as const;
guildBan(guildId: Snowflake, userId: Snowflake) {
return `/guilds/${guildId}/bans/${userId}` as const;
},
/**
@@ -294,8 +296,8 @@ export const Routes = {
* - POST `/guilds/{guild.id}/roles`
* - PATCH `/guilds/{guild.id}/roles`
*/
guildRoles(guildID: Snowflake) {
return `/guilds/${guildID}/roles` as const;
guildRoles(guildId: Snowflake) {
return `/guilds/${guildId}/roles` as const;
},
/**
@@ -303,8 +305,8 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/roles/{role.id}`
* - DELETE `/guilds/{guild.id}/roles/{role.id}`
*/
guildRole(guildID: Snowflake, roleID: Snowflake) {
return `/guilds/${guildID}/roles/${roleID}` as const;
guildRole(guildId: Snowflake, roleId: Snowflake) {
return `/guilds/${guildId}/roles/${roleId}` as const;
},
/**
@@ -312,40 +314,40 @@ export const Routes = {
* - GET `/guilds/{guild.id}/prune`
* - POST `/guilds/{guild.id}/prune`
*/
guildPrune(guildID: Snowflake) {
return `/guilds/${guildID}/prune` as const;
guildPrune(guildId: Snowflake) {
return `/guilds/${guildId}/prune` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/regions`
*/
guildVoiceRegions(guildID: Snowflake) {
return `/guilds/${guildID}/regions` as const;
guildVoiceRegions(guildId: Snowflake) {
return `/guilds/${guildId}/regions` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/invites`
*/
guildInvites(guildID: Snowflake) {
return `/guilds/${guildID}/invites` as const;
guildInvites(guildId: Snowflake) {
return `/guilds/${guildId}/invites` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/integrations`
*/
guildIntegrations(guildID: Snowflake) {
return `/guilds/${guildID}/integrations` as const;
guildIntegrations(guildId: Snowflake) {
return `/guilds/${guildId}/integrations` as const;
},
/**
* Route for:
* - DELETE `/guilds/{guild.id}/integrations/{integration.id}`
*/
guildIntegration(guildID: Snowflake, integrationID: Snowflake) {
return `/guilds/${guildID}/integrations/${integrationID}` as const;
guildIntegration(guildId: Snowflake, integrationId: Snowflake) {
return `/guilds/${guildId}/integrations/${integrationId}` as const;
},
/**
@@ -353,32 +355,32 @@ export const Routes = {
* - GET `/guilds/{guild.id}/widget`
* - PATCH `/guilds/{guild.id}/widget`
*/
guildWidgetSettings(guildID: Snowflake) {
return `/guilds/${guildID}/widget` as const;
guildWidgetSettings(guildId: Snowflake) {
return `/guilds/${guildId}/widget` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/widget.json`
*/
guildWidgetJSON(guildID: Snowflake) {
return `/guilds/${guildID}/widget.json` as const;
guildWidgetJSON(guildId: Snowflake) {
return `/guilds/${guildId}/widget.json` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/vanity-url`
*/
guildVanityUrl(guildID: Snowflake) {
return `/guilds/${guildID}/vanity-url` as const;
guildVanityUrl(guildId: Snowflake) {
return `/guilds/${guildId}/vanity-url` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/widget.png`
*/
guildWidgetImage(guildID: Snowflake) {
return `/guilds/${guildID}/widget.png` as const;
guildWidgetImage(guildId: Snowflake) {
return `/guilds/${guildId}/widget.png` as const;
},
/**
@@ -404,8 +406,8 @@ export const Routes = {
* - GET `/guilds/{guild.id}/templates`
* - POST `/guilds/{guild.id}/templates`
*/
guildTemplates(guildID: Snowflake) {
return `/guilds/${guildID}/templates` as const;
guildTemplates(guildId: Snowflake) {
return `/guilds/${guildId}/templates` as const;
},
/**
@@ -414,8 +416,8 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/templates/{template.code}`
* - DELETE `/guilds/{guild.id}/templates/{template.code}`
*/
guildTemplate(guildID: Snowflake, code: string) {
return `/guilds/${guildID}/templates/${code}` as const;
guildTemplate(guildId: Snowflake, code: string) {
return `/guilds/${guildId}/templates/${code}` as const;
},
/**
@@ -424,10 +426,10 @@ export const Routes = {
* - GET `/users/{user.id}`
* - PATCH `/users/@me`
*
* @param [userID='@me'] The user ID, defaulted to `@me`
* @param [userId='@me'] The user ID, defaulted to `@me`
*/
user(userID: Snowflake | '@me' = '@me') {
return `/users/${userID}` as const;
user(userId: Snowflake | '@me' = '@me') {
return `/users/${userId}` as const;
},
/**
@@ -442,8 +444,8 @@ export const Routes = {
* Route for:
* - DELETE `/users/@me/guilds/{guild.id}`
*/
userGuild(guildID: Snowflake) {
return `/users/@me/guilds/${guildID}` as const;
userGuild(guildId: Snowflake) {
return `/users/@me/guilds/${guildId}` as const;
},
/**
@@ -475,16 +477,16 @@ export const Routes = {
* - GET `/channels/{channel.id}/webhooks`
* - POST `/channels/{channel.id}/webhooks`
*/
channelWebhooks(channelID: Snowflake) {
return `/channels/${channelID}/webhooks` as const;
channelWebhooks(channelId: Snowflake) {
return `/channels/${channelId}/webhooks` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/webhooks`
*/
guildWebhooks(guildID: Snowflake) {
return `/guilds/${guildID}/webhooks` as const;
guildWebhooks(guildId: Snowflake) {
return `/guilds/${guildId}/webhooks` as const;
},
/**
@@ -499,8 +501,8 @@ export const Routes = {
*
* - POST `/webhooks/{application.id}/{interaction.token}`
*/
webhook(webhookID: Snowflake, webhookToken?: string) {
const parts = ['', 'webhooks', webhookID];
webhook(webhookId: Snowflake, webhookToken?: string) {
const parts = ['', 'webhooks', webhookId];
if (webhookToken) parts.push(webhookToken);
@@ -520,10 +522,10 @@ export const Routes = {
* - PATCH `/webhooks/{application.id}/{interaction.token}/messages/{message.id}`
* - DELETE `/webhooks/{application.id}/{interaction.token}/messages/{message.id}`
*
* @param [messageID='@original'] The message ID to change, defaulted to `@original`
* @param [messageId='@original'] The message ID to change, defaulted to `@original`
*/
webhookMessage(webhookID: Snowflake, webhookToken: string, messageID: Snowflake | '@original' = '@original') {
return `/webhooks/${webhookID}/${webhookToken}/messages/${messageID}` as const;
webhookMessage(webhookId: Snowflake, webhookToken: string, messageId: Snowflake | '@original' = '@original') {
return `/webhooks/${webhookId}/${webhookToken}/messages/${messageId}` as const;
},
/**
@@ -531,8 +533,8 @@ export const Routes = {
* - POST `/webhooks/{webhook.id}/{webhook.token}/github`
* - POST `/webhooks/{webhook.id}/{webhook.token}/slack`
*/
webhookPlatform(webhookID: Snowflake, webhookToken: string, platform: 'github' | 'slack') {
return `/webhooks/${webhookID}/${webhookToken}/${platform}` as const;
webhookPlatform(webhookId: Snowflake, webhookToken: string, platform: 'github' | 'slack') {
return `/webhooks/${webhookId}/${webhookToken}/${platform}` as const;
},
/**
@@ -573,8 +575,8 @@ export const Routes = {
* - PUT `/applications/{application.id}/commands`
* - POST `/applications/{application.id}/commands`
*/
applicationCommands(applicationID: Snowflake) {
return `/applications/${applicationID}/commands` as const;
applicationCommands(applicationId: Snowflake) {
return `/applications/${applicationId}/commands` as const;
},
/**
@@ -583,8 +585,8 @@ export const Routes = {
* - PATCH `/applications/{application.id}/commands/{command.id}`
* - DELETE `/applications/{application.id}/commands/{command.id}`
*/
applicationCommand(applicationID: Snowflake, commandID: Snowflake) {
return `/applications/${applicationID}/commands/${commandID}` as const;
applicationCommand(applicationId: Snowflake, commandId: Snowflake) {
return `/applications/${applicationId}/commands/${commandId}` as const;
},
/**
@@ -593,8 +595,8 @@ export const Routes = {
* - PUT `/applications/{application.id}/guilds/{guild.id}/commands`
* - POST `/applications/{application.id}/guilds/{guild.id}/commands`
*/
applicationGuildCommands(applicationID: Snowflake, guildID: Snowflake) {
return `/applications/${applicationID}/guilds/${guildID}/commands` as const;
applicationGuildCommands(applicationId: Snowflake, guildId: Snowflake) {
return `/applications/${applicationId}/guilds/${guildId}/commands` as const;
},
/**
@@ -603,16 +605,16 @@ export const Routes = {
* - PATCH `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
* - DELETE `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
*/
applicationGuildCommand(applicationID: Snowflake, guildID: Snowflake, commandID: Snowflake) {
return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}` as const;
applicationGuildCommand(applicationId: Snowflake, guildId: Snowflake, commandId: Snowflake) {
return `/applications/${applicationId}/guilds/${guildId}/commands/${commandId}` as const;
},
/**
* Route for:
* - POST `/interactions/{interaction.id}/{interaction.token}/callback`
*/
interactionCallback(interactionID: Snowflake, interactionToken: string) {
return `/interactions/${interactionID}/${interactionToken}/callback` as const;
interactionCallback(interactionId: Snowflake, interactionToken: string) {
return `/interactions/${interactionId}/${interactionToken}/callback` as const;
},
/**
@@ -620,8 +622,8 @@ export const Routes = {
* - GET `/guilds/{guild.id}/member-verification`
* - PATCH `/guilds/{guild.id}/member-verification`
*/
guildMemberVerification(guildID: Snowflake) {
return `/guilds/${guildID}/member-verification` as const;
guildMemberVerification(guildId: Snowflake) {
return `/guilds/${guildId}/member-verification` as const;
},
/**
@@ -629,8 +631,8 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/voice-states/@me`
* - PATCH `/guilds/{guild.id}/voice-states/{user.id}`
*/
guildVoiceState(guildID: Snowflake, userID: Snowflake | '@me' = '@me') {
return `/guilds/${guildID}/voice-states/${userID}` as const;
guildVoiceState(guildId: Snowflake, userId: Snowflake | '@me' = '@me') {
return `/guilds/${guildId}/voice-states/${userId}` as const;
},
/**
@@ -638,8 +640,8 @@ export const Routes = {
* - GET `/applications/{application.id}/guilds/{guild.id}/commands/permissions`
* - PUT `/applications/{application.id}/guilds/{guild.id}/commands/permissions`
*/
guildApplicationCommandsPermissions(applicationID: Snowflake, guildID: Snowflake) {
return `/applications/${applicationID}/guilds/${guildID}/commands/permissions` as const;
guildApplicationCommandsPermissions(applicationId: Snowflake, guildId: Snowflake) {
return `/applications/${applicationId}/guilds/${guildId}/commands/permissions` as const;
},
/**
@@ -647,8 +649,8 @@ export const Routes = {
* - GET `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}/permissions`
* - PUT `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}/permissions`
*/
applicationCommandPermissions(applicationID: Snowflake, guildID: Snowflake, commandID: Snowflake) {
return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}/permissions` as const;
applicationCommandPermissions(applicationId: Snowflake, guildId: Snowflake, commandId: Snowflake) {
return `/applications/${applicationId}/guilds/${guildId}/commands/${commandId}/permissions` as const;
},
/**
@@ -656,13 +658,66 @@ export const Routes = {
* - GET `/guilds/{guild.id}/welcome-screen`
* - PATCH `/guilds/{guild.id}/welcome-screen`
*/
guildWelcomeScreen(guildID: Snowflake) {
return `/guilds/${guildID}/welcome-screen` as const;
guildWelcomeScreen(guildId: Snowflake) {
return `/guilds/${guildId}/welcome-screen` as const;
},
/**
* Route for:
* - POST `/stage-instances`
*/
stageInstances() {
return `/stage-instances` as const;
},
/**
* Route for:
* - GET `/stage-instances/{channel.id}`
* - PATCH `/stage-instances/{channel.id}`
* - DELETE `/stage-instances/{channel.id}`
*/
stageInstance(channelId: Snowflake) {
return `/stage-instances/${channelId}` as const;
},
/**
* Route for:
* - GET `/stickers/{sticker.id}`
*/
sticker(stickerId: Snowflake) {
return `/stickers/${stickerId}` as const;
},
/**
* Route for:
* - GET `/sticker-packs`
*/
nitroStickerPacks() {
return '/sticker-packs' as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/stickers`
* - POST `/guilds/{guild.id}/stickers`
*/
guildStickers(guildId: Snowflake) {
return `/guilds/${guildId}/stickers` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/stickers/{sticker.id}`
* - PATCH `/guilds/{guild.id}/stickers/{sticker.id}`
* - DELETE `/guilds/{guild.id}/stickers/{sticker.id}`
*/
guildSticker(guildId: Snowflake, stickerId: Snowflake) {
return `/guilds/${guildId}/stickers/${stickerId}` as const;
},
};
export const RouteBases = {
api: 'https://discord.com/api',
api: `https://discord.com/api/v${APIVersion}`,
cdn: 'https://cdn.discordapp.com',
invite: 'https://discord.gg',
template: 'https://discord.new',
@@ -683,3 +738,27 @@ export const OAuth2Routes = {
// Freeze OAuth2 route object
Object.freeze(OAuth2Routes);
export interface DiscordErrorFieldInformation {
code: string;
message: string;
}
export interface DiscordErrorGroupWrapper {
_errors: DiscordError[];
}
export type DiscordErrorData =
| DiscordErrorGroupWrapper
| DiscordErrorFieldInformation
| { [k: string]: DiscordErrorData }
| string;
/**
* https://discord.com/developers/docs/reference#error-messages
*/
export interface DiscordError {
code: number;
message: string;
errors?: DiscordErrorData;
}

View File

@@ -4,12 +4,12 @@ import type { APIApplication, APIGuild, APIUser, APIWebhook, OAuth2Scopes } from
/**
* https://discord.com/developers/docs/topics/oauth2#get-current-application-information
*/
export type RESTGetAPIOauth2CurrentApplicationResult = Omit<APIApplication, 'flags'>;
export type RESTGetAPIOAuth2CurrentApplicationResult = Omit<APIApplication, 'flags'>;
/**
* https://discord.com/developers/docs/topics/oauth2#get-current-authorization-information
*/
export interface RESTGetAPIOauth2CurrentAuthorizationResult {
export interface RESTGetAPIOAuth2CurrentAuthorizationResult {
/**
* the current application
*/
@@ -195,5 +195,5 @@ export interface RESTPostOAuth2AccessTokenWithBotAndWebhookIncomingScopeResult {
webhook: APIWebhook;
}
export type RESTPostOAuth2AccessTokenWithBotAndGuildsAndWebhookIncomingScopeResult = RESTPostOAuth2AccessTokenWithBotAndGuildsScopeResult &
RESTPostOAuth2AccessTokenWithBotAndWebhookIncomingScopeResult;
export type RESTPostOAuth2AccessTokenWithBotAndGuildsAndWebhookIncomingScopeResult =
RESTPostOAuth2AccessTokenWithBotAndGuildsScopeResult & RESTPostOAuth2AccessTokenWithBotAndWebhookIncomingScopeResult;

View File

@@ -0,0 +1,56 @@
import type { Snowflake } from '../../globals.ts';
import type { APIStageInstance, StageInstancePrivacyLevel } from '../../payloads/v8/mod.ts';
/**
* https://discord.com/developers/docs/resources/stage-instance#create-stage-instance
*/
export interface RESTPostAPIStageInstanceJSONBody {
/**
* The id of the stage channel
*/
channel_id: Snowflake;
/**
* The topic of the stage instance (1-120 characters)
*/
topic: string;
/**
* The privacy level of the stage instance
*
* @default GuildOnly
*/
privacy_level?: StageInstancePrivacyLevel;
}
/**
* https://discord.com/developers/docs/resources/stage-instance#create-stage-instance
*/
export type RESTPostAPIStageInstanceResult = APIStageInstance;
/**
* https://discord.com/developers/docs/resources/stage-instance#get-stage-instance
*/
export type RESTGetAPIStageInstanceResult = APIStageInstance;
/**
* https://discord.com/developers/docs/resources/stage-instance#update-stage-instance
*/
export interface RESTPatchAPIStageInstanceJSONBody {
/**
* The topic of the stage instance (1-120 characters)
*/
topic?: string;
/**
* The privacy level of the stage instance
*/
privacy_level?: StageInstancePrivacyLevel;
}
/**
* https://discord.com/developers/docs/resources/stage-instance#update-stage-instance
*/
export type RESTPatchAPIStageInstanceResult = APIStageInstance;
/**
* https://discord.com/developers/docs/resources/stage-instance#delete-stage-instance
*/
export type RESTDeleteAPIStageInstanceResult = never;

51
deno/rest/v8/sticker.ts Normal file
View File

@@ -0,0 +1,51 @@
import type { APISticker, APIStickerPack } from '../../payloads/v8/mod.ts';
export type RESTGetAPIStickerResult = APISticker;
export interface RESTGetNitroStickerPacksResult {
sticker_packs: APIStickerPack[];
}
export type RESTGetAPIGuildStickersResult = APISticker[];
export type RESTGetAPIGuildStickerResult = APISticker;
export interface RESTPostAPIGuildStickerFormDataBody {
/**
* Name of the sticker (2-30 characters)
*/
name: string;
/**
* Description of the sticker (empty or 2-100 characters)
*/
description: string;
/**
* The Discord name of a unicode emoji representing the sticker's expression (2-200 characters)
*/
tags: string;
/**
* The sticker file to upload, must be a PNG, APNG, or Lottie JSON file, max 500 KB
*/
file: unknown;
}
export type RESTPostAPIGuildStickerResult = APISticker;
export interface RESTPatchAPIGuildStickerJSONBody {
/**
* Name of the sticker (2-30 characters)
*/
name?: string;
/**
* Description of the sticker (2-100 characters)
*/
description?: string | null;
/**
* The Discord name of a unicode emoji representing the sticker's expression (2-200 characters)
*/
tags?: string;
}
export type RESTPatchAPIGuildStickerResult = APISticker;
export type RESTDeleteAPIGuildStickerResult = never;

View File

@@ -1,5 +1,13 @@
import type { Snowflake } from '../../globals.ts';
import type { APIAllowedMentions, APIEmbed, APIMessage, APIWebhook } from '../../payloads/v8/mod.ts';
import type {
APIAllowedMentions,
APIActionRowComponent,
APIEmbed,
APIMessage,
APIWebhook,
APIAttachment,
} from '../../payloads/v8/mod.ts';
import type { Nullable } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook
@@ -109,12 +117,24 @@ export interface RESTPostAPIWebhookWithTokenJSONBody {
tts?: boolean;
/**
* Embedded `rich` content
*
* See https://discord.com/developers/docs/resources/channel#embed-object
*/
embeds?: APIEmbed[];
/**
* Allowed mentions for the message
*
* See https://discord.com/developers/docs/resources/channel#allowed-mentions-object
*/
allowed_mentions?: APIAllowedMentions;
/**
* The components to include with the message
*
* Requires an application-owned webhook
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent[];
}
/**
@@ -200,12 +220,25 @@ export type RESTPostAPIWebhookWithTokenGitHubResult = never;
*/
export type RESTPostAPIWebhookWithTokenGitHubWaitResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/webhook#get-webhook-message
*/
export type RESTGetAPIWebhookWithTokenMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
*/
export type RESTPatchAPIWebhookWithTokenMessageJSONBody = Nullable<
Pick<RESTPostAPIWebhookWithTokenJSONBody, 'content' | 'embeds' | 'allowed_mentions'>
>;
export interface RESTPatchAPIWebhookWithTokenMessageJSONBody
extends Nullable<
Pick<RESTPostAPIWebhookWithTokenJSONBody, 'content' | 'embeds' | 'allowed_mentions' | 'components'>
> {
/**
* Attached files to keep
*
* See https://discord.com/developers/docs/resources/channel#attachment-object
*/
attachments?: APIAttachment[] | null;
}
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
@@ -228,11 +261,6 @@ export type RESTPatchAPIWebhookWithTokenMessageFormDataBody =
file: unknown;
});
/**
* https://discord.com/developers/docs/resources/webhook#get-webhook-message
*/
export type RESTGetAPIWebhookWithTokenMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
*/
@@ -242,7 +270,3 @@ export type RESTPatchAPIWebhookWithTokenMessageResult = APIMessage;
* https://discord.com/developers/docs/resources/webhook#delete-webhook-message
*/
export type RESTDeleteAPIWebhookWithTokenMessageResult = never;
type Nullable<T> = {
[P in keyof T]: T[P] | null;
};

28
deno/rest/v9/auditLog.ts Normal file
View File

@@ -0,0 +1,28 @@
import type { Snowflake } from '../../globals.ts';
import type { APIAuditLog, AuditLogEvent } from '../../payloads/v9/auditLog.ts';
/**
* https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log
*/
export interface RESTGetAPIAuditLogQuery {
/**
* Filter the log for actions made by a user
*/
user_id?: Snowflake;
/**
* The type of audit log events
*/
action_type?: AuditLogEvent;
/**
* Filter the log before a certain entry ID
*/
before?: Snowflake;
/**
* How many entries are returned (default 50, minimum 1, maximum 100)
*
* @default 50
*/
limit?: number;
}
export type RESTGetAPIAuditLogResult = APIAuditLog;

652
deno/rest/v9/channel.ts Normal file
View File

@@ -0,0 +1,652 @@
import type { Permissions, Snowflake } from '../../globals.ts';
import type {
APIActionRowComponent,
APIAllowedMentions,
APIAttachment,
APIChannel,
APIEmbed,
APIExtendedInvite,
APIFollowedChannel,
APIMessage,
APIMessageReference,
APIOverwrite,
APIThreadList,
APIThreadMember,
APIUser,
ChannelType,
InviteTargetType,
MessageFlags,
OverwriteType,
ThreadAutoArchiveDuration,
VideoQualityMode,
} from '../../payloads/v9/mod.ts';
/**
* https://discord.com/developers/docs/resources/channel#get-channel
*/
export type RESTGetAPIChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#modify-channel
*/
export interface RESTPatchAPIChannelJSONBody {
/**
* 1-100 character channel name
*
* Channel types: all
*/
name?: string;
/**
* The type of channel; only conversion between `text` and `news`
* is supported and only in guilds with the "NEWS" feature
*
* Channel types: text, news
*/
type?: ChannelType.GuildNews | ChannelType.GuildText;
/**
* The position of the channel in the left-hand listing
*
* Channel types: all excluding newsThread, publicThread, privateThread
*/
position?: number | null;
/**
* 0-1024 character channel topic
*
* Channel types: text, news
*/
topic?: string | null;
/**
* Whether the channel is nsfw
*
* Channel types: text, news, store
*/
nsfw?: boolean | null;
/**
* Amount of seconds a user has to wait before sending another message (0-21600);
* bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`,
* are unaffected
*
* Channel types: text, newsThread, publicThread, privateThread
*/
rate_limit_per_user?: number | null;
/**
* The bitrate (in bits) of the voice channel; 8000 to 96000 (128000 for VIP servers)
*
* Channel types: voice
*/
bitrate?: number | null;
/**
* The user limit of the voice channel; 0 refers to no limit, 1 to 99 refers to a user limit
*
* Channel types: voice
*/
user_limit?: number | null;
/**
* Channel or category-specific permissions
*
* Channel types: all excluding newsThread, publicThread, privateThread
*/
permission_overwrites?: APIOverwrite[] | null;
/**
* ID of the new parent category for a channel
*
* Channel types: text, news, store, voice
*/
parent_id?: Snowflake | null;
/**
* Voice region id for the voice or stage channel, automatic when set to `null`
*
* See https://discord.com/developers/docs/resources/voice#voice-region-object
*/
rtc_region?: string | null;
/**
* The camera video quality mode of the voice channel
*
* See https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes
*/
video_quality_mode?: VideoQualityMode | null;
/**
* Whether the thread should be archived
*
* Channel types: newsThread, publicThread, privateThread
*/
archived?: boolean;
/**
* The amount of time in minutes to wait before automatically archiving the thread
*
* Channel types: newsThread, publicThread, privateThread
*/
auto_archive_duration?: ThreadAutoArchiveDuration;
/**
* Whether the thread should be locked
*
* Channel types: newsThread, publicThread, privateThread
*/
locked?: boolean;
/**
* Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity
*
* Channel types: text, news
*/
default_auto_archive_duration?: ThreadAutoArchiveDuration;
}
/**
* https://discord.com/developers/docs/resources/channel#modify-channel
*/
export type RESTPatchAPIChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#deleteclose-channel
*/
export type RESTDeleteAPIChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#get-channel-messages
*/
export interface RESTGetAPIChannelMessagesQuery {
/**
* Get messages around this message ID
*/
around?: Snowflake;
/**
* Get messages before this message ID
*/
before?: Snowflake;
/**
* Get messages after this message ID
*/
after?: Snowflake;
/**
* Max number of messages to return (1-100)
*
* @default 50
*/
limit?: number;
}
/**
* https://discord.com/developers/docs/resources/channel#get-channel-messages
*/
export type RESTGetAPIChannelMessagesResult = APIMessage[];
/**
* https://discord.com/developers/docs/resources/channel#get-channel-message
*/
export type RESTGetAPIChannelMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
*/
export type APIMessageReferenceSend = Partial<APIMessageReference> &
Required<Pick<APIMessageReference, 'message_id'>> & {
/**
* Whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message
*
* @default true
*/
fail_if_not_exists?: boolean;
};
/**
* https://discord.com/developers/docs/resources/channel#create-message
*/
export interface RESTPostAPIChannelMessageJSONBody {
/**
* The message contents (up to 2000 characters)
*/
content?: string;
/**
* A nonce that can be used for optimistic message sending
*/
nonce?: number | string;
/**
* `true` if this is a TTS message
*/
tts?: boolean;
/**
* Embedded `rich` content (up to 6000 characters)
*
* See https://discord.com/developers/docs/resources/channel#embed-object
*/
embeds?: APIEmbed[];
/**
* Embedded `rich` content
*
* See https://discord.com/developers/docs/resources/channel#embed-object
* @deprecated Use `embeds` instead
*/
embed?: APIEmbed;
/**
* Allowed mentions for a message
*
* See https://discord.com/developers/docs/resources/channel#allowed-mentions-object
*/
allowed_mentions?: APIAllowedMentions;
/**
* Include to make your message a reply
*
* See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
*/
message_reference?: APIMessageReferenceSend;
/**
* The components to include with the message
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent[];
/**
* IDs of up to 3 stickers in the server to send in the message
*
* See https://discord.com/developers/docs/resources/sticker#sticker-object
*/
sticker_ids?: [Snowflake] | [Snowflake, Snowflake] | [Snowflake, Snowflake, Snowflake];
}
/**
* https://discord.com/developers/docs/resources/channel#create-message
*/
export type RESTPostAPIChannelMessageFormDataBody =
| {
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPostAPIChannelMessageJSONBody & {
/**
* The file contents
*/
file: unknown;
});
/**
* https://discord.com/developers/docs/resources/channel#create-message
*/
export type RESTPostAPIChannelMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/channel#crosspost-message
*/
export type RESTPostAPIChannelMessageCrosspostResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/channel#create-reaction
*/
export type RESTPutAPIChannelMessageReactionResult = never;
/**
* https://discord.com/developers/docs/resources/channel#delete-own-reaction
*/
export type RESTDeleteAPIChannelMessageOwnReaction = never;
/**
* https://discord.com/developers/docs/resources/channel#delete-user-reaction
*/
export type RESTDeleteAPIChannelMessageUserReactionResult = never;
/*
* https://discord.com/developers/docs/resources/channel#get-reactions
*/
export interface RESTGetAPIChannelMessageReactionUsersQuery {
/**
* Get users after this user ID
*/
after?: Snowflake;
/**
* Max number of users to return (1-100)
*
* @default 25
*/
limit?: number;
}
/**
* https://discord.com/developers/docs/resources/channel#get-reactions
*/
export type RESTGetAPIChannelMessageReactionUsersResult = APIUser[];
/**
* https://discord.com/developers/docs/resources/channel#delete-all-reactions
*/
export type RESTDeleteAPIChannelAllMessageReactionsResult = never;
/**
* https://discord.com/developers/docs/resources/channel#delete-all-reactions-for-emoji
*/
export type RESTDeleteAPIChannelMessageReactionResult = never;
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/
export interface RESTPatchAPIChannelMessageJSONBody {
/**
* The new message contents (up to 2000 characters)
*/
content?: string | null;
/**
* Embedded `rich` content (up to 6000 characters)
*
* See https://discord.com/developers/docs/resources/channel#embed-object
*/
embeds?: APIEmbed[] | null;
/**
* Embedded `rich` content
*
* See https://discord.com/developers/docs/resources/channel#embed-object
* @deprecated Use `embeds` instead
*/
embed?: APIEmbed | null;
/**
* Edit the flags of a message (only `SUPPRESS_EMBEDS` can currently be set/unset)
*
* When specifying flags, ensure to include all previously set flags/bits
* in addition to ones that you are modifying
*
* See https://discord.com/developers/docs/resources/channel#message-object-message-flags
*/
flags?: MessageFlags | null;
/**
* Allowed mentions for the message
*
* See https://discord.com/developers/docs/resources/channel#allowed-mentions-object
*/
allowed_mentions?: APIAllowedMentions | null;
/**
* Attached files to keep
*
* See https://discord.com/developers/docs/resources/channel#attachment-object
*/
attachments?: APIAttachment[] | null;
/**
* The components to include with the message
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent[] | null;
}
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/
export type RESTPatchAPIChannelMessageFormDataBody =
| {
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPatchAPIChannelMessageJSONBody & {
/**
* The file contents
*/
file: unknown;
});
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/
export type RESTPatchAPIChannelMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/channel#delete-message
*/
export type RESTDeleteAPIChannelMessageResult = never;
/**
* https://discord.com/developers/docs/resources/channel#bulk-delete-messages
*/
export interface RESTPostAPIChannelMessagesBulkDeleteJSONBody {
/**
* An array of message ids to delete (2-100)
*/
messages: Snowflake[];
}
/**
* https://discord.com/developers/docs/resources/channel#bulk-delete-messages
*/
export type RESTPostAPIChannelMessagesBulkDeleteResult = never;
/**
* https://discord.com/developers/docs/resources/channel#edit-channel-permissions
*/
export interface RESTPutAPIChannelPermissionJSONBody {
/**
* The bitwise value of all allowed permissions
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
allow: Permissions;
/**
* The bitwise value of all disallowed permissions
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
deny: Permissions;
/**
* `0` for a role or `1` for a member
*/
type: OverwriteType;
}
/**
* https://discord.com/developers/docs/resources/channel#edit-channel-permissions
*/
export type RESTPutAPIChannelPermissionResult = never;
/**
* https://discord.com/developers/docs/resources/channel#get-channel-invites
*/
export type RESTGetAPIChannelInvitesResult = APIExtendedInvite[];
/**
* https://discord.com/developers/docs/resources/channel#create-channel-invite
*/
export interface RESTPostAPIChannelInviteJSONBody {
/**
* Duration of invite in seconds before expiry, or 0 for never
*
* @default 86400 (24 hours)
*/
max_age?: number;
/**
* Max number of uses or 0 for unlimited
*
* @default 0
*/
max_uses?: number;
/**
* Whether this invite only grants temporary membership
*
* @default false
*/
temporary?: boolean;
/**
* If true, don't try to reuse a similar invite
* (useful for creating many unique one time use invites)
*
* @default false
*/
unique?: boolean;
/**
* The type of target for this voice channel invite
*
* See https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types
*/
target_type?: InviteTargetType;
/**
* The id of the user whose stream to display for this invite
* - Required if `target_type` is 1
* - The user must be streaming in the channel
*/
target_user_id?: Snowflake;
/**
* The id of the embedded application to open for this invite
* - Required if `target_type` is 2
* - The application must have the `EMBEDDED` flag
*/
target_application_id?: Snowflake;
}
/**
* https://discord.com/developers/docs/resources/channel#create-channel-invite
*/
export type RESTPostAPIChannelInviteResult = APIExtendedInvite;
/**
* https://discord.com/developers/docs/resources/channel#delete-channel-permission
*/
export type RESTDeleteAPIChannelPermissionResult = never;
/**
* https://discord.com/developers/docs/resources/channel#follow-news-channel
*/
export interface RESTPostAPIChannelFollowersJSONBody {
/**
* ID of target channel
*/
webhook_channel_id: Snowflake;
}
/**
* https://discord.com/developers/docs/resources/channel#follow-news-channel
*/
export type RESTPostAPIChannelFollowersResult = APIFollowedChannel;
/**
* https://discord.com/developers/docs/resources/channel#trigger-typing-indicator
*/
export type RESTPostAPIChannelTypingResult = never;
/**
* https://discord.com/developers/docs/resources/channel#get-pinned-messages
*/
export type RESTGetAPIChannelPinsResult = APIMessage[];
/**
* https://discord.com/developers/docs/resources/channel#add-pinned-channel-message
*/
export type RESTPutAPIChannelPinResult = never;
/**
* https://discord.com/developers/docs/resources/channel#delete-pinned-channel-message
*/
export type RESTDeleteAPIChannelPinResult = never;
/**
* https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
*/
export interface RESTPutAPIChannelRecipientJSONBody {
/**
* Access token of a user that has granted your app the `gdm.join` scope
*/
access_token: string;
/**
* Nickname of the user being added
*/
nick?: string;
}
/**
* https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
*/
export type RESTPutAPIChannelRecipientResult = unknown;
/**
* https://discord.com/developers/docs/resources/channel#group-dm-remove-recipient
*/
export type RESTDeleteAPIChannelRecipientResult = unknown;
/**
* https://discord.com/developers/docs/resources/channel#start-thread-with-message
*/
export interface RESTPostAPIChannelMessagesThreadsJSONBody {
/**
* 1-100 character thread name
*/
name: string;
/**
* The amount of time in minutes to wait before automatically archiving the thread
*
* The 3 day and 7 day archive durations require the server to be boosted. The [guild features](https://discord.com/developers/docs/resources/guild#guild-object-guild-features) will indicate if a server is able to use those settings.
*/
auto_archive_duration: ThreadAutoArchiveDuration;
}
/**
* https://discord.com/developers/docs/resources/channel#start-thread-with-message
*/
export type RESTPostAPIChannelMessagesThreadsResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#start-thread-without-message
*/
export interface RESTPostAPIChannelThreadsJSONBody extends RESTPostAPIChannelMessagesThreadsJSONBody {
/**
* The type of thread to create
*
* In API v9, `type` defaults to `PRIVATE_THREAD`.
* In API v10 this will be changed to be a required field, with no default.
*
* See https://discord.com/developers/docs/resources/channel#channel-object-channel-types
*
* @default 12
*/
type?: ChannelType.GuildNewsThread | ChannelType.GuildPublicThread | ChannelType.GuildPrivateThread;
}
/**
* https://discord.com/developers/docs/resources/channel#start-thread-without-message
*/
export type RESTPostAPIChannelThreadsResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#join-thread
*/
export type RESTPutAPIChannelThreadMembersResult = never;
/**
* https://discord.com/developers/docs/resources/channel#leave-thread
*/
export type RESTDeleteAPIChannelThreadMembersResult = never;
/**
* https://discord.com/developers/docs/resources/channel#list-thread-members
*/
export type RESTGetAPIChannelThreadMembersResult = APIThreadMember[];
/*
* https://discord.com/developers/docs/resources/channel#list-public-archived-threads
*/
export interface RESTGetAPIChannelThreadsArchivedQuery {
/**
* Get threads before this id or ISO8601 timestamp
*/
before?: Snowflake | string;
/**
* Max number of thread to return
*/
limit?: number;
}
/**
* https://discord.com/developers/docs/resources/channel#list-active-threads
*
* @deprecated Use [List Active Guild Threads](https://discord.com/developers/docs/resources/guild#list-active-threads) instead. Will be removed in v10.
*/
export type RESTGetAPIChannelThreadsResult = APIThreadList;
/**
* https://discord.com/developers/docs/resources/channel#list-joined-private-archived-threads
*/
export type RESTGetAPIChannelUsersThreadsArchivedResult = APIThreadList;

61
deno/rest/v9/emoji.ts Normal file
View File

@@ -0,0 +1,61 @@
import type { Snowflake } from '../../globals.ts';
import type { APIEmoji } from '../../payloads/v9/mod.ts';
/**
* https://discord.com/developers/docs/resources/emoji#list-guild-emojis
*/
export type RESTGetAPIGuildEmojisResult = APIEmoji[];
/**
* https://discord.com/developers/docs/resources/emoji#get-guild-emoji
*/
export type RESTGetAPIGuildEmojiResult = APIEmoji;
/**
* https://discord.com/developers/docs/resources/emoji#create-guild-emoji-json-params
*/
export interface RESTPostAPIGuildEmojiJSONBody {
/**
* Name of the emoji
*/
name: string;
/**
* The 128x128 emoji image
*
* https://discord.com/developers/docs/reference#image-data
*/
image: string;
/**
* Roles for which this emoji will be whitelisted
*/
roles?: Snowflake[];
}
/**
* https://discord.com/developers/docs/resources/emoji#create-guild-emoji
*/
export type RESTPostAPIGuildEmojiResult = APIEmoji;
/**
* https://discord.com/developers/docs/resources/emoji#modify-guild-emoji
*/
export interface RESTPatchAPIGuildEmojiJSONBody {
/**
* Name of the emoji
*/
name?: string;
/**
* Roles for which this emoji will be whitelisted
*/
roles?: Snowflake[] | null;
}
/**
* https://discord.com/developers/docs/resources/emoji#modify-guild-emoji
*/
export type RESTPatchAPIGuildEmojiResult = APIEmoji;
/**
* https://discord.com/developers/docs/resources/emoji#delete-guild-emoji
*/
export type RESTDeleteAPIGuildEmojiResult = never;

11
deno/rest/v9/gateway.ts Normal file
View File

@@ -0,0 +1,11 @@
import type { APIGatewayBotInfo, APIGatewayInfo } from '../../payloads/v9/mod.ts';
/**
* https://discord.com/developers/docs/topics/gateway#get-gateway
*/
export type RESTGetAPIGatewayResult = APIGatewayInfo;
/**
* https://discord.com/developers/docs/topics/gateway#get-gateway-bot
*/
export type RESTGetAPIGatewayBotResult = APIGatewayBotInfo;

783
deno/rest/v9/guild.ts Normal file
View File

@@ -0,0 +1,783 @@
import type { Permissions, Snowflake } from '../../globals.ts';
import type {
APIBan,
APIChannel,
APIExtendedInvite,
APIGuild,
APIGuildIntegration,
APIGuildMember,
APIGuildMembershipScreening,
APIGuildPreview,
APIGuildWelcomeScreen,
APIGuildWidget,
APIGuildWidgetSettings,
APIRole,
APIThreadList,
APIVoiceRegion,
GuildDefaultMessageNotifications,
GuildExplicitContentFilter,
GuildFeature,
GuildSystemChannelFlags,
GuildVerificationLevel,
GuildWidgetStyle,
} from '../../payloads/v9/mod.ts';
import type { Nullable } from '../../utils/internals.ts';
import type { RESTPutAPIChannelPermissionJSONBody } from './channel.ts';
export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionJSONBody {
id: number | string;
}
export type APIGuildCreatePartialChannel = Partial<
Pick<APIChannel, 'type' | 'topic' | 'nsfw' | 'bitrate' | 'user_limit' | 'rate_limit_per_user'>
> & {
name: string;
id?: number | string;
parent_id?: number | string | null;
permission_overwrites?: APIGuildCreateOverwrite[];
};
export interface APIGuildCreateRole extends RESTPostAPIGuildRoleJSONBody {
id: number | string;
}
/**
* https://discord.com/developers/docs/resources/guild#create-guild
*/
export interface RESTPostAPIGuildsJSONBody {
/**
* Name of the guild (2-100 characters)
*/
name: string;
/**
* Voice region id
*
* See https://discord.com/developers/docs/resources/voice#voice-region-object
*/
region?: string;
/**
* base64 1024x1024 png/jpeg image for the guild icon
*
* See https://discord.com/developers/docs/reference#image-data
*/
icon?: string;
/**
* Verification level
*
* See https://discord.com/developers/docs/resources/guild#guild-object-verification-level
*/
verification_level?: GuildVerificationLevel;
/**
* Default message notification level
*
* See https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
*/
default_message_notifications?: GuildDefaultMessageNotifications;
/**
* Explicit content filter level
*
* See https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level
*/
explicit_content_filter?: GuildExplicitContentFilter;
/**
* New guild roles
*
* **When using this parameter, the first member of the array is used to change properties of the guild's @everyone role.
* If you are trying to bootstrap a guild with additional roles, keep this in mind.**
*
* *When using this parameter, the required `id` field within each role object is an integer placeholder,
* and will be replaced by the API upon consumption. Its purpose is to allow you to overwrite a role's permissions
* in a channel when also passing in channels with the channels array.*
*
* See https://discord.com/developers/docs/topics/permissions#role-object
*/
roles?: APIGuildCreateRole[];
/**
* New guild's channels
*
* **When using the channels parameter, the `position` field is ignored, and none of the default channels are created.**
*
* *When using the channels parameter, the `id` field within each channel object may be set to an integer placeholder,
* and will be replaced by the API upon consumption. Its purpose is to allow you to create `GUILD_CATEGORY` channels
* by setting the `parent_id` field on any children to the category's id field.
* Category channels must be listed before any children.*
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
channels?: APIGuildCreatePartialChannel[];
/**
* ID for afk channel
*/
afk_channel_id?: number | Snowflake | null;
/**
* AFK timeout in seconds
*/
afk_timeout?: number;
/**
* The id of the channel where guild notices such as welcome messages and boost events are posted
*/
system_channel_id?: number | Snowflake | null;
/**
* System channel flags
*
* See https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags
*/
system_channel_flags?: GuildSystemChannelFlags;
}
/**
* https://discord.com/developers/docs/resources/guild#create-guild
*/
export type RESTPostAPIGuildsResult = APIGuild;
/**
* https://discord.com/developers/docs/resources/guild#get-guild
*/
export interface RESTGetAPIGuildQuery {
/**
* When `true`, will return approximate member and presence counts for the guild
*
* @default false
*/
with_counts?: boolean;
}
/**
* https://discord.com/developers/docs/resources/guild#get-guild
*/
export type RESTGetAPIGuildResult = APIGuild;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-preview
*/
export type RESTGetAPIGuildPreviewResult = APIGuildPreview;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild
*/
export interface RESTPatchAPIGuildJSONBody {
/**
* New name for the guild (2-100 characters)
*/
name?: string;
/**
* Voice region id
*
* See https://discord.com/developers/docs/resources/voice#voice-region-object
*/
region?: string | null;
/**
* Verification level
*
* See https://discord.com/developers/docs/resources/guild#guild-object-verification-level
*/
verification_level?: GuildVerificationLevel | null;
/**
* Default message notification level
*
* See https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
*/
default_message_notifications?: GuildDefaultMessageNotifications | null;
/**
* Explicit content filter level
*
* See https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level
*/
explicit_content_filter?: GuildExplicitContentFilter | null;
/**
* ID for afk channel
*/
afk_channel_id?: Snowflake | null;
/**
* AFK timeout in seconds
*/
afk_timeout?: number;
/**
* base64 1024x1024 png/jpeg/gif image for the guild icon (can be animated gif when the guild has `ANIMATED_ICON` feature)
*
* See https://discord.com/developers/docs/reference#image-data
*/
icon?: string | null;
/**
* User id to transfer guild ownership to (must be owner)
*/
owner_id?: Snowflake;
/**
* base64 16:9 png/jpeg image for the guild splash (when the guild has `INVITE_SPLASH` feature)
*
* See https://discord.com/developers/docs/reference#image-data
*/
splash?: string | null;
/**
* base64 png/jpeg image for the guild discovery splash (when the guild has `DISCOVERABLE` feature)
*/
discovery_splash?: string | null;
/**
* base64 16:9 png/jpeg image for the guild banner (when the guild has `BANNER` feature)
*/
banner?: string | null;
/**
* The id of the channel where guild notices such as welcome messages and boost events are posted
*/
system_channel_id?: Snowflake | null;
/**
* System channel flags
*
* See https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags
*/
system_channel_flags?: GuildSystemChannelFlags;
/**
* The id of the channel where Community guilds display rules and/or guidelines
*/
rules_channel_id?: Snowflake | null;
/**
* The id of the channel where admins and moderators of Community guilds receive notices from Discord
*/
public_updates_channel_id?: Snowflake | null;
/**
* The preferred locale of a Community guild used in server discovery and notices from Discord; defaults to "en-US"
*
* @default "en-US" (if the value is set to `null`)
*/
preferred_locale?: string | null;
/**
* Enabled guild features
*
* See https://discord.com/developers/docs/resources/guild#guild-object-guild-features
*/
features?: GuildFeature[];
/**
* The description for the guild, if the guild is discoverable
*/
description?: string | null;
}
/**
* https://discord.com/developers/docs/resources/guild#modify-guild
*/
export type RESTPatchAPIGuildResult = APIGuild;
/**
* https://discord.com/developers/docs/resources/guild#delete-guild
*/
export type RESTDeleteAPIGuildResult = never;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-channels
*/
export type RESTGetAPIGuildChannelsResult = APIChannel[];
/**
* https://discord.com/developers/docs/resources/guild#create-guild-channel
*/
export type RESTPostAPIGuildChannelJSONBody = Omit<APIGuildCreatePartialChannel, 'id'>;
/**
* https://discord.com/developers/docs/resources/guild#create-guild-channel
*/
export type RESTPostAPIGuildChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
*/
export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{
/**
* Channel id
*/
id: Snowflake;
/**
* Sorting position of the channel
*/
position: number;
/**
* Sync channel overwrites with the new parent, when moving to a new `parent_id`
*/
lock_permissions?: boolean;
/**
* The new parent id of this channel
*/
parent_id?: Snowflake | null;
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
*/
export type RESTPatchAPIGuildChannelPositionsResult = never;
/**
* https://discord.com/developers/docs/resources/guild#list-active-threads
*/
export type RESTGetAPIGuildThreadsResult = Omit<APIThreadList, 'has_more'>;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-member
*/
export type RESTGetAPIGuildMemberResult = APIGuildMember;
/**
* https://discord.com/developers/docs/resources/guild#list-guild-members
*/
export interface RESTGetAPIGuildMembersQuery {
/**
* Max number of members to return (1-1000)
*
* @default 1
*/
limit?: number;
/**
* The highest user id in the previous page
*
* @default 0
*/
after?: Snowflake;
}
/**
* https://discord.com/developers/docs/resources/guild#list-guild-members
*/
export type RESTGetAPIGuildMembersResult = APIGuildMember[];
/**
* https://discord.com/developers/docs/resources/guild#search-guild-members
*/
export interface RESTGetAPIGuildMembersSearchQuery {
/**
* Query string to match username(s) and nickname(s) against
*/
query: string;
/**
* Max number of members to return (1-1000)
*
* @default 1
*/
limit?: number;
}
export type RESTGetAPIGuildMembersSearchResult = APIGuildMember[];
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member
*/
export interface RESTPutAPIGuildMemberJSONBody {
/**
* An oauth2 access token granted with the `guilds.join` to the bot's application for the user you want to add to the guild
*/
access_token: string;
/**
* Value to set users nickname to
*
* Requires `MANAGE_NICKNAMES` permission
*/
nick?: string;
/**
* Array of role ids the member is assigned
*
* Requires `MANAGE_ROLES` permission
*/
roles?: Snowflake[];
/**
* Whether the user is muted in voice channels
*
* Requires `MUTE_MEMBERS` permission
*/
mute?: boolean;
/**
* Whether the user is deafened in voice channels
*
* Requires `DEAFEN_MEMBERS` permission
*/
deaf?: boolean;
}
export type RESTPutAPIGuildMemberResult = APIGuildMember | undefined;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-member
*/
export interface RESTPatchAPIGuildMemberJSONBody {
/**
* Value to set users nickname to
*
* Requires `MANAGE_NICKNAMES` permission
*/
nick?: string | null;
/**
* Array of role ids the member is assigned
*
* Requires `MANAGE_ROLES` permission
*/
roles?: Snowflake[] | null;
/**
* Whether the user is muted in voice channels. Will throw a 400 if the user is not in a voice channel
*
* Requires `MUTE_MEMBERS` permission
*/
mute?: boolean | null;
/**
* Whether the user is deafened in voice channels. Will throw a 400 if the user is not in a voice channel
*
* Requires `DEAFEN_MEMBERS` permission
*/
deaf?: boolean | null;
/**
* ID of channel to move user to (if they are connected to voice)
*
* Requires `MOVE_MEMBERS` permission
*/
channel_id?: Snowflake | null;
}
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member
*/
export type RESTPatchAPIGuildMemberResult = APIGuildMember;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-nick
*/
export interface RESTPatchAPICurrentGuildMemberNicknameJSONBody {
/**
* Value to set users nickname to
*
* Requires `CHANGE_NICKNAME` permission
*/
nick?: string | null;
}
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-nick
*/
export type RESTPatchAPICurrentGuildMemberNicknameResult = Required<RESTPatchAPICurrentGuildMemberNicknameJSONBody>;
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member-role
*/
export type RESTPutAPIGuildMemberRoleResult = never;
/**
* https://discord.com/developers/docs/resources/guild#remove-guild-member-role
*/
export type RESTDeleteAPIGuildMemberRoleResult = never;
/**
* https://discord.com/developers/docs/resources/guild#remove-guild-member
*/
export type RESTDeleteAPIGuildMemberResult = never;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-bans
*/
export type RESTGetAPIGuildBansResult = APIBan[];
/**
* https://discord.com/developers/docs/resources/guild#get-guild-ban
*/
export type RESTGetAPIGuildBanResult = APIBan;
/**
* https://discord.com/developers/docs/resources/guild#create-guild-ban
*/
export interface RESTPutAPIGuildBanJSONBody {
/**
* Number of days to delete messages for (0-7)
*/
delete_message_days?: number;
/**
* Reason for the ban
*/
reason?: string;
}
/**
* https://discord.com/developers/docs/resources/guild#create-guild-ban
*/
export type RESTPutAPIGuildBanResult = never;
/**
* https://discord.com/developers/docs/resources/guild#remove-guild-ban
*/
export type RESTDeleteAPIGuildBanResult = never;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-roles
*/
export type RESTGetAPIGuildRolesResult = APIRole[];
/**
* https://discord.com/developers/docs/resources/guild#create-guild-role
*/
export interface RESTPostAPIGuildRoleJSONBody {
/**
* Name of the role
*
* @default "new role"
*/
name?: string | null;
/**
* Bitwise value of the enabled/disabled permissions
*
* @default "default role permissions in guild"
*/
permissions?: Permissions | null;
/**
* RGB color value
*
* @default 0
*/
color?: number | null;
/**
* Whether the role should be displayed separately in the sidebar
*
* @default false
*/
hoist?: boolean | null;
/**
* Whether the role should be mentionable
*
* @default false
*/
mentionable?: boolean | null;
}
/**
* https://discord.com/developers/docs/resources/guild#create-guild-role
*/
export type RESTPostAPIGuildRoleResult = APIRole;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
*/
export type RESTPatchAPIGuildRolePositionsJSONBody = Array<{
/**
* Role id
*/
id: Snowflake;
/**
* Sorting position of the role
*/
position?: number;
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
*/
export type RESTPatchAPIGuildRolePositionsResult = APIRole[];
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role
*/
export interface RESTPatchAPIGuildRoleJSONBody {
/**
* Name of the role
*/
name?: string | null;
/**
* Bitwise value of the enabled/disabled permissions
*/
permissions?: Permissions | null;
/**
* RGB color value
*/
color?: number | null;
/**
* Whether the role should be displayed separately in the sidebar
*/
hoist?: boolean | null;
/**
* Whether the role should be mentionable
*/
mentionable?: boolean | null;
}
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role
*/
export type RESTPatchAPIGuildRoleResult = APIRole;
/**
* https://discord.com/developers/docs/resources/guild#delete-guild-role
*/
export type RESTDeleteAPIGuildRoleResult = never;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-prune-count
*/
export interface RESTGetAPIGuildPruneCountQuery {
/**
* Number of days to count prune for (1 or more)
*
* @default 7
*/
days?: number;
/**
* Role(s) to include
*
* While this is typed as a string, it represents an array of
* role IDs delimited by commas
*
* See https://discord.com/developers/docs/resources/guild#get-guild-prune-count-query-string-params
*/
include_roles?: string;
}
/**
* https://discord.com/developers/docs/resources/guild#get-guild-prune-count
*/
export interface RESTGetAPIGuildPruneCountResult {
pruned: number;
}
/**
* https://discord.com/developers/docs/resources/guild#begin-guild-prune
*/
export interface RESTPostAPIGuildPruneJSONBody {
/**
* Number of days to count prune for (1 or more)
*
* @default 7
*/
days?: number;
/**
* Whether `pruned is returned, discouraged for large guilds
*
* @default true
*/
compute_prune_count?: boolean;
/**
* Role(s) to include
*/
include_roles?: Snowflake[];
}
/**
* https://discord.com/developers/docs/resources/guild#begin-guild-prune
*/
export interface RESTPostAPIGuildPruneResult {
pruned: number | null;
}
/**
* https://discord.com/developers/docs/resources/guild#get-guild-voice-regions
*/
export type RESTGetAPIGuildVoiceRegionsResult = APIVoiceRegion[];
/**
* https://discord.com/developers/docs/resources/guild#get-guild-invites
*/
export type RESTGetAPIGuildInvitesResult = APIExtendedInvite[];
/**
* https://discord.com/developers/docs/resources/guild#get-guild-integrations
*/
export type RESTGetAPIGuildIntegrationsResult = APIGuildIntegration[];
/**
* https://discord.com/developers/docs/resources/guild#delete-guild-integration
*/
export type RESTDeleteAPIGuildIntegrationResult = never;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-widget-settings
*/
export type RESTGetAPIGuildWidgetSettingsResult = APIGuildWidgetSettings;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-widget
*/
export type RESTPatchAPIGuildWidgetSettingsJSONBody = Partial<APIGuildWidgetSettings>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-widget
*/
export type RESTPatchAPIGuildWidgetSettingsResult = APIGuildWidgetSettings;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-widget
*/
export type RESTGetAPIGuildWidgetJSONResult = APIGuildWidget;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-vanity-url
*/
export interface RESTGetAPIGuildVanityUrlResult {
code: string | null;
uses: number;
}
/**
* https://discord.com/developers/docs/resources/guild#get-guild-widget-image
*/
export interface RESTGetAPIGuildWidgetImageQuery {
/**
* Style of the widget image returned
*
* @default "shield"
*/
style?: GuildWidgetStyle;
}
/**
* Note: while the return type is `ArrayBuffer`, the expected result is
* a buffer of sorts (depends if in browser or on node.js/deno).
*/
export type RESTGetAPIGuildWidgetImageResult = ArrayBuffer;
export type RESTGetAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
export interface RESTPatchAPIGuildMemberVerificationJSONBody {
/**
* Whether Membership Screening is enabled
*/
enabled?: boolean;
/**
* Array of field objects serialized in a string
*/
form_fields?: string;
/**
* The server description to show in the screening form
*/
description?: string | null;
}
export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
export interface RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody {
/**
* The id of the channel the user is currently in
*/
channel_id: Snowflake;
/**
* Toggles the user's suppress state
*/
suppress?: boolean;
/**
* Sets the user's request to speak
*/
request_to_speak_timestamp?: string | null;
}
export interface RESTPatchAPIGuildVoiceStateUserJSONBody {
/**
* The id of the channel the user is currently in
*/
channel_id: Snowflake;
/**
* Toggles the user's suppress state
*/
suppress?: boolean;
}
/**
* https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen
*/
export type RESTGetAPIGuildWelcomeScreenResult = APIGuildWelcomeScreen;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
*/
export interface RESTPatchAPIGuildWelcomeScreenJSONBody extends Nullable<Partial<APIGuildWelcomeScreen>> {
/**
* Whether the welcome screen is enabled
*/
enabled?: boolean | null;
}

View File

@@ -0,0 +1,237 @@
import type {
APIApplicationCommand,
APIApplicationCommandPermission,
APIGuildApplicationCommandPermissions,
APIInteractionResponse,
APIInteractionResponseCallbackData,
} from '../../payloads/v9/mod.ts';
import type {
RESTDeleteAPIWebhookWithTokenMessageResult,
RESTGetAPIWebhookWithTokenMessageResult,
RESTPatchAPIWebhookWithTokenMessageFormDataBody,
RESTPatchAPIWebhookWithTokenMessageJSONBody,
RESTPatchAPIWebhookWithTokenMessageResult,
RESTPostAPIWebhookWithTokenWaitResult,
} from './webhook.ts';
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-global-application-commands
*/
export type RESTGetAPIApplicationCommandsResult = APIApplicationCommand[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-global-application-command
*/
export type RESTGetAPIApplicationCommandResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command
*/
export type RESTPostAPIApplicationCommandsJSONBody = Omit<APIApplicationCommand, 'id' | 'application_id'>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command
*/
export type RESTPostAPIApplicationCommandsResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command
*/
export type RESTPatchAPIApplicationCommandJSONBody = Partial<RESTPostAPIApplicationCommandsJSONBody>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command
*/
export type RESTPatchAPIApplicationCommandResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands
*/
export type RESTPutAPIApplicationCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands
*/
export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-commands
*/
export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command
*/
export type RESTGetAPIApplicationGuildCommandResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command
*/
export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command
*/
export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandJSONBody = Partial<RESTPostAPIApplicationCommandsJSONBody>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands
*/
export type RESTPutAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands
*/
export type RESTPutAPIApplicationGuildCommandsResult = APIApplicationCommand[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response
*/
export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response
*/
export type RESTPostAPIInteractionCallbackFormDataBody =
| {
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPostAPIInteractionCallbackJSONBody & {
/**
* The file contents
*/
file: unknown;
});
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-original-interaction-response
*/
export type RESTGetAPIInteractionOriginalResponseResult = RESTGetAPIWebhookWithTokenMessageResult;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response
*/
export type RESTPatchAPIInteractionOriginalResponseJSONBody = RESTPatchAPIWebhookWithTokenMessageJSONBody;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response
*/
export type RESTPatchAPIInteractionOriginalResponseFormDataBody = RESTPatchAPIWebhookWithTokenMessageFormDataBody;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response
*/
export type RESTPatchAPIInteractionOriginalResponseResult = RESTPatchAPIWebhookWithTokenMessageResult;
/**
* https://discord.com/developers/docs/interactions/slash-commands#delete-original-interaction-response
*/
export type RESTDeleteAPIInteractionOriginalResponseResult = RESTDeleteAPIWebhookWithTokenMessageResult;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-followup-message
*/
export type RESTPostAPIInteractionFollowupJSONBody = APIInteractionResponseCallbackData;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-followup-message
*/
export type RESTPostAPIInteractionFollowupFormDataBody =
| {
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPostAPIInteractionFollowupJSONBody & {
/**
* The file contents
*/
file: unknown;
});
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-followup-message
*/
export type RESTPostAPIInteractionFollowupResult = RESTPostAPIWebhookWithTokenWaitResult;
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-followup-message
*/
export type RESTGetAPIInteractionFollowupResult = RESTGetAPIWebhookWithTokenMessageResult;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message
*/
export type RESTPatchAPIInteractionFollowupJSONBody = RESTPatchAPIWebhookWithTokenMessageJSONBody;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message
*/
export type RESTPatchAPIInteractionFollowupFormDataBody = RESTPatchAPIWebhookWithTokenMessageFormDataBody;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message
*/
export type RESTPatchAPIInteractionFollowupResult = RESTPatchAPIWebhookWithTokenMessageResult;
/**
* https://discord.com/developers/docs/interactions/slash-commands#delete-followup-message
*/
export type RESTDeleteAPIInteractionFollowupResult = RESTDeleteAPIWebhookWithTokenMessageResult;
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command-permissions
*/
export type RESTGetAPIGuildApplicationCommandsPermissionsResult = APIGuildApplicationCommandPermissions[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-application-command-permissions
*/
export type RESTGetAPIApplicationCommandPermissionsResult = APIGuildApplicationCommandPermissions;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-application-command-permissions
*/
export interface RESTPutAPIApplicationCommandPermissionsJSONBody {
permissions: APIApplicationCommandPermission[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-application-command-permissions
*/
export type RESTPutAPIApplicationCommandPermissionsResult = APIGuildApplicationCommandPermissions;
/**
* https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions
*/
export type RESTPutAPIGuildApplicationCommandsPermissionsJSONBody = Pick<
APIGuildApplicationCommandPermissions,
'id' | 'permissions'
>[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions
*/
export type RESTPutAPIGuildApplicationCommandsPermissionsResult = APIGuildApplicationCommandPermissions[];

22
deno/rest/v9/invite.ts Normal file
View File

@@ -0,0 +1,22 @@
import type { APIInvite } from '../../payloads/v9/mod.ts';
/**
* https://discord.com/developers/docs/resources/invite#get-invite
*/
export interface RESTGetAPIInviteQuery {
/**
* Whether the invite should contain approximate member counts
*/
with_counts?: boolean;
/**
* Whether the invite should contain the expiration date
*/
with_expiration?: boolean;
}
export type RESTGetAPIInviteResult = APIInvite;
/**
* https://discord.com/developers/docs/resources/invite#delete-invite
*/
export type RESTDeleteAPIInviteResult = APIInvite;

808
deno/rest/v9/mod.ts Normal file
View File

@@ -0,0 +1,808 @@
import type { Snowflake } from '../../globals.ts';
export * from '../common.ts';
export * from './auditLog.ts';
export * from './channel.ts';
export * from './emoji.ts';
export * from './gateway.ts';
export * from './guild.ts';
export * from './interactions.ts';
export * from './invite.ts';
export * from './oauth2.ts';
export * from './stageInstance.ts';
export * from './sticker.ts';
export * from './template.ts';
export * from './user.ts';
export * from './voice.ts';
export * from './webhook.ts';
export const APIVersion = '9';
export const Routes = {
/**
* Route for:
* - GET `/guilds/{guild.id}/audit-logs`
*/
guildAuditLog(guildId: Snowflake) {
return `/guilds/${guildId}/audit-logs` as const;
},
/**
* Route for:
* - GET `/channels/{channel.id}`
* - PATCH `/channels/{channel.id}`
* - DELETE `/channels/{channel.id}`
*/
channel(channelId: Snowflake) {
return `/channels/${channelId}` as const;
},
/**
* Route for:
* - GET `/channels/{channel.id}/messages`
* - POST `/channels/{channel.id}/messages`
*/
channelMessages(channelId: Snowflake) {
return `/channels/${channelId}/messages` as const;
},
/**
* Route for:
* - GET `/channels/{channel.id}/messages/{message.id}`
* - PATCH `/channels/{channel.id}/messages/{message.id}`
* - DELETE `/channels/{channel.id}/messages/{message.id}`
*/
channelMessage(channelId: Snowflake, messageId: Snowflake) {
return `/channels/${channelId}/messages/${messageId}` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/messages/{message.id}/crosspost`
*/
channelMessageCrosspost(channelId: Snowflake, messageId: Snowflake) {
return `/channels/${channelId}/messages/${messageId}/crosspost` as const;
},
/**
* Route for:
* - PUT `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me`
* - DELETE `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me`
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageOwnReaction(channelId: Snowflake, messageId: Snowflake, emoji: string) {
return `/channels/${channelId}/messages/${messageId}/reactions/${emoji}/@me` as const;
},
/**
* Route for:
* - DELETE `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/{user.id}`
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageUserReaction(channelId: Snowflake, messageId: Snowflake, emoji: string, userId: Snowflake) {
return `/channels/${channelId}/messages/${messageId}/reactions/${emoji}/${userId}` as const;
},
/**
* Route for:
* - GET `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}`
* - DELETE `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}`
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageReaction(channelId: Snowflake, messageId: Snowflake, emoji: string) {
return `/channels/${channelId}/messages/${messageId}/reactions/${emoji}` as const;
},
/**
* Route for:
* - DELETE `/channels/{channel.id}/messages/{message.id}/reactions`
*/
channelMessageAllReactions(channelId: Snowflake, messageId: Snowflake) {
return `/channels/${channelId}/messages/${messageId}/reactions` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/messages/bulk-delete`
*/
channelBulkDelete(channelId: Snowflake) {
return `/channels/${channelId}/messages/bulk-delete` as const;
},
/**
* Route for:
* - PUT `/channels/{channel.id}/permissions/{overwrite.id}`
* - DELETE `/channels/{channel.id}/permissions/{overwrite.id}`
*/
channelPermission(channelId: Snowflake, overwriteId: Snowflake) {
return `/channels/${channelId}/permissions/${overwriteId}` as const;
},
/**
* Route for:
* - GET `/channels/{channel.id}/invites`
* - POST `/channels/{channel.id}/invites`
*/
channelInvites(channelId: Snowflake) {
return `/channels/${channelId}/invites` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/followers`
*/
channelFollowers(channelId: Snowflake) {
return `/channels/${channelId}/followers` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/typing`
*/
channelTyping(channelId: Snowflake) {
return `/channels/${channelId}/typing` as const;
},
/**
* Route for:
* - GET `/channels/{channel.id}/pins`
*/
channelPins(channelId: Snowflake) {
return `/channels/${channelId}/pins` as const;
},
/**
* Route for:
* - PUT `/channels/{channel.id}/pins/{message.id}`
* - DELETE `/channels/{channel.id}/pins/{message.id}`
*/
channelPin(channelId: Snowflake, messageId: Snowflake) {
return `/channels/${channelId}/pins/${messageId}` as const;
},
/**
* Route for:
* - PUT `/channels/{channel.id}/recipients/{user.id}`
* - DELETE `/channels/{channel.id}/recipients/{user.id}`
*/
channelRecipient(channelId: Snowflake, userId: Snowflake) {
return `/channels/${channelId}/recipients/${userId}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/emojis`
* - POST `/guilds/{guild.id}/emojis`
*/
guildEmojis(guildId: Snowflake) {
return `/guilds/${guildId}/emojis` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/emojis/{emoji.id}`
* - PATCH `/guilds/{guild.id}/emojis/{emoji.id}`
* - DELETE `/guilds/{guild.id}/emojis/{emoji.id}`
*/
guildEmoji(guildId: Snowflake, emojiId: Snowflake) {
return `/guilds/${guildId}/emojis/${emojiId}` as const;
},
/**
* Route for:
* - POST `/guilds`
*/
guilds() {
return '/guilds' as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}`
* - PATCH `/guilds/{guild.id}`
* - DELETE `/guilds/{guild.id}`
*/
guild(guildId: Snowflake) {
return `/guilds/${guildId}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/preview`
*/
guildPreview(guildId: Snowflake) {
return `/guilds/${guildId}/preview` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/channels`
* - POST `/guilds/{guild.id}/channels`
* - PATCH `/guilds/{guild.id}/channels`
*/
guildChannels(guildId: Snowflake) {
return `/guilds/${guildId}/channels` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/members/{user.id}`
* - PUT `/guilds/{guild.id}/members/{user.id}`
* - PATCH `/guilds/{guild.id}/members/{user.id}`
* - DELETE `/guilds/{guild.id}/members/{user.id}`
*/
guildMember(guildId: Snowflake, userId: Snowflake) {
return `/guilds/${guildId}/members/${userId}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/members`
*/
guildMembers(guildId: Snowflake) {
return `/guilds/${guildId}/members` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/members/search`
*/
guildMembersSearch(guildId: Snowflake) {
return `/guilds/${guildId}/members/search` as const;
},
/**
* Route for:
* - PATCH `/guilds/{guild.id}/members/@me/nick`
*/
guildCurrentMemberNickname(guildId: Snowflake) {
return `/guilds/${guildId}/members/@me/nick` as const;
},
/**
* Route for:
* - PUT `/guilds/{guild.id}/members/{user.id}/roles/{role.id}`
* - DELETE `/guilds/{guild.id}/members/{user.id}/roles/{role.id}`
*/
guildMemberRole(guildId: Snowflake, memberId: Snowflake, roleId: Snowflake) {
return `/guilds/${guildId}/members/${memberId}/roles/${roleId}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/bans`
*/
guildBans(guildId: Snowflake) {
return `/guilds/${guildId}/bans` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/bans/{user.id}`
* - PUT `/guilds/{guild.id}/bans/{user.id}`
* - DELETE `/guilds/{guild.id}/bans/{user.id}`
*/
guildBan(guildId: Snowflake, userId: Snowflake) {
return `/guilds/${guildId}/bans/${userId}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/roles`
* - POST `/guilds/{guild.id}/roles`
* - PATCH `/guilds/{guild.id}/roles`
*/
guildRoles(guildId: Snowflake) {
return `/guilds/${guildId}/roles` as const;
},
/**
* Route for:
* - PATCH `/guilds/{guild.id}/roles/{role.id}`
* - DELETE `/guilds/{guild.id}/roles/{role.id}`
*/
guildRole(guildId: Snowflake, roleId: Snowflake) {
return `/guilds/${guildId}/roles/${roleId}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/prune`
* - POST `/guilds/{guild.id}/prune`
*/
guildPrune(guildId: Snowflake) {
return `/guilds/${guildId}/prune` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/regions`
*/
guildVoiceRegions(guildId: Snowflake) {
return `/guilds/${guildId}/regions` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/invites`
*/
guildInvites(guildId: Snowflake) {
return `/guilds/${guildId}/invites` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/integrations`
*/
guildIntegrations(guildId: Snowflake) {
return `/guilds/${guildId}/integrations` as const;
},
/**
* Route for:
* - DELETE `/guilds/{guild.id}/integrations/{integration.id}`
*/
guildIntegration(guildId: Snowflake, integrationId: Snowflake) {
return `/guilds/${guildId}/integrations/${integrationId}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/widget`
* - PATCH `/guilds/{guild.id}/widget`
*/
guildWidgetSettings(guildId: Snowflake) {
return `/guilds/${guildId}/widget` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/widget.json`
*/
guildWidgetJSON(guildId: Snowflake) {
return `/guilds/${guildId}/widget.json` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/vanity-url`
*/
guildVanityUrl(guildId: Snowflake) {
return `/guilds/${guildId}/vanity-url` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/widget.png`
*/
guildWidgetImage(guildId: Snowflake) {
return `/guilds/${guildId}/widget.png` as const;
},
/**
* Route for:
* - GET `/invites/{invite.code}`
* - DELETE `/invites/{invite.code}`
*/
invite(code: string) {
return `/invites/${code}` as const;
},
/**
* Route for:
* - GET `/guilds/templates/{template.code}`
* - POST `/guilds/templates/{template.code}`
*/
template(code: string) {
return `/guilds/templates/${code}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/templates`
* - POST `/guilds/{guild.id}/templates`
*/
guildTemplates(guildId: Snowflake) {
return `/guilds/${guildId}/templates` as const;
},
/**
* Route for:
* - PUT `/guilds/{guild.id}/templates/{template.code}`
* - PATCH `/guilds/{guild.id}/templates/{template.code}`
* - DELETE `/guilds/{guild.id}/templates/{template.code}`
*/
guildTemplate(guildId: Snowflake, code: string) {
return `/guilds/${guildId}/templates/${code}` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/threads`
* - POST `/channels/{channel.id}/messages/{message.id}/threads`
*/
threads(parentId: Snowflake, messageId?: Snowflake) {
const parts = ['', 'channels', parentId];
if (messageId) parts.push('messages', messageId);
parts.push('threads');
return parts.join('/') as `/channels/${Snowflake}/threads` | `/channels/${Snowflake}/messages/${Snowflake}/threads`;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/threads/active`
*/
guildActiveThreads(guildId: Snowflake) {
return `/guilds/${guildId}/threads/active` as const;
},
/**
* Route for:
* - GET `/channels/{channel.id}/threads/active`
* (deprecated, use [List Active Guild Threads](https://discord.com/developers/docs/resources/guild#list-active-threads) instead.
* Will be removed in v10.)
* - GET `/channels/{channel.id}/threads/archived/public`
* - GET `/channels/{channel.id}/threads/archived/private`
*/
channelThreads(channelId: Snowflake, archived?: 'public' | 'private') {
const parts = ['', 'channels', channelId, 'threads'];
if (archived) parts.push('archived', archived);
else parts.push('active');
return parts.join('/') as
| `/channels/${Snowflake}/threads/active`
| `/channels/${Snowflake}/threads/archived/${'public' | 'private'}`;
},
/**
* Route for:
* - GET `/channels/{channel.id}/users/@me/threads/archived/prviate`
*/
channelJoinedArchivedThreads(channelId: Snowflake) {
return `/channels/${channelId}/users/@me/threads/archived/private` as const;
},
/**
* Route for:
* - GET `/channels/{thread.id}/thread-members`
* - PUT `/channels/{thread.id}/thread-members/@me`
* - PUT `/channels/{thread.id}/thread-members/{user.id}`
* - DELETE `/channels/{thread.id}/thread-members/@me`
* - DELETE `/channels/{thread.id}/thread-members/{user.id}`
*/
threadMembers(threadId: Snowflake, userId?: Snowflake | '@me') {
const parts = ['', 'channels', threadId, 'thread-members'];
if (userId) parts.push(userId);
return parts.join('/') as
| `/channels/${Snowflake}/thread-members`
| `/channels/${Snowflake}/thread-members/${Snowflake | '@me'}`;
},
/**
* Route for:
* - GET `/users/@me`
* - GET `/users/{user.id}`
* - PATCH `/users/@me`
*
* @param [userId='@me'] The user ID, defaulted to `@me`
*/
user(userId: Snowflake | '@me' = '@me') {
return `/users/${userId}` as const;
},
/**
* Route for:
* - GET `/users/@me/guilds`
*/
userGuilds() {
return `/users/@me/guilds` as const;
},
/**
* Route for:
* - DELETE `/users/@me/guilds/{guild.id}`
*/
userGuild(guildId: Snowflake) {
return `/users/@me/guilds/${guildId}` as const;
},
/**
* Route for:
* - POST `/users/@me/channels`
*/
userChannels() {
return `/users/@me/channels` as const;
},
/**
* Route for:
* - GET `/users/@me/connections`
*/
userConnections() {
return `/users/@me/connections` as const;
},
/**
* Route for:
* - GET `/voice/regions`
*/
voiceRegions() {
return `/voice/regions` as const;
},
/**
* Route for:
* - GET `/channels/{channel.id}/webhooks`
* - POST `/channels/{channel.id}/webhooks`
*/
channelWebhooks(channelId: Snowflake) {
return `/channels/${channelId}/webhooks` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/webhooks`
*/
guildWebhooks(guildId: Snowflake) {
return `/guilds/${guildId}/webhooks` as const;
},
/**
* Route for:
* - GET `/webhooks/{webhook.id}`
* - GET `/webhooks/{webhook.id}/{webhook.token}`
* - PATCH `/webhooks/{webhook.id}`
* - PATCH `/webhooks/{webhook.id}/{webhook.token}`
* - DELETE `/webhooks/{webhook.id}`
* - DELETE `/webhooks/{webhook.id}/{webhook.token}`
* - POST `/webhooks/{webhook.id}/{webhook.token}`
*
* - POST `/webhooks/{application.id}/{interaction.token}`
*/
webhook(webhookId: Snowflake, webhookToken?: string) {
const parts = ['', 'webhooks', webhookId];
if (webhookToken) parts.push(webhookToken);
return parts.join('/') as `/webhooks/${Snowflake}` | `/webhooks/${Snowflake}/${string}`;
},
/**
* Route for:
* - GET `/webhooks/{webhook.id}/{webhook.token}/messages/@original`
* - GET `/webhooks/{webhook.id}/{webhook.token}/messages/{message.id}`
* - PATCH `/webhooks/{webhook.id}/{webhook.token}/messages/@original`
* - PATCH `/webhooks/{webhook.id}/{webhook.token}/messages/{message.id}`
* - DELETE `/webhooks/{webhook.id}/{webhook.token}/messages/@original`
* - DELETE `/webhooks/{webhook.id}/{webhook.token}/messages/{message.id}`
*
* - PATCH `/webhooks/{application.id}/{interaction.token}/messages/@original`
* - PATCH `/webhooks/{application.id}/{interaction.token}/messages/{message.id}`
* - DELETE `/webhooks/{application.id}/{interaction.token}/messages/{message.id}`
*
* @param [messageId='@original'] The message ID to change, defaulted to `@original`
*/
webhookMessage(webhookId: Snowflake, webhookToken: string, messageId: Snowflake | '@original' = '@original') {
return `/webhooks/${webhookId}/${webhookToken}/messages/${messageId}` as const;
},
/**
* Route for:
* - POST `/webhooks/{webhook.id}/{webhook.token}/github`
* - POST `/webhooks/{webhook.id}/{webhook.token}/slack`
*/
webhookPlatform(webhookId: Snowflake, webhookToken: string, platform: 'github' | 'slack') {
return `/webhooks/${webhookId}/${webhookToken}/${platform}` as const;
},
/**
* Route for:
* - GET `/gateway`
*/
gateway() {
return `/gateway` as const;
},
/**
* Route for:
* - GET `/gateway/bot`
*/
gatewayBot() {
return `/gateway/bot` as const;
},
/**
* Route for:
* - GET `/oauth2/applications/@me`
*/
oauth2CurrentApplication() {
return `/oauth2/applications/@me` as const;
},
/**
* Route for:
* - GET `/oauth2/@me`
*/
oauth2CurrentAuthorization() {
return `/oauth2/@me` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/commands`
* - PUT `/applications/{application.id}/commands`
* - POST `/applications/{application.id}/commands`
*/
applicationCommands(applicationId: Snowflake) {
return `/applications/${applicationId}/commands` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/commands/{command.id}`
* - PATCH `/applications/{application.id}/commands/{command.id}`
* - DELETE `/applications/{application.id}/commands/{command.id}`
*/
applicationCommand(applicationId: Snowflake, commandId: Snowflake) {
return `/applications/${applicationId}/commands/${commandId}` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/guilds/{guild.id}/commands`
* - PUT `/applications/{application.id}/guilds/{guild.id}/commands`
* - POST `/applications/{application.id}/guilds/{guild.id}/commands`
*/
applicationGuildCommands(applicationId: Snowflake, guildId: Snowflake) {
return `/applications/${applicationId}/guilds/${guildId}/commands` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
* - PATCH `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
* - DELETE `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
*/
applicationGuildCommand(applicationId: Snowflake, guildId: Snowflake, commandId: Snowflake) {
return `/applications/${applicationId}/guilds/${guildId}/commands/${commandId}` as const;
},
/**
* Route for:
* - POST `/interactions/{interaction.id}/{interaction.token}/callback`
*/
interactionCallback(interactionId: Snowflake, interactionToken: string) {
return `/interactions/${interactionId}/${interactionToken}/callback` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/member-verification`
* - PATCH `/guilds/{guild.id}/member-verification`
*/
guildMemberVerification(guildId: Snowflake) {
return `/guilds/${guildId}/member-verification` as const;
},
/**
* Route for:
* - PATCH `/guilds/{guild.id}/voice-states/@me`
* - PATCH `/guilds/{guild.id}/voice-states/{user.id}`
*/
guildVoiceState(guildId: Snowflake, userId: Snowflake | '@me' = '@me') {
return `/guilds/${guildId}/voice-states/${userId}` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/guilds/{guild.id}/commands/permissions`
* - PUT `/applications/{application.id}/guilds/{guild.id}/commands/permissions`
*/
guildApplicationCommandsPermissions(applicationId: Snowflake, guildId: Snowflake) {
return `/applications/${applicationId}/guilds/${guildId}/commands/permissions` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}/permissions`
* - PUT `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}/permissions`
*/
applicationCommandPermissions(applicationId: Snowflake, guildId: Snowflake, commandId: Snowflake) {
return `/applications/${applicationId}/guilds/${guildId}/commands/${commandId}/permissions` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/welcome-screen`
* - PATCH `/guilds/{guild.id}/welcome-screen`
*/
guildWelcomeScreen(guildId: Snowflake) {
return `/guilds/${guildId}/welcome-screen` as const;
},
/**
* Route for:
* - POST `/stage-instances`
*/
stageInstances() {
return `/stage-instances` as const;
},
/**
* Route for:
* - GET `/stage-instances/{channel.id}`
* - PATCH `/stage-instances/{channel.id}`
* - DELETE `/stage-instances/{channel.id}`
*/
stageInstance(channelId: Snowflake) {
return `/stage-instances/${channelId}` as const;
},
/**
* Route for:
* - GET `/stickers/{sticker.id}`
*/
sticker(stickerId: Snowflake) {
return `/stickers/${stickerId}` as const;
},
/**
* Route for:
* - GET `/sticker-packs`
*/
nitroStickerPacks() {
return '/sticker-packs' as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/stickers`
* - POST `/guilds/{guild.id}/stickers`
*/
guildStickers(guildId: Snowflake) {
return `/guilds/${guildId}/stickers` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/stickers/{sticker.id}`
* - PATCH `/guilds/{guild.id}/stickers/{sticker.id}`
* - DELETE `/guilds/{guild.id}/stickers/{sticker.id}`
*/
guildSticker(guildId: Snowflake, stickerId: Snowflake) {
return `/guilds/${guildId}/stickers/${stickerId}` as const;
},
};
export const RouteBases = {
api: `https://discord.com/api/v${APIVersion}`,
cdn: 'https://cdn.discordapp.com',
invite: 'https://discord.gg',
template: 'https://discord.new',
gift: 'https://discord.gift',
} as const;
// Freeze bases object
Object.freeze(RouteBases);
export const OAuth2Routes = {
authorizationURL: `https://discord.com/api/v${APIVersion}/oauth2/authorize`,
tokenURL: `https://discord.com/api/v${APIVersion}/oauth2/token`,
/**
* See https://tools.ietf.org/html/rfc7009
*/
tokenRevocationURL: `https://discord.com/api/v${APIVersion}/oauth2/token/revoke`,
} as const;
// Freeze OAuth2 route object
Object.freeze(OAuth2Routes);

199
deno/rest/v9/oauth2.ts Normal file
View File

@@ -0,0 +1,199 @@
import type { Permissions, Snowflake } from '../../globals.ts';
import type { APIApplication, APIGuild, APIUser, APIWebhook, OAuth2Scopes } from '../../payloads/v9/mod.ts';
/**
* https://discord.com/developers/docs/topics/oauth2#get-current-application-information
*/
export type RESTGetAPIOAuth2CurrentApplicationResult = Omit<APIApplication, 'flags'>;
/**
* https://discord.com/developers/docs/topics/oauth2#get-current-authorization-information
*/
export interface RESTGetAPIOAuth2CurrentAuthorizationResult {
/**
* the current application
*/
application: Partial<APIApplication>;
/**
* the scopes the user has authorized the application for
*/
scopes: OAuth2Scopes[];
/**
* when the access token expires
*/
expires: string;
/**
* the user who has authorized, if the user has authorized with the `identify` scope
*/
user?: APIUser;
}
/**
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant
*/
export interface RESTOAuth2AuthorizationQuery {
response_type: 'code';
client_id: Snowflake;
scope: string;
redirect_uri?: string;
state?: string;
prompt?: 'consent' | 'none';
}
/**
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-redirect-url-example
*/
export interface RESTOAuth2AuthorizationQueryResult {
code: string;
state?: string;
}
/**
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-redirect-url-example
*/
export interface RESTPostOAuth2AccessTokenURLEncodedData {
client_id: Snowflake;
client_secret: string;
grant_type: 'authorization_code';
code: string;
redirect_uri?: string;
}
/**
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-access-token-response
*/
export interface RESTPostOAuth2AccessTokenResult {
access_token: string;
token_type: string;
expires_in: number;
refresh_token: string;
scope: string;
}
/**
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-refresh-token-exchange-example
*/
export interface RESTPostOAuth2RefreshTokenURLEncodedData {
client_id: Snowflake;
client_secret: string;
grant_type: 'refresh_token';
refresh_token: string;
}
export type RESTPostOAuth2RefreshTokenResult = RESTPostOAuth2AccessTokenResult;
/**
* https://discord.com/developers/docs/topics/oauth2#implicit-grant
*/
export interface RESTOAuth2ImplicitAuthorizationQuery {
response_type: 'token';
client_id: Snowflake;
scope: string;
redirect_uri?: string;
state?: string;
prompt?: 'consent' | 'none';
}
/**
* https://discord.com/developers/docs/topics/oauth2#implicit-grant-redirect-url-example
*/
export type RESTOAuth2ImplicitAuthorizationURLFragmentResult = Omit<RESTPostOAuth2AccessTokenResult, 'refresh_token'>;
/**
* https://discord.com/developers/docs/topics/oauth2#client-credentials-grant
*/
export interface RESTPostOAuth2ClientCredentialsURLEncodedData {
grant_type: 'client_credentials';
scope: string;
}
export type RESTPostOAuth2ClientCredentialsResult = RESTOAuth2ImplicitAuthorizationURLFragmentResult;
/**
* https://discord.com/developers/docs/topics/oauth2#bot-authorization-flow-bot-auth-parameters
*/
export interface RESTOAuth2BotAuthorizationQuery {
/**
* Your app's client id
*/
client_id: Snowflake;
/**
* Needs to include bot for the bot flow
*/
scope:
| OAuth2Scopes.Bot
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}`
| `${OAuth2Scopes.Bot}${' ' | '%20'}${string}`
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}${string}${' ' | '%20'}`;
/**
* The permissions you're requesting
*
* See https://discord.com/developers/docs/topics/permissions
*/
permissions?: Permissions;
/**
* Pre-fills the dropdown picker with a guild for the user
*/
guild_id?: Snowflake;
/**
* `true` or `false`—disallows the user from changing the guild dropdown
*/
disable_guild_select?: boolean;
}
/**
* https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization
*/
export interface RESTOAuth2AdvancedBotAuthorizationQuery {
client_id: Snowflake;
/**
* This assumes you include the `bot` scope alongside others (like `identify` for example)
*/
scope:
| OAuth2Scopes.Bot
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}`
| `${OAuth2Scopes.Bot}${' ' | '%20'}${string}`
| `${string}${' ' | '%20'}${OAuth2Scopes.Bot}${string}${' ' | '%20'}`;
/**
* The required permissions bitfield, stringified
*/
permissions?: Permissions;
guild_id?: Snowflake;
disable_guild_select?: boolean;
response_type: string;
redirect_uri?: string;
}
export interface RESTOAuth2AdvancedBotAuthorizationQueryResult {
code: string;
state?: string;
guild_id: Snowflake;
permissions: Permissions;
}
/**
* https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization-extended-bot-authorization-access-token-example
*/
export interface RESTPostOAuth2AccessTokenWithBotAndGuildsScopeResult {
access_token: string;
token_type: string;
expires_in: number;
refresh_token: string;
scope: string;
guild: APIGuild;
}
/**
* https://discord.com/developers/docs/topics/oauth2#webhooks-webhook-token-response-example
*/
export interface RESTPostOAuth2AccessTokenWithBotAndWebhookIncomingScopeResult {
access_token: string;
token_type: string;
expires_in: number;
refresh_token: string;
scope: string;
webhook: APIWebhook;
}
export type RESTPostOAuth2AccessTokenWithBotAndGuildsAndWebhookIncomingScopeResult =
RESTPostOAuth2AccessTokenWithBotAndGuildsScopeResult & RESTPostOAuth2AccessTokenWithBotAndWebhookIncomingScopeResult;

View File

@@ -0,0 +1,56 @@
import type { Snowflake } from '../../globals.ts';
import type { APIStageInstance, StageInstancePrivacyLevel } from '../../payloads/v9/mod.ts';
/**
* https://discord.com/developers/docs/resources/stage-instance#create-stage-instance
*/
export interface RESTPostAPIStageInstanceJSONBody {
/**
* The id of the stage channel
*/
channel_id: Snowflake;
/**
* The topic of the stage instance (1-120 characters)
*/
topic: string;
/**
* The privacy level of the stage instance
*
* @default GuildOnly
*/
privacy_level?: StageInstancePrivacyLevel;
}
/**
* https://discord.com/developers/docs/resources/stage-instance#create-stage-instance
*/
export type RESTPostAPIStageInstanceResult = APIStageInstance;
/**
* https://discord.com/developers/docs/resources/stage-instance#get-stage-instance
*/
export type RESTGetAPIStageInstanceResult = APIStageInstance;
/**
* https://discord.com/developers/docs/resources/stage-instance#update-stage-instance
*/
export interface RESTPatchAPIStageInstanceJSONBody {
/**
* The topic of the stage instance (1-120 characters)
*/
topic?: string;
/**
* The privacy level of the stage instance
*/
privacy_level?: StageInstancePrivacyLevel;
}
/**
* https://discord.com/developers/docs/resources/stage-instance#update-stage-instance
*/
export type RESTPatchAPIStageInstanceResult = APIStageInstance;
/**
* https://discord.com/developers/docs/resources/stage-instance#delete-stage-instance
*/
export type RESTDeleteAPIStageInstanceResult = never;

51
deno/rest/v9/sticker.ts Normal file
View File

@@ -0,0 +1,51 @@
import type { APISticker, APIStickerPack } from '../../payloads/v9/mod.ts';
export type RESTGetAPIStickerResult = APISticker;
export interface RESTGetNitroStickerPacksResult {
sticker_packs: APIStickerPack[];
}
export type RESTGetAPIGuildStickersResult = APISticker[];
export type RESTGetAPIGuildStickerResult = APISticker;
export interface RESTPostAPIGuildStickerFormDataBody {
/**
* Name of the sticker (2-30 characters)
*/
name: string;
/**
* Description of the sticker (empty or 2-100 characters)
*/
description: string;
/**
* The Discord name of a unicode emoji representing the sticker's expression (2-200 characters)
*/
tags: string;
/**
* The sticker file to upload, must be a PNG, APNG, or Lottie JSON file, max 500 KB
*/
file: unknown;
}
export type RESTPostAPIGuildStickerResult = APISticker;
export interface RESTPatchAPIGuildStickerJSONBody {
/**
* Name of the sticker (2-30 characters)
*/
name?: string;
/**
* Description of the sticker (2-100 characters)
*/
description?: string | null;
/**
* The Discord name of a unicode emoji representing the sticker's expression (2-200 characters)
*/
tags?: string;
}
export type RESTPatchAPIGuildStickerResult = APISticker;
export type RESTDeleteAPIGuildStickerResult = never;

70
deno/rest/v9/template.ts Normal file
View File

@@ -0,0 +1,70 @@
import type { APIGuild, APITemplate } from '../../payloads/v9/mod.ts';
/**
* https://discord.com/developers/docs/resources/template#get-template
*/
export type RESTGetAPITemplateResult = APITemplate;
/**
* https://discord.com/developers/docs/resources/template#create-guild-from-template
*/
export interface RESTPostAPITemplateCreateGuildJSONBody {
/**
* Name of the guild (2-100 characters)
*/
name: string;
/**
* base64 1024x1024 png/jpeg image for the guild icon
*
* See https://discord.com/developers/docs/reference#image-data
*/
icon?: string;
}
/**
* https://discord.com/developers/docs/resources/template#create-guild-from-template
*/
export type RESTPostAPITemplateCreateGuildResult = APIGuild;
/**
* https://discord.com/developers/docs/resources/template#get-guild-templates
*/
export type RESTGetAPIGuildTemplatesResult = APITemplate[];
/**
* https://discord.com/developers/docs/resources/template#create-guild-template
*/
export interface RESTPostAPIGuildTemplatesJSONBody {
/**
* Name of the template (1-100 characters)
*/
name: string;
/**
* Description for the template (0-120 characters)
*/
description?: string | null;
}
/**
* https://discord.com/developers/docs/resources/template#create-guild-template
*/
export type RESTPostAPIGuildTemplatesResult = APITemplate;
/**
* https://discord.com/developers/docs/resources/template#sync-guild-template
*/
export type RESTPutAPIGuildTemplateSyncResult = APITemplate;
/**
* https://discord.com/developers/docs/resources/template#modify-guild-template
*/
export type RESTPatchAPIGuildTemplateJSONBody = Partial<RESTPostAPIGuildTemplatesJSONBody>;
/**
* https://discord.com/developers/docs/resources/template#modify-guild-template
*/
export type RESTPatchAPIGuildTemplateResult = APITemplate;
/**
* https://discord.com/developers/docs/resources/template#delete-guild-template
*/
export type RESTDeleteAPIGuildTemplateResult = APITemplate;

90
deno/rest/v9/user.ts Normal file
View File

@@ -0,0 +1,90 @@
import type { Permissions, Snowflake } from '../../globals.ts';
import type { APIChannel, APIConnection, APIUser, GuildFeature } from '../../payloads/v9/mod.ts';
/**
* https://discord.com/developers/docs/resources/user#get-current-user
*/
export type RESTGetAPICurrentUserResult = APIUser;
/**
* https://discord.com/developers/docs/resources/user#get-user
*/
export type RESTGetAPIUserResult = APIUser;
/**
* https://discord.com/developers/docs/resources/user#modify-current-user
*/
export interface RESTPatchAPICurrentUserJSONBody {
/**
* User's username, if changed may cause the user's discriminator to be randomized
*/
username?: string;
/**
* If passed, modifies the user's avatar
*/
avatar?: string | null;
}
/**
* https://discord.com/developers/docs/resources/user#modify-current-user
*/
export type RESTPatchAPICurrentUserResult = APIUser;
/**
* https://discord.com/developers/docs/resources/user#get-current-user-guilds
*/
export interface RESTGetAPICurrentUserGuildsQuery {
/**
* Get guilds before this guild ID
*/
before?: Snowflake;
/**
* Get guilds after this guild ID
*/
after?: Snowflake;
/**
* Max number of guilds to return (1-100)
*
* @default 100
*/
limit?: number;
}
export interface RESTAPIPartialCurrentUserGuild {
id: Snowflake;
name: string;
icon: string | null;
owner: boolean;
features: GuildFeature[];
permissions: Permissions;
}
/**
* https://discord.com/developers/docs/resources/user#get-current-user-guilds
*/
export type RESTGetAPICurrentUserGuildsResult = RESTAPIPartialCurrentUserGuild[];
/**
* https://discord.com/developers/docs/resources/user#leave-guild
*/
export type RESTDeleteAPICurrentUserGuildResult = never;
/**
* https://discord.com/developers/docs/resources/user#create-dm
*/
export interface RESTPostAPICurrentUserCreateDMChannelJSONBody {
/**
* The recipient to open a DM channel with
*/
recipient_id: string;
}
/**
* https://discord.com/developers/docs/resources/user#create-dm
*/
export type RESTPostAPICurrentUserCreateDMChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/user#get-user-connections
*/
export type RESTGetAPICurrentUserConnectionsResult = APIConnection[];

6
deno/rest/v9/voice.ts Normal file
View File

@@ -0,0 +1,6 @@
import type { APIVoiceRegion } from '../../payloads/v9/mod.ts';
/**
* https://discord.com/developers/docs/resources/voice#list-voice-regions
*/
export type GetAPIVoiceRegionsResult = APIVoiceRegion[];

276
deno/rest/v9/webhook.ts Normal file
View File

@@ -0,0 +1,276 @@
import type { Snowflake } from '../../globals.ts';
import type {
APIAllowedMentions,
APIActionRowComponent,
APIEmbed,
APIMessage,
APIWebhook,
APIAttachment,
} from '../../payloads/v9/mod.ts';
import type { Nullable } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook
*/
export interface RESTPostAPIChannelWebhookJSONBody {
/**
* Name of the webhook (1-80 characters)
*/
name: string;
/**
* Image for the default webhook avatar
*
* See https://discord.com/developers/docs/reference#image-data
*/
avatar?: string | null;
}
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook
*/
export type RESTPostAPIChannelWebhookResult = APIWebhook;
/**
* https://discord.com/developers/docs/resources/webhook#get-channel-webhooks
*/
export type RESTGetAPIChannelWebhooksResult = APIWebhook[];
/**
* https://discord.com/developers/docs/resources/webhook#get-guild-webhooks
*/
export type RESTGetAPIGuildWebhooksResult = APIWebhook[];
/**
* https://discord.com/developers/docs/resources/webhook#get-webhook
*/
export type RESTGetAPIWebhookResult = APIWebhook;
/**
* https://discord.com/developers/docs/resources/webhook#get-webhook-with-token
*/
export type RESTGetAPIWebhookWithTokenResult = Omit<APIWebhook, 'user'>;
/**
* https://discord.com/developers/docs/resources/webhook#modify-webhook
*/
export interface RESTPatchAPIWebhookJSONBody {
/**
* The default name of the webhook
*/
name?: string;
/**
* Image for the default webhook avatar
*
* See https://discord.com/developers/docs/reference#image-data
*/
avatar?: string | null;
/**
* The new channel id this webhook should be moved to
*/
channel_id?: Snowflake;
}
/**
* https://discord.com/developers/docs/resources/webhook#modify-webhook
*/
export type RESTPatchAPIWebhookResult = APIWebhook;
/**
* https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token
*/
export type RESTPatchAPIWebhookWithTokenJSONBody = Omit<RESTPatchAPIWebhookJSONBody, 'channel_id'>;
/**
* https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token
*/
export type RESTPatchAPIWebhookWithTokenResult = RESTGetAPIWebhookWithTokenResult;
/**
* https://discord.com/developers/docs/resources/webhook#delete-webhook
*/
export type RESTDeleteAPIWebhookResult = never;
/**
* https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token
*/
export type RESTDeleteAPIWebhookWithTokenResult = never;
/**
* https://discord.com/developers/docs/resources/webhook#execute-webhook
*/
export interface RESTPostAPIWebhookWithTokenJSONBody {
/**
* The message contents (up to 2000 characters)
*/
content?: string;
/**
* Override the default username of the webhook
*/
username?: string;
/**
* Override the default avatar of the webhook
*/
avatar_url?: string;
/**
* `true` if this is a TTS message
*/
tts?: boolean;
/**
* Embedded `rich` content
*
* See https://discord.com/developers/docs/resources/channel#embed-object
*/
embeds?: APIEmbed[];
/**
* Allowed mentions for the message
*
* See https://discord.com/developers/docs/resources/channel#allowed-mentions-object
*/
allowed_mentions?: APIAllowedMentions;
/**
* The components to include with the message
*
* Requires an application-owned webhook
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent[];
}
/**
* https://discord.com/developers/docs/resources/webhook#execute-webhook
*/
export type RESTPostAPIWebhookWithTokenFormDataBody =
| {
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPostAPIWebhookWithTokenJSONBody & {
/**
* The file contents
*/
file: unknown;
});
/**
* https://discord.com/developers/docs/resources/webhook#execute-webhook-querystring-params
*/
export interface RESTPostAPIWebhookWithTokenQuery {
/**
* Waits for server confirmation of message send before response, and returns the created message body
* (defaults to `false`; when `false` a message that is not saved does not return an error)
*
* @default false
*/
wait?: boolean;
/**
* Send a message to the specified thread within a webhook's channel. The thread will automatically be unarchived.
*/
thread_id?: Snowflake;
}
/**
* https://discord.com/developers/docs/resources/webhook#execute-webhook
*/
export type RESTPostAPIWebhookWithTokenResult = never;
/**
* Received when a call to https://discord.com/developers/docs/resources/webhook#execute-webhook receives
* the `wait` query parameter set to `true`
*
* See https://discord.com/developers/docs/resources/webhook#execute-webhook-querystring-params
*/
export type RESTPostAPIWebhookWithTokenWaitResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook-querystring-params
*/
export type RESTPostAPIWebhookWithTokenSlackQuery = RESTPostAPIWebhookWithTokenQuery;
/**
* https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook
*/
export type RESTPostAPIWebhookWithTokenSlackResult = never;
/**
* Received when a call to https://discord.com/developers/docs/resources/webhook#execute-webhook receives
* the `wait` query parameter set to `true`
*
* See https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook-querystring-params
*/
export type RESTPostAPIWebhookWithTokenSlackWaitResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook-querystring-params
*/
export type RESTPostAPIWebhookWithTokenGitHubQuery = RESTPostAPIWebhookWithTokenQuery;
/**
* https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook
*/
export type RESTPostAPIWebhookWithTokenGitHubResult = never;
/**
* Received when a call to https://discord.com/developers/docs/resources/webhook#execute-webhook receives
* the `wait` query parameter set to `true`
*
* See https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook-querystring-params
*/
export type RESTPostAPIWebhookWithTokenGitHubWaitResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/webhook#get-webhook-message
*/
export type RESTGetAPIWebhookWithTokenMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
*/
export interface RESTPatchAPIWebhookWithTokenMessageJSONBody
extends Nullable<
Pick<RESTPostAPIWebhookWithTokenJSONBody, 'content' | 'embeds' | 'allowed_mentions' | 'components'>
> {
/**
* Attached files to keep
*
* See https://discord.com/developers/docs/resources/channel#attachment-object
*/
attachments?: APIAttachment[] | null;
}
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
*/
export type RESTPatchAPIWebhookWithTokenMessageFormDataBody =
| {
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPatchAPIWebhookWithTokenMessageJSONBody & {
/**
* The file contents
*/
file: unknown;
});
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
*/
export type RESTPatchAPIWebhookWithTokenMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/webhook#delete-webhook-message
*/
export type RESTDeleteAPIWebhookWithTokenMessageResult = never;

View File

@@ -1,4 +1,4 @@
// This file exports all the types available in the recommended API version
// Thereby, things MAY break in the future. Try sticking to imports from a specific version
export * from './v8.ts';
export * from './v9.ts';

View File

@@ -9,7 +9,7 @@ export enum RPCErrorCodes {
InvalidEvent,
InvalidChannel,
InvalidPermissions,
InvalidClientID,
InvalidClientId,
InvalidOrigin,
InvalidToken,
InvalidUser,
@@ -24,7 +24,7 @@ export enum RPCErrorCodes {
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc-rpc-close-event-codes
*/
export enum RPCCloseEventCodes {
InvalidClientID = 4000,
InvalidClientId = 4000,
InvalidOrigin,
RateLimited,
TokenRevoked,

33
deno/rpc/v9.ts Normal file
View File

@@ -0,0 +1,33 @@
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc-rpc-error-codes
*/
export enum RPCErrorCodes {
UnknownError = 1000,
InvalidPayload = 4000,
InvalidCommand = 4002,
InvalidGuild,
InvalidEvent,
InvalidChannel,
InvalidPermissions,
InvalidClientId,
InvalidOrigin,
InvalidToken,
InvalidUser,
OAuth2Error = 5000,
SelectChannelTimedOut,
GetGuildTimedOut,
SelectVoiceForceRequired,
CaptureShortcutAlreadyListening,
}
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc-rpc-close-event-codes
*/
export enum RPCCloseEventCodes {
InvalidClientId = 4000,
InvalidOrigin,
RateLimited,
TokenRevoked,
InvalidVersion,
InvalidEncoding,
}

3
deno/utils/internals.ts Normal file
View File

@@ -0,0 +1,3 @@
export type Nullable<T> = {
[P in keyof T]: T[P] | null;
};

View File

@@ -1,4 +1,4 @@
// This file exports all the utility functions available in the recommended API / Gateway version
// Thereby, things MAY break in the future. Try sticking to imports from a specific version
export * from './v8.ts';
export * from './v9.ts';

View File

@@ -2,33 +2,55 @@ import {
APIApplicationCommandDMInteraction,
APIApplicationCommandGuildInteraction,
APIApplicationCommandInteraction,
APIButtonComponent,
APIButtonComponentWithCustomId,
APIButtonComponentWithURL,
APIDMInteraction,
APIGuildInteraction,
APIInteraction,
APIMessageComponentDMInteraction,
APIMessageComponentGuildInteraction,
APIMessageComponentInteraction,
ButtonStyle,
} from '../payloads/v8/mod.ts';
// Interactions
/**
* A type-guard check for guild interactions.
* @param interaction The interaction to check against the
* @returns A boolean that indicates if the interaction was received from a guild
* A type-guard check for DM interactions
* @param interaction The interaction to check against
* @returns A boolean that indicates if the interaction was received in a DM channel
*/
export function isDMInteraction(interaction: APIInteraction): interaction is APIDMInteraction {
return Reflect.has(interaction, 'user');
}
/**
* A type-guard check for guild interactions
* @param interaction The interaction to check against
* @returns A boolean that indicates if the interaction was received in a guild
*/
export function isGuildInteraction(interaction: APIInteraction): interaction is APIGuildInteraction {
return Reflect.has(interaction, 'guild_id');
}
// ApplicationCommandInteractions
/**
* A type-guard check for DM interactions.
* @param interaction The interaction to check against
* @returns A boolean that indicates if the interaction was received from a direct message
* A type-guard check for DM application command interactions
* @param interaction The application command interaction to check against
* @returns A boolean that indicates if the application command interaction was received in a DM channel
*/
export function isDMInteraction(interaction: APIInteraction): interaction is APIDMInteraction {
return !isGuildInteraction(interaction);
export function isApplicationCommandDMInteraction(
interaction: APIApplicationCommandInteraction,
): interaction is APIApplicationCommandDMInteraction {
return isDMInteraction(interaction);
}
/**
* A type-guard check for guild application command interactions.
* A type-guard check for guild application command interactions
* @param interaction The interaction to check against
* @returns A boolean that indicates if the command interaction was received from a guild
* @returns A boolean that indicates if the application command interaction was received in a guild
*/
export function isApplicationCommandGuildInteraction(
interaction: APIApplicationCommandInteraction,
@@ -36,13 +58,46 @@ export function isApplicationCommandGuildInteraction(
return isGuildInteraction(interaction);
}
// MessageComponentInteractions
/**
* A type-guard check for direct message application command interactions.
* @param interaction The interaction to check against
* @returns A boolean that indicates if the command interaction was received from a direct message
* A type-guard check for DM message component interactions
* @param interaction The message component interaction to check against
* @returns A boolean that indicates if the message component interaction was received in a DM channel
*/
export function isApplicationCommandDMInteraction(
interaction: APIApplicationCommandInteraction,
): interaction is APIApplicationCommandDMInteraction {
return !isGuildInteraction(interaction);
export function isMessageComponentDMInteraction(
interaction: APIMessageComponentInteraction,
): interaction is APIMessageComponentDMInteraction {
return isDMInteraction(interaction);
}
/**
* A type-guard check for guild message component interactions
* @param interaction The interaction to check against
* @returns A boolean that indicates if the message component interaction was received in a guild
*/
export function isMessageComponentGuildInteraction(
interaction: APIMessageComponentInteraction,
): interaction is APIMessageComponentGuildInteraction {
return isGuildInteraction(interaction);
}
// Buttons
/**
* A type-guard check for buttons that have a `url` attached to them.
* @param component The button to check against
* @returns A boolean that indicates if the button has a `url` attached to it
*/
export function isLinkButton(component: APIButtonComponent): component is APIButtonComponentWithURL {
return component.style === ButtonStyle.Link;
}
/**
* A type-guard check for buttons that have a `custom_id` attached to them.
* @param button The button to check against
* @returns A boolean that indicates if the button has a `custom_id` attached to it
*/
export function isInteractionButton(component: APIButtonComponent): component is APIButtonComponentWithCustomId {
return component.style !== ButtonStyle.Link;
}

103
deno/utils/v9.ts Normal file
View File

@@ -0,0 +1,103 @@
import {
APIApplicationCommandDMInteraction,
APIApplicationCommandGuildInteraction,
APIApplicationCommandInteraction,
APIButtonComponent,
APIButtonComponentWithCustomId,
APIButtonComponentWithURL,
APIDMInteraction,
APIGuildInteraction,
APIInteraction,
APIMessageComponentDMInteraction,
APIMessageComponentGuildInteraction,
APIMessageComponentInteraction,
ButtonStyle,
} from '../payloads/v9/mod.ts';
// Interactions
/**
* A type-guard check for DM interactions
* @param interaction The interaction to check against
* @returns A boolean that indicates if the interaction was received in a DM channel
*/
export function isDMInteraction(interaction: APIInteraction): interaction is APIDMInteraction {
return Reflect.has(interaction, 'user');
}
/**
* A type-guard check for guild interactions
* @param interaction The interaction to check against
* @returns A boolean that indicates if the interaction was received in a guild
*/
export function isGuildInteraction(interaction: APIInteraction): interaction is APIGuildInteraction {
return Reflect.has(interaction, 'guild_id');
}
// ApplicationCommandInteractions
/**
* A type-guard check for DM application command interactions
* @param interaction The application command interaction to check against
* @returns A boolean that indicates if the application command interaction was received in a DM channel
*/
export function isApplicationCommandDMInteraction(
interaction: APIApplicationCommandInteraction,
): interaction is APIApplicationCommandDMInteraction {
return isDMInteraction(interaction);
}
/**
* A type-guard check for guild application command interactions
* @param interaction The interaction to check against
* @returns A boolean that indicates if the application command interaction was received in a guild
*/
export function isApplicationCommandGuildInteraction(
interaction: APIApplicationCommandInteraction,
): interaction is APIApplicationCommandGuildInteraction {
return isGuildInteraction(interaction);
}
// MessageComponentInteractions
/**
* A type-guard check for DM message component interactions
* @param interaction The message component interaction to check against
* @returns A boolean that indicates if the message component interaction was received in a DM channel
*/
export function isMessageComponentDMInteraction(
interaction: APIMessageComponentInteraction,
): interaction is APIMessageComponentDMInteraction {
return isDMInteraction(interaction);
}
/**
* A type-guard check for guild message component interactions
* @param interaction The interaction to check against
* @returns A boolean that indicates if the message component interaction was received in a guild
*/
export function isMessageComponentGuildInteraction(
interaction: APIMessageComponentInteraction,
): interaction is APIMessageComponentGuildInteraction {
return isGuildInteraction(interaction);
}
// Buttons
/**
* A type-guard check for buttons that have a `url` attached to them.
* @param component The button to check against
* @returns A boolean that indicates if the button has a `url` attached to it
*/
export function isLinkButton(component: APIButtonComponent): component is APIButtonComponentWithURL {
return component.style === ButtonStyle.Link;
}
/**
* A type-guard check for buttons that have a `custom_id` attached to them.
* @param button The button to check against
* @returns A boolean that indicates if the button has a `custom_id` attached to it
*/
export function isInteractionButton(component: APIButtonComponent): component is APIButtonComponentWithCustomId {
return component.style !== ButtonStyle.Link;
}

6
deno/v9.ts Normal file
View File

@@ -0,0 +1,6 @@
export * from './globals.ts';
export * from './gateway/v9.ts';
export * from './payloads/v9/mod.ts';
export * from './rest/v9/mod.ts';
export * from './rpc/v9.ts';
export * as Utils from './utils/v9.ts';

View File

@@ -3,7 +3,7 @@ export const VoiceGatewayVersion = '4';
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-opcodes
*/
export enum VoiceOPCodes {
export enum VoiceOpcodes {
/**
* Begin a voice websocket connection
*/
@@ -61,7 +61,7 @@ export enum VoiceCloseCodes {
/**
* You sent an invalid opcode
*/
UnknownOpCode = 4001,
UnknownOpcode = 4001,
/**
* You sent a invalid payload in your identifying to the Gateway
*/

View File

@@ -1,4 +1,4 @@
// This file exports all the types available in the recommended gateway version
// Thereby, things MAY break in the future. Try sticking to imports from a specific version
export * from './v8';
export * from './v9';

View File

@@ -13,7 +13,10 @@ import type {
APIGuildIntegration,
APIGuildMember,
APIMessage,
APIMessageComponentInteraction,
APIRole,
APIStageInstance,
APISticker,
APIUnavailableGuild,
APIUser,
GatewayActivity,
@@ -22,6 +25,7 @@ import type {
InviteTargetType,
PresenceUpdateStatus,
} from '../payloads/v8/index';
import type { Nullable } from '../utils/internals';
export * from './common';
@@ -30,7 +34,7 @@ export const GatewayVersion = '8';
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes
*/
export const enum GatewayOPCodes {
export const enum GatewayOpcodes {
/**
* An event was dispatched
*/
@@ -91,7 +95,7 @@ export const enum GatewayCloseCodes {
*
* See https://discord.com/developers/docs/topics/gateway#payloads-and-opcodes
*/
UnknownOpCode,
UnknownOpcode,
/**
* You sent an invalid payload to us. Don't do that!
*
@@ -165,21 +169,21 @@ export const enum GatewayCloseCodes {
* https://discord.com/developers/docs/topics/gateway#list-of-intents
*/
export const enum GatewayIntentBits {
GUILDS = 1 << 0,
GUILD_MEMBERS = 1 << 1,
GUILD_BANS = 1 << 2,
GUILD_EMOJIS = 1 << 3,
GUILD_INTEGRATIONS = 1 << 4,
GUILD_WEBHOOKS = 1 << 5,
GUILD_INVITES = 1 << 6,
GUILD_VOICE_STATES = 1 << 7,
GUILD_PRESENCES = 1 << 8,
GUILD_MESSAGES = 1 << 9,
GUILD_MESSAGE_REACTIONS = 1 << 10,
GUILD_MESSAGE_TYPING = 1 << 11,
DIRECT_MESSAGES = 1 << 12,
DIRECT_MESSAGE_REACTIONS = 1 << 13,
DIRECT_MESSAGE_TYPING = 1 << 14,
Guilds = 1 << 0,
GuildMembers = 1 << 1,
GuildBans = 1 << 2,
GuildEmojisAndStickers = 1 << 3,
GuildIntegrations = 1 << 4,
GuildWebhooks = 1 << 5,
GuildInvites = 1 << 6,
GuildVoiceStates = 1 << 7,
GuildPresences = 1 << 8,
GuildMessages = 1 << 9,
GuildMessageReactions = 1 << 10,
GuildMessageTyping = 1 << 11,
DirectMessages = 1 << 12,
DirectMessageReactions = 1 << 13,
DirectMessageTyping = 1 << 14,
}
/**
@@ -206,6 +210,7 @@ export const enum GatewayDispatchEvents {
GuildRoleCreate = 'GUILD_ROLE_CREATE',
GuildRoleDelete = 'GUILD_ROLE_DELETE',
GuildRoleUpdate = 'GUILD_ROLE_UPDATE',
GuildStickersUpdate = 'GUILD_STICKERS_UPDATE',
GuildUpdate = 'GUILD_UPDATE',
IntegrationCreate = 'INTEGRATION_CREATE',
IntegrationDelete = 'INTEGRATION_DELETE',
@@ -222,6 +227,9 @@ export const enum GatewayDispatchEvents {
MessageReactionRemoveEmoji = 'MESSAGE_REACTION_REMOVE_EMOJI',
MessageUpdate = 'MESSAGE_UPDATE',
PresenceUpdate = 'PRESENCE_UPDATE',
StageInstanceCreate = 'STAGE_INSTANCE_CREATE',
StageInstanceDelete = 'STAGE_INSTANCE_DELETE',
StageInstanceUpdate = 'STAGE_INSTANCE_UPDATE',
Ready = 'READY',
Resumed = 'RESUMED',
TypingStart = 'TYPING_START',
@@ -261,6 +269,7 @@ export type GatewayDispatchPayload =
| GatewayGuildModifyDispatch
| GatewayGuildRoleDeleteDispatch
| GatewayGuildRoleModifyDispatch
| GatewayGuildStickersUpdateDispatch
| GatewayIntegrationCreateDispatch
| GatewayIntegrationDeleteDispatch
| GatewayIntegrationUpdateDispatch
@@ -276,6 +285,9 @@ export type GatewayDispatchPayload =
| GatewayMessageReactionRemoveEmojiDispatch
| GatewayMessageUpdateDispatch
| GatewayPresenceUpdateDispatch
| GatewayStageInstanceCreateDispatch
| GatewayStageInstanceDeleteDispatch
| GatewayStageInstanceUpdateDispatch
| GatewayReadyDispatch
| GatewayResumedDispatch
| GatewayTypingStartDispatch
@@ -303,9 +315,7 @@ export type GatewayApplicationCommandModifyDispatch = DataPayload<
* https://discord.com/developers/docs/topics/gateway#application-command-update
* https://discord.com/developers/docs/topics/gateway#application-command-delete
*/
export interface GatewayApplicationCommandModifyDispatchData extends APIApplicationCommand {
guild_id?: string;
}
export type GatewayApplicationCommandModifyDispatchData = APIApplicationCommand;
/**
* https://discord.com/developers/docs/topics/gateway#application-command-create
@@ -341,7 +351,7 @@ export type GatewayApplicationCommandDeleteDispatchData = GatewayApplicationComm
* https://discord.com/developers/docs/topics/gateway#hello
*/
export interface GatewayHello extends NonDispatchPayload {
op: GatewayOPCodes.Hello;
op: GatewayOpcodes.Hello;
d: GatewayHelloData;
}
@@ -359,7 +369,7 @@ export interface GatewayHelloData {
* https://discord.com/developers/docs/topics/gateway#heartbeating
*/
export interface GatewayHeartbeatRequest extends NonDispatchPayload {
op: GatewayOPCodes.Heartbeat;
op: GatewayOpcodes.Heartbeat;
d: never;
}
@@ -367,7 +377,7 @@ export interface GatewayHeartbeatRequest extends NonDispatchPayload {
* https://discord.com/developers/docs/topics/gateway#heartbeating-example-gateway-heartbeat-ack
*/
export interface GatewayHeartbeatAck extends NonDispatchPayload {
op: GatewayOPCodes.HeartbeatAck;
op: GatewayOpcodes.HeartbeatAck;
d: never;
}
@@ -375,7 +385,7 @@ export interface GatewayHeartbeatAck extends NonDispatchPayload {
* https://discord.com/developers/docs/topics/gateway#invalid-session
*/
export interface GatewayInvalidSession extends NonDispatchPayload {
op: GatewayOPCodes.InvalidSession;
op: GatewayOpcodes.InvalidSession;
d: GatewayInvalidSessionData;
}
@@ -388,7 +398,7 @@ export type GatewayInvalidSessionData = boolean;
* https://discord.com/developers/docs/topics/gateway#reconnect
*/
export interface GatewayReconnect extends NonDispatchPayload {
op: GatewayOPCodes.Reconnect;
op: GatewayOpcodes.Reconnect;
d: never;
}
@@ -432,7 +442,7 @@ export interface GatewayReadyDispatchData {
/**
* Contains `id` and `flags`
*
* See https://discord.com/developers/docs/topics/oauth2#application-object
* See https://discord.com/developers/docs/resources/application#application-object
*/
application: Pick<APIApplication, 'id' | 'flags'>;
}
@@ -630,6 +640,30 @@ export interface GatewayGuildEmojisUpdateDispatchData {
emojis: APIEmoji[];
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-stickers-update
*/
export type GatewayGuildStickersUpdateDispatch = DataPayload<
GatewayDispatchEvents.GuildStickersUpdate,
GatewayGuildStickersUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-stickers-update
*/
export interface GatewayGuildStickersUpdateDispatchData {
/**
* ID of the guild
*/
guild_id: Snowflake;
/**
* Array of stickers
*
* See https://discord.com/developers/docs/resources/sticker#sticker-object
*/
stickers: APISticker[];
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-integrations-update
*/
@@ -701,9 +735,10 @@ export type GatewayGuildMemberUpdateDispatch = DataPayload<
/**
* https://discord.com/developers/docs/topics/gateway#guild-member-update
*/
export type GatewayGuildMemberUpdateDispatchData = Omit<APIGuildMember, 'deaf' | 'mute' | 'user'> &
export type GatewayGuildMemberUpdateDispatchData = Omit<APIGuildMember, 'deaf' | 'mute' | 'user' | 'joined_at'> &
Partial<Pick<APIGuildMember, 'deaf' | 'mute'>> &
Required<Pick<APIGuildMember, 'user'>> & {
Required<Pick<APIGuildMember, 'user'>> &
Nullable<Pick<APIGuildMember, 'joined_at'>> & {
/**
* The id of the guild
*/
@@ -889,7 +924,7 @@ export type GatewayInteractionCreateDispatch = DataPayload<
/**
* https://discord.com/developers/docs/topics/gateway#interaction-create
*/
export type GatewayInteractionCreateDispatchData = APIApplicationCommandInteraction;
export type GatewayInteractionCreateDispatchData = APIApplicationCommandInteraction | APIMessageComponentInteraction;
/**
* https://discord.com/developers/docs/topics/gateway#invite-create
@@ -1134,6 +1169,45 @@ export type GatewayPresenceUpdateDispatch = DataPayload<
*/
export type GatewayPresenceUpdateDispatchData = RawGatewayPresenceUpdate;
/**
* https://discord.com/developers/docs/topics/gateway#stage-instance-create
*/
export type GatewayStageInstanceCreateDispatch = DataPayload<
GatewayDispatchEvents.StageInstanceCreate,
GatewayStageInstanceCreateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#stage-instance-create
*/
export type GatewayStageInstanceCreateDispatchData = APIStageInstance;
/**
* https://discord.com/developers/docs/topics/gateway#stage-instance-delete
*/
export type GatewayStageInstanceDeleteDispatch = DataPayload<
GatewayDispatchEvents.StageInstanceDelete,
GatewayStageInstanceDeleteDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#stage-instance-delete
*/
export type GatewayStageInstanceDeleteDispatchData = APIStageInstance;
/**
* https://discord.com/developers/docs/topics/gateway#stage-instance-update
*/
export type GatewayStageInstanceUpdateDispatch = DataPayload<
GatewayDispatchEvents.StageInstanceUpdate,
GatewayStageInstanceUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#stage-instance-update
*/
export type GatewayStageInstanceUpdateDispatchData = APIStageInstance;
/**
* https://discord.com/developers/docs/topics/gateway#typing-start
*/
@@ -1250,7 +1324,7 @@ export interface GatewayWebhooksUpdateDispatchData {
* https://discord.com/developers/docs/topics/gateway#heartbeating
*/
export interface GatewayHeartbeat {
op: GatewayOPCodes.Heartbeat;
op: GatewayOpcodes.Heartbeat;
d: GatewayHeartbeatData;
}
@@ -1263,7 +1337,7 @@ export type GatewayHeartbeatData = number | null;
* https://discord.com/developers/docs/topics/gateway#identify
*/
export interface GatewayIdentify {
op: GatewayOPCodes.Identify;
op: GatewayOpcodes.Identify;
d: GatewayIdentifyData;
}
@@ -1303,7 +1377,7 @@ export interface GatewayIdentifyData {
/**
* Presence structure for initial presence information
*
* See https://discord.com/developers/docs/topics/gateway#update-status
* See https://discord.com/developers/docs/topics/gateway#update-presence
*/
presence?: GatewayPresenceUpdateData;
/**
@@ -1336,7 +1410,7 @@ export interface GatewayIdentifyProperties {
* https://discord.com/developers/docs/topics/gateway#resume
*/
export interface GatewayResume {
op: GatewayOPCodes.Resume;
op: GatewayOpcodes.Resume;
d: GatewayResumeData;
}
@@ -1362,7 +1436,7 @@ export interface GatewayResumeData {
* https://discord.com/developers/docs/topics/gateway#request-guild-members
*/
export interface GatewayRequestGuildMembers {
op: GatewayOPCodes.RequestGuildMembers;
op: GatewayOpcodes.RequestGuildMembers;
d: GatewayRequestGuildMembersData;
}
@@ -1405,7 +1479,7 @@ export interface GatewayRequestGuildMembersData {
* https://discord.com/developers/docs/topics/gateway#update-voice-state
*/
export interface GatewayVoiceStateUpdate {
op: GatewayOPCodes.VoiceStateUpdate;
op: GatewayOpcodes.VoiceStateUpdate;
d: GatewayVoiceStateUpdateData;
}
@@ -1432,15 +1506,15 @@ export interface GatewayVoiceStateUpdateData {
}
/**
* https://discord.com/developers/docs/topics/gateway#update-status
* https://discord.com/developers/docs/topics/gateway#update-presence
*/
export interface GatewayUpdatePresence {
op: GatewayOPCodes.PresenceUpdate;
op: GatewayOpcodes.PresenceUpdate;
d: GatewayPresenceUpdateData;
}
/**
* https://discord.com/developers/docs/topics/gateway#update-status-gateway-status-update-structure
* https://discord.com/developers/docs/topics/gateway#update-presence-gateway-presence-update-structure
*/
export interface GatewayPresenceUpdateData {
/**
@@ -1456,7 +1530,7 @@ export interface GatewayPresenceUpdateData {
/**
* The user's new status
*
* See https://discord.com/developers/docs/topics/gateway#update-status-status-types
* See https://discord.com/developers/docs/topics/gateway#update-presence-status-types
*/
status: PresenceUpdateStatus;
/**
@@ -1477,7 +1551,7 @@ interface BasePayload {
/**
* Opcode for the payload
*/
op: GatewayOPCodes;
op: GatewayOpcodes;
/**
* Event data
*/
@@ -1495,7 +1569,7 @@ interface BasePayload {
type NonDispatchPayload = Omit<BasePayload, 't'>;
interface DataPayload<Event extends GatewayDispatchEvents, D = unknown> extends BasePayload {
op: GatewayOPCodes.Dispatch;
op: GatewayOpcodes.Dispatch;
t: Event;
d: D;
}

1717
gateway/v9.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,13 @@
/**
* https://discord.com/developers/docs/reference#snowflakes
*/
export type Snowflake = `${bigint}`;
export type Snowflake = string;
/**
* https://discord.com/developers/docs/topics/permissions
* @internal
*/
export type Permissions = `${bigint}`;
export type Permissions = string;
/**
* https://discord.com/developers/docs/reference#message-formatting-formats
@@ -61,6 +61,24 @@ export const FormattingPatterns = {
* The `name` and `id` group properties are present on the `exec` result of this expression
*/
StaticEmoji: /<:(?<name>\w{2,32}):(?<id>\d{17,20})>/,
/**
* Regular expression for matching a timestamp, either default or custom styled
*
* The `timestamp` and `style` group properties are present on the `exec` result of this expression
*/
Timestamp: /<t:(?<timestamp>-?\d{1,13})(:(?<style>[tTdDfFR]))?>/,
/**
* Regular expression for matching strictly default styled timestamps
*
* The `timestamp` group property is present on the `exec` result of this expression
*/
DefaultStyledTimestamp: /<t:(?<timestamp>-?\d{1,13})>/,
/**
* Regular expression for matching strictly custom styled timestamps
*
* The `timestamp` and `style` group properties are present on the `exec` result of this expression
*/
StyledTimestamp: /<t:(?<timestamp>-?\d{1,13}):(?<style>[tTdDfFR])>/,
} as const;
/**

2488
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,10 @@
{
"name": "discord-api-types",
"version": "0.18.0",
"version": "0.22.0",
"description": "Discord API typings that are kept up to date for use in bot library creation.",
"main": "./v8.js",
"module": "./v8.mjs",
"types": "./v8.d.ts",
"main": "./v9.js",
"module": "./v9.mjs",
"types": "./v9.d.ts",
"exports": {
"./globals": {
"require": "./globals.js",
@@ -18,6 +18,10 @@
"require": "./v8.js",
"import": "./v8.mjs"
},
"./v9": {
"require": "./v9.js",
"import": "./v9.mjs"
},
"./gateway": {
"require": "./gateway/index.js",
"import": "./gateway/index.mjs"
@@ -72,20 +76,24 @@
"build:deno": "node ./scripts/deno.mjs",
"build:node": "tsc && run-p esm:*",
"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:node": "rimraf {gateway,payloads,rest,rpc,voice,utils}/**/*.{js,mjs,d.ts,*map} {globals,v*}.{js,mjs,d.ts,*map}",
"clean": "run-p clean:*",
"esm:gateway": "gen-esm-wrapper ./gateway/index.js ./gateway/index.mjs",
"esm:globals": "gen-esm-wrapper ./globals.js ./globals.mjs",
"esm:payloads": "gen-esm-wrapper ./payloads/index.js ./payloads/index.mjs",
"esm:rest": "gen-esm-wrapper ./rest/index.js ./rest/index.mjs",
"esm:rpc": "gen-esm-wrapper ./rpc/index.js ./rpc/index.mjs",
"esm:utils": "gen-esm-wrapper ./utils/index.js ./utils/index.mjs",
"esm:voice": "gen-esm-wrapper ./voice/index.js ./voice/index.mjs",
"esm:globals": "gen-esm-wrapper ./globals.js ./globals.mjs",
"esm:versions": "node ./scripts/versions.mjs",
"lint": "eslint --fix --ext mjs,ts {gateway,payloads,rest,rpc,voice,utils}/** {globals,v*}.ts",
"test:lint": "eslint --ext mjs,ts {gateway,payloads,rest,rpc,voice,utils}/** {globals,v*}.ts",
"prepublishOnly": "run-s clean test:lint build:node",
"esm:voice": "gen-esm-wrapper ./voice/index.js ./voice/index.mjs",
"lint": "eslint --fix --ext mjs,ts {gateway,payloads,rest,rpc,voice,utils}/**/*.ts {globals,v*}.ts",
"postpublish": "run-s clean:node build:deno",
"prepare": "is-ci || husky install",
"prepublishOnly": "run-s clean test:lint build:node",
"test:lint": "eslint --ext mjs,ts {gateway,payloads,rest,rpc,voice,utils}/**/*.ts {globals,v*}.ts",
"pretest:types": "tsc",
"test:types": "tsd",
"posttest:types": "npm run clean:node",
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md"
},
"keywords": [
@@ -104,27 +112,29 @@
"node": ">=12"
},
"devDependencies": {
"@babel/core": "^7.13.15",
"@babel/eslint-parser": "^7.13.14",
"@babel/plugin-syntax-top-level-await": "^7.12.13",
"@commitlint/cli": "^12.1.1",
"@commitlint/config-angular": "^12.1.1",
"@types/node": "^14.14.37",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"@babel/core": "^7.14.6",
"@babel/eslint-parser": "^7.14.7",
"@babel/plugin-syntax-top-level-await": "^7.14.5",
"@commitlint/cli": "^12.1.4",
"@commitlint/config-angular": "^12.1.4",
"@types/node": "^16.3.3",
"@typescript-eslint/eslint-plugin": "^4.28.3",
"@typescript-eslint/parser": "^4.28.3",
"conventional-changelog-cli": "^2.1.1",
"eslint": "^7.24.0",
"eslint-config-marine": "^8.3.2",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.1",
"gen-esm-wrapper": "^1.1.1",
"husky": "^4.3.8",
"lint-staged": "^10.5.4",
"eslint": "^7.30.0",
"eslint-config-marine": "^9.0.6",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"gen-esm-wrapper": "^1.1.2",
"husky": "^7.0.1",
"is-ci": "^3.0.0",
"lint-staged": "^11.0.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0",
"prettier": "^2.3.2",
"pretty-quick": "^3.1.1",
"rimraf": "^3.0.2",
"typescript": "^4.2.4"
"tsd": "^0.17.0",
"typescript": "^4.3.5"
},
"repository": {
"type": "git",
@@ -154,15 +164,9 @@
}
]
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged && lint-staged && npm run build:deno && git add deno",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"{gateway,payloads,rest,rpc,voice,shortcuts,utils}/**/*.{mjs,js,ts}": "eslint --fix --ext mjs,js,ts",
"globals.ts": "eslint --fix --ext mjs,js,ts"
"{gateway,payloads,rest,rpc,voice,utils}/**/*.{mjs,js,ts}": "eslint --fix --ext mjs,js,ts",
"{globals,v*}.ts": "eslint --fix --ext mjs,js,ts"
},
"commitlint": {
"extends": [
@@ -194,5 +198,15 @@
"pascal-case"
]
}
},
"standard-version": {
"skip": {
"changelog": true,
"commit": true,
"tag": true
}
},
"tsd": {
"directory": "tests"
}
}

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