Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Client

The main client class.

param

The client options.

example
const { Client } = require('dogehq');
const client = new Client();

client.on('ready', () => console.log('Im ready!'));

client.login('token', 'accessToken');

Hierarchy

Index

Constructors

constructor

Properties

Private Readonly _immediates

_immediates: Set<Immediate> = ...

The immediates.

Private Readonly _intervals

_intervals: Set<Timeout> = ...

The intervals.

Private Optional Readonly _options

_options: ClientOptions

The client options that you set.

Private Readonly _timeouts

_timeouts: Set<Timeout> = ...

The timeouts.

connection

connection: Connection

The raw connection.

refreshToken

refreshToken: null | string

The refresh token that you used to auth.

rooms

rooms: Collection<string, Room>

The top public rooms.

token

token: null | string

The token that you used to auth.

user

user: null | ClientUser

The client user.

users

users: Collection<string, User>

The users.

wrapper

wrapper: { connection: Connection; mutation: { addSpeaker: (userId: string) => Promise<void>; askToSpeak: () => void; ban: (username: string, reason: string) => void; banFromRoomChat: (userId: string) => Promise<void>; changeModStatus: (userId: string, value: boolean) => Promise<void>; changeRoomCreator: (userId: string) => Promise<void>; createRoom: (data: { description: string; name: string; privacy: string }) => Promise<{ error: string } | { room: Room }>; createRoomFromScheduledRoom: (data: { description: string; id: string; name: string }) => Promise<{ room: Room }>; createScheduledRoom: (data: { description: string; name: string; scheduledFor: string }) => Promise<ScheduledRoom | { error: string }>; deleteRoomChatMessage: (userId: string, messageId: string) => Promise<void>; deleteScheduledRoom: (id: string) => any; editProfile: (data: { avatarUrl: string; bannerUrl?: string; bio: string; displayName: string; username: string }) => Promise<{ isUsernameTaken: boolean }>; editRoom: (data: { description: string; name: string; privacy: string }) => Promise<{ error: string } | { room: Room }>; editScheduledRoom: (id: string, data: { description: string; name: string; scheduledFor: string }) => Promise<ScheduledRoom | { error: string }>; follow: (userId: string, value: boolean) => Promise<void>; inviteToRoom: (userId: string) => void; leaveRoom: () => Promise<{ roomId: string }>; roomBan: (userId: string, shouldBanIp?: boolean) => Promise<void>; roomUpdate: (data: { autoSpeaker?: boolean; description?: string; name?: string; privacy?: string }) => Promise<void>; sendRoomChatMsg: (ast: MessageToken<string, unknown>[], whisperedTo?: string[]) => Promise<void>; setDeaf: (isDeafened: boolean) => Promise<Record<string, never>>; setListener: (userId: string) => Promise<void>; setMute: (isMuted: boolean) => Promise<Record<string, never>>; speakingChange: (value: boolean) => void; unbanFromRoom: (userId: string) => Promise<void>; unbanFromRoomChat: (userId: string) => Promise<void>; userBlock: (userId: string) => Promise<void>; userCreateBot: (username: string) => Promise<CreateBotResponse>; userUnblock: (userId: string) => Promise<void> }; query: { getBlockedFromRoomUsers: (cursor?: number) => Promise<{ nextCursor: null | number; users: User[] }>; getFollowList: (username: string, isFollowing: boolean, cursor?: number) => Promise<{ nextCursor: null | number; users: UserWithFollowInfo[] }>; getInviteList: (cursor?: number) => Promise<{ nextCursor: null | number; users: User[] }>; getMyFollowing: (cursor?: number) => Promise<{ nextCursor: null | number; users: UserWithFollowInfo[] }>; getMyScheduledRoomsAboutToStart: (roomId: string) => Promise<{ scheduledRooms: ScheduledRoom[] }>; getRoomUsers: () => Promise<GetRoomUsersResponse>; getScheduledRooms: (cursor?: string, getOnlyMyScheduledRooms?: boolean) => Promise<GetScheduledRoomsResponse>; getTopPublicRooms: (cursor?: number) => Promise<GetTopPublicRoomsResponse>; getUserProfile: (idOrUsername: string) => Promise<null | UserWithFollowInfo | { error: string }>; joinRoomAndGetInfo: (roomId: string) => Promise<JoinRoomAndGetInfoResponse | { error: string }>; search: (query: string) => Promise<{ items: (User | Room)[] }> }; subscribe: { handRaised: (handler: Handler<{ userId: string }>) => () => void; invitationToRoom: (handler: Handler<InvitationToRoomResponse>) => () => void; newChatMsg: (handler: Handler<{ msg: Message; userId: string }>) => () => void; newRoomDetails: (handler: Handler<NewRoomDetailsResponse>) => () => void; speakerAdded: (handler: Handler<{ deafMap: BooleanMap; muteMap: BooleanMap; userId: string }>) => () => void; speakerRemoved: (handler: Handler<{ deafMap: BooleanMap; muteMap: BooleanMap; userId: string }>) => () => void; userJoinRoom: (handler: Handler<{ user: User }>) => () => void; userLeaveRoom: (handler: Handler<{ roomId: string; userId: string }>) => () => void } }

