This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

twitch-pro
TypeScript icon, indicating that this package has built-in type declarations

1.0.1-beta • Public • Published

twitch-pro

twitch-pro is a Node.js library that simplifies interactions with the Twitch API and Twitch IRC chat.

Installation

You can install twitch-pro using npm:

npm install twitch-pro

Usage

Initialize Twitch Client Options

Before using twitch-pro, you need to provide your Twitch client ID and OAuth2 token. Replace "your_client_id" and "your_token" with your actual Twitch client ID and OAuth2 token respectively.

const opts = {
    clientId: "your_client_id", // Replace with your Twitch client ID here
    token: "your_token",  // Replace with your Twitch OAuth2 token here
    nickname: "MaxA_MM" // Your Twitch username
}

Initialize WebSocket Client Options

Similarly, for WebSocket client options, replace "your_token" with your Twitch OAuth2 token.

const wsOpts = {
    token: "your_token", // Replace with your Twitch OAuth2 token here
    nickname: "MaxA_MM" // Your Twitch username
};

Creating Twitch Client and WebSocket Client Instances

You can create instances of the Twitch Client and WebSocket Client using the provided options.

import { Client, Events, WSClient } from "twitch-pro";
import { error, log } from "console";

const client = new Client(opts); // Twitch Client instance
const ws = new WSClient(wsOpts); // WebSocket Client instance

Connecting to Twitch API and IRC Chat

You can connect to the Twitch API and IRC chat by calling the connect() method on the Twitch Client and WebSocket Client instances respectively.

client.connect()
    .then(() => log(`Successfully connected to Twitch API`));

ws.connect();

Registering Event Handlers

You can register event handlers for various WebSocket events such as ready, message, join, close, and error.

ws.on(Events.Ready, async () => {
    log("WebSocket is ready");
    ws.ping();
    ws.join('maxa_mm');
});

ws.on(Events.Message, async (msg) => {
    log(msg.content);
});

// Add handlers for other events: Join, Close, Error

Configuration

Ensure to replace "your_client_id" and "your_token" with your actual Twitch client ID and OAuth2 token respectively. This ensures proper authentication when connecting to Twitch services.

Contributing

Contributions are welcome! If you encounter any bugs or have suggestions for improvements, please feel free to submit issues or pull requests.

License

This project is licensed under the MIT License.

Package Sidebar

Install

npm i twitch-pro

Weekly Downloads

1

Version

1.0.1-beta

License

MIT

Unpacked Size

41 kB

Total Files

25

Last publish

Collaborators

  • maxa_mm