Events

Methods

# debugEvents()

Enables debug mode and logs event objects to the console

Since:
  • 1.0.2

# disableSenderCorrection()

Disables the sender correction for emulated events. Only useful for specific test-cases.

You can call this via window.Events.disableSenderCorrection()

Since:
  • 1.0.0

# expectsEventListener(listener) → {boolean}

Returns whether the window expects an event for the specified listener.

Parameters:
Name Type Description
listener string

The event-listener to check for.

Since:
  • 1.0.0
Returns:
Type
boolean

# expectsEventName(name) → {boolean}

Returns whether the window expects an event for the specified name.

Parameters:
Name Type Description
name string

The event-name to check for.

Since:
  • 1.0.0
Returns:
Type
boolean

# expectsEvents() → {boolean}

Returns whether the window expects any onEventReceived events.

Since:
  • 1.0.0
Returns:
Type
boolean

# isSkippable(event) → {boolean}

Returns whether the given event would not get queued by the StreamElements API.

Parameters:
Name Type Description
event string

The event-name to check for.

Since:
  • 1.0.0
Returns:
Type
boolean

# onBotCounterHandler(e)

Calls window.onBotCounter and gets triggered everytime a bot-counter gets updated. (Through chat commands for example)

Parameters:
Name Type Description
e BotCounterEvent

The event data object

Since:
  • 1.0.0

# onCheerHandler(e)

Calls window.onCheer and gets triggered when someone cheers (uses Bits) in your channel.

Parameters:
Name Type Description
e CheerEvent

The event data object

Since:
  • 1.0.0

# onCommunityGiftHandler(e)

Calls window.onCommunityGift and gets triggered for each gifted sub in a SubBomb. Has the same data as onSubGift and a fixed recipient.

Parameters:
Name Type Description
e CommunityGiftEvent

The event data object

Since:
  • 1.0.0

# onDeleteMessageHandler(e)

Calls window.onDeleteMessage and gets triggered everytime a single message is deleted in your chat, by a moderator. You can use the passed messageId to delete the message in your own chat widget.

Parameters:
Name Type Description
e DeleteMessageEvent

The event data object

Since:
  • 1.0.0

# onDeleteMessagesHandler(e)

Calls window.onMessage and gets triggered everytime multiple messages are deleted in your chat, by a moderator. This could occur on timeouts and bans and affects every message the user sent in chat this session. You can use the passed userId to delete all messages of that user in your own chat widget.

Parameters:
Name Type Description
e DeleteMessagesEvent

The event data object

Since:
  • 1.0.0

# onEventReceivedHandler(p)

Handles the 'onEventReceived' event and forwards the data parameter to the corresponding handler. This function auto-determines which handler should be called, based on the provided data object.

Parameters:
Name Type Description
p object

The proxied obj parameter of the original onEventReceived event

Since:
  • 1.0.0

# onEventSkipHandler()

Calls window.onEventSkip and gets triggered everytime you try to skip an alert in your dashboard.

Since:
  • 1.0.0

# onFollowHandler(e)

Calls window.onFollow and gets triggered when someone follows your channel.

Parameters:
Name Type Description
e FollowEvent

The event data object

Since:
  • 1.0.0

# onKVStoreUpdateHandler(e)

Calls window.onKVStoreUpdate and gets triggered everytime a value changes. NOTE: This will also get triggered across widgets to communicate between them.

Parameters:
Name Type Description
e KVStoreUpdateEvent

The event data object

Since:
  • 1.0.0

# onMessageHandler(e)

Calls window.onMessage and gets triggered everytime someone sends a message in your chat. If the message originates from Twitch chat, it will get transformed to a {@see ChatMessage} object.

Parameters:
Name Type Description
e MessageEvent

The event data object

Since:
  • 1.0.0

# onRaidHandler(e)

Calls window.onCheer and gets triggered when someone raids your channel.

Parameters:
Name Type Description
e RaidEvent

The event data object

Since:
  • 1.0.0

# onResubHandler(e)

Calls window.onResub and gets triggered when someone resubscribes on your channel.

Parameters:
Name Type Description
e ResubEvent

The event data object

Since:
  • 1.0.0

# onSessionUpdateHandler(p)

Handles and forwards the 'onSessionUpdate' event data to window.onSessionUpdate.

Parameters:
Name Type Description
p object

The proxied obj parameter of the original onSessionUpdate event

Since:
  • 1.0.0

# onSubBombCompleteHandler(e, recipients)

Calls window.onSubBombComplete and gets triggered after a SubBomb completes and all recipients are known. Passes an array of recipient names as second parameter.

Parameters:
Name Type Description
e SubBombEvent

The event data object

recipients Array.<string>

An array of recipient names

Since:
  • 1.0.0

# onSubBombHandler(e)

Calls window.onSubBomb and gets triggered when a SubBomb occurs. This event will trigger on the initial SubBomb message and only contains the sender and amount. Recipients are not known yet.

Parameters:
Name Type Description
e SubBombEvent

The event data object

Since:
  • 1.0.0

# onSubGiftHandler(e)

Calls window.onSubGift and gets triggered when someone gifts a subscription to another user (targeted).

Parameters:
Name Type Description
e SubGiftEvent

The event data object

Since:
  • 1.0.0

# onSubscriberHandler(e)

Calls window.onSubscriber and gets triggered when someone subscribes for the first time (first month) on your channel.

Parameters:
Name Type Description
e SubscriberEvent

The event data object

Since:
  • 1.0.0

# onTipHandler(e)

Calls window.onTip and gets triggered when you receive a tip through StreamElements.

Parameters:
Name Type Description
e TipEvent

The event data object

Since:
  • 1.0.0

# onToggleSoundHandler(e)

Calls window.onToggleSound and gets triggered everytime the user toggles the sound for alerts.

Parameters:
Name Type Description
e ToggleSoundEvent

The event data object

Since:
  • 1.0.0

# onWidgetButtonHandler(e)

Calls window.onWidgetButton and gets triggered everytime you press a custom button (defined in your fields) via the overlay editor.

Parameters:
Name Type Description
e WidgetButtonEvent

The event data object

Since:
  • 1.0.0

# onWidgetLoadHandler(p)

Handles and forwards the 'onWidgetLoad' event-data to window.onWidgetLoad.

Parameters:
Name Type Description
p object

The proxied obj parameter of the original onWidgetLoad event

Since:
  • 1.0.0

# preflightEventListeners()

Checks which listener-functions are set on the window and adds them to the corresponding expectedEvents array.

Since:
  • 1.0.0

# registerOnEventReceived()

Registers the onEventReceived listener, if any event is expected.

Since:
  • 1.0.0

# registerOnSessionUpdate()

Registers the onSessionUpdate listener, if the onSessionUpdate function was set on the window.

Since:
  • 1.0.0

# registerOnWidgetLoad()

Registers the onWidgetLoad listener, if the onWidgetLoad function was set on the window.

Since:
  • 1.0.0

# unregisterOnEventReceived()

Unregisters the onEventReceived listener.

Since:
  • 1.0.0

# unregisterOnSessionUpdate()

Unregisters the onSessionUpdate listener.

Since:
  • 1.0.0

# unregisterOnWidgetLoad()

Unregisters the onEventReceived listener.

Since:
  • 1.0.0

Type Definitions

# BotCounterEvent

Type:
  • object
Properties
Name Type Description
counter string
value number

# CheerEvent

Type:
  • object
Properties
Name Type Description
_id string
name string
amount number
message string
sessionTop boolean
type string
originalEventName string

# CommunityGiftEvent

Type:
  • object
Properties
Name Type Description
_id string
name string
amount number
count number
tier string
message string
sender string
gifted boolean
isCommunityGift boolean
playedAsCommunityGift boolean
sessionTop boolean
type string
originalEventName string

# DeleteMessageEvent

Type:
  • object
Properties
Name Type Description
msgId string

# DeleteMessagesEvent

Type:
  • object
Properties
Name Type Description
userId string

# FollowEvent

Type:
  • object
Properties
Name Type Description
_id string
name string
sessionTop boolean
type string
originalEventName string

# KVStoreUpdateEvent

Type:
  • object
Properties
Name Type Description
key string
value object

# MessageEvent

Type:
  • object
Properties
Name Type Description
service string
renderedText string
data object
Properties
Name Type Description
time number
tags object
Properties
Name Type Description
badge-info string
badges string
client-nonce string
color string
display-name string
emotes string
flags string
id string
mod string
room-id string
subscriber string
tmi-sent-ts number
turbo string
user-id string
user-type string
nick string
userId string
displayName string
displayColor string
badges Array.<object>
Properties
Name Type Description
type string
version string
url string
description string
channel string
text string
isAction boolean
emotes Array.<object>
Properties
Name Type Description
type string
name string
id string
gif boolean
urls object
start number
end number
msgId string

# RaidEvent

Type:
  • object
Properties
Name Type Description
_id string
name string
amount number
sessionTop boolean
type string
originalEventName string

# ResubEvent

Type:
  • object
Properties
Name Type Description
_id string
name string
amount number
tier string
message string
sessionTop boolean
type string
originalEventName string

# SubBombEvent

Type:
  • object
Properties
Name Type Description
_id string
name string
amount number
count number
tier string
message string
sender string
bulkGifted boolean
sessionTop boolean
type string
originalEventName string

# SubGiftEvent

Type:
  • object
Properties
Name Type Description
_id string
name string
amount number
tier string
message string
sender string
gifted boolean
sessionTop boolean
type string
originalEventName string

# SubscriberEvent

Type:
  • object
Properties
Name Type Description
_id string
name string
amount number
tier string
sessionTop boolean
type string
originalEventName string

# TipEvent

Type:
  • object
Properties
Name Type Description
_id string
name string
amount number
message string
sessionTop boolean
type string
originalEventName string

# ToggleSoundEvent

Type:
  • object
Properties
Name Type Description
muted boolean

# WidgetButtonEvent

Type:
  • object
Properties
Name Type Description
listener string
field string
value string