The wrapper.

Type declaration

  • connection: Connection
  • mutation: { addSpeaker: (userId: string) => Promise<void>; askToSpeak: () => void; ban: (username: string, reason: string) => void; banFromRoomChat: (userId: string) => Promise<void>; changeModStatus: (userId: string, value: boolean) => Promise<void>; changeRoomCreator: (userId: string) => Promise<void>; createRoom: (data: { description: string; name: string; privacy: string }) => Promise<{ error: string } | { room: Room }>; createRoomFromScheduledRoom: (data: { description: string; id: string; name: string }) => Promise<{ room: Room }>; createScheduledRoom: (data: { description: string; name: string; scheduledFor: string }) => Promise<ScheduledRoom | { error: string }>; deleteRoomChatMessage: (userId: string, messageId: string) => Promise<void>; deleteScheduledRoom: (id: string) => any; editProfile: (data: { avatarUrl: string; bannerUrl?: string; bio: string; displayName: string; username: string }) => Promise<{ isUsernameTaken: boolean }>; editRoom: (data: { description: string; name: string; privacy: string }) => Promise<{ error: string } | { room: Room }>; editScheduledRoom: (id: string, data: { description: string; name: string; scheduledFor: string }) => Promise<ScheduledRoom | { error: string }>; follow: (userId: string, value: boolean) => Promise<void>; inviteToRoom: (userId: string) => void; leaveRoom: () => Promise<{ roomId: string }>; roomBan: (userId: string, shouldBanIp?: boolean) => Promise<void>; roomUpdate: (data: { autoSpeaker?: boolean; description?: string; name?: string; privacy?: string }) => Promise<void>; sendRoomChatMsg: (ast: MessageToken<string, unknown>[], whisperedTo?: string[]) => Promise<void>; setDeaf: (isDeafened: boolean) => Promise<Record<string, never>>; setListener: (userId: string) => Promise<void>; setMute: (isMuted: boolean) => Promise<Record<string, never>>; speakingChange: (value: boolean) => void; unbanFromRoom: (userId: string) => Promise<void>; unbanFromRoomChat: (userId: string) => Promise<void>; userBlock: (userId: string) => Promise<void>; userCreateBot: (username: string) => Promise<CreateBotResponse>; userUnblock: (userId: string) => Promise<void> }

    Allows you to call functions that mutate the ws state

    • addSpeaker: (userId: string) => Promise<void>
        • (userId: string): Promise<void>
        • Parameters

          • userId: string

          Returns Promise<void>

    • askToSpeak: () => void
        • (): void
        • Returns void

    • ban: (username: string, reason: string) => void
        • (username: string, reason: string): void
        • Parameters

          • username: string
          • reason: string

          Returns void

    • banFromRoomChat: (userId: string) => Promise<void>
        • (userId: string): Promise<void>
        • Parameters

          • userId: string

          Returns Promise<void>

    • changeModStatus: (userId: string, value: boolean) => Promise<void>
        • (userId: string, value: boolean): Promise<void>
        • Parameters

          • userId: string
          • value: boolean

          Returns Promise<void>

    • changeRoomCreator: (userId: string) => Promise<void>
        • (userId: string): Promise<void>
        • Parameters

          • userId: string

          Returns Promise<void>

    • createRoom: (data: { description: string; name: string; privacy: string }) => Promise<{ error: string } | { room: Room }>
        • (data: { description: string; name: string; privacy: string }): Promise<{ error: string } | { room: Room }>
        • Parameters

          • data: { description: string; name: string; privacy: string }
            • description: string
            • name: string
            • privacy: string

          Returns Promise<{ error: string } | { room: Room }>

    • createRoomFromScheduledRoom: (data: { description: string; id: string; name: string }) => Promise<{ room: Room }>
        • (data: { description: string; id: string; name: string }): Promise<{ room: Room }>
        • Parameters

          • data: { description: string; id: string; name: string }
            • description: string
            • id: string
            • name: string

          Returns Promise<{ room: Room }>

    • createScheduledRoom: (data: { description: string; name: string; scheduledFor: string }) => Promise<ScheduledRoom | { error: string }>
        • (data: { description: string; name: string; scheduledFor: string }): Promise<ScheduledRoom | { error: string }>
        • Parameters

          • data: { description: string; name: string; scheduledFor: string }
            • description: string
            • name: string
            • scheduledFor: string

          Returns Promise<ScheduledRoom | { error: string }>

    • deleteRoomChatMessage: (userId: string, messageId: string) => Promise<void>
        • (userId: string, messageId: string): Promise<void>
        • Parameters

          • userId: string
          • messageId: string

          Returns Promise<void>

    • deleteScheduledRoom: (id: string) => any
        • (id: string): any
        • Parameters

          • id: string

          Returns any

    • editProfile: (data: { avatarUrl: string; bannerUrl?: string; bio: string; displayName: string; username: string }) => Promise<{ isUsernameTaken: boolean }>
        • (data: { avatarUrl: string; bannerUrl?: string; bio: string; displayName: string; username: string }): Promise<{ isUsernameTaken: boolean }>
        • Parameters

          • data: { avatarUrl: string; bannerUrl?: string; bio: string; displayName: string; username: string }
            • avatarUrl: string
            • Optional bannerUrl?: string
            • bio: string
            • displayName: string
            • username: string

          Returns Promise<{ isUsernameTaken: boolean }>

    • editRoom: (data: { description: string; name: string; privacy: string }) => Promise<{ error: string } | { room: Room }>
        • (data: { description: string; name: string; privacy: string }): Promise<{ error: string } | { room: Room }>
        • Parameters

          • data: { description: string; name: string; privacy: string }
            • description: string
            • name: string
            • privacy: string

          Returns Promise<{ error: string } | { room: Room }>

    • editScheduledRoom: (id: string, data: { description: string; name: string; scheduledFor: string }) => Promise<ScheduledRoom | { error: string }>
        • (id: string, data: { description: string; name: string; scheduledFor: string }): Promise<ScheduledRoom | { error: string }>
        • Parameters

          • id: string
          • data: { description: string; name: string; scheduledFor: string }
            • description: string
            • name: string
            • scheduledFor: string

          Returns Promise<ScheduledRoom | { error: string }>

    • follow: (userId: string, value: boolean) => Promise<void>
        • (userId: string, value: boolean): Promise<void>
        • Parameters

          • userId: string
          • value: boolean

          Returns Promise<void>

    • inviteToRoom: (userId: string) => void
        • (userId: string): void
        • Parameters

          • userId: string

          Returns void

    • leaveRoom: () => Promise<{ roomId: string }>
        • (): Promise<{ roomId: string }>
        • Returns Promise<{ roomId: string }>

    • roomBan: (userId: string, shouldBanIp?: boolean) => Promise<void>
        • (userId: string, shouldBanIp?: boolean): Promise<void>
        • Parameters

          • userId: string
          • Optional shouldBanIp: boolean

          Returns Promise<void>

    • roomUpdate: (data: { autoSpeaker?: boolean; description?: string; name?: string; privacy?: string }) => Promise<void>
        • (data: { autoSpeaker?: boolean; description?: string; name?: string; privacy?: string }): Promise<void>
        • Parameters

          • data: { autoSpeaker?: boolean; description?: string; name?: string; privacy?: string }
            • Optional autoSpeaker?: boolean
            • Optional description?: string
            • Optional name?: string
            • Optional privacy?: string

          Returns Promise<void>

    • sendRoomChatMsg: (ast: MessageToken<string, unknown>[], whisperedTo?: string[]) => Promise<void>
        • (ast: MessageToken<string, unknown>[], whisperedTo?: string[]): Promise<void>
        • Parameters

          • ast: MessageToken<string, unknown>[]
          • Optional whisperedTo: string[]

          Returns Promise<void>

    • setDeaf: (isDeafened: boolean) => Promise<Record<string, never>>
        • (isDeafened: boolean): Promise<Record<string, never>>
        • Parameters

          • isDeafened: boolean

          Returns Promise<Record<string, never>>

    • setListener: (userId: string) => Promise<void>
        • (userId: string): Promise<void>
        • Parameters

          • userId: string

          Returns Promise<void>

    • setMute: (isMuted: boolean) => Promise<Record<string, never>>
        • (isMuted: boolean): Promise<Record<string, never>>
        • Parameters

          • isMuted: boolean

          Returns Promise<Record<string, never>>

    • speakingChange: (value: boolean) => void
        • (value: boolean): void
        • Parameters

          • value: boolean

          Returns void

    • unbanFromRoom: (userId: string) => Promise<void>
        • (userId: string): Promise<void>
        • Parameters

          • userId: string

          Returns Promise<void>

    • unbanFromRoomChat: (userId: string) => Promise<void>
        • (userId: string): Promise<void>
        • Parameters

          • userId: string

          Returns Promise<void>

    • userBlock: (userId: string) => Promise<void>
        • (userId: string): Promise<void>
        • Parameters

          • userId: string

          Returns Promise<void>

    • userCreateBot: (username: string) => Promise<CreateBotResponse>
        • (username: string): Promise<CreateBotResponse>
        • Parameters

          • username: string

          Returns Promise<CreateBotResponse>

    • userUnblock: (userId: string) => Promise<void>
        • (userId: string): Promise<void>
        • Parameters

          • userId: string

          Returns Promise<void>

  • query: { getBlockedFromRoomUsers: (cursor?: number) => Promise<{ nextCursor: null | number; users: User[] }>; getFollowList: (username: string, isFollowing: boolean, cursor?: number) => Promise<{ nextCursor: null | number; users: UserWithFollowInfo[] }>; getInviteList: (cursor?: number) => Promise<{ nextCursor: null | number; users: User[] }>; getMyFollowing: (cursor?: number) => Promise<{ nextCursor: null | number; users: UserWithFollowInfo[] }>; getMyScheduledRoomsAboutToStart: (roomId: string) => Promise<{ scheduledRooms: ScheduledRoom[] }>; getRoomUsers: () => Promise<GetRoomUsersResponse>; getScheduledRooms: (cursor?: string, getOnlyMyScheduledRooms?: boolean) => Promise<GetScheduledRoomsResponse>; getTopPublicRooms: (cursor?: number) => Promise<GetTopPublicRoomsResponse>; getUserProfile: (idOrUsername: string) => Promise<null | UserWithFollowInfo | { error: string }>; joinRoomAndGetInfo: (roomId: string) => Promise<JoinRoomAndGetInfoResponse | { error: string }>; search: (query: string) => Promise<{ items: (User | Room)[] }> }

    Allows you to call functions that return information about the ws state

    • getBlockedFromRoomUsers: (cursor?: number) => Promise<{ nextCursor: null | number; users: User[] }>
        • (cursor?: number): Promise<{ nextCursor: null | number; users: User[] }>
        • Parameters

          • Optional cursor: number

          Returns Promise<{ nextCursor: null | number; users: User[] }>

    • getFollowList: (username: string, isFollowing: boolean, cursor?: number) => Promise<{ nextCursor: null | number; users: UserWithFollowInfo[] }>
        • (username: string, isFollowing: boolean, cursor?: number): Promise<{ nextCursor: null | number; users: UserWithFollowInfo[] }>
        • Parameters

          • username: string
          • isFollowing: boolean
          • Optional cursor: number

          Returns Promise<{ nextCursor: null | number; users: UserWithFollowInfo[] }>

    • getInviteList: (cursor?: number) => Promise<{ nextCursor: null | number; users: User[] }>
        • (cursor?: number): Promise<{ nextCursor: null | number; users: User[] }>
        • Parameters

          • Optional cursor: number

          Returns Promise<{ nextCursor: null | number; users: User[] }>

    • getMyFollowing: (cursor?: number) => Promise<{ nextCursor: null | number; users: UserWithFollowInfo[] }>
        • (cursor?: number): Promise<{ nextCursor: null | number; users: UserWithFollowInfo[] }>
        • Parameters

          • Optional cursor: number

          Returns Promise<{ nextCursor: null | number; users: UserWithFollowInfo[] }>

    • getMyScheduledRoomsAboutToStart: (roomId: string) => Promise<{ scheduledRooms: ScheduledRoom[] }>
        • (roomId: string): Promise<{ scheduledRooms: ScheduledRoom[] }>
        • Parameters

          • roomId: string

          Returns Promise<{ scheduledRooms: ScheduledRoom[] }>

    • getRoomUsers: () => Promise<GetRoomUsersResponse>
        • (): Promise<GetRoomUsersResponse>
        • Returns Promise<GetRoomUsersResponse>

    • getScheduledRooms: (cursor?: string, getOnlyMyScheduledRooms?: boolean) => Promise<GetScheduledRoomsResponse>
        • (cursor?: string, getOnlyMyScheduledRooms?: boolean): Promise<GetScheduledRoomsResponse>
        • Parameters

          • Optional cursor: string
          • Optional getOnlyMyScheduledRooms: boolean

          Returns Promise<GetScheduledRoomsResponse>

    • getTopPublicRooms: (cursor?: number) => Promise<GetTopPublicRoomsResponse>
        • (cursor?: number): Promise<GetTopPublicRoomsResponse>
        • Parameters

          • Optional cursor: number

          Returns Promise<GetTopPublicRoomsResponse>

    • getUserProfile: (idOrUsername: string) => Promise<null | UserWithFollowInfo | { error: string }>
        • (idOrUsername: string): Promise<null | UserWithFollowInfo | { error: string }>
        • Parameters

          • idOrUsername: string

          Returns Promise<null | UserWithFollowInfo | { error: string }>

    • joinRoomAndGetInfo: (roomId: string) => Promise<JoinRoomAndGetInfoResponse | { error: string }>
        • (roomId: string): Promise<JoinRoomAndGetInfoResponse | { error: string }>
        • Parameters

          • roomId: string

          Returns Promise<JoinRoomAndGetInfoResponse | { error: string }>

    • search: (query: string) => Promise<{ items: (User | Room)[] }>
        • (query: string): Promise<{ items: (User | Room)[] }>
        • Parameters

          • query: string

          Returns Promise<{ items: (User | Room)[] }>

  • subscribe: { handRaised: (handler: Handler<{ userId: string }>) => () => void; invitationToRoom: (handler: Handler<InvitationToRoomResponse>) => () => void; newChatMsg: (handler: Handler<{ msg: Message; userId: string }>) => () => void; newRoomDetails: (handler: Handler<NewRoomDetailsResponse>) => () => void; speakerAdded: (handler: Handler<{ deafMap: BooleanMap; muteMap: BooleanMap; userId: string }>) => () => void; speakerRemoved: (handler: Handler<{ deafMap: BooleanMap; muteMap: BooleanMap; userId: string }>) => () => void; userJoinRoom: (handler: Handler<{ user: User }>) => () => void; userLeaveRoom: (handler: Handler<{ roomId: string; userId: string }>) => () => void }

    Allows you to subscribe to various pre-defined websocket events

    • handRaised: (handler: Handler<{ userId: string }>) => () => void
        • (handler: Handler<{ userId: string }>): () => void
        • Parameters

          • handler: Handler<{ userId: string }>

          Returns () => void

            • (): void
            • Returns void

    • invitationToRoom: (handler: Handler<InvitationToRoomResponse>) => () => void
        • (handler: Handler<InvitationToRoomResponse>): () => void
        • Parameters

          • handler: Handler<InvitationToRoomResponse>

          Returns () => void

            • (): void
            • Returns void

    • newChatMsg: (handler: Handler<{ msg: Message; userId: string }>) => () => void
        • (handler: Handler<{ msg: Message; userId: string }>): () => void
        • Parameters

          • handler: Handler<{ msg: Message; userId: string }>

          Returns () => void

            • (): void
            • Returns void

    • newRoomDetails: (handler: Handler<NewRoomDetailsResponse>) => () => void
        • (handler: Handler<NewRoomDetailsResponse>): () => void
        • Parameters

          • handler: Handler<NewRoomDetailsResponse>

          Returns () => void

            • (): void
            • Returns void

    • speakerAdded: (handler: Handler<{ deafMap: BooleanMap; muteMap: BooleanMap; userId: string }>) => () => void
        • (handler: Handler<{ deafMap: BooleanMap; muteMap: BooleanMap; userId: string }>): () => void
        • Parameters

          • handler: Handler<{ deafMap: BooleanMap; muteMap: BooleanMap; userId: string }>

          Returns () => void

            • (): void
            • Returns void

    • speakerRemoved: (handler: Handler<{ deafMap: BooleanMap; muteMap: BooleanMap; userId: string }>) => () => void
        • (handler: Handler<{ deafMap: BooleanMap; muteMap: BooleanMap; userId: string }>): () => void
        • Parameters

          • handler: Handler<{ deafMap: BooleanMap; muteMap: BooleanMap; userId: string }>

          Returns () => void

            • (): void
            • Returns void

    • userJoinRoom: (handler: Handler<{ user: User }>) => () => void
        • (handler: Handler<{ user: User }>): () => void
        • Parameters

          • handler: Handler<{ user: User }>

          Returns () => void

            • (): void
            • Returns void

    • userLeaveRoom: (handler: Handler<{ roomId: string; userId: string }>) => () => void
        • (handler: Handler<{ roomId: string; userId: string }>): () => void
        • Parameters

          • handler: Handler<{ roomId: string; userId: string }>

          Returns () => void

            • (): void
            • Returns void

