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.

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

Properties

roomSlug?: string

Room Slug

userUuid?: string

UUID of the connected user

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

API DiceBox Actions

Type declaration

roll: {
    create: ((dice, options?) => Promise<IApiResponse<"roll", IRoll>>);
    get: ((id) => Promise<IApiResponse<"roll", IRoll>>);
    update: ((id, payload) => Promise<IApiResponse<"roll", IRoll>>);
    updateBulk: ((rolls) => Promise<IApiResponse<"roll[]", IRoll[]>>);
} = ...

API Roll Actions

Type declaration

room: {
    list: (() => Promise<IApiResponse<"room[]", IRoom[]>>);
    create: (() => Promise<IApiResponse<"room", IRoom>>);
    get: ((slug, passcode?) => Promise<IApiResponse<"room", IRoom>>);
    join: ((slug, passcode?) => Promise<IApiResponse<"room", IRoom>>);
    leave: ((slug, participantId?) => Promise<IApiResponse<"room", IRoom>>);
    updateParticipant: ((slug, participantId, data) => Promise<IApiResponse<"room", IRoom>>);
    updateRolls: ((slug, dice, participant?) => Promise<any>);
    update: ((slug, room) => Promise<any>);
    deleteRolls: ((slug) => Promise<any>);
    updateBackground: ((slug, file) => Promise<any>);
} = ...

API Room Actions

Type declaration

  • list: (() => Promise<IApiResponse<"room[]", IRoom[]>>)

    List all created or joined rooms

  • create: (() => Promise<IApiResponse<"room", IRoom>>)

    Create a new room

  • get: ((slug, passcode?) => Promise<IApiResponse<"room", IRoom>>)

    Get a room by ID

    Param: slug

    Room slug

    Param: passcode

    Passcode for access is the room is private

      • (slug, passcode?): 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, passcode?) => Promise<IApiResponse<"room", IRoom>>)

    Join a room

    Param: slug

    Room slug

    Param: passcode

    Passcode for entry if the room is private

      • (slug, passcode?): 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, participantId?) => Promise<IApiResponse<"room", IRoom>>)

    Leave a room

    Param: slug

    Room slug

    Param: participantId

    Participant ID

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

        Parameters

        • slug: string

          Room slug

        • Optional participantId: string

          Participant ID

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

  • updateParticipant: ((slug, participantId, data) => Promise<IApiResponse<"room", IRoom>>)

    Update a participant

    Param: slug

    Room slug

    Param: participantId

    Participant ID

    Param: data

    Participant information

    Param: data.username

    Update participant username

    Param: data.color

    Update participant color. Example #FF0000

      • (slug, participantId, data): Promise<IApiResponse<"room", IRoom>>
      • Update a participant

        Parameters

        • slug: string

          Room slug

        • participantId: number

          Participant ID

        • data: Partial<IRoomParticipant>

          Participant information

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

  • updateRolls: ((slug, dice, participant?) => 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.

    Param: slug

    Room slug

    Param: dice

    object to patch onto the dice in the room

    Param: dice.is_cleared

    set to true to clear all active dice in room

    Param: participant

    optional participant id of the dice to clear. Only room owner may clear dice they did not roll. supply '*' to clear all dice for all players, including you

      • (slug, dice, participant?): 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

            set to true to clear all active dice in room

        • Optional participant: string | number

          optional participant id of the dice to clear. Only room owner may clear dice they did not roll. supply '*' to clear all dice for all players, including you

        Returns Promise<any>

  • update: ((slug, room) => Promise<any>)

    Update Room Update data about the room like room name

    Param: slug

    Room slug

    Param: room

    object containing room data to patch

    Param: room.name

    room name to change to

    Param: room.is_public

    set to true to make room public, false to make private

    Param: room.passcode

    passcode to use for a private room (is_public == false)

      • (slug, room): Promise<any>
      • Update Room Update data about the room like room name

        Parameters

        • slug: string

          Room slug

        • room: {
              name: string;
              is_public: boolean;
              passcode: string;
          }

          object containing room data to patch

          • name: string

            room name to change to

          • is_public: boolean

            set to true to make room public, false to make private

          • passcode: string

            passcode to use for a private room (is_public == false)

        Returns Promise<any>

  • deleteRolls: ((slug) => Promise<any>)

    Clear roll history Update data about the room like room name

    Param: slug

    Room slug

      • (slug): Promise<any>
      • Clear roll history Update data about the room like room name

        Parameters

        • slug: string

          Room slug

        Returns Promise<any>

  • updateBackground: ((slug, file) => Promise<any>)

    Update Room Background Update data about the room like room name

    Param: slug

    Room slug

    Param: file

    File object (as created by a file input) containing the file to upload

      • (slug, file): Promise<any>
      • Update Room Background Update data about the room like room name

        Parameters

        • slug: string

          Room slug

        • file: File

          File object (as created by a file input) containing the file to upload

        Returns Promise<any>

theme: {
    get: ((id) => 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

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.

    Parameters

    • callback: ((state) => any)

      The function to execute when the connection state changes

        • (state): any
        • Parameters

          • state: string

          Returns any

    Returns ThreeDDiceAPI

    Throws

    APIConnectError if the live connection has not been established

  • Execute a callback when a participant connection is established.

    This is called once per-participant connection, excluding your own connection.

    Parameters

    Returns ThreeDDiceAPI

    Throws

    APIRoomConnectError if the room connection has not been established

  • Execute a callback when a participant connection is lost or disconnected

    This is called once per-participant connection, excluding your own connection.

    Parameters

    Returns ThreeDDiceAPI

    Throws

    APIRoomConnectError if the room connection has not been established

  • Parameters

    • eventName: string
    • data: {
          [key: string]: any;
      }
      • [key: string]: any

    Returns void

Generated using TypeDoc