const { Client, OAuthProvider, DefaultRequestRunner } = require('@mixer/client-node');

const channel = 2;
const client = new Client(new DefaultRequestRunner());
client.use(new OAuthProvider(client, {
    clientId: 'your-client-id',
    secret: 'your-optional-secret-key',
}))
.attempt()
.then(() => client.chat.join(channel))
.then(res => {
    console.log('join chat response:', res);
})
.catch(err => {
    console.log('error joining chat:', err);
});

@@ -3,55 +3,13 @@
 nst 
-%7B Client, OAuthProvider, DefaultRequestRunner %7D
+Mixer
  = r
@@ -20,15 +20,13 @@
 re('
-@mixer/
+beam-
 clie
@@ -40,28 +40,50 @@
 ');%0A
-%0A
 const 
-channel = 2
+ws = require('ws');%0A%0Alet userInfo
 ;%0A
+%0A
 cons
@@ -97,16 +97,22 @@
 t = new 
+Mixer.
 Client(n
@@ -114,16 +114,22 @@
 ent(new 
+Mixer.
 DefaultR
@@ -144,16 +144,155 @@
 nner());
+%0A%0A// With OAuth we don't need to log in. The OAuth Provider will attach%0A// the required information to all of our requests after this call.
 %0Aclient.
@@ -299,16 +299,22 @@
 use(new 
+Mixer.
 OAuthPro
@@ -337,209 +337,1629 @@
     
-clientId: 'your-client-id',%0A    secret: 'your-optional-secret-key',
+tokens: %7B%0A        access: 'Click here to get your Token!',%0A        expires: Date.now() + (365 * 24 * 60 * 60 * 1000)%0A    %7D,%0A%7D));%0A%0A// Gets the user that the Access Token we provided above belongs to.%0Aclient.request('GET', 'users/current')%0A.then(response =%3E %7B%0A    userInfo = response.body;%0A    return new Mixer.ChatService(client).join(response.body.channel.id);%0A%7D)%0A.then(response =%3E %7B%0A    const body = response.body;%0A    return createChatSocket(userInfo.id, userInfo.channel.id, body.endpoints, body.authkey);
 %0A%7D)
-)
 %0A.
+c
 at
-tempt()%0A.then(() =%3E client.chat.join(channel))%0A.then(res =%3E %7B%0A    console.log('join chat response:', res);%0A%7D)%0A.catch(er
+ch(error =%3E %7B%0A    console.error('Something went wrong.');%0A    console.error(error);%0A%7D);%0A%0A/**%0A * Creates a Mixer chat socket and sets up listeners to various chat events.%0A * @param %7Bnumber%7D userId The user to authenticate as%0A * @param %7Bnumber%7D channelId The channel id to join%0A * @param %7Bstring%5B%5D%7D endpoints An array of endpoints to connect to%0A * @param %7Bstring%7D authkey An authentication key to connect with%0A * @returns %7BPromise.%3C%3E%7D%0A */%0Afunction createChatSocket (userId, channelId, endpoints, authkey) %7B%0A    // Chat connection%0A    const socket = new Mixer.Socket(ws, endpoints).boot();%0A%0A    // Greet a joined user%0A    socket.on('UserJoin', data =%3E %7B%0A        socket.call('msg', %5B%60Hi $%7Bdata.username%7D! I'm pingbot! Write !ping and I will pong back!%60%5D);%0A    %7D);%0A%0A    // React to our !pong command%0A    socket.on('ChatMessage', data =%3E %7B%0A        if (data.message.message%5B0%5D.data.toLowerCase().startsWith('!ping')) %7B%0A            socket.call('msg', %5B%60@$%7Bdata.user_name%7D PONG!%60%5D);%0A            console.log(%60Ponged $%7Bdata.user_name%7D%60);%0A        %7D%0A    %7D);%0A%0A    // Handle errors%0A    socket.on('error', erro
 r =%3E %7B%0A
+    
     
@@ -1970,41 +1970,278 @@
 ole.
-log('error joining chat:', err);%0A
+error('Socket error');%0A        console.error(error);%0A    %7D);%0A%0A    return socket.auth(channelId, userId, authkey)%0A    .then(() =%3E %7B%0A        console.log('Login successful');%0A        return socket.call('msg', %5B'Hi! I%5C'm pingbot! Write !ping and I will pong back!'%5D);%0A    
 %7D);%0A
+%7D%0A

update examples