Skip to content

Latest commit

 

History

History
908 lines (664 loc) · 18.8 KB

Commands.md

File metadata and controls

908 lines (664 loc) · 18.8 KB

Chat Client

Commands

Each and every actions support Promises. Some commands requires you to be logged in.

Contents

  • Action - Send an action message on a channel. (/me <message>)
  • Ban - Ban username on channel.
  • Clear - Clear all messages on a channel.
  • Color - Change the color of your username.
  • Commercial - Run commercial on a channel for X seconds.
  • Connect - Connect to server.
  • Disconnect - Disconnect from server.
  • Emoteonly - Enable emote-only on a channel.
  • Emoteonlyoff - Disable emote-only on a channel.
  • Followersonly - Enable followers-only on a channel.
  • Followersonlyoff - Disable followers-only on a channel.
  • Host - Host a channel.
  • Join - Join a channel.
  • Mod - Mod username on channel.
  • Mods - Get list of mods on a channel.
  • Part - Leave a channel.
  • Ping - Send a PING to the server.
  • R9kbeta - Enable R9KBeta on a channel.
  • R9kbetaoff - Disable R9KBeta on a channel.
  • Raw - Send a RAW message to the server.
  • Say - Send a message on a channel.
  • Slow - Enable slow mode on a channel.
  • Slowoff - Disable slow mode on a channel.
  • Subscribers - Enable subscriber-only on a channel.
  • Subscribersoff - Disable subscriber-only on a channel.
  • Timeout - Timeout username on channel for X seconds.
  • Unban - Unban username on channel.
  • Unhost - End the current hosting.
  • Unmod - Unmod user on a channel.
  • Whisper - Send an instant message to a user.

Action

Send an action message on a channel. (/me <message>)

Parameters:

  • channel: String - Channel name (Required)
  • message: String - Message (Required)
client.action('channel', 'Your message');

Promises:

  • Resolved on message sent1
  • Rejected on request timed out

1: There is no possible way to know if a message has been sent successfully unless we create two connections. This promise will always be resolved unless you are trying to send a message and you're not connected to a server.

client
  .action('channel', 'Your message')
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

Ban

Ban username on channel.

Parameters:

  • channel: String - Channel name (Required)
  • username: String - Username to ban (Required)
  • reason: String - Reason for the ban (Optional)
client.ban('channel', 'username', 'reason');

Promises:

client
  .ban('channel', 'username', 'reason')
  .then(function(data) {
    // data returns [channel, username, reason]
  })
  .catch(function(err) {
    //
  });

Clear

Clear all messages on a channel.

Parameters:

  • channel: String - Channel name (Required)
client.clear('channel');

Promises:

client
  .clear('channel')
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

Color

Change the color of your username.

Parameters:

  • color: String - Color name (Required)

Note: Turbo users can change their color using hexadecimal color (like #000000 or #FFFFFF) and non-turbo users can choose one of the following colors:

  • Blue
  • BlueViolet
  • CadetBlue
  • Chocolate
  • Coral
  • DodgerBlue
  • Firebrick
  • GoldenRod
  • Green
  • HotPink
  • OrangeRed
  • Red
  • SeaGreen
  • SpringGreen
  • YellowGreen
client.color('#C0C0C0');
client.color('SpringGreen');

Promises:

client
  .color('#C0C0C0')
  .then(function(data) {
    // data returns [color]
  })
  .catch(function(err) {
    //
  });

Commercial

Run commercial on a channel for X seconds. Available lengths (seconds) are 30, 60, 90, 120, 150, 180.

Parameters:

  • channel: String - Channel name (Required)
  • seconds: Integer - Commercial lengths (Required)
client.commercial('channel', 30);

Promises:

client
  .commercial('channel', 30)
  .then(function(data) {
    // data returns [channel, seconds]
  })
  .catch(function(err) {
    //
  });

Connect

Connect to server.

client.connect();

Promises:

  • Resolved once connected to the server1
  • Rejected if disconnected from server

1: Only fire once, will not fire upon reconnection.

client
  .connect()
  .then(function(data) {
    // data returns [server, port]
  })
  .catch(function(err) {
    //
  });

Disconnect

Disconnect from server.

client.disconnect();

Promises:

  • Resolved when the socket is closed
  • Rejected if socket is already closed
client
  .disconnect()
  .then(function(data) {
    // data returns [server, port]
  })
  .catch(function(err) {
    //
  });

Emoteonly

Enable emote-only on a channel.

Parameters:

  • channel: String - Channel name (Required)
client.emoteonly('channel');

Promises:

client
  .emoteonly('channel')
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

Emoteonlyoff

Disable emote-only on a channel.

Parameters:

  • channel: String - Channel name (Required)
client.emoteonlyoff('channel');

Promises:

client
  .emoteonlyoff('channel')
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

Followersonly

Enable followers-only on a channel.

Parameters:

  • channel: String - Channel name (Required)
  • length: Integer - Length in minutes (Optional, default is 30)
client.followersonly('channel', 30);

Promises:

client
  .followersonly('channel', 30)
  .then(function(data) {
    // data returns [channel, minutes]
  })
  .catch(function(err) {
    //
  });

Followersonlyoff

Disabled followers-only on a channel.

Parameters:

  • channel: String - Channel name (Required)
client.followersonlyoff('channel');

Promises:

client
  .followersonlyoff('channel')
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

Host

Host a channel.

Parameters:

  • channel: String - Channel name (Required)
  • target: String - Channel to host (Required)
client.host('channel', 'target');

Promises:

client
  .host('channel', 'target')
  .then(function(data) {
    // data returns [channel, target]
  })
  .catch(function(err) {
    //
  });

Join

Join a channel.

Parameters:

  • channel: String - Channel name (Required)
client.join('channel');

Promises:

client
  .join('channel')
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

Mod

Mod username on channel.

Parameters:

  • channel: String - Channel name (Required)
  • username: String - Username to add as a moderator (Required)
client.mod('channel', 'username');

Promises:

client
  .mod('channel', 'username')
  .then(function(data) {
    // data returns [channel, username]
  })
  .catch(function(err) {
    //
  });

Mods

Get list of mods on a channel.

Parameters:

  • channel: String - Channel name (Required)
client.mods('channel');

Promises:

client
  .mods('channel')
  .then(function(data) {
    // data returns [moderators]
  })
  .catch(function(err) {
    //
  });

Part

Leave a channel.

Parameters:

  • channel: String - Channel name (Required)
client.part('channel');

Promises:

  • Resolved on leaving a channel
  • Rejected on request timed out
client
  .part('channel')
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

Ping

Send a PING to the server.

client.ping();

Promises:

  • Resolved on PONG received
  • Rejected on request timed out
client
  .ping()
  .then(function(data) {
    // data returns [latency]
  })
  .catch(function(err) {
    //
  });

R9kbeta

Enable R9KBeta on a channel.

Parameters:

  • channel: String - Channel name (Required)
client.r9kbeta('channel');

Promises:

client
  .r9kbeta('channel')
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

R9kbetaoff

Disable R9KBeta on a channel.

Parameters:

  • channel: String - Channel name (Required)
client.r9kbetaoff('channel');

Promises:

client
  .r9kbetaoff('channel')
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

Raw

Send a RAW message to the server.

Parameters:

  • message: String - Message to send to the server (Required)
client.raw('CAP REQ :twitch.tv/tags');

Promises:

  • Resolved on message sent
  • Rejected on request timed out
client
  .raw('CAP REQ :twitch.tv/tags')
  .then(function(data) {
    // data returns [message]
  })
  .catch(function(err) {
    //
  });

Say

Send a message on a channel.

Parameters:

  • channel: String - Channel name (Required)
  • message: String - Message (Required)
client.say('channel', 'Your message');

Promises:

  • Resolved on message sent1
  • Rejected on request timed out

1: There is no possible way to know if a message has been sent successfully unless we create two connections. This promise will always be resolved unless you are trying to send a message and you're not connected to server.

client
  .say('channel', 'Your message')
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

Slow

Enable slow mode on a channel.

Parameters:

  • channel: String - Channel name (Required)
  • length: Integer - Length in seconds (Optional, default is 300)
client.slow('channel', 300);

Promises:

client
  .slow('channel', 300)
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

Slowoff

Disable slow mode on a channel.

Parameters:

  • channel: String - Channel name (Required)
client.slowoff('channel');

Promises:

client
  .slowoff('channel', 300)
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

Subscribers

Enable subscriber-only on a channel.

Parameters:

  • channel: String - Channel name (Required)
client.subscribers('channel');

Promises:

client
  .subscribers('channel')
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

Subscribersoff

Disable subscriber-only on a channel.

Parameters:

  • channel: String - Channel name (Required)
client.subscribersoff('channel');

Promises:

client
  .subscribersoff('channel')
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

Timeout

Timeout username on channel for X seconds.

Parameters:

  • channel: String - Channel name (Required)
  • username: String - Username to timeout (Required)
  • length: Integer - Length in seconds (Optional, default is 300)
  • reason: String - Reason for the timeout (Optional)
client.timeout('channel', 'username', 300, 'reason');

Promises:

client
  .timeout('channel', 'username', 300, 'reason')
  .then(function(data) {
    // data returns [channel, username, seconds, reason]
  })
  .catch(function(err) {
    //
  });

Unban

Unban username on channel.

Parameters:

  • channel: String - Channel name (Required)
  • username: String - Username to unban (Required)
client.unban('channel', 'username');

Promises:

client
  .unban('channel', 'username')
  .then(function(data) {
    // data returns [channel, username]
  })
  .catch(function(err) {
    //
  });

Unhost

End the current hosting. You must be the broadcaster or an editor.

Parameters:

  • channel: String - Channel name (Required)
client.unhost('channel');

Promises:

client
  .unhost('channel')
  .then(function(data) {
    // data returns [channel]
  })
  .catch(function(err) {
    //
  });

Unmod

Unmod user on a channel.

Parameters:

  • channel: String - Channel name (Required)
  • username: String - Username to unmod (Required)
client.unmod('channel', 'username');

Promises:

client
  .unmod('channel', 'username')
  .then(function(data) {
    // data returns [channel, username]
  })
  .catch(function(err) {
    //
  });

Whisper

Send an instant message to a user.

Parameters:

  • username: String - Username (Required)
  • message: String - Message (Required)
client.whisper('username', 'Your message');

Promises:

  • Resolved on message sent1
  • Rejected on request timed out

1: There is no possible way to know if a message has been sent successfully unless we create two connections. This promise will always be resolved unless you are trying to send a message and you're not connected to server.

client
  .whisper('username', 'Your message')
  .then(function(data) {
    // data returns [username, message]
  })
  .catch(function(err) {
    //
  });