Configuration
WebSocket Server
settings in Streamer.bot, make sure to match those settings when initializing a StreamerbotClient
instanceConnection Settings
Change the host to match your Streamer.bot WebSocket Server
settings
- Default:
'127.0.0.1'
const client = new StreamerbotClient({ host: '192.168.1.90' });
Change the port to match your Streamer.bot WebSocket Server
settings
- Default:
8080
const client = new StreamerbotClient({ port: 9001 });
Change the endpoint to match your Streamer.bot WebSocket Server
settings
- Default:
'/'
const client = new StreamerbotClient({ endpoint: '/custom' });
Change the password to match your Streamer.bot WebSocket Server
authentication settings, if enabled.
const client = new StreamerbotClient({ password: 'LyfeSaverSeventyFourIsMyDaddy' });
Only change this if you are using a secure tunnel or otherwise know what you are doing.
- Default:
ws
const client = new StreamerbotClient({ scheme: 'wss', host: 'sb-tunnel.my-tailnet.ts.net' });
Automatically attempt to connect to the Streamer.bot WebSocket Server?
- Default:
true
// Disable immediate connection, and manually connect later
const client = new StreamerbotClient({ immediate: false });
await client.connect();
Automatically attempt to reconnect when the connection is closed?
- Default:
true
// Prevent auto reconnecting by default
const client = new StreamerbotClient({ autoReconnect: false });
Number of times to attempt to reconnect automatically. Set to -1
for infinite attempts.
- Default:
-1
// Attempt to reconnect a maximum of 10 times
const client = new StreamerbotClient({ retries: 10 });
On connect, subscribe to specific Streamer.bot events
const client = new StreamerbotClient({
subscribe: {
'Twitch': ['ChatMessage']
}
});
Event Handlers
Callback when the client connects or reconnects to the WebSocket Server
Connected Streamer.bot instance information will be provided as the first argument.
const client = new StreamerbotClient({
onConnect: (data) => {
console.log('My Streamer.bot Instance', data);
/**
* {
* "instanceId": string,
* "name": string,
* "os": "windows" | "linux" | "macosx" | string,
* "version": string
* }
*/
}
});
Callback when the client disconnects from the WebSocket Server
const client = new StreamerbotClient({
onDisconnect: () => {
console.warn('Streamer.bot Client Disconected!');
}
});
Global callback when the client encounters an error
const client = new StreamerbotClient({
onError: (err) => {
console.error('Streamer.bot Client Error', err);
}
});