UNPKG

twitch-js

Version:

Javascript library for the Twitch Messaging Interface.

76 lines 2.65 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); var Chat_1 = __importStar(require("./Chat")), ChatTypes = Chat_1; exports.Chat = Chat_1.default; exports.ChatTypes = ChatTypes; var Api_1 = __importStar(require("./Api")), ApiTypes = Api_1; exports.Api = Api_1.default; exports.ApiTypes = ApiTypes; __export(require("./twitch")); /** * Interact with chat and make requests to Twitch API. * * ## Initializing * ``` * const token = 'cfabdegwdoklmawdzdo98xt2fo512y' * const username = 'ronni' * const twitchJs = new TwitchJs({ token, username }) * * twitchJs.chat.connect().then(globalUserState => { * // Do stuff ... * }) * * twitchJs.api.get('channel').then(response => { * // Do stuff ... * }) * ``` */ var TwitchJs = /** @class */ (function () { function TwitchJs(options) { var token = options.token, username = options.username, clientId = options.clientId, log = options.log, onAuthenticationFailure = options.onAuthenticationFailure, chat = options.chat, api = options.api; this.chat = new Chat_1.default(__assign(__assign({ log: log }, chat), { token: token, username: username, onAuthenticationFailure: onAuthenticationFailure })); this.api = new Api_1.default(__assign(__assign({ log: log }, api), { token: token, clientId: clientId, onAuthenticationFailure: onAuthenticationFailure })); } /** * Update client options. */ TwitchJs.prototype.updateOptions = function (options) { var chat = options.chat, api = options.api; if (chat) { this.chat.updateOptions(chat); } if (api) { this.api.updateOptions(api); } }; TwitchJs.Chat = Chat_1.default; TwitchJs.Api = Api_1.default; return TwitchJs; }()); exports.default = TwitchJs; //# sourceMappingURL=index.js.map