Skip to content

Latest commit

 

History

History
75 lines (50 loc) · 1.58 KB

Methods.md

File metadata and controls

75 lines (50 loc) · 1.58 KB

Chat Client

Methods

Contents

client.getChannels()

Get the current channels. (Array)

console.log(client.getChannels());

client.getOptions()

Get the current options. (Object)

console.log(client.getOptions());

client.getUsername()

Get the current username. (String)

console.log(client.getUsername());

client.isMod()

NOT RECOMMENDED

Function to check if user is a mod on a channel. (Boolean)

Important: Might not be accurate.

Parameters:

  • channel: String - Channel name
  • username: String - Username
if (client.isMod('#schmoopiie', 'bob')) {
  // Do something..
}

RECOMMENDED

Everytime you receive a message on Twitch, you receive an object that contains all the information you need from the user.

client.on('chat', function(channel, user, message, self) {
  if (user.mod) {
    // User is a mod.
  }
});

client.readyState()

Get the current state of the socket. (String)

// Returns one of the following states: "CONNECTING", "OPEN", "CLOSING" or "CLOSED".
console.log(client.readyState());