Methods

addListener

clearImmediate

  • clearImmediate(immediate: Immediate): void

clearInterval

  • clearInterval(interval: Timeout): void

clearTimeout

  • clearTimeout(timeout: Timeout): void

createBot

  • createBot(username: string): Promise<null | string>
  • Creates a bot account.

    Parameters

    • username: string

      The username of the bot account.

    Returns Promise<null | string>

    The api key.

destroy

  • destroy(): void

emit

eventNames

  • eventNames(): (string | symbol)[]

getBotCredentials

getMaxListeners

  • getMaxListeners(): number

listenerCount

  • listenerCount<E>(event: E): number

listeners

  • listeners<E>(event: E): Function[]

login

  • login(token: string, refreshToken: string): Promise<void>
  • Login to the DogeHouse API.

    Parameters

    • token: string

      The token.

    • refreshToken: string

      The refresh token.

    Returns Promise<void>

off

on

once

prependListener

prependOnceListener

rawListeners

  • rawListeners<E>(event: E): Function[]

removeAllListeners

  • removeAllListeners<E>(event?: E): Client

removeListener

setImmediate

  • setImmediate(fn: (...args: unknown[]) => void, ...args: unknown[]): Immediate
  • Sets an immediate.

    Parameters

    • fn: (...args: unknown[]) => void

      The function to execute.

        • (...args: unknown[]): void
        • Parameters

          • Rest ...args: unknown[]

          Returns void

    • Rest ...args: unknown[]

      The extra args.

    Returns Immediate

    The immediate.

setInterval

  • setInterval(fn: (...args: unknown[]) => void, delay: number, ...args: unknown[]): Timeout
  • Sets an interval.

    Parameters

    • fn: (...args: unknown[]) => void

      The function to execute.

        • (...args: unknown[]): void
        • Parameters

          • Rest ...args: unknown[]

          Returns void

    • delay: number

      Time to execute.

    • Rest ...args: unknown[]

      The extra args.

    Returns Timeout

    The interval.

setMaxListeners

  • setMaxListeners(maxListeners: number): Client

setTimeout

  • setTimeout(fn: (...args: unknown[]) => void, delay: number, ...args: unknown[]): Timeout
  • Sets a timeout.

    Parameters

    • fn: (...args: unknown[]) => void

      The function to execute.

        • (...args: unknown[]): void
        • Parameters

          • Rest ...args: unknown[]

          Returns void

    • delay: number

      Time to delay.

    • Rest ...args: unknown[]

      The extra args.

    Returns Timeout

    The timeout.

Generated using TypeDoc