@api-typings/discord

API Typings for the Discord API

Usage no npm install needed!

<script type="module">
  import apiTypingsDiscord from 'https://cdn.skypack.dev/@api-typings/discord';
</script>

README

API Typings – Discord API

npm license

API Typings for v9 of Discord's REST & Gateway API.

Install

npm install -D @api-typings/discord

Usage

JavaScript

// Common JS
const { Guild, Snowflake } = require('@api-typings/discord');
// ES Module
import { Guild, Snowflake } from '@api-typings/discord';

/**
 * @param {Snowflake} id - The ID of the guild to get.
 * @returns {Promise<Guild>}
 */ 
async function getGuild(id) { ... }

TypeScript

import type { Guild, Snowflake } from '@api-typings/discord';

/**
 * @param id - The ID of the guild to get.
 */ 
async function getGuild(id: Snowflake): Promise<Guild> { ... }

Structure

File structure is closely organized to Discord's documentation, with each resources' endpoints separated into an endpoints/ folder, e.g.,

Documentation

- Resources
    - Application
    - Audit Log
    - Channel
    - ...

Directory

resources/
├── endpoints/
│   ├── Application.ts
│   ├── AuditLog.ts
│   └── Channel.ts
├── Application.ts
├── AuditLog.ts
├── Channel.ts
└── ...