Skip to content

Class Client

🏭 Constructors

constructor

ts
new Client(options: ClientOptions): Client

Parameters

  • options: ClientOptions

Return Type

  • Client

Defined in: packages/discord-rpc/Client.ts:130

🏷️ Properties

_nonceMap private

ts
_nonceMap: Map<string, Object> = ...

Defined in: packages/discord-rpc/Client.ts:121

accessToken private optional

ts
accessToken: string

Defined in: packages/discord-rpc/Client.ts:86

application optional

ts
application: APIApplication

current application

Defined in: packages/discord-rpc/Client.ts:102

clientId

ts
clientId: string

application id

Defined in: packages/discord-rpc/Client.ts:75

clientSecret optional

ts
clientSecret: string

application secret

Defined in: packages/discord-rpc/Client.ts:79

connectionPromise private optional

ts
connectionPromise: Promise<void>

Defined in: packages/discord-rpc/Client.ts:120

dispatcher optional

ts
dispatcher: Dispatcher

Defined in: packages/discord-rpc/Client.ts:113

pipeId optional

ts
pipeId: number

pipe id

Defined in: packages/discord-rpc/Client.ts:84

refreshTimeout private optional

ts
refreshTimeout: Timeout

Defined in: packages/discord-rpc/Client.ts:119

refreshToken private optional

ts
refreshToken: string

Defined in: packages/discord-rpc/Client.ts:87

tokenType private

ts
tokenType: string = 'Bearer'

Defined in: packages/discord-rpc/Client.ts:88

transport readonly

ts
transport: Transport

transport instance

Defined in: packages/discord-rpc/Client.ts:93

user optional

ts
user: ClientUser

current user

Defined in: packages/discord-rpc/Client.ts:98

🔑 Accessors

isConnected

Defined in: packages/discord-rpc/Client.ts:115

🔧 Methods

authenticate private

ts
authenticate(): Promise<void>

Return Type

  • Promise<void>

Defined in: packages/discord-rpc/Client.ts:210

authorize private

ts
authorize(options: AuthorizeOptions): Promise<void>

Parameters

  • options: AuthorizeOptions

Return Type

  • Promise<void>

Defined in: packages/discord-rpc/Client.ts:253

connect

ts
connect(): Promise<void>

connect to the local rpc server

Return Type

  • Promise<void>

Defined in: packages/discord-rpc/Client.ts:321

destroy

ts
destroy(): Promise<void>

disconnects from the local rpc server

Return Type

  • Promise<void>

Defined in: packages/discord-rpc/Client.ts:382

hanleAccessTokenResponse private

ts
hanleAccessTokenResponse(data: any): void

Parameters

  • data: any

Return Type

  • void

Defined in: packages/discord-rpc/Client.ts:238

login

ts
login(options: AuthorizeOptions): Promise<void>

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

Parameters

  • options: AuthorizeOptions options for the authorization

Return Type

  • Promise<void>

Defined in: packages/discord-rpc/Client.ts:367

refreshAccessToken private

ts
refreshAccessToken(): Promise<void>

Return Type

  • Promise<void>

Defined in: packages/discord-rpc/Client.ts:218

subscribe

ts
subscribe(event: "OVERLAY" | "CURRENT_USER_UPDATE" | "GUILD_STATUS" | "GUILD_CREATE" | "CHANNEL_CREATE" | "RELATIONSHIP_UPDATE" | "VOICE_CHANNEL_SELECT" | "VOICE_STATE_CREATE" | "VOICE_STATE_DELETE" | "VOICE_STATE_UPDATE" | "VOICE_SETTINGS_UPDATE" | "VOICE_SETTINGS_UPDATE_2" | "VOICE_CONNECTION_STATUS" | "SPEAKING_START" | "SPEAKING_STOP" | "GAME_JOIN" | "GAME_SPECTATE" | "ACTIVITY_JOIN" | "ACTIVITY_JOIN_REQUEST" | "ACTIVITY_SPECTATE" | "ACTIVITY_INVITE" | "ACTIVITY_PIP_MODE_UPDATE" | "NOTIFICATION_CREATE" | "MESSAGE_CREATE" | "MESSAGE_UPDATE" | "MESSAGE_DELETE" | "LOBBY_DELETE" | "LOBBY_UPDATE" | "LOBBY_MEMBER_CONNECT" | "LOBBY_MEMBER_DISCONNECT" | "LOBBY_MEMBER_UPDATE" | "LOBBY_MESSAGE" | "OVERLAY_UPDATE" | "ENTITLEMENT_CREATE" | "ENTITLEMENT_DELETE" | "USER_ACHIEVEMENT_UPDATE" | "VOICE_CHANNEL_EFFECT_SEND" | "THERMAL_STATE_UPDATE", args: any): Promise<Object>

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.

Parameters

  • event: "OVERLAY" | "CURRENT_USER_UPDATE" | "GUILD_STATUS" | "GUILD_CREATE" | "CHANNEL_CREATE" | "RELATIONSHIP_UPDATE" | "VOICE_CHANNEL_SELECT" | "VOICE_STATE_CREATE" | "VOICE_STATE_DELETE" | "VOICE_STATE_UPDATE" | "VOICE_SETTINGS_UPDATE" | "VOICE_SETTINGS_UPDATE_2" | "VOICE_CONNECTION_STATUS" | "SPEAKING_START" | "SPEAKING_STOP" | "GAME_JOIN" | "GAME_SPECTATE" | "ACTIVITY_JOIN" | "ACTIVITY_JOIN_REQUEST" | "ACTIVITY_SPECTATE" | "ACTIVITY_INVITE" | "ACTIVITY_PIP_MODE_UPDATE" | "NOTIFICATION_CREATE" | "MESSAGE_CREATE" | "MESSAGE_UPDATE" | "MESSAGE_DELETE" | "LOBBY_DELETE" | "LOBBY_UPDATE" | "LOBBY_MEMBER_CONNECT" | "LOBBY_MEMBER_DISCONNECT" | "LOBBY_MEMBER_UPDATE" | "LOBBY_MESSAGE" | "OVERLAY_UPDATE" | "ENTITLEMENT_CREATE" | "ENTITLEMENT_DELETE" | "USER_ACHIEVEMENT_UPDATE" | "VOICE_CHANNEL_EFFECT_SEND" | "THERMAL_STATE_UPDATE" event name now subscribed to
  • args: any args for the event

Return Type

  • Promise<Object>

Defined in: packages/discord-rpc/Client.ts:306