Triangle.js Docs
    Preparing search index...

    Interface Client

    interface Client {
        "client.close": string;
        "client.dead": string;
        "client.dm": {
            content: string;
            raw: DM;
            relationship: Classes.Relationship;
            reply: (message: string) => Promise<string | void | DM>;
        };
        "client.error": string;
        "client.fail": Error;
        "client.friended": { avatar: number
        | null; id: string; name: string };
        "client.game.abort": void;
        "client.game.end":
            | {
                duration: number;
                players: {
                    id: string;
                    lifetime: number;
                    name: string;
                    points: number;
                    raw: Scoreboard;
                    won: boolean;
                }[];
                source: "scoreboard";
            }
            | {
                duration: number;
                players: {
                    id: string;
                    name: string;
                    points: number;
                    raw: Types.Game.Leaderboard;
                    won: boolean;
                }[];
                source: "leaderboard";
            };
        "client.game.over": | {
            data: {
                gameoverreason: GameOverReason;
                killer: { gameid: number; type: "sizzle"; username?: string
                | null };
            };
            reason: "finish";
        }
        | { reason: "abort" }
        | { reason: "end" }
        | { reason: "leave" };
        "client.game.round.end": string | null;
        "client.game.round.start": [(cb: Func) => void, Engine.Engine];
        "client.game.start": { ft: number; multi: boolean; wb: number } & {
            players: { id: string; name: string; points: 0 }[];
        };
        "client.notify": {
            bgcolor?: `#${string}`;
            buttons?: { classes?: string; icon?: string; label: string }[];
            classes?: string;
            color?: `#${string}`;
            fcolor?: `#${string}`;
            header?: string;
            icon?: string;
            id?: string;
            msg: string;
            subcolor?: `#${string}`;
            subicon?: string;
            timeout?: number;
        };
        "client.ready": {
            endpoint: string;
            social: {
                notifications: Notification[];
                presences: {
                    [userId: string]: {
                        detail: string;
                        invitable: boolean;
                        status: string;
                    };
                };
                relationships: Types.Social.Relationship[];
                total_online: number;
            };
        };
        "client.ribbon.error": string;
        "client.ribbon.log": string;
        "client.ribbon.receive": { command: string; data?: any };
        "client.ribbon.send": { command: string; data?: any };
        "client.ribbon.warn": string;
        "client.room.join": Classes.Room;
        "client.room.players": Types.Room.Player[];
    }
    Index

    Properties

    "client.close": string

    Fires when the websocket closes. Note: the websocket might just be migrating, to check for a fully disconnected client, use client.dead

    "client.dead": string

    Fires when the client dies.

    "client.dm": {
        content: string;
        raw: DM;
        relationship: Classes.Relationship;
        reply: (message: string) => Promise<string | void | DM>;
    }

    Fires when a DM (direct message) has been received and AFTER any unknown data has been loaded about the user. client.dm does NOT fire when receiving a social.dm event triggered by a message sent by the client.

    "client.error": string

    Fires when recieving an "err" notification. Data is the "msg" of the notification

    "client.fail": Error

    Fires whenever Ribbon.#connect() throws an error.

    "client.friended": { avatar: number | null; id: string; name: string }

    Fires whenever the client is friended

    "client.game.abort": void

    Same as game.abort

    "client.game.end":
        | {
            duration: number;
            players: {
                id: string;
                lifetime: number;
                name: string;
                points: number;
                raw: Scoreboard;
                won: boolean;
            }[];
            source: "scoreboard";
        }
        | {
            duration: number;
            players: {
                id: string;
                name: string;
                points: number;
                raw: Types.Game.Leaderboard;
                won: boolean;
            }[];
            source: "leaderboard";
        }

    Fires when a game ends. Likely known issue:

    "client.game.over":
        | {
            data: {
                gameoverreason: GameOverReason;
                killer: { gameid: number; type: "sizzle"; username?: string
                | null };
            };
            reason: "finish";
        }
        | { reason: "abort" }
        | { reason: "end" }
        | { reason: "leave" }

    Fires when the client's game ends (topout). Finish = game.replay.end, abort = game.abort, end = game.end or game.advance or game.score

    "client.game.round.end": string | null

    Fires when a round is over, sends the user id of the winning player, if there is one.

    "client.game.round.start": [(cb: Func) => void, Engine.Engine]

    Fires when a round starts (this includes 1-round games)

    "client.game.start": { ft: number; multi: boolean; wb: number } & {
        players: { id: string; name: string; points: 0 }[];
    }

    Fires when a game starts

    "client.notify": {
        bgcolor?: `#${string}`;
        buttons?: { classes?: string; icon?: string; label: string }[];
        classes?: string;
        color?: `#${string}`;
        fcolor?: `#${string}`;
        header?: string;
        icon?: string;
        id?: string;
        msg: string;
        subcolor?: `#${string}`;
        subicon?: string;
        timeout?: number;
    }

    Any notification popup

    "client.ready": {
        endpoint: string;
        social: {
            notifications: Notification[];
            presences: {
                [userId: string]: {
                    detail: string;
                    invitable: boolean;
                    status: string;
                };
            };
            relationships: Types.Social.Relationship[];
            total_online: number;
        };
    }

    Fires inside Client.create(), will never fire afterwards.

    "client.ribbon.error": string

    Fires whenever Ribbon encounters an error

    "client.ribbon.log": string

    Fires whenever a Ribbon log is outputted

    "client.ribbon.receive": { command: string; data?: any }

    Fires when a message is recived from the server. Contains the raw data of the server message. Useful for logging, do not use for handling events for functionality. Instead, use client.on(<event>).

    "client.ribbon.send": { command: string; data?: any }

    Fires when a message is sent to the server. Contains the raw data of the server message. Useful for logging.

    "client.ribbon.warn": string

    Fires whenever a Ribbon warning is outputted

    "client.room.join": Classes.Room

    Fires when the client joins a room

    "client.room.players": Types.Room.Player[]

    Fires whenever the players state changes.