discordjs / discord-api-types

Up to date Discord API Typings, versioned by the API version
https://discord-api-types.dev
MIT License
513 stars 112 forks source link
deno discord discord-api discord-bot discordjs gateway hacktoberfest rest typescript typings

Discord API Types

discord-api-types

GitHub npm deno Patreon Donate Ko-fi Donate GitHub Sponsors Powered by Vercel

Simple type definitions for the Discord API.

Installation

Install with npm / yarn / pnpm:

npm install discord-api-types
yarn add discord-api-types
pnpm add 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

const { APIUser } = require('discord-api-types/v10');
// TypeScript/ES Module support
import { APIUser } from 'discord-api-types/v10';

You may also import just certain parts of the module that you need. The possible values are: globals, gateway, gateway/v*, payloads, payloads/v*, rest, rest/v*, rpc, rpc/v*, utils, utils/v*, voice, and voice/v*. Below are some examples

const { GatewayVersion } = require('discord-api-types/gateway/v10');
// TypeScript/ES Module support
import { GatewayVersion } from 'discord-api-types/gateway/v10';

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 runtime. You have 3 ways you can import them:

  1. Directly from GitHub
// Importing a specific API version
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v10.ts';
  1. From deno.land/x
// Importing a specific API version
import { APIUser } from 'https://deno.land/x/discord_api_types/v10.ts';
  1. From skypack.dev
// Importing a specific API version
import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v10?dts';

Project Structure

The exports of each API version is split into three main parts:

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, 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 on a case by case basis. They will be documented with an @unstable tag and are not subject with the same versioning rules.