Reference

Typings

AdvancedHeartbeatInfo extends HeartbeatInfo

Advanced information for a heartbeat

interface AdvancedHeartbeatInfo {
  intervalTime: number;
  interval: NodeJS.Timeout | null;
}

AnyGuildChannel

Type definition for all guild channel classes

type AnyGuildChannel =
  | NewsChannel
  | StageChannel
  | StoreChannel
  | TextChannel
  | VoiceChannel;

Attachment

An attachment to send to the API

interface Attachment {
  /**
   * The name of this attachment
   */
  name: string;

  /**
   * The data for this buffer
   */
  data: Buffer;
}

ClientOptions

Options to instantiate a client

interface ClientOptions {
  /**
   * The token of this client
   * This defaults to `process.env.DISCORD_TOKEN` if none is provided
   */
  token?: Token;

  /**
   * Total number of members where the gateway will stop sending offline members in the guild member list
   */
  largeThreshold?: number;

  /**
   * Intents to use for this client
   */
  intents: Intents;

  /**
   * An optional user agent to add in the requests to the API
   * @see https://discord.com/developers/docs/reference#user-agent
   */
  userAgent?: string;
}

ClientStatus

The state of the client connection

enum ClientStatus {
  Disconnected,
  Connecting,
  Connected,
  Reconnecting,
  Resuming,
}

HeartbeatInfo

Data about an heartbeat

interface HeartbeatInfo {
  first: boolean;
  acknowledged: boolean;
}

Intents

Intents to send to the API

enum Intents {
  guilds = 1,
  guildMembers = 2,
  guildBans = 4,
  guildEmojis = 8,
  guildIntegrations = 16,
  guildWebhooks = 32,
  guildInvites = 64,
  guildVoiceStates = 128,
  guildPresences = 256,
  guildMessages = 512,
  guildMessageReactions = 1024,
  guildMessageTyping = 2048,
  directMessages = 4096,
  directMessageReactions = 8192,
  directMessageTyping = 16384,
}

Json

Any JSON data

type Json = Json[] | boolean | number | string | { [property: string]: Json };

Path

The path for a request to the API

type Path = `/${string}`;

RateLimitHandler

Data about ratelimits related to a bucket

interface RateLimitHandler {
  /**
   * A unique string denoting the rate limit being encountered
   */
  bucket: string;

  /**
   * The number of requests that can be made
   */
  limit: number;

  /**
   * The number of remaining requests that can be made
   */
  remaining: number;

  /**
   * Epoch time (seconds) at which the rate limit resets
   */
  reset?: number;

  /**
   * Routes that share the same bucket
   */
  routes: `${RequestMethod} ${Path}`[];
}

RequestMethod

The method of a request to the API

type RequestMethod = "DELETE" | "GET" | "PATCH" | "POST" | "PUT";

RequestOptions

The options for this request

interface RequestOptions {
  /**
   * The base url for this request
   */
  url?: string;

  /**
   * The query of this request
   */
  query?: URLSearchParams;

  /**
   * Headers to be sent for this request
   */
  headers?: OutgoingHttpHeaders;

  /**
   * Attachments to add to the body of this request
   */
  attachments?: Attachment[];

  /**
   * The JSON body of this request
   */
  body?: Json;
}

RequestStatus

The status of a request to the API

enum RequestStatus {
  Pending,
  InProgress,
  Finished,
  Failed,
}

Response

A response received from the API

interface Response {
  /**
   * The received data
   */
  data: string | null;

  /**
   * The status code received for this request
   */
  statusCode: number;

  /**
   * Headers received from the API
   */
  headers: IncomingHttpHeaders;

  /**
   * The status message received for this request
   */
  status: string;

  /**
   * The APIRequest object that instantiated this
   */
  request: APIRequest;
}

Snowflake

Represents a DIscord's snowflake

type Snowflake = string;

Token

A valid token for the API

type Token = `${string}.${string}.${string}`;
Last Updated:
Contributors: NotReallyEight