Giter Club home page Giter Club logo

discord-api-types's Introduction

Discord API Types

GitHub npm Patreon Donate Ko-fi Donate

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

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 common directory. 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 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 datamining and have not yet been confirmed in a way as described will NOT be included.

Usage

You can require / import the module directly, which will give you the latest types as of the current API version. This is considered the default version and will be updated according to Discord's default API version; this means it may break at any point in time.

We strongly recommend you use a version when importing this module! This will prevent breaking changes when updating the module.

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

You should instead consider adding the API version you want to target by appending /v*, where the * represents the API version.

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

discord-api-types's People

Contributors

advaith1 avatar didinele avatar fyko avatar kyranet avatar notsugden avatar tttie avatar vaporoxx avatar vladfrangu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.