You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
npm install @botk4cp3r/kick.jsapi
# or
yarn add @botk4cp3r/kick.js
# or
pnpm add @botk4cp3r/kick.js
๐ Quick Start
const{ KickClient }=require('@botk4cp3r/kick.js');// Create client instanceconstclient=newKickClient({token: 'your-api-token',webhookPort: 3000,webhookPath: '/webhook',webhookBaseUrl: 'http://your-domain.com'});// Start webhook server and subscribe to eventsasyncfunctioninit(){awaitclient.startWebhookServer();// Subscribe to all available eventsawaitclient.subscribeToEvents(['chat.message.sent','channel.followed','channel.subscription.new','channel.subscription.renewal','channel.subscription.gifts']);console.log('Bot is ready!');}// Listen for eventsclient.on('chatMessage',message=>{console.log(`${message.sender.username}: ${message.content}`);});client.on('channelFollowed',data=>{console.log(`New follower: ${data.follower.username}!`);});client.on('subscriptionNew',data=>{console.log(`New sub: ${data.subscriber.username}!`);});// Send a chat messageawaitclient.sendChatMessage({content: 'Hello World!',type: 'bot'});init().catch(console.error);
๐ฌ Chat System
Send Bot Messages
// Simple bot messageawaitclient.sendChatMessage({content: 'Hello from bot!',type: 'bot'});// Simple user messageawaitclient.sendChatMessage({content: 'Hello! Kappa',type: 'user',broadcasterUserId: '123456'});
Listen for Chat Events
// New messagesclient.on('chatMessage',msg=>{console.log(`${msg.sender.username}: ${msg.content}`);// Auto-respond to commandsif(msg.content==='!ping'){client.sendChatMessage({content: 'Pong! ๐',type: 'bot'});}});
// Subscribe to specific eventsawaitclient.subscribeToEvents(['chat.message.sent','channel.followed','subscription.new','channel.subscription.renewal','channel.subscription.gifts']);// Listen for eventsclient.on('channelFollowed',data=>{console.log(`New follower: ${data.follower.username}`);});client.on('subscriptionNew',data=>{console.log(`New sub: ${data.subscriber.username}`);});
constAVAILABLE_EVENTS={'chat.message.sent',// New chat messages'channel.followed',// When someone follows the channel'channel.subscription.renewal',// Subscription renewals'channel.subscription.gifts',// Gifted subscriptions'channel.subscription.new'// New subscriptions};
Managing Subscriptions
// Get current subscriptionsconstcurrentSubs=awaitclient.getEventSubscriptions();console.log('Current subscriptions:',currentSubs);// Subscribe to specific eventsconstsubscription=awaitclient.subscribeToEvents(['chat.message.sent','channel.followed']);// Subscribe with custom webhook methodconstwebhookSub=awaitclient.subscribeToEvents(['channel.subscription.new','channel.subscription.gifts']);// Unsubscribe from eventsawaitclient.unsubscribeFromEvents(['subscription-id-1','subscription-id-2']);
// Get single channelconstchannel=awaitclient.getChannels(['123456']);// Get multiple channelsconstchannels=awaitclient.getChannels(['123','456','789']);
Update Channel
// Update stream title and categoryawaitclient.updateChannel({categoryId: '123',streamTitle: '๐ด New Stream Title!'});// Update just titleawaitclient.updateChannel({streamTitle: '๐ด Playing Games!'});
๐ฎ Category System
Search Categories
// Search all categoriesconstallCategories=awaitclient.searchCategories();// Search specific gameconstgaming=awaitclient.searchCategories('Minecraft');// Get category by IDconstcategory=awaitclient.getCategory('123');
๐ฅ User Management
Get User Information
// Get single userconstuser=awaitclient.getUsers(['123456']);// Get multiple usersconstusers=awaitclient.getUsers(['123','456','789']);
๐จ Error Handling
try{awaitclient.sendChatMessage({content: 'Test message'});}catch(error){if(errorinstanceofUnauthorizedError){console.error('Token is invalid or expired');}elseif(errorinstanceofForbiddenError){console.error('Insufficient permissions');}elseif(errorinstanceofRateLimitError){console.error(`Rate limited. Try again in ${error.retryAfter} seconds`);}else{console.error('Unknown error:',error.message);}}