chore: docusaurus upgrade (#1163)

* chore: docusaurus upgrade

* chore: lock my file

* fix: oi

* chore: drop broken links to a warn

* chore: screw it, no direct link

* chore: doing it live

* chore: bring it back

* chore: remove client redirect as its needless

* chore: deno install bc why not

* chore: tabs
This commit is contained in:
Vlad Frangu
2024-12-20 12:09:23 +02:00
committed by GitHub
parent 5d472cbfba
commit 9f327dd999
21 changed files with 23673 additions and 16662 deletions

View File

@@ -2,7 +2,7 @@
"root": true,
"extends": ["neon/common", "neon/node", "neon/typescript", "neon/react", "neon/jsx", "neon/jsx-a11y", "neon/prettier"],
"parserOptions": {
"ecmaVersion": 2020,
"ecmaVersion": 2022,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
@@ -28,6 +28,9 @@
"rules": {
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
"import/extensions": "off",
"no-restricted-globals": "off"
"no-restricted-globals": "off",
"tsdoc/syntax": "off",
"@typescript-eslint/unbound-method": "off",
"import/order": "off"
}
}

View File

@@ -28,12 +28,52 @@ Discord API Types is a community-maintained project that brings API types for Di
## Installation
Install with [`npm`](https://www.npmjs.com/) / [`yarn`](https://yarnpkg.com) / [`pnpm`](https://pnpm.js.org/):
Install with [`npm`](https://www.npmjs.com/) / [`yarn`](https://yarnpkg.com) / [`pnpm`](https://pnpm.js.org/) /
[`bun`](https://bun.sh/) / [`deno`](https://deno.land/):
```bash npm2yarn2pnpm
<Tabs groupId="npm2yarn2pnpm">
<TabItem value="npm" label="npm">
```bash
npm install discord-api-types
```
</TabItem>
<TabItem value="yarn" label="yarn">
```bash
yarn add discord-api-types
```
</TabItem>
<TabItem value="pnpm" label="pnpm">
```bash
pnpm add discord-api-types
```
</TabItem>
<TabItem value="bun" label="bun">
```bash
bun add discord-api-types
```
</TabItem>
<TabItem value="deno" label="deno">
```bash
deno install npm:discord-api-types
```
</TabItem>
</Tabs>
### Usage
You can only import this module by specifying the API version you want to target. Append `/v*` to the import path, where

View File

@@ -1,255 +0,0 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
const { join } = require('node: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: {
v10: { path: 'v10.ts', label: 'API v10' },
v9: { path: 'v9.ts', label: 'API v9' },
'voice/v4': { path: 'voice/v4.ts', label: 'Voice v4' },
globals: { path: 'globals.ts', label: 'Global Types' },
},
slug: 'discord-api-types'
}
],
gitRefName: 'main',
})
]
],
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'),
require.resolve('./src/css/font.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: {
logo: {
src: '/svgs/mini_logo.svg'
},
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) => ({
activeBaseRegex: `api/(${version}/)${i === 0 ? '?' : ''}discord-api-types.*`,
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=discordjs&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: 'TR1O0DBFL9',
apiKey: '6822440beca69053ab122881d75064dc',
indexName: 'discord-api-types',
contextualSearch: true
}
})
};
module.exports = config;

View File

@@ -0,0 +1,280 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import type { Config } from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
import type typedocPluginFunction from '@apify/docusaurus-plugin-typedoc-api/src/index.ts';
// import type { Options as RedirectOptions } from '@docusaurus/plugin-client-redirects';
import { convertNpmToPackageManagers } from '@sapphire/docusaurus-plugin-npm2yarn2pnpm';
import { ts2esm2cjs } from '@sapphire/docusaurus-plugin-ts2esm2cjs';
import { themes } from 'prism-react-renderer';
import { URL, fileURLToPath } from 'node:url';
import versions from './versions.json' with { type: 'json' };
const { github: lightCodeTheme, vsDark: darkCodeTheme } = themes;
type TypedocPluginOptions = Parameters<typeof typedocPluginFunction>[1];
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';
const defaultApiVersion = 'v10';
const config: Config = {
title: 'discord-api-types documentation',
url: BaseUrl,
baseUrl: '/',
// Banner at the top of `/api/next` route redirects to the wrong URL
onBrokenLinks: 'warn',
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'
}
]
}
],
[
'@apify/docusaurus-plugin-typedoc-api',
{
projectRoot: fileURLToPath(new URL('../', import.meta.url)),
packages: [
{
path: './',
entry: {
v10: { path: 'v10.ts', label: 'API v10' },
v9: { path: 'v9.ts', label: 'API v9' },
'voice/v4': { path: 'voice/v4.ts', label: 'Voice v4' },
globals: { path: 'globals.ts', label: 'Global Types' }
},
slug: 'discord-api-types'
}
],
gitRefName: 'main',
rehypePlugins: [],
remarkPlugins: []
} satisfies Partial<TypedocPluginOptions>
]
// [
// '@docusaurus/plugin-client-redirects',
// {
// redirects: [
// {
// from: '/api',
// to: `/api/discord-api-types-${defaultApiVersion}`
// }
// ]
// } satisfies RedirectOptions
// ]
],
presets: [
[
'@docusaurus/preset-classic',
{
docs: {
sidebarPath: './sidebars.ts',
showLastUpdateAuthor: false,
showLastUpdateTime: false,
remarkPlugins: [convertNpmToPackageManagers, ts2esm2cjs]
},
blog: false,
theme: {
customCss: [
require.resolve('./src/css/custom.scss'),
require.resolve('./src/css/tippy-discord.css'),
require.resolve('./src/css/discordjs.scss'),
require.resolve('./src/css/font.scss')
]
}
} satisfies Preset.Options
]
],
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: '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: {
logo: {
src: '/svgs/mini_logo.svg'
},
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/discord-api-types-${defaultApiVersion}`,
label: 'API',
position: 'left',
items: [
{
label: versions.length === 0 ? 'Development Time' : 'next 🚧',
to:
versions.length === 0
? `api/discord-api-types-${defaultApiVersion}`
: `api/next/discord-api-types-${defaultApiVersion}`
},
...versions.map((version, index) => ({
activeBaseRegex: `api/(${version}/)${index === 0 ? '?' : ''}discord-api-types.*`,
label: version,
to: index === 0 ? `api/discord-api-types-${defaultApiVersion}` : `api/${version}/discord-api-types-${defaultApiVersion}`
}))
]
},
// 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=discordjs&utm_campaign=oss'
},
links: [
{
title: 'Donate',
items: [
{
label: 'GitHub Sponsors',
href: 'https://discord-api-types.dev/sponsor'
},
{
label: 'Ko-fi',
href: 'https://discord-api-types.dev/kofi'
},
{
label: 'Patreon',
href: 'https://discord-api-types.dev/patreon'
}
]
},
{
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: 'TR1O0DBFL9',
apiKey: '6822440beca69053ab122881d75064dc',
indexName: 'discord-api-types',
contextualSearch: true
}
} satisfies Preset.ThemeConfig
};
export default config;

39077
website/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@
"scripts": {
"docusaurus": "docusaurus",
"start": "npm run clean && docusaurus start",
"build": "npm run clean && cross-env DOCUSAURUS_SSR_CONCURRENCY=2 NODE_OPTIONS=\"--max_old_space_size=7500\" docusaurus build",
"build": "npm run clean && cross-env NODE_OPTIONS=\"--max_old_space_size=7500\" docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
@@ -24,56 +24,53 @@
"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"
"vercel-build": "npm run build",
"postinstall": "patch-package"
},
"dependencies": {
"@docusaurus/core": "canary",
"@docusaurus/plugin-pwa": "canary",
"@docusaurus/preset-classic": "canary",
"@docusaurus/theme-common": "canary",
"@docusaurus/theme-search-algolia": "canary",
"@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",
"@docusaurus/core": "^3.6.3",
"@docusaurus/plugin-client-redirects": "^3.6.3",
"@docusaurus/plugin-pwa": "^3.6.3",
"@docusaurus/preset-classic": "^3.6.3",
"@docusaurus/theme-common": "^3.6.3",
"@docusaurus/theme-search-algolia": "^3.6.3",
"@heroicons/react": "^2.2.0",
"@mdx-js/react": "^3.1.0",
"@sapphire/docusaurus-plugin-npm2yarn2pnpm": "^2.0.2",
"@sapphire/docusaurus-plugin-ts2esm2cjs": "^2.0.2",
"@svgr/webpack": "^8.1.0",
"@tippyjs/react": "^4.2.6",
"clsx": "^1.1.1",
"docusaurus-plugin-sass": "^0.2.2",
"docusaurus-plugin-typedoc-api": "^2.0.1",
"npm-to-yarn": "^1.0.1",
"prism-react-renderer": "^1.3.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"sass": "^1.52.3",
"swr": "^1.3.0"
"clsx": "^2.1.1",
"docusaurus-plugin-sass": "^0.2.5",
"npm-to-yarn": "^3.0.0",
"prism-react-renderer": "^2.4.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"sass": "^1.81.0",
"swr": "^2.2.5"
},
"devDependencies": {
"@commitlint/cli": "^17.0.2",
"@commitlint/config-conventional": "^17.0.2",
"@docusaurus/module-type-aliases": "canary",
"@sapphire/prettier-config": "^1.4.3",
"@sapphire/ts-config": "^3.3.4",
"@types/node": "^17.0.42",
"@types/react": "^18.0.12",
"@types/react-dom": "^18.0.5",
"@apify/docusaurus-plugin-typedoc-api": "^4.3.1",
"@docusaurus/module-type-aliases": "^3.6.3",
"@sapphire/prettier-config": "^2.0.0",
"@sapphire/ts-config": "^5.0.1",
"@types/node": "^22.10.1",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"cross-env": "^7.0.3",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.17.0",
"eslint-config-neon": "^0.1.42",
"lint-staged": "^13.0.1",
"markdownlint": "^0.25.1",
"markdownlint-cli2": "^0.14.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.17",
"typedoc-plugin-djs-links": "^1.0.4",
"typedoc-plugin-markdown": "^3.12.1",
"typedoc-plugin-mdn-links": "^1.0.6",
"typescript": "^4.7.3"
"eslint": "^8.57.1",
"eslint-config-neon": "^0.1.62",
"markdownlint": "^0.36.1",
"markdownlint-cli2": "^0.15.0",
"patch-package": "^8.0.0",
"prettier": "^3.4.1",
"pretty-quick": "^4.0.0",
"typedoc": "^0.27.1",
"typedoc-plugin-djs-links": "^2.2.1",
"typedoc-plugin-markdown": "^4.3.0",
"typedoc-plugin-mdn-links": "^4.0.2",
"typescript": "^5.7.2"
},
"browserslist": {
"production": [

View File

@@ -0,0 +1,42 @@
diff --git a/node_modules/@apify/docusaurus-plugin-typedoc-api/lib/plugin/sidebar.js b/node_modules/@apify/docusaurus-plugin-typedoc-api/lib/plugin/sidebar.js
index e85a672..3287970 100644
--- a/node_modules/@apify/docusaurus-plugin-typedoc-api/lib/plugin/sidebar.js
+++ b/node_modules/@apify/docusaurus-plugin-typedoc-api/lib/plugin/sidebar.js
@@ -71,11 +71,13 @@ function extractSidebar(packages, scopes, changelogs, sortSidebar) {
// Always include the overview as the 1st item
const indexHref = pkg.entryPoints.find(entry => entry.index)?.reflection.permalink ?? '';
subItems = subItems.sort((a, d) => sortSidebar('label' in a ? a.label : '', 'label' in d ? d.label : ''));
- subItems.unshift({
- href: indexHref,
- label: 'Overview',
- type: 'link'
- });
+ // DAPI-TYPES START - Remove overview as it has no use
+ // subItems.unshift({
+ // href: indexHref,
+ // label: 'Overview',
+ // type: 'link'
+ // });
+ // DAPI-TYPES END
if (pkg.changelogPath && changelogs) {
subItems.push({
href: utils.normalizeUrl([indexHref, 'changelog']),
diff --git a/node_modules/@apify/docusaurus-plugin-typedoc-api/lib/plugin/url.js b/node_modules/@apify/docusaurus-plugin-typedoc-api/lib/plugin/url.js
index efff9c4..2956729 100644
--- a/node_modules/@apify/docusaurus-plugin-typedoc-api/lib/plugin/url.js
+++ b/node_modules/@apify/docusaurus-plugin-typedoc-api/lib/plugin/url.js
@@ -29,9 +29,11 @@ function getKindSlug(decl) {
}
function getPackageSlug(pkgConfig, importPath, isSinglePackage) {
// Monorepo with 1 package has special handling
- if (isSinglePackage && pkgConfig.packageSlug !== '.') {
- return '.';
- }
+// DAPI-TYPES START - This breaks the website since we are a single-package, multiple entrypoint module
+// if (isSinglePackage && pkgConfig.packageSlug !== '.') {
+// return '.';
+// }
+// DAPI-TYPES END
// packages/foo -> foo
const slug = pkgConfig.packageSlug ?? path__default.default.basename(pkgConfig.packagePath);

View File

@@ -1,4 +1,4 @@
module.exports = {
export default {
sidebar: [
{
type: 'autogenerated',

View File

@@ -1,4 +1,4 @@
import { ClipboardCopyIcon } from '@heroicons/react/outline';
import { ClipboardIcon } from '@heroicons/react/24/outline';
import Tippy from '@tippyjs/react';
import clsx from 'clsx';
import type { FC } from 'react';
@@ -7,7 +7,7 @@ import styles from './InstallTabButton.module.css';
interface Props {
handleClickInstallButton(): void;
installCommand: string;
readonly installCommand: string;
}
const InstallTabButton: FC<Props> = ({ installCommand, handleClickInstallButton }) => {
@@ -33,7 +33,7 @@ const InstallTabButton: FC<Props> = ({ installCommand, handleClickInstallButton
>
<div className={clsx(styles.buttonContent)}>
{installCommand}
<ClipboardCopyIcon className={styles.copyIcon} />
<ClipboardIcon className={styles.copyIcon} />
</div>
</button>
</Tippy>

View File

@@ -1,7 +1,6 @@
import { npmToPnpm } from '@sapphire/docusaurus-plugin-npm2yarn2pnpm';
import { npmToPnpm, npmToYarn, npmToBun } from '@sapphire/docusaurus-plugin-npm2yarn2pnpm';
import TabItem from '@theme/TabItem';
import Tabs from '@theme/Tabs';
import npmToYarn from 'npm-to-yarn';
import type { FC } from 'react';
import React from 'react';
import InstallTabButton from './InstallTabButton';
@@ -14,8 +13,10 @@ async function handleClickInstallButton(command: string) {
const InstallTabs: FC = () => {
const npmInstallCommand = 'npm install discord-api-types';
const yarnInstallCommand = npmToYarn(npmInstallCommand, 'yarn');
const yarnInstallCommand = npmToYarn(npmInstallCommand);
const pnpmInstallCommand = npmToPnpm(npmInstallCommand);
const bunInstallCommand = npmToBun(npmInstallCommand);
const denoInstallCommand = 'deno install npm:discord-api-types';
return (
<div className={styles.buttons}>
@@ -44,6 +45,22 @@ const InstallTabs: FC = () => {
installCommand={pnpmInstallCommand}
/>
</TabItem>
<TabItem label="bun" value="bun">
<InstallTabButton
handleClickInstallButton={() => {
void handleClickInstallButton(bunInstallCommand);
}}
installCommand={bunInstallCommand}
/>
</TabItem>
<TabItem label="deno" value="deno">
<InstallTabButton
handleClickInstallButton={() => {
void handleClickInstallButton(denoInstallCommand);
}}
installCommand={denoInstallCommand}
/>
</TabItem>
</Tabs>
</div>
);

View File

@@ -1,6 +1,6 @@
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Layout from '@theme/Layout';
import React, { useEffect } from 'react';
import React from 'react';
import { SWRConfig } from 'swr';
import HeadTags from '../components/Home/HeadTags';
import HomePageHeader from '../components/Home/HomePageHeader';
@@ -9,25 +9,6 @@ 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 />

View File

@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["./babel.config.js", "docs", "./docusaurus.config.js", "projects", "scripts", "./sidebars.js", "src/**/*.tsx", "static"]
"include": ["./babel.config.js", "docs", "./docusaurus.config.ts", "projects", "scripts", "./sidebars.ts", "src/**/*.tsx", "static"]
}

View File

@@ -1,5 +1,5 @@
{
"extends": "@sapphire/ts-config",
"extends": ["@sapphire/ts-config"],
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",

View File

@@ -1,264 +0,0 @@
---
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 `#developing-djs`
channel.
:::
### 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, must have received the green light to be used, or must be present in the
[stable OpenAPI specification](https://github.com/discord/discord-api-spec/blob/main/specs/openapi.json).
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 and
files you need to keep in mind when contributing.
```bash {2,4-6,9-10,12-16}
├── 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)Body|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 module 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

@@ -1,167 +0,0 @@
---
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.
:::

View File

@@ -1 +0,0 @@
[{"entryPoints":{"v10":{"path":"v10.ts","label":"API v10"},"v9":{"path":"v9.ts","label":"API v9"},"voice/v4":{"path":"voice/v4.ts","label":"Voice v4"},"globals":{"path":"globals.ts","label":"Global Types"}},"packagePath":"./","packageSlug":"discord-api-types","packageName":"discord-api-types","packageVersion":"0.37.111"}]

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

View File

@@ -28,12 +28,51 @@ Discord API Types is a community-maintained project that brings API types for Di
## Installation
Install with [`npm`](https://www.npmjs.com/) / [`yarn`](https://yarnpkg.com) / [`pnpm`](https://pnpm.js.org/):
Install with [`npm`](https://www.npmjs.com/) / [`yarn`](https://yarnpkg.com) / [`pnpm`](https://pnpm.js.org/) / [`bun`](https://bun.sh/) / [`deno`](https://deno.land/):
```bash npm2yarn2pnpm
<Tabs groupId="npm2yarn2pnpm">
<TabItem value="npm" label="npm">
```bash
npm install discord-api-types
```
</TabItem>
<TabItem value="yarn" label="yarn">
```bash
yarn add discord-api-types
```
</TabItem>
<TabItem value="pnpm" label="pnpm">
```bash
pnpm add discord-api-types
```
</TabItem>
<TabItem value="bun" label="bun">
```bash
bun add discord-api-types
```
</TabItem>
<TabItem value="deno" label="deno">
```bash
deno install npm:discord-api-types
```
</TabItem>
</Tabs>
### Usage
You can only import this module by specifying the API version you want to target. Append `/v*` to the import path, where

View File

@@ -1,8 +0,0 @@
{
"sidebar": [
{
"type": "autogenerated",
"dirName": "."
}
]
}

View File

@@ -1,4 +1,3 @@
[
"0.37.112",
"0.37.111"
]
"0.37.112"
]