Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/harmony/src/rest/mod.ts>RESTManager

An easy to use Discord API Library for Deno.
Go to Latest
class RESTManager
Re-export
import { RESTManager } from "https://deno.land/x/harmony@v2.6.0/src/rest/mod.ts";

An easier to use interface for interacting with Discord REST API.

Constructors

new
RESTManager(options?: RESTOptions)

Properties

api: APIMap

API Map - easy to use way for interacting with Discord API.

Examples:

  • rest.api.users['123'].get().then(userPayload => doSomething)
    
  • rest.api.guilds['123'].channels.post({ name: 'my-channel', type: 0 }).then(channelPayload => {})
    
apiURL
optional
canary: boolean

Whether REST Manager is using Canary API

readonly
optional
client: Client

Optional Harmony Client object

endpoints: RESTEndpoints
globalDelay: number | null | Promise<void>
globalLimit
globalRemaining
globalReset: number | null
readonly
handlers: Collection<string, BucketHandler>
headers: Record<string, string>

Headers object which patch the current ones

requestTimeout: number
restTimeOffset: number
retryLimit: number
readonly
timers: Set<number>
token: string | (() => string | undefined) | undefined

Token being used for Authorization

tokenType: TokenType

Token Type of the Token if any

optional
userAgent: string

Optional custom User Agent (header)

version: number

API Version being used by REST Manager

Methods

delete(
url: string,
body?: unknown,
maxRetries?,
bucket?: string | null,
rawResponse?: boolean,
options?: RequestOptions,
): Promise<any>

Makes a DELETE Request to API

get(
url: string,
body?: unknown,
maxRetries?,
bucket?: string | null,
rawResponse?: boolean,
options?: RequestOptions,
): Promise<any>

Makes a GET Request to API

make(
url: string,
body?: unknown,
_maxRetries?,
bucket?: string | null,
rawResponse?: boolean,
options?: RequestOptions,
): Promise<any>

Makes a Request to Discord API.

patch(
url: string,
body?: unknown,
maxRetries?,
bucket?: string | null,
rawResponse?: boolean,
options?: RequestOptions,
): Promise<any>

Makes a PATCH Request to API

post(
url: string,
body?: unknown,
maxRetries?,
bucket?: string | null,
rawResponse?: boolean,
options?: RequestOptions,
): Promise<any>

Makes a POST Request to API

put(
url: string,
body?: unknown,
maxRetries?,
bucket?: string | null,
rawResponse?: boolean,
options?: RequestOptions,
): Promise<any>

Makes a PUT Request to API

request<T = any>(
path: string,
options?: RequestOptions,
): Promise<T>
resolveBucket(url: string): string
setTimeout(fn: (...args: unknown[]) => unknown, ms: number): number