### Browser Example Usage Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/1.get-started/0.installation.md Example HTML file demonstrating how to instantiate the StreamerbotClient in the browser after including the script. ```html Streamer.bot Client ``` -------------------------------- ### Initialize StreamerbotClient (Default) Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/1.get-started/1.setup.md Initializes a new StreamerbotClient instance using the default constructor. The client automatically connects to the default WebSocket server location at ws://127.0.0.1:8080/. This is the simplest way to get started. ```ts const client = new StreamerbotClient(); // Client is connected to ws://127.0.0.1:8080/ ``` -------------------------------- ### Get Commands Example Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md Example of how to call the `getCommands` method on the Streamerbot client to retrieve command information. ```ts const response = await client.getCommands(); ``` -------------------------------- ### Install Streamerbot Client Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/0.index.md Installs the Streamerbot client package using pnpm. This is the initial step to integrate the client into your project. ```bash pnpm add @streamerbot/client ``` -------------------------------- ### Browser Installation (unpkg) Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/1.get-started/0.installation.md Include the Streamerbot client script in your HTML for browser usage via unpkg CDN. ```html ``` -------------------------------- ### Installation with Package Managers Source: https://github.com/streamerbot/client/blob/main/packages/client/README.md Installs the Streamer.bot client library using popular package managers like Yarn, npm, or pnpm. ```bash yarn add @streamerbot/client npm install @streamerbot/client pnpm install @streamerbot/client ``` -------------------------------- ### Installation Source: https://github.com/streamerbot/client/blob/main/packages/vue/README.md Installs the Streamer.bot client and Vue packages using popular package managers. ```bash yarn add @streamerbot/client @streamerbot/vue npm install @streamerbot/client @streamerbot/vue pnpm install @streamerbot/client @streamerbot/vue ``` -------------------------------- ### Browser Installation (jsDelivr) Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/1.get-started/0.installation.md Include the Streamerbot client script in your HTML for browser usage via jsDelivr CDN. ```html ``` -------------------------------- ### NodeJS/TypeScript Installation Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/1.get-started/0.installation.md Install the @streamerbot/client package using common package managers like pnpm, yarn, or npm. ```bash pnpm install @streamerbot/client ``` ```bash yarn add @streamerbot/client ``` ```bash npm install @streamerbot/client ``` -------------------------------- ### Get Global Example Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md Example of calling `getGlobals` (note: the provided example uses `getGlobals` but the description is for `getGlobal`). Assuming it's a typo and meant to show fetching a single global. ```ts const response = await client.getGlobals(); ``` -------------------------------- ### Get Credits Example Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md An example of how to call the `getCredits` method to fetch the current credits system data. ```ts const response = await client.getCredits(); ``` -------------------------------- ### Module Installation (Skypack) Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/1.get-started/0.installation.md Import the Streamerbot client directly from Skypack CDN for projects using the ` ``` ```javascript import { StreamerbotClient } from 'https://cdn.skypack.dev/@streamerbot/client'; ``` -------------------------------- ### Installation via CDN Source: https://github.com/streamerbot/client/blob/main/packages/client/README.md Includes the Streamer.bot client library in a web page using a CDN link. ```html ``` -------------------------------- ### GetActions Example Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md Demonstrates how to use the Streamer.bot client to fetch a list of available actions. Includes example request and response payloads. ```ts const response = await client.getActions(); ``` ```json { "status": "ok", "id": "[request-id]", "actions" : [ { "enabled": true, "group": "None", "id": "a0ff6f91-a51e-4b7d-948b-5e03ff4a82f0", "name": "Action Number One", "subaction_count": 4 }, { "enabled": false, "group": "None", "id": "84a0dfe7-5033-4e14-964b-ce2dfe9f5e09", "name": "Action Number Two", "subaction_count": 18 }, ], "count": 2 } ``` -------------------------------- ### Install @streamerbot/vue Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/5.packages/0.vue.md Instructions for installing the Streamer.bot Vue package using different package managers (pnpm, npm, yarn). ```bash pnpm install @streamerbot/vue ``` ```bash npm install @streamerbot/vue ``` ```bash yarn add @streamerbot/vue ``` -------------------------------- ### Example: Send Message Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md An example demonstrating how to send a chat message to a platform using the client. ```ts const response = await client.sendMessage('twitch', 'Hello, world!'); ``` -------------------------------- ### Test Credits Example Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md An example of how to call the `testCredits` method to populate the credits system with test data. ```ts const response = await client.testCredits(); ``` -------------------------------- ### Basic Usage Example Source: https://github.com/streamerbot/client/blob/main/packages/client/README.md Demonstrates how to create a StreamerbotClient instance and listen for 'Twitch.ChatMessage' events. ```typescript import { StreamerbotClient } from '@streamerbot/client'; // Create a new client with default options const client = new StreamerbotClient(); // Subscription will automatically be added to client with your listener function client.on('Twitch.ChatMessage', (data) => { console.log('Twitch Chat Message Received!', data); }); ``` -------------------------------- ### Get Emotes Example Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md Example of calling the `getEmotes` method to fetch Twitch emotes. ```ts const response = await client.getEmotes('twitch'); ``` -------------------------------- ### Get Globals Example Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md Example of calling the `getGlobals` method to retrieve all persisted global variables. ```ts const response = await client.getGlobals(); ``` -------------------------------- ### Install @streamerbot/client Source: https://github.com/streamerbot/client/blob/main/README.md Instructions for installing the Streamer.bot client library using various package managers like yarn, npm, and pnpm. ```bash yarn add @streamerbot/client npm install @streamerbot/client pnpm install @streamerbot/client ``` -------------------------------- ### Get Code Triggers Example Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md An example of how to call the `getCodeTriggers` method on the Streamer.bot client to retrieve code triggers. ```ts const response = await client.getCodeTriggers(); ``` -------------------------------- ### Example: Fetch User Globals Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md An example demonstrating how to use the client to fetch global variables for a specific user on a given platform. ```ts const response = await client.getUserGlobals('twitch'); ``` -------------------------------- ### Get Monitored YouTube Broadcasts Example Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md Example of how to call the `getMonitoredYouTubeBroadcasts` method on the Streamerbot client. ```ts const response = await client.getMonitoredYouTubeBroadcasts(); ``` -------------------------------- ### Example: Send Message as Bot Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md An example demonstrating how to send a chat message using the bot account. ```ts const response = await client.getUserGlobal('twitch', 'Hello, from bot account!', { bot: true }); ``` -------------------------------- ### Clear Credits Example Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md An example of how to call the `clearCredits` method to reset the credits system. ```ts const response = await client.clearCredits(); ``` -------------------------------- ### Execute Code Trigger Example Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md An example demonstrating how to use the `executeCodeTrigger` method to run a custom trigger named 'myCustomTrigger' with specific arguments. ```ts // Execute a trigger named 'myCustomTrigger', with some custom arguments const response = await client.executeCodeTrigger('myCustomTrigger', { value: 23, someArg: 'testing!' }); ``` -------------------------------- ### NodeJS/TypeScript Import Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/1.get-started/0.installation.md Demonstrates how to import the StreamerbotClient in different NodeJS module formats (.ts, .mjs, .cjs). ```typescript import { StreamerbotClient } from '@streamerbot/client'; ``` ```javascript import { StreamerbotClient } from '@streamerbot/client'; ``` ```javascript const StreamerbotClient = require('@streamerbot/client'); ``` -------------------------------- ### getBroadcaster Example Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md Demonstrates how to retrieve information about the connected broadcaster accounts across different platforms like Twitch and YouTube. Includes an example response payload. ```ts const response = await client.getBroadcaster(); ``` ```json { "status": "ok", "id": "[request-id]", "platforms": { "twitch": { "broadcastUser": "SomeUsername", "broadcastUserName": "someusername", "broadcastUserId": "12345678", "broadcastIsAfilliate": true, "broadcastIsPartner": false } }, "connected": ["twitch"], "disconnected": ["youtube"] } ``` -------------------------------- ### Example Usage of useStreamerbot Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/5.packages/0.vue.md A Vue component example demonstrating how to use the `useStreamerbot` composable to connect to Streamer.bot, subscribe to events, and display received data. ```vue ``` -------------------------------- ### Initialize StreamerbotClient (Custom Options) Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/1.get-started/1.setup.md Initializes a new StreamerbotClient instance with custom connection settings. Users can specify the host, port, and endpoint to connect to a non-default WebSocket server location. The client automatically connects to the configured location. ```ts const client = new StreamerbotClient({ host: '127.0.0.1', port: 9001, endpoint: '/' }); // Client is connected to ws://127.0.0.1:9001/ ``` -------------------------------- ### Example: Fetch Specific User Global Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md An example demonstrating how to fetch a specific user global variable by providing the user ID and variable name. ```ts const response = await client.getUserGlobal('twitch', '12345678', 'test'); ``` -------------------------------- ### getActiveViewers Example Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md Demonstrates how to fetch a list of all active viewers for connected Twitch or YouTube accounts. Includes an example response payload with viewer details. ```ts const response = await client.getActiveViewers(); ``` ```json { "status": "ok", "id": "[request-id]", "viewers" : [ { "id": "12345678", "login": "someusername", "display": "SomeUsername", "subscribed": true, "role": "Broadcaster", "groups": [], "channelPointsUsed": 5661, "previousActive": "2023-01-28T12:36:45.3764724-05:00", "exempt": false } ] } ``` -------------------------------- ### Streamerbot Client API Documentation Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md This section provides comprehensive documentation for the Streamerbot client API. It covers method signatures, parameters, response types, and usage examples for various functionalities. ```APIDOC getUserGlobalsResponse.ts: Type definition for the response when fetching all user global variables. ```ts type GetUserGlobalsResponse = StreamerbotResponse<{ variables: { [key: string]: { name: string; value: string | number | boolean | null; lastWrite: string; platform: 'twitch' | 'youtube' | 'trovo' | 'kick'; userId: string; userLogin: string; userName: string; } }; count: number; status: 'ok' | 'error'; }>; ``` getUserGlobal Method: Fetches user global variables by user ID and (optionally) variable name. Requires Streamer.bot v0.2.5. Signature: `getUserGlobal(platform: P, userId: U, name: K = null, persisted = true): Promise | GetUserGlobalByNameResponse>`{lang=ts} Parameters: - platform: ('twitch' | 'youtube' | 'trovo' | 'kick') - Select the platform to fetch globals for (required). - userId: string - Provide the specific user ID to fetch globals for (required). - name: string - Optionally provide a variable name. - persisted: boolean - Default: `true`. Determines if only persisted variables should be fetched. Response Types: - GetUserGlobalResponse: For fetching all variables for a user. ```ts type GetUserGlobalResponse = StreamerbotResponse<{ variables: { [key: string]: { name: string; value: string | number | boolean | null; lastWrite: string; } }; count: number; status: 'ok'; }>; ``` - GetUserGlobalByNameResponse: For fetching a specific variable by name. ```ts type GetUserGlobalByNameResponse = StreamerbotResponse<{ variable: { name: string; value: string | number | boolean | null; lastWrite: string; }; status: 'ok'; }>; ``` Examples: - Fetch all user global variables for a given user ID: ```ts const response = await client.getUserGlobal('twitch', '12345678'); ``` - Fetch a specific user global variable by user ID and variable name: ```ts const response = await client.getUserGlobal('twitch', '12345678', 'test'); ``` sendMessage Method: Sends a chat message to the selected platform. Requires Streamer.bot v0.2.5. Signature: ```ts sendMessage( platform: 'twitch' | 'youtube' | 'trovo' | 'kick', message: string, options?: { bot?: boolean; internal?: boolean; replyId?: string; broadcastId?: string; } ): Promise ``` Parameters: - platform: ('twitch' | 'youtube' | 'trovo' | 'kick') - Select the platform to send the message to (required). - message: string - Enter the content of the message to send (required). - options.bot: boolean - Default: `false`. Send with the bot account? - options.internal: boolean - Default: `true`. Send as an `Internal` message. Useful in combination with the `Ignore Internal` option on Commands. - options.replyId: string - Optional message id to send a reply to. Currently only supported by Twitch. - options.broadcastId: string - Optional broadcast id to send the message to. Currently only supported by YouTube. Response Type: - SendMessageResponse: Contains the ID of the sent message and its status. ```ts type SendMessageResponse = StreamerbotResponse<{ id: string; status: 'ok' | 'error'; error?: string; }>; ``` Examples: - Send a message with the Twitch broadcaster account: ```ts const response = await client.sendMessage('twitch', 'Hello, world!'); ``` - Send a message with the Twitch bot account: ```ts const response = await client.getUserGlobal('twitch', 'Hello, from bot account!', { bot: true }); ``` getUserPronouns Method: Fetches user pronouns (alejo.io). Requires Streamer.bot v0.2.5. Signature: `getUserPronouns(platform: 'twitch' | 'youtube' | 'trovo' | 'kick', userLogin: string)`{lang=ts} Parameters: - platform: ('twitch' | 'youtube' | 'trovo' | 'kick') - Select the platform to fetch pronouns for. Currently only supported by Twitch (required). - userLogin: string - Provide the specific user login to fetch pronouns for (required). ``` -------------------------------- ### Basic Streamer.bot Client Usage Source: https://github.com/streamerbot/client/blob/main/README.md A fundamental example of how to initialize the StreamerbotClient and subscribe to Twitch chat messages. ```typescript import { StreamerbotClient } from '@streamerbot/client'; // Create a new client with default options const client = new StreamerbotClient(); // Subscription will automatically be added to client with your listener function client.on('Twitch.ChatMessage', (data) => { console.log('Twitch Chat Message Received!', data); }); ``` -------------------------------- ### Get Instance Information Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md Fetches information about the connected Streamer.bot instance, including its ID, name, operating system, and version. This is useful for understanding the environment the bot is running in. ```ts client.getInfo(): Promise ``` ```APIDOC GetInfoResponse: status: 'ok' | 'error' id: string info: instanceId: string name: string os: 'windows' | 'linux' | 'macosx' | string osVersion: string version: string source?: 'websocketServer' | 'streamDeckServer' | 'httpServer' | string ``` ```ts const infoResponse = await client.getInfo(); ``` ```json { "status": "ok", "id": "[request-id]", "info" : { "instanceId": "c1a51f77-ec2e-4051-8378-94e4e8b6044b", "name": "Streamer.bot", "os": "windows", "osVersion": "10.0.22631.0", "version": "0.2.5", "source": "websocketServer" } } ``` -------------------------------- ### Receive Twitch Chat Messages Source: https://github.com/streamerbot/client/blob/main/examples/browser/index.html This C# code snippet demonstrates how to subscribe to and handle incoming Twitch chat messages using the Streamer.bot client. It utilizes an event handler for new messages. ```C# using Streamer.Bot.Client.Events; // Assuming 'client' is an instance of Streamer.Bot.Client.StreamerBotClient client.OnMessageReceived += (sender, e) => { Console.WriteLine($"[{e.ChannelName}] {e.Username}: {e.Message}"); }; // Ensure the client is connected and listening for events. ``` -------------------------------- ### Get Commands API Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md Fetches a list of commands available on the connected Streamer.bot instance. Requires Streamer.bot v0.2.5 or later. ```ts getCommands: Promise ``` -------------------------------- ### Get Actions Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/1.requests.md Fetches a list of all available actions configured in the connected Streamer.bot instance. This allows clients to programmatically access and trigger bot actions. ```ts client.getActions(): Promise ``` -------------------------------- ### Send Twitch Chat Message Source: https://github.com/streamerbot/client/blob/main/examples/browser/index.html This C# code snippet shows how to send a message to a Twitch chat channel using the Streamer.bot client. It requires the client to be connected and authenticated. ```C# using Streamer.Bot.Client.Events; // Assuming 'client' is an instance of Streamer.Bot.Client.StreamerBotClient string channelName = "your_channel_name"; string message = "Hello from Streamer.bot!"; client.SendMessage(channelName, message); ``` -------------------------------- ### Streamerbot Event Subscription Syntax Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/3.api/2.events.md Demonstrates the structure of event sources and types in Streamerbot and how to use the shorthand syntax for subscribing to events using the `.on()` method. This is a common pattern for event handling in the client. ```ts const StreamerbotEvents = { Application: ['ActionAdded', 'ActionUpdated', 'ActionDeleted'], Command: ['Triggered', 'Cooldown'], CrowdControl: [ 'GameSessionStart', 'GameSessionEnd', 'EffectRequest', 'EffectSuccess', 'EffectFailure', 'TimedEffectStarted', 'TimedEffectEnded', 'TimedEffectUpdated', ], Custom: ['Event', 'CodeEvent'], DonorDrive: ['Donation', 'ProfileUpdated', 'Incentive'], Elgato: [ 'WaveLinkOutputSwitched', 'WaveLinkOutputVolumeChanged', 'WaveLinkOutputMuteChanged', 'WaveLinkSelectedOutputChanged', 'WaveLinkInputVolumeChanged', 'WaveLinkInputMuteChanged', 'WaveLinkInputNameChanged', 'WaveLinkMicrophoneGainChanged', 'WaveLinkMicrophoneOutputVolumeChanged', 'WaveLinkMicrophoneBalanceChanged', 'WaveLinkMicrophoneMuteChanged', 'WaveLinkMicrophoneSettingChanged', 'WaveLinkFilterAdded', 'WaveLinkFilterChanged', 'WaveLinkFilterDeleted', 'WaveLinkFilterBypassStateChanged', 'WaveLinkConnected', 'WaveLinkDisconnected', 'WaveLinkInputLevelMeterChanged', 'WaveLinkOutputLevelMeterChanged', ], FileTail: ['Changed'], FileWatcher: ['Changed', 'Created', 'Deleted', 'Renamed'], Fourthwall: [ 'ProductCreated', 'ProductUpdated', 'GiftPurchase', 'OrderPlaced', 'OrderUpdated', 'Donation', 'SubscriptionPurchased', 'SubscriptionExpired', 'SubscriptionChanged', ], General: ['Custom'], HotKey: ['Press'], HypeRate: ['HeartRatePulse'], Kofi: ['Donation', 'Subscription', 'Resubscription', 'ShopOrder', 'Commission'], Midi: ['Message'], Misc: [ 'TimedAction', 'Test', 'ProcessStarted', 'ProcessStopped', 'ChatWindowAction', 'StreamerbotStarted', 'StreamerbotExiting', 'ToastActivation', 'GlobalVariableUpdated', 'ApplicationImport', ], Obs: [ 'Connected', 'Disconnected', 'Event', 'SceneChanged', 'StreamingStarted', 'StreamingStopped', 'RecordingStarted', 'RecordingStopped', ], Patreon: ['FollowCreated', 'FollowDeleted', 'PledgeCreated', 'PledgeUpdated', 'PledgeDeleted'], Pulsoid: ['HeartRatePulse'], Quote: ['Added', 'Show'], Raw: ['Action', 'SubAction', 'ActionCompleted'], Shopify: ['OrderCreated', 'OrderPaid'], SpeakerBot: ['Connected', 'Disconnected'], SpeechToText: ['Dictation', 'Command'], StreamDeck: ['Action', 'Connected', 'Disconnected', 'Info'], StreamElements: ['Tip', 'Merch', 'Connected', 'Disconnected'], Streamlabs: ['Donation', 'Merchandise', 'Connected', 'Disconnected'], StreamlabsDesktop: [ 'Connected', 'Disconnected', 'SceneChanged', 'StreamingStarted', 'StreamingStopped', 'RecordingStarted', 'RecordingStopped', ], ThrowingSystem: [ 'Connected', 'WebsocketConnected', 'WebsocketDisconnected', 'EventsConnected', 'EventsDisconnected', 'ItemHit', 'TriggerActivated', 'TriggerEnded', ], TipeeeStream: ['Donation'], TreatStream: ['Treat'], Trovo: [ 'BroadcasterAuthenticated', 'BroadcasterChatConnected', 'BroadcasterChatDisconnected', 'FirstWords', 'PresentViewers', 'ChatMessage', 'Follow', 'SpellCast', 'CustomSpellCast', 'Raid', 'Subscription', 'Resubscription', 'GiftSubscription', 'MassGiftSubscription', 'StreamOnline', 'StreamOffline', ], Twitch: [ 'Follow', 'Cheer', 'Sub', 'ReSub', 'GiftSub', 'GiftBomb', 'Raid', 'HypeTrainStart', 'HypeTrainUpdate', 'HypeTrainLevelUp', 'HypeTrainEnd', 'RewardRedemption', 'RewardCreated', 'RewardUpdated', 'RewardDeleted', 'CommunityGoalContribution', 'CommunityGoalEnded', 'StreamUpdate', 'Whisper', 'FirstWord', 'SubCounterRollover', 'BroadcastUpdate', 'StreamUpdateGameOnConnect', 'PresentViewers', 'PollCreated', 'PollUpdated', 'PollCompleted', 'PredictionCreated', 'PredictionUpdated', 'PredictionCompleted', 'PredictionCanceled', 'PredictionLocked', 'ChatMessage', 'ChatMessageDeleted', 'UserTimedOut', 'UserBanned', 'Announcement', 'AdRun', 'BotWhisper', 'CharityDonation', 'CharityCompleted', 'CoinCheer', 'ShoutoutCreated', 'UserUntimedOut', 'CharityStarted', 'CharityProgress', 'GoalBegin', 'GoalProgress', 'GoalEnd', 'ShieldModeBegin', 'ShieldModeEnd', 'AdMidRoll', 'StreamOnline', 'StreamOffline', 'ShoutoutReceived', 'ChatCleared', 'RaidStart', 'RaidSend', 'RaidCancelled', ] }; // Example usage: // client.on('Application.ActionAdded', (data) => { console.log(data) }); ``` -------------------------------- ### Client Initialization with Event Subscriptions Source: https://github.com/streamerbot/client/blob/main/apps/docs/content/2.guide/1.events.md Demonstrates how to initialize the StreamerbotClient and automatically subscribe to events. Supports subscribing to all events with '*' or specific events via an object configuration. ```ts const client = new StreamerbotClient({ subscribe: '*' }); const client = new StreamerbotClient({ subscribe: { 'Twitch': ['ChatMessage'] } }); ```