Twitch IRC Capability WebSocket (help)

zaekof profile image NOGIER Loïc Updated on ・1 min read

I'am trying to get a event when a moderator unban a user in the chat, i send a resquest for twitch.tv/tags but i didn't receive any messages when user was ban or unban...

it is my actual code :

const WebSocket = require('ws');

const ws = new WebSocket('wss://irc-ws.chat.twitch.tv:443');

ws.onopen = function(event) {
  console.log('INFO: Socket Opened'); 
  ws.send('CAP REQ :twitch.tv/commands');
  ws.send('CAP REQ :twitch.tv/membership');
  ws.send('CAP REQ :twitch.tv/tags');
  ws.send('PASS oauth:...');
  ws.send('NICK zaekof_');
  ws.send('JOIN #zaekof_');
  ws.send('USER #zaekof_');
ws.onerror = function(error) {
  console.log('ERR: ', error);
ws.onclose = function() {
  console.log('INFO: Socket Closed');
ws.onmessage = function(event) {
  console.log('RECV: ', event.data);

When i'am connected on irc chat, i receive a follows messages :

RECV:  :tmi.twitch.tv CAP * ACK :twitch.tv/commands
RECV:  :tmi.twitch.tv CAP * ACK :twitch.tv/membership
RECV:  :tmi.twitch.tv CAP * ACK :twitch.tv/tags

RECV:  :tmi.twitch.tv 001 zaekof_ :Welcome, GLHF!
:tmi.twitch.tv 002 zaekof_ :Your host is tmi.twitch.tv
:tmi.twitch.tv 003 zaekof_ :This server is rather new
:tmi.twitch.tv 004 zaekof_ :-
:tmi.twitch.tv 375 zaekof_ :-
:tmi.twitch.tv 372 zaekof_ :You are in a maze of twisty passages, all alike.:tmi.twitch.tv 376 zaekof_ :>

Would anyone have an idea to help me?


Posted on May 16 '19 by:


markdown guide

did you consider using that lib ? docs.tmijs.org/v1.4.2/Events.html

It will facilitate you the job :)


Thanks for reply, i go look :)


It is a right way to do what i want ?

const tmi = require("tmi.js");

let options = {
  options: {
    debug: true,
    clientId: '...'
  connection: {
    server: 'irc-ws.chat.twitch.tv',
    reconnect: true,
    secure: true
  identity: {
    username: "zaekof_",
    password: "oauth:..."
  channels: [ "#zaekof_" ]

let client = new tmi.client(options);

client.on("notice", (channel, msgid, message) => {
  console.log(msgid, message);


I didn't have any return when i use /unban in chat, just :

[16:34] info: [#zaekof_] ... has been banned.

I'm confused, I must have missed something ^

you have to put the ids from the bot or you depend and ban from this user you or the bot because it will listen commands from the ids you enter client secret or id