Skip to main content
Module

x/discord_rpc_deno/mod.ts>Client

port of @xhayper/discord-rpc to deno
Go to Latest
class Client
Re-export
import { Client } from "https://deno.land/x/discord_rpc_deno@v1.0.25/mod.ts";

Constructors

new
Client(options: ClientOptions)

Properties

private
_nonceMap: Map<string, { resolve: (value?: any) => void; reject: (reason?: any) => void; error: RPCError; }>
private
optional
accessToken: string
private
optional
connectionPromise: Promise<void>
private
optional
refreshTimeout: number
private
optional
refreshToken: string
private
tokenType: string
optional
application: APIApplication

current application

cdnHost: string
clientId: string

application id

optional
clientSecret: string

application secret

readonly
isConnected
origin: string
optional
pipeId: number

pipe id

readonly
transport: Transport

transport instance

optional
user: ClientUser

current user

Methods

private
authenticate(): Promise<void>
private
authorize(options: AuthorizeOptions): Promise<void>
private
hanleAccessTokenResponse(data: any): void
private
refreshAccessToken(): Promise<void>
connect(): Promise<void>

connect to the local rpc server

destroy(): Promise<void>

disconnects from the local rpc server

fetch(
method: string,
path: string,
req?: { body?: BodyInit; query?: string; headers?: HeadersInit; },
): Promise<Response>
login(options?: AuthorizeOptions): Promise<void>

will try to authorize if a scope is specified, else it's the same as connect()

on<E extends keyof ClientEvents>(event: E, listener: ClientEvents[E]): this

For RPC event, make sure to subscribe to the event.

once<E extends keyof ClientEvents>(event: E, listener: ClientEvents[E]): this

For RPC event, make sure to subscribe to the event.

request<A = any, D = any>(
cmd: RPC_CMD,
args?: any,
evt?: RPC_EVT,
): Promise<CommandIncoming<A, D>>
subscribe(event: Exclude<RPC_EVT, "READY" | "ERROR">, args?: any): Promise<{ unsubscribe: () => void; }>

Used to subscribe to events. evt of the payload should be set to the event being subscribed to. args of the payload should be set to the args needed for the event.