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

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) => Promise<any>);
    update: ((slug, room) => Promise<any>);
} = ...

API Room Actions

Type declaration

  • list: (() => Promise<IApiResponse<"room[]", IRoom[]>>)
  • create: (() => Promise<IApiResponse<"room", IRoom>>)
  • get: ((slug, passcode?) => Promise<IApiResponse<"room", IRoom>>)
      • (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>>)
      • (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>>)
      • (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>>)
      • (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) => Promise<any>)
      • (slug, dice): 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>

  • update: ((slug, room) => Promise<any>)
      • (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>

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