Compare commits

...

22 Commits

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

* fix: actually make the changelog generation work

* chore: cleanup

* chore: safety

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

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

* fix: add github token to branch creation

* fix: actually patch the module on install

* chore: cleanup some more of the PR

* chore: make the script more agnostic

* chore: cleanup package-lock

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

* chore: add missing field
2022-05-25 09:22:51 +03:00
Superchupu
dc1c887821 chore: fix docs typo (#445) 2022-05-25 02:13:59 +03:00
dependabot[bot]
a088bb4f77 chore(deps): bump ejs from 3.1.6 to 3.1.8 in /website (#443)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Vlad <kingdgrizzle@gmail.com>
2022-05-25 00:30:42 +03:00
dependabot[bot]
f1cc0ab163 chore(deps): bump ansi-regex from 3.0.0 to 3.0.1 in /website (#442)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-25 00:29:11 +03:00
Vlad Frangu
c8ba0c9319 chore: docs site (#405) 2022-05-25 00:23:55 +03:00
155 changed files with 35698 additions and 635 deletions

2
.github/labeler.yml vendored
View File

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

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

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

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

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

View File

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

View File

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

View File

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

View File

@@ -1,3 +1,22 @@
## [0.33.2](https://github.com/discordjs/discord-api-types/compare/0.33.1...0.33.2) (2022-06-01)
### Bug Fixes
- **docs-site:** website link colors ([#457](https://github.com/discordjs/discord-api-types/issues/457)) ([51e664d](https://github.com/discordjs/discord-api-types/commit/51e664d8e826e7f0aa467c000f3a1707fc283a36))
- **GatewayGuildCreateDispatch:** add extra fields that were missing ([#458](https://github.com/discordjs/discord-api-types/issues/458)) ([15fcd1b](https://github.com/discordjs/discord-api-types/commit/15fcd1b2a85e8d1e136416a66326a4aadcc301fb))
- **RestPostAPIBaseApplicationJSONBody:** make `default_member_permissions` optional ([#460](https://github.com/discordjs/discord-api-types/issues/460)) ([6a813be](https://github.com/discordjs/discord-api-types/commit/6a813be83382e1606f1921cf00179fe1ce75c04f))
## [0.33.1](https://github.com/discordjs/discord-api-types/compare/0.33.0...0.33.1) (2022-05-26)
### Bug Fixes
- **RESTPostAPIApplicationGuildCommands:** correct types due to unions ([#447](https://github.com/discordjs/discord-api-types/issues/447)) ([6d85ad6](https://github.com/discordjs/discord-api-types/commit/6d85ad6b1d707b980f9897ea68dd4b7573b3a770))
### Features
- **RESTJSONErrorCodes:** add error `50600` ([#444](https://github.com/discordjs/discord-api-types/issues/444)) ([5ef49f4](https://github.com/discordjs/discord-api-types/commit/5ef49f41cecaa1d5937428a5c58f1d88bfc61266))
- **RESTPostAPIGuildChannels:** update post body fields ([#419](https://github.com/discordjs/discord-api-types/issues/419)) ([748db34](https://github.com/discordjs/discord-api-types/commit/748db34e30338cf4a9fd8ce7b86d1d5c7dde63b1))
# [0.33.0](https://github.com/discordjs/discord-api-types/compare/0.32.1...0.33.0) (2022-05-16)
### Code Refactoring

View File

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

View File

@@ -1,3 +1,22 @@
## [0.33.2](https://github.com/discordjs/discord-api-types/compare/0.33.1...0.33.2) (2022-06-01)
### Bug Fixes
- **docs-site:** website link colors ([#457](https://github.com/discordjs/discord-api-types/issues/457)) ([51e664d](https://github.com/discordjs/discord-api-types/commit/51e664d8e826e7f0aa467c000f3a1707fc283a36))
- **GatewayGuildCreateDispatch:** add extra fields that were missing ([#458](https://github.com/discordjs/discord-api-types/issues/458)) ([15fcd1b](https://github.com/discordjs/discord-api-types/commit/15fcd1b2a85e8d1e136416a66326a4aadcc301fb))
- **RestPostAPIBaseApplicationJSONBody:** make `default_member_permissions` optional ([#460](https://github.com/discordjs/discord-api-types/issues/460)) ([6a813be](https://github.com/discordjs/discord-api-types/commit/6a813be83382e1606f1921cf00179fe1ce75c04f))
## [0.33.1](https://github.com/discordjs/discord-api-types/compare/0.33.0...0.33.1) (2022-05-26)
### Bug Fixes
- **RESTPostAPIApplicationGuildCommands:** correct types due to unions ([#447](https://github.com/discordjs/discord-api-types/issues/447)) ([6d85ad6](https://github.com/discordjs/discord-api-types/commit/6d85ad6b1d707b980f9897ea68dd4b7573b3a770))
### Features
- **RESTJSONErrorCodes:** add error `50600` ([#444](https://github.com/discordjs/discord-api-types/issues/444)) ([5ef49f4](https://github.com/discordjs/discord-api-types/commit/5ef49f41cecaa1d5937428a5c58f1d88bfc61266))
- **RESTPostAPIGuildChannels:** update post body fields ([#419](https://github.com/discordjs/discord-api-types/issues/419)) ([748db34](https://github.com/discordjs/discord-api-types/commit/748db34e30338cf4a9fd8ce7b86d1d5c7dde63b1))
# [0.33.0](https://github.com/discordjs/discord-api-types/compare/0.32.1...0.33.0) (2022-05-16)
### Code Refactoring

View File

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

View File

@@ -502,12 +502,8 @@ export interface GatewayChannelPinsUpdateDispatchData {
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-update
*/
export type GatewayGuildModifyDispatch = DataPayload<
GatewayDispatchEvents.GuildCreate | GatewayDispatchEvents.GuildUpdate,
GatewayGuildModifyDispatchData
>;
export type GatewayGuildModifyDispatch = DataPayload<GatewayDispatchEvents.GuildUpdate, GatewayGuildModifyDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-update
@@ -517,13 +513,13 @@ export type GatewayGuildModifyDispatchData = APIGuild;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
*/
export type GatewayGuildCreateDispatch = GatewayGuildModifyDispatch;
export type GatewayGuildCreateDispatch = DataPayload<GatewayDispatchEvents.GuildCreate, GatewayGuildCreateDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-create-guild-create-extra-fields
*/
export type GatewayGuildCreateDispatchData = APIGuild & {
export interface GatewayGuildCreateDispatchData extends APIGuild {
/**
* When this guild was joined at
*
@@ -598,7 +594,7 @@ export type GatewayGuildCreateDispatchData = APIGuild & {
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object
*/
guild_scheduled_events: APIGuildScheduledEvent[];
};
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-update

View File

@@ -500,13 +500,9 @@ export interface GatewayChannelPinsUpdateDispatchData {
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-update
*/
export type GatewayGuildModifyDispatch = DataPayload<
GatewayDispatchEvents.GuildCreate | GatewayDispatchEvents.GuildUpdate,
GatewayGuildModifyDispatchData
>;
export type GatewayGuildModifyDispatch = DataPayload<GatewayDispatchEvents.GuildUpdate, GatewayGuildModifyDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-update
@@ -516,13 +512,13 @@ export type GatewayGuildModifyDispatchData = APIGuild;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
*/
export type GatewayGuildCreateDispatch = GatewayGuildModifyDispatch;
export type GatewayGuildCreateDispatch = DataPayload<GatewayDispatchEvents.GuildCreate, GatewayGuildCreateDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-create-guild-create-extra-fields
*/
export type GatewayGuildCreateDispatchData = APIGuild & {
export interface GatewayGuildCreateDispatchData extends APIGuild {
/**
* When this guild was joined at
*
@@ -597,7 +593,7 @@ export type GatewayGuildCreateDispatchData = APIGuild & {
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object
*/
guild_scheduled_events: APIGuildScheduledEvent[];
};
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-update

View File

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

View File

@@ -5,7 +5,7 @@ import type { Snowflake } from '../../../../globals.ts';
*/
export interface APIGuildApplicationCommandPermissions {
/**
* The id of the command
* The id of the command or the application id if that permission applies to all commands
*/
id: Snowflake;
/**

View File

@@ -73,11 +73,11 @@ export interface APIApplicationCommand {
/**
* Set of permissions represented as a bitset
*/
default_member_permissions?: Permissions | null;
default_member_permissions: Permissions | null;
/**
* Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible
*/
dm_permission?: boolean | null;
dm_permission?: boolean;
/**
* Whether the command is enabled by default when the app is added to a guild
*

View File

@@ -5,7 +5,7 @@ import type { Snowflake } from '../../../../globals.ts';
*/
export interface APIGuildApplicationCommandPermissions {
/**
* The id of the command
* The id of the command or the application id if that permission applies to all commands
*/
id: Snowflake;
/**

View File

@@ -73,11 +73,11 @@ export interface APIApplicationCommand {
/**
* Set of permissions represented as a bitset
*/
default_member_permissions?: Permissions | null;
default_member_permissions: Permissions | null;
/**
* Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible
*/
dm_permission?: boolean | null;
dm_permission?: boolean;
/**
* Whether the command is enabled by default when the app is added to a guild
*

View File

@@ -195,6 +195,8 @@ export enum RESTJSONErrorCodes {
RequestBodyContainsInvalidJSON = 50109,
YouDoNotHavePermissionToSendThisSticker = 50600,
TwoFactorAuthenticationIsRequired = 60003,
NoUsersWithDiscordTagExist = 80004,

View File

@@ -49,6 +49,8 @@ export type APIGuildCreatePartialChannel = StrictPartial<
| 'rate_limit_per_user'
| 'default_auto_archive_duration'
| 'position'
| 'rtc_region'
| 'video_quality_mode'
| 'flags'
>
> &

View File

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

View File

@@ -49,6 +49,8 @@ export type APIGuildCreatePartialChannel = StrictPartial<
| 'rate_limit_per_user'
| 'default_auto_archive_duration'
| 'position'
| 'rtc_region'
| 'video_quality_mode'
| 'flags'
>
> &

View File

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

View File

@@ -502,12 +502,8 @@ export interface GatewayChannelPinsUpdateDispatchData {
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-update
*/
export type GatewayGuildModifyDispatch = DataPayload<
GatewayDispatchEvents.GuildCreate | GatewayDispatchEvents.GuildUpdate,
GatewayGuildModifyDispatchData
>;
export type GatewayGuildModifyDispatch = DataPayload<GatewayDispatchEvents.GuildUpdate, GatewayGuildModifyDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-update
@@ -517,13 +513,13 @@ export type GatewayGuildModifyDispatchData = APIGuild;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
*/
export type GatewayGuildCreateDispatch = GatewayGuildModifyDispatch;
export type GatewayGuildCreateDispatch = DataPayload<GatewayDispatchEvents.GuildCreate, GatewayGuildCreateDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-create-guild-create-extra-fields
*/
export type GatewayGuildCreateDispatchData = APIGuild & {
export interface GatewayGuildCreateDispatchData extends APIGuild {
/**
* When this guild was joined at
*
@@ -598,7 +594,7 @@ export type GatewayGuildCreateDispatchData = APIGuild & {
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object
*/
guild_scheduled_events: APIGuildScheduledEvent[];
};
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-update

View File

@@ -500,13 +500,9 @@ export interface GatewayChannelPinsUpdateDispatchData {
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-update
*/
export type GatewayGuildModifyDispatch = DataPayload<
GatewayDispatchEvents.GuildCreate | GatewayDispatchEvents.GuildUpdate,
GatewayGuildModifyDispatchData
>;
export type GatewayGuildModifyDispatch = DataPayload<GatewayDispatchEvents.GuildUpdate, GatewayGuildModifyDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-update
@@ -516,13 +512,13 @@ export type GatewayGuildModifyDispatchData = APIGuild;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
*/
export type GatewayGuildCreateDispatch = GatewayGuildModifyDispatch;
export type GatewayGuildCreateDispatch = DataPayload<GatewayDispatchEvents.GuildCreate, GatewayGuildCreateDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-create-guild-create-extra-fields
*/
export type GatewayGuildCreateDispatchData = APIGuild & {
export interface GatewayGuildCreateDispatchData extends APIGuild {
/**
* When this guild was joined at
*
@@ -597,7 +593,7 @@ export type GatewayGuildCreateDispatchData = APIGuild & {
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object
*/
guild_scheduled_events: APIGuildScheduledEvent[];
};
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-update

1836
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@@ -5,7 +5,7 @@ import type { Snowflake } from '../../../../globals';
*/
export interface APIGuildApplicationCommandPermissions {
/**
* The id of the command
* The id of the command or the application id if that permission applies to all commands
*/
id: Snowflake;
/**

View File

@@ -73,11 +73,11 @@ export interface APIApplicationCommand {
/**
* Set of permissions represented as a bitset
*/
default_member_permissions?: Permissions | null;
default_member_permissions: Permissions | null;
/**
* Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible
*/
dm_permission?: boolean | null;
dm_permission?: boolean;
/**
* Whether the command is enabled by default when the app is added to a guild
*

View File

@@ -5,7 +5,7 @@ import type { Snowflake } from '../../../../globals';
*/
export interface APIGuildApplicationCommandPermissions {
/**
* The id of the command
* The id of the command or the application id if that permission applies to all commands
*/
id: Snowflake;
/**

View File

@@ -73,11 +73,11 @@ export interface APIApplicationCommand {
/**
* Set of permissions represented as a bitset
*/
default_member_permissions?: Permissions | null;
default_member_permissions: Permissions | null;
/**
* Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible
*/
dm_permission?: boolean | null;
dm_permission?: boolean;
/**
* Whether the command is enabled by default when the app is added to a guild
*

View File

@@ -195,6 +195,8 @@ export enum RESTJSONErrorCodes {
RequestBodyContainsInvalidJSON = 50109,
YouDoNotHavePermissionToSendThisSticker = 50600,
TwoFactorAuthenticationIsRequired = 60003,
NoUsersWithDiscordTagExist = 80004,

View File

@@ -49,6 +49,8 @@ export type APIGuildCreatePartialChannel = StrictPartial<
| 'rate_limit_per_user'
| 'default_auto_archive_duration'
| 'position'
| 'rtc_region'
| 'video_quality_mode'
| 'flags'
>
> &

View File

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

View File

@@ -49,6 +49,8 @@ export type APIGuildCreatePartialChannel = StrictPartial<
| 'rate_limit_per_user'
| 'default_auto_archive_duration'
| 'position'
| 'rtc_region'
| 'video_quality_mode'
| 'flags'
>
> &

View File

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

View File

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

View File

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

View File

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

22
website/.editorconfig Normal file
View File

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

13
website/.eslintignore Normal file
View File

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

141
website/.eslintrc Normal file
View File

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

33
website/.gitignore vendored Normal file
View File

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

View File

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

10
website/.prettierignore Normal file
View File

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

17
website/.prettierrc.js Normal file
View File

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

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

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

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

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

24
website/LICENSE.md Normal file
View File

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

27
website/README.md Normal file
View File

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

View File

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

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

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

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

View File

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

30509
website/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

103
website/package.json Normal file
View File

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

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

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

8
website/sidebars.js Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,18 @@
import clsx from 'clsx';
import React, { FC, memo } from 'react';
import styles from './HomePageHeader.module.css';
import InstallTabs from './InstallButton/InstallTabs';
const HomePageHeader: FC = () => (
<>
<header className={clsx('hero', styles.heroBanner)}>
<div className="container">
<img src="/svgs/logo_long_blurple.svg" alt="Discord API Types Logo" className={styles.logo}></img>
<h1 className={styles.fontSemiTitle}>In-depth typings you can use when working with Discord&#39;s API</h1>
<InstallTabs />
</div>
</header>
</>
);
export default memo(HomePageHeader);

View File

@@ -0,0 +1,6 @@
.features {
display: flex;
align-items: center;
padding: 2rem 0;
width: 100%;
}

View File

@@ -0,0 +1,52 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* THIRD_PARTY_LICENSE file in the `website` directory of this source tree.
*/
import React, { FC } from 'react';
import Feature from './Features/Feature';
import StatisticsFeature from './Features/StatisticsFeature';
import type { FeatureItem } from './Features/Types';
import styles from './HomepageFeatures.module.css';
const FeatureList: FeatureItem[] = [
{
title: 'About',
description: (
<>
discord-api-types is a simple module that helps you work with the data returned from Discord&#39;s API.
<br />
<br />
With this module, you&#39;re able to work with raw data while also making sure what you access exists, and what type it may be.
</>
)
},
{
title: 'Key Features',
description: (
<>
<ul>
<li>Supports both Node.js and Deno</li>
<li>Supports both CommonJS and ESM</li>
<li>Receives updates as fast as they are documented</li>
</ul>
</>
)
}
];
const HomePageFeatures: FC = () => (
<section className={styles.features}>
<div className="container">
<div className="row">
{FeatureList.map((props, idx) => (
<Feature key={idx} {...props} />
))}
<StatisticsFeature />
</div>
</div>
</section>
);
export default HomePageFeatures;

View File

@@ -0,0 +1,36 @@
.button {
box-shadow: var(--discord_api_types-paper-drop-shadow-4);
}
@media screen and (max-width: 966px) {
.button {
--ifm-button-size-multiplier: 1.25;
}
}
.buttonContent {
display: flex;
align-items: center;
}
.copyIcon {
height: 20px;
margin-left: 8px;
}
.colorGreen {
color: #3ba55c;
}
html[data-theme='dark'] .button {
background-color: #23272a;
border-color: #23272a;
}
html[data-theme='dark'] .button:hover {
background-color: #4f545c29;
}
html[data-theme='dark'] .buttonContent {
color: #b9bbbe;
}

View File

@@ -0,0 +1,41 @@
import { ClipboardCopyIcon } from '@heroicons/react/outline';
import Tippy from '@tippyjs/react';
import clsx from 'clsx';
import React, { FC, useState } from 'react';
import styles from './InstallTabButton.module.css';
interface Props {
installCommand: string;
handleClickInstallButton: () => void;
}
const InstallTabButton: FC<Props> = ({ installCommand, handleClickInstallButton }) => {
const [showTippy, setShowTippy] = useState(false);
const toggleTippy = () => {
setShowTippy(true);
setTimeout(() => {
setShowTippy(false);
}, 1000);
};
return (
<Tippy visible={showTippy} content="Copied!" placement="auto" arrow theme="discord">
<button
className={clsx('button', 'button--secondary', 'button--lg', styles.button)}
onClick={() => {
handleClickInstallButton();
toggleTippy();
}}
>
<div className={clsx(styles.buttonContent)}>
{installCommand}
<ClipboardCopyIcon className={styles.copyIcon} />
</div>
</button>
</Tippy>
);
};
export default InstallTabButton;

View File

@@ -0,0 +1,9 @@
.buttons {
display: flex;
align-items: center;
justify-content: center;
}
.tabs {
justify-content: center;
}

View File

@@ -0,0 +1,51 @@
import { npmToPnpm } from '@sapphire/docusaurus-plugin-npm2yarn2pnpm';
import TabItem from '@theme/TabItem';
import Tabs from '@theme/Tabs';
import npmToYarn from 'npm-to-yarn';
import React, { FC } from 'react';
import InstallTabButton from './InstallTabButton';
import styles from './InstallTabs.module.css';
const InstallTabs: FC = () => {
const npmInstallCommand = 'npm install discord-api-types';
const yarnInstallCommand = npmToYarn(npmInstallCommand, 'yarn');
const pnpmInstallCommand = npmToPnpm(npmInstallCommand);
const handleClickInstallButton = async (command: string) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
await window.navigator.clipboard.writeText(command);
};
return (
<div className={styles.buttons}>
<Tabs groupId="npm2yarn2pnpm" className={styles.tabs}>
<TabItem value="npm" label="npm" default>
<InstallTabButton
installCommand={npmInstallCommand}
handleClickInstallButton={() => {
void handleClickInstallButton(npmInstallCommand);
}}
/>
</TabItem>
<TabItem value="yarn" label="yarn">
<InstallTabButton
installCommand={yarnInstallCommand}
handleClickInstallButton={() => {
void handleClickInstallButton(yarnInstallCommand);
}}
/>
</TabItem>
<TabItem value="pnpm" label="pnpm">
<InstallTabButton
installCommand={pnpmInstallCommand}
handleClickInstallButton={() => {
void handleClickInstallButton(pnpmInstallCommand);
}}
/>
</TabItem>
</Tabs>
</div>
);
};
export default InstallTabs;

164
website/src/css/custom.scss Normal file
View File

@@ -0,0 +1,164 @@
:root {
--ifm-color-primary: #2563eb;
--ifm-color-primary-dark: #1554e0;
--ifm-color-primary-darker: #1350d4;
--ifm-color-primary-darkest: #1042ae;
--ifm-color-primary-light: #3e75ed;
--ifm-color-primary-lighter: #4a7eee;
--ifm-color-primary-lightest: #7098f2;
--ifm-code-font-size: 95%;
--ifm-font-family-monospace: 'Fira Code', 'Meslo NGF', 'JetBrains Mono', 'Menlo', SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
'Courier New', monospace;
--discord_api_types-paper-drop-shadow-4: rgb(0 0 0 / 20%) 0px 2px 4px -1px, rgb(0 0 0 / 14%) 0px 4px 5px 0px, rgb(0 0 0 / 12%) 0px 1px 10px 0px;
/* discord.js themeing */
--ifm-link-color: hsl(235, 85%, 65%);
--ifm-footer-link-color: hsl(235, 85%, 82%);
--ifm-navbar-background-color: #4752c4;
--ifm-menu-link-sublist-icon-filter: invert(100%) sepia(94%) saturate(17%) hue-rotate(223deg) brightness(104%) contrast(98%);
--ifm-navbar-height: 64px;
--ifm-navbar-link-color: #e5e7eb;
--ifm-navbar-link-active-color: #e5e7eb;
--ifm-navbar-link-hover-color: #e5e7eb;
--ifm-font-weight-semibold: 700;
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);
@media screen and (max-width: 997px) {
--ifm-menu-color: var(--ifm-navbar-link-color);
--ifm-menu-color-active: var(--ifm-navbar-link-hover-color);
--ifm-menu-color-background-active: rgba(255, 255, 255, 0.05);
}
}
html[data-theme='dark'] {
--ifm-color-primary: #81d4fa;
--ifm-color-primary-dark: #5dc8f9;
--ifm-color-primary-darker: #4ac1f8;
--ifm-color-primary-darkest: #14aff6;
--ifm-color-primary-light: #a5e0fb;
--ifm-color-primary-lighter: #b8e7fc;
--ifm-color-primary-lightest: #eef9fe;
--discord_api_types-paper-drop-shadow-4: rgb(0 0 0 / 20%) 0px 2px 4px -1px, rgb(0 0 0 / 14%) 0px 4px 5px 0px, rgb(0 0 0 / 12%) 0px 1px 10px 0px;
/* discord.js themeing */
--ifm-background-color: #1d1d1d;
--ifm-navbar-background-color: #4752c4;
--ifm-link-color: hsl(235, 85%, 82%);
--docusaurus-highlighted-code-line-bg: rgba(255, 255, 255, 0.1);
}
.footer--dark {
--tw-text-opacity: 1;
--ifm-footer-color: rgba(229, 231, 235, var(--tw-text-opacity));
--ifm-footer-title-color: rgba(229, 231, 235, var(--tw-text-opacity));
--ifm-footer-background-color: #4752c4;
}
footer > .container {
display: grid;
place-content: center;
> :first-child {
text-align: center;
> :last-child {
margin-bottom: calc(var(--ifm-spacing-vertical) * 0.5);
}
}
}
.footer__item {
padding: 0.5em 0;
}
.markdown__logo {
margin-top: -8rem;
margin-bottom: -8rem;
}
@media screen and (max-width: 966px) {
.markdown__logo {
padding-top: 6rem;
padding-bottom: 6rem;
}
}
.navbar__logo > img {
height: 64px;
width: 64px;
margin-top: -25%;
}
.navbar__link {
line-height: 1.25rem;
display: inline-flex;
align-items: center;
}
.dropdown {
line-height: 1.25rem;
display: inline-flex;
font-size: 14px;
align-items: center;
}
.navbar__link--active {
background-color: rgba($color: #000000, $alpha: 0.2);
border-radius: 0.375rem;
}
.navbar__inner {
height: 100%;
padding-left: 1rem;
}
.navbar__item {
margin-right: 2rem;
font-size: 14px;
height: 100%;
align-items: center;
border-radius: 0.375rem;
}
.navbar__item:hover {
background-color: rgba($color: #000000, $alpha: 0.3);
border-radius: 0.375rem;
}
// Inspired from docusaurus - see THIRD_PARTY_LICENSE.md
.header-github-link {
position: relative;
padding-left: 2.5rem;
}
.header-github-link::before {
content: '';
width: 24px;
height: 24px;
display: flex;
background: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='white' d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E")
no-repeat;
position: absolute;
left: 0.5rem;
margin-right: 2rem;
}
@media (max-width: 1500px) {
.navbar__item {
margin-right: 1rem;
}
}
@media (max-width: 996px) {
// Hide navbar branding
.navbar__brand {
display: none;
}
// Hide navigation items when in mobile view
.navbar__item {
display: none;
}
}

View File

@@ -0,0 +1,50 @@
.navbar__inner {
padding-left: 0.5rem;
padding-right: 0.5rem;
max-width: 80rem;
margin-left: auto;
margin: auto;
}
@media (min-width: 640px) {
.navbar__inner {
padding-left: 1rem;
padding-right: 1rem;
}
}
@media (min-width: 1024px) {
.navbar__inner {
padding-left: 2rem;
padding-right: 2rem;
}
}
.main-wrapper {
> :not(.hero) {
max-width: 96rem;
width: 100%;
margin-left: auto;
margin-right: auto;
}
> .theme-back-to-top-button {
width: 3rem;
}
}
// Theme the theme switcher icon to always be white
.navbar__items.navbar__items--right > :nth-child(2),
.navbar-sidebar__brand > :nth-child(2) {
color: #f5f6f7;
> :first-child:hover {
background-color: rgba($color: #000000, $alpha: 0.3);
border-radius: 0.375rem;
}
}
.navbar-sidebar__back,
.navbar__toggle {
color: #f5f6f7;
}

View File

@@ -0,0 +1,29 @@
.tippy-box[data-theme~='discord'] {
color: rgba(229, 231, 235, 1);
padding-left: 0.5rem;
padding-right: 0.5rem;
padding-top: 0.25rem;
padding-bottom: 0.25rem;
border-radius: 0.25rem;
background-color: #3ba55c;
}
.tippy-box[data-theme~='discord'] > .tippy-content {
font-weight: 600;
}
.tippy-box[data-theme~='discord'][data-placement^='top'] > .tippy-arrow::before {
border-top-color: rgba(59, 165, 92, 1);
}
.tippy-box[data-theme~='discord'][data-placement^='bottom'] > .tippy-arrow::before {
border-top-color: rgba(59, 165, 92, 1);
}
.tippy-box[data-theme~='discord'][data-placement^='left'] > .tippy-arrow::before {
border-top-color: rgba(59, 165, 92, 1);
}
.tippy-box[data-theme~='discord'][data-placement^='right'] > .tippy-arrow::before {
border-top-color: rgba(59, 165, 92, 1);
}

3
website/src/index.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
/// <reference types="node" />
/// <reference types="@docusaurus/module-type-aliases" />
/// <reference types="@docusaurus/theme-classic" />

View File

@@ -0,0 +1,49 @@
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Layout from '@theme/Layout';
import React, { useEffect } from 'react';
import { SWRConfig } from 'swr';
import HeadTags from '../components/Home/HeadTags';
import HomePageHeader from '../components/Home/HomePageHeader';
import HomePageFeatures from '../components/Home/HomepageFeatures';
export default function Home(): JSX.Element {
const { siteConfig } = useDocusaurusContext();
useEffect(() => {
console.log('%cHold Up!', `color: #23529B; font-size: 72px; font-weight: bold; -webkit-text-stroke: 2px #23529B`);
console.log(
[
'%cIf someone told you to copy/paste something here,',
'it is likely that you are being tricked and/or scammed.',
'For more information check out\n\nhttps://en.wikipedia.org/wiki/Self-XSS'
].join(' '),
'font-size: 16px;'
);
console.log(
[
'%cWhile we do everything in our power to ensure your security,',
'pasting anything in here could give attackers access to your private information!'
].join(' '),
'font-size: 18px; font-weight: bold; color: red;'
);
}, []);
return (
<>
<HeadTags />
<Layout title="Home" description={siteConfig.tagline}>
<SWRConfig
value={{
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
fetcher: (resource: string, init: RequestInit) => fetch(resource, init).then((res) => res.json())
}}
>
<HomePageHeader />
<main>
<HomePageFeatures />
</main>
</SWRConfig>
</Layout>
</>
);
}

View File

@@ -0,0 +1,5 @@
const IntlFormatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 2 });
export function formatNumber(number: number): string {
return IntlFormatter.format(number);
}

0
website/static/.nojekyll Normal file
View File

View File

@@ -0,0 +1 @@
/* /index.html 200

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

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