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

x/discord_rpc_deno/src/Client.ts>Client

port of @xhayper/discord-rpc to deno
Go to Latest
class Client
import { Client } from "https://deno.land/x/discord_rpc_deno@1.0.8/src/Client.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
debug: boolean

debug mode

readonly
logger: log.Logger

logger

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()

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.