Used to communicate with the dddice API and live server. This is typically not initialized directly by a developer but created after calling ThreeDDice#connect.

Hierarchy

  • ThreeDDiceAPI

Constructors

  • The constructor of the ThreeDDiceAPI class

    Parameters

    • Optional apiKey: string

      The API key used to communicate with the server

    • Optional appName: string

      Optional string to identify the application which is communicating with the API

    Returns ThreeDDiceAPI

Methods

  • Connect to the live server and begin listening to room events.

    Note: Your user must be a participant in a room in order to listen to events, otherwise an error is thrown.

    Parameters

    • roomSlug: string

      Room slug to listen on

    • Optional roomPasscode: string

      Private passcode to access room

    • Optional userUuid: string

      Personal User UUID to listen to whispers

    Returns ThreeDDiceAPI

  • Execute a callback when the connection state changes.

    Throws

    APIConnectError if the live connection has not been established

    Parameters

    • callback: ((state: string) => any)

      The function to execute when the connection state changes

        • (state: string): any
        • Parameters

          • state: string

          Returns any

    Returns ThreeDDiceAPI

Properties

diceBox: { list: ((filter?: string) => Promise<IApiResponse<"theme[]", ITheme[]>>); next: (() => Promise<null | IApiResponse<"theme[]", ITheme[]>>) } = ...

API DiceBox Actions

Type declaration

roll: { create: ((dice: IDiceRoll[], options?: Partial<IDiceRollOptions>) => Promise<IApiResponse<"roll", IRoll>>); get: ((id: string) => Promise<IApiResponse<"roll", IRoll>>); update: ((id: string, payload: { dice: { uuid: string; is_hidden?: boolean }[]; room?: string }) => Promise<IApiResponse<"roll", IRoll>>); updateBulk: ((rolls: { uuid: string; dice: { uuid: string; is_hidden?: boolean }[]; room?: string }[]) => Promise<IApiResponse<"roll[]", IRoll[]>>) } = ...

API Roll Actions

Type declaration

  • create: ((dice: IDiceRoll[], options?: Partial<IDiceRollOptions>) => Promise<IApiResponse<"roll", IRoll>>)
  • get: ((id: string) => Promise<IApiResponse<"roll", IRoll>>)
  • update: ((id: string, payload: { dice: { uuid: string; is_hidden?: boolean }[]; room?: string }) => Promise<IApiResponse<"roll", IRoll>>)
      • (id: string, payload: { dice: { uuid: string; is_hidden?: boolean }[]; room?: string }): Promise<IApiResponse<"roll", IRoll>>
      • Update a roll

        Parameters

        • id: string
        • payload: { dice: { uuid: string; is_hidden?: boolean }[]; room?: string }
          • dice: { uuid: string; is_hidden?: boolean }[]
          • Optional room?: string

        Returns Promise<IApiResponse<"roll", IRoll>>

  • updateBulk: ((rolls: { uuid: string; dice: { uuid: string; is_hidden?: boolean }[]; room?: string }[]) => Promise<IApiResponse<"roll[]", IRoll[]>>)
      • (rolls: { uuid: string; dice: { uuid: string; is_hidden?: boolean }[]; room?: string }[]): Promise<IApiResponse<"roll[]", IRoll[]>>
      • Bulk update rolls

        Parameters

        • rolls: { uuid: string; dice: { uuid: string; is_hidden?: boolean }[]; room?: string }[]

        Returns Promise<IApiResponse<"roll[]", IRoll[]>>

room: { list: (() => Promise<IApiResponse<"room[]", IRoom[]>>); create: (() => Promise<IApiResponse<"room", IRoom>>); get: ((slug: string, passcode?: string) => Promise<IApiResponse<"room", IRoom>>); join: ((slug: string, passcode?: string) => Promise<IApiResponse<"room", IRoom>>); leave: ((slug: string, participantId?: string) => Promise<IApiResponse<"room", IRoom>>); updateParticipant: ((slug: string, participantId: number, data: { username?: string; color?: string }) => Promise<IApiResponse<"room", IRoom>>); updateRolls: ((slug: string, dice: { is_cleared: boolean }) => Promise<any>) } = ...

API Room Actions

Type declaration

  • list: (() => Promise<IApiResponse<"room[]", IRoom[]>>)
  • create: (() => Promise<IApiResponse<"room", IRoom>>)
  • get: ((slug: string, passcode?: string) => Promise<IApiResponse<"room", IRoom>>)
      • (slug: string, passcode?: string): Promise<IApiResponse<"room", IRoom>>
      • Get a room by ID

        Parameters

        • slug: string

          Room slug

        • Optional passcode: string

          Passcode for access is the room is private

        Returns Promise<IApiResponse<"room", IRoom>>

  • join: ((slug: string, passcode?: string) => Promise<IApiResponse<"room", IRoom>>)
      • (slug: string, passcode?: string): Promise<IApiResponse<"room", IRoom>>
      • Join a room

        Parameters

        • slug: string

          Room slug

        • Optional passcode: string

          Passcode for entry if the room is private

        Returns Promise<IApiResponse<"room", IRoom>>

  • leave: ((slug: string, participantId?: string) => Promise<IApiResponse<"room", IRoom>>)
      • (slug: string, participantId?: string): Promise<IApiResponse<"room", IRoom>>
      • Leave a room

        Parameters

        • slug: string

          Room slug

        • Optional participantId: string

          Participant ID

        Returns Promise<IApiResponse<"room", IRoom>>

  • updateParticipant: ((slug: string, participantId: number, data: { username?: string; color?: string }) => Promise<IApiResponse<"room", IRoom>>)
      • (slug: string, participantId: number, data: { username?: string; color?: string }): Promise<IApiResponse<"room", IRoom>>
      • Update a participant

        Parameters

        • slug: string

          Room slug

        • participantId: number

          Participant ID

        • data: { username?: string; color?: string }

          Participant information

          • Optional username?: string

            Update participant username

          • Optional color?: string

            Update participant color. Example #FF0000

        Returns Promise<IApiResponse<"room", IRoom>>

  • updateRolls: ((slug: string, dice: { is_cleared: boolean }) => Promise<any>)
      • (slug: string, dice: { is_cleared: boolean }): Promise<any>
      • Update Room Rolls Automatically pickup dice from the board or unhide dice to players for all rolls in a room and for the current player.

        Parameters

        • slug: string

          Room slug

        • dice: { is_cleared: boolean }

          object to patch onto the dice in the room

          • is_cleared: boolean

        Returns Promise<any>

theme: { get: ((id: string) => Promise<IApiResponse<"theme", ITheme>>) } = ...

API Theme Actions

Type declaration

user: { get: (() => Promise<IApiResponse<"user", IUser>>); guest: (() => Promise<IApiResponse<"string", string>>) } = ...

API User Actions

Type declaration

Generated using TypeDoc