LinaTsukusu / youtube-chat

Fetch YouTube Live chats
MIT License
211 stars 46 forks source link

It is still working in 2024! 😄 #100

Open Khyretos opened 10 months ago

Khyretos commented 10 months ago

i just tested the package, and i can confirm it is still working.

here is my example to connect to

/* global settings, bot */

const { LiveChat } = require('youtube-chat');

// If channelId is specified, liveId in the current stream is automatically acquired.
// Recommended

// Or specify LiveID in Stream manually.

const liveChat = new LiveChat({ liveId: '4xDzrJKXOOY' }); // LoFi girl
console.log('hey');

// Emit at start of observation chat.
// liveId: string
liveChat.on('start', liveId => {
  /* Your code here! */
  console.log(liveId);
});

// Emit at end of observation chat.
// reason: string?
liveChat.on('end', reason => {
  /* Your code here! */
  console.log(reason);
});

// Emit at receive chat.
// chat: ChatItem
liveChat.on('chat', chatItem => {
  /* Your code here! */
  console.log(chatItem);
});

// Emit when an error occurs
// err: Error or any
liveChat.on('error', err => {
  /* Your code here! */
  console.log(err);
});

async function test() {
  // Start fetch loop
  const ok = await liveChat.start();
  if (!ok) {
    console.log('Failed to start, check emitted error');
  }
}

test();
neverclear86 commented 10 months ago

I thought it wouldn't work, but it does! Thank you