🎉Events

Time to go over the events that are available for you to subscribe to, as well as all the data that each event emits.

Available Events

This is the *current* list of available events, as time goes on more events may be added, but to keep overlays that have been made working, event types will never be removed unless absolutely necessary.

  • message

  • command

  • sticker

  • support

  • follow

  • subscription

  • giftsub

  • resub

  • host

  • raid

Event Data

Each event has different data that it will emit when the event happens, so let's go over those!

Message

The message event is likely the event that will be most commonly used. It is also the event that has the most "pre-processing" done to it. First, we'll just show you what it looks like, then we'll give a brief overview of how it's structured.

interface IMessageEmote {
  type: "emote";
  url: string;
  text: string;
}

interface IMessageText {
  type: "text";
  text: string;
}

type IMessage = IMessageEmote | IMessageText;

interface IChatMessage {
  user: {
    displayName?: string;
    name: string;
    id: string;
    color: string;
    badges?: string[];
    avatar: string;
    isMod: boolean;
    isSub: boolean;
  };
  special?: string;
  message: IMessage[];
  id: string;
  from: string;
}

This is the message event, it is the IChatMessage that will be emitted to your listener. Most of this event should be pretty obvious, the slightly unconventional part is the way the actual chat message is formatted. Within the event, there is an array property called message this property is an array that contains n elements that are either a text message, or an emote message. This is done like this because Pixel Chat parses out all emotes for you! The other small thing to note is the from property, this property specifies what platform the message is from, be that twitch of trovo etc.

Command

interface ICommand {
  command: string;
  user: {
    displayName?: string;
    name: string;
    id: string;
    color: string;
    badges?: string[];
    avatar: string;
    isMod: boolean;
    isSub: boolean;
  };
  args: string[];
  from: string;
}

This is the command event, it is emitted every time there is a message event and is designed to make dealing with commands a little bit easier. The command property will always be the first word in the message, and the args array will be everything that comes after that, split by spaces.

Sticker

interface ISticker {
  user: {
    name: string;
    avatar: string;
  };
  sticker: {
    url: string;
    name: string;
    currency: string;
    price: number;
    bg: {
      initial: string | null;
      loop: string | null;
    };
  };
}

The sticker event is an event exclusive to Trovo, and emits whenever a sticker is used in chat. the event will contain info such as the url to the gif of the sticker, as well as the urls for the background animations assuming they exist for the said sticker.

Support

interface ISupport {
  username: string;
  avatar: string;
  amount: number | string;
  message?: string;
  currency: string;
}

This is going to be your basic support events, such as bits, mana, or elixir. The "currency" field represents what currency was used and as of writing this will always be one of [bits, mana, elixir].

Follow

interface IFollow {
  user: {
    name: string;
    avatar: string;
  };
}

This is your basic follow event, it will be fired whenever a viewer follows the channel.

Subscription

interface ISubscription {
  user: {
    name: string;
    avatar: string;
  };
  level?: number;
}

GiftSub

interface IGiftSub {
  user: {
    name: string;
    avatar: string;
  };
  recipient: {
    name: string;
    avatar: string;
  };
  level?: number;
}

Resub

interface IResubscription {
  user: {
    name: string;
    avatar: string;
  };
  months: number;
  message?: string;
}

Host

interface IHost {
  user: {
    name: string;
    avatar: string;
  };
  viewers?: number;
}

Please note that host events are not emitted for Twitch channels, as these events are not easily available from twitch.

Raid

interface IRaid {
  user: {
    name: string;
    avatar: string;
  };
  viewers?: number;
}

Last updated