Skip to content
This repository has been archived by the owner on Jul 3, 2021. It is now read-only.

[events] chat

PossiblyKris edited this page Jan 28, 2017 · 6 revisions
Key Type Description
cid String Message id
message String Message sent
sub Integer Sender's subscription level
uid Integer Sender's id
un String Sender's username
from Object User object
mentions Array Array of mentioned users' objects
type String Message type (message/mention/emote)

Example

bot.on('chat', function(data) {
    // 2 methods to get sender's name
    console.log("Username: "+data.raw.un);
    console.log("Username: "+data.from.username);
});

Data returned

{
    raw {
        cid: 'xxxxxxxx-xxxxxxxxx',
        message: 'hello world',
        sub: 0,
        uid: xxxxxx,
        un: 'username'
    },
    id: 'xxxxxxxx-xxxxxxxxxx',
    from:
      User { 
        avatarID: 'xxxxxxxx',
        badge: 'xxxxxx',
        blurb: undefined,
        gRole: 0,
        grab: false,
        id: xxxxxxx,
        ignores: undefined,
        joined: 'xxxx-xx-xx xx:xx:xx.xxxxxx',
        language: null,
        level: 3,
        notifications: undefined,
        pp: undefined,
        pw: undefined,
        role: 0,
        slug: null,
        status: 1,
        sub: 1,
        username: 'username',
        vote: 0,
        xp: undefined
    },
    message: 'hello world',
    mentions: [ 
      User {
        avatarID: 'base06',
        badge: null,
        blurb: undefined,
        gRole: 0,
        grab: false,
        id: xxxxxxx,
        ignores: undefined,
        joined: '2012-02-27 12:54:49.051668',
        language: 'en',
        level: 17,
        notifications: undefined,
        pp: undefined,
        pw: undefined,
        role: 5,
        slug: 'xxxxxxxxx',
        status: 1,
        sub: 0,
        username: 'xxxxxxxxx',
        vote: 0,
        xp: undefined
      }
    ],
    muted: false,
    type: 'message'
}
Clone this wiki locally