UNPKG

twitch-commando

Version:

Twitch Bot Commando Client

522 lines (308 loc) 10.3 kB
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> ### Table of Contents - [TwitchChatChannel][1] - [name][2] - [id][3] - [say][4] - [CommandoConstants][5] - [ClientOptions][6] - [TwitchCommandoClient][7] - [enableVerboseLogging][8] - [connect][9] - [say][10] - [action][11] - [whisper][12] - [registerCommandsIn][13] - [registerDetaultCommands][14] - [setProvider][15] - [join][16] - [part][17] - [getUsername][18] - [getChannels][19] - [isOwner][20] - [CommandArgument][21] - [CommandOptions][22] - [TwichChatCommand][23] - [run][24] - [TwitchChatMessage][25] - [text][26] - [author][27] - [id][28] - [channel][29] - [color][30] - [emotes][31] - [timestamp][32] - [messageType][33] - [reply][34] - [actionReply][35] - [TwitchChatUser][36] - [name][37] - [username][38] - [mod][39] - [badges][40] - [subscriber][41] - [id][42] - [userType][43] - [turbo][44] - [whisper][45] - [channel][46] - [isBroadcaster][47] ## TwitchChatChannel Twitch Channel object **Parameters** - `originalMessage` **[Object][48]** - `client` **[TwitchCommandoClient][49]** ## name Channel name ## id Channel ID ## say Send text message in the channel **Parameters** - `text` **[String][50]** Message text ## CommandoConstants Type: [Object][48] **Properties** - `GLOBAL_SETTINGS_KEY` **[String][50]?** Global settings key to save global bot preferences - `GLOBAL_EMOTES_URL` **[String][50]?** Service url for Emotes service - `BOT_TYPE_NORMAL` **[String][50]?** Normal bot type (user, not mod) - `BOT_TYPE_NORMAL_MODDED` **[String][50]?** Normal bot type with mod (user, channel mod) - `BOT_TYPE_KNOWN` **[String][50]?** Known bot - `BOT_TYPE_VERIFIED` **[String][50]?** Verified bot - `MESSAGE_LIMITS` **[String][50]?** Enumeration for message limits configuration ## ClientOptions Client configuration options Type: [Object][48] **Properties** - `verboseLogging` **[Boolean][51]** Enable verbose logging (default: false) - `username` **[String][50]** Bot username - `oauth` **[String][50]** Bot oauth password (without oauth:) - `botOwners` **[Array][52]&lt;[String][50]>** List of bot owners username (default: empty array) - `prefix` **[String][50]** Default command prefix (default: !) - `greetOnJoin` **[Boolean][51]** Denotes if the bot must send a message when join a channel (default: false) - `channels` **[Array][52]&lt;[String][50]>** Initials channels to join (default: empty array) - `onJoinMessage` **[String][50]** On Join message (sent if greetOnJoin = true) - `autoJoinBotChannel` **[Boolean][51]** Denotes if the bot must autojoin its own channel (default: true) - `enableJoinCommand` **[Boolean][51]** Denotes if enable the !join and !part command in bot channel (default: true) - `botType` **[String][50]** Define the bot type, will be used for message limits control. See CommandoConstants for available bot type values (default: BOT_TYPE_NORMAL) - `enableRateLimitingControl` **[Boolean][51]** Enable Rate Limiting control (default: true) - `skipMembership` **[Boolean][51]** Skip PART\\JOIN events (default: true) - `enableVerboseLogging` **[Boolean][51]** Enable Verbose Logging up to debug level (default: false) - `joinInterval` **[Number][53]** TMI Join Interval in milliseconds (default: 350ms instead of default tmi 2000ms) ## TwitchCommandoClient **Extends EventEmitter** The Commando Client class **Parameters** - `options` **[ClientOptions][54]** Client configuration options ### enableVerboseLogging Enable verbose logging ### connect Connect the bot to Twitch Chat ### say Send a text message in the channel **Parameters** - `channel` **[String][50]** Channel destination - `message` **[String][50]** Message text - `addRandomEmote` **[Boolean][51]** Add random emote to avoid message duplication (optional, default `false`) ### action Send an action message in the channel **Parameters** - `channel` **[String][50]** - `message` **[String][50]** - `addRandomEmote` **[Boolean][51]** Add random emote to avoid message duplication (optional, default `false`) Returns **[String][50]** ### whisper Send a private message to the user with given text **Parameters** - `username` **[String][50]** - `message` **[String][50]** Returns **any** ### registerCommandsIn Register commands in given path (recursive) **Parameters** - `path` **[String][50]** ### registerDetaultCommands Register default commands, like !help ### setProvider Set Settings Provider class **Parameters** - `provider` ### join Request the bot to join a channel **Parameters** - `channel` **[String][50]** Channel to join Returns **[Promise][55]&lt;[String][50]>** ### part Request the bot to leave a channel **Parameters** - `channel` **[String][50]** Channel to leave Returns **[Promise][55]&lt;[String][50]>** ### getUsername Gets the bot username Returns **[String][50]** ### getChannels Gets the bot channels Returns **[Array][52]&lt;[String][50]>** ### isOwner Checks if the message author is one of bot owners **Parameters** - `author` **[TwitchChatUser][56]** Message author Returns **[Boolean][51]** ## CommandArgument Command argument Type: [Object][48] **Properties** - `name` **[String][50]** Argument key name - `type` **[Object][48]** Argument type - `defaultValue` **[Object][48]** Argument default value ## CommandOptions Command Options Type: [Object][48] **Properties** - `name` **[String][50]** Command name - `modOnly` **[Boolean][51]** Restricted only to channel mods - `ownerOnly` **[Boolean][51]** Restricted only to bot owners - `broadcasterOnly` **[Boolean][51]** Restricted only to channel owner - `description` **[String][50]** Command description - `examples` **[Array][52]&lt;[String][50]>** Command examples - `args` **[Array][52]&lt;[CommandArgument][57]>** Arguments - `group` **[String][50]** Command group - `aliases` **[Array][52]&lt;[String][50]>** Command aliases - `botChannelOnly` **[Boolean][51]** Restricted to bot channel only - `hideFromHelp` **[Boolean][51]** Hide the command from help command - `privmsgOnly` **[Boolean][51]** Restricted to privmsg only ## TwichChatCommand Base class to implement custom commands **Parameters** - `client` **[TwitchCommandoClient][49]** The TwitchCommandoClient - `options` **[CommandOptions][58]** Command options ### run Method called when command is executed **Parameters** - `msg` **[TwitchChatMessage][59]** Message received - `parameters` **[object][48]** Arguments parsed ## TwitchChatMessage This class represents the chat message **Parameters** - `originalMessage` **[object][48]** - `channel` **[String][50]** - `client` **[TwitchCommandoClient][49]** ### text Text of the message Returns **[String][50]** ### author The author of the message Returns **[TwitchChatUser][56]** ### id The ID of the message Returns **[String][50]** ### channel The channel where the message has been sent in Returns **[TwitchChatChannel][60]** ### color Text color Returns **[String][50]** ### emotes Emotes contained in the message ### timestamp Message sent date Returns **[Date][61]** ### messageType Message type Returns **[String][50]** ### reply Helper method to reply quickly to a message. Create a message to send in the channel with @author <text> **Parameters** - `text` **[String][50]** - `addRamndomEmote` (optional, default `false`) - `addRandomEmote` **[Boolean][51]** Add random emote to avoid message duplication ### actionReply Helper method to reply quickly to a message with an action **Parameters** - `text` **[String][50]** - `addRamndomEmote` (optional, default `false`) - `addRandomEmote` **[Boolean][51]** Add random emote to avoid message duplication ## TwitchChatUser This class represents a chat user **Parameters** - `originalMessage` **[Object][48]** - `client` **[TwitchCommandoClient][49]** ### name ### username ### mod ### badges ### subscriber ### id ### userType ### turbo ### whisper Whisper a message to the user **Parameters** - `message` **[String][50]** Message Text ### channel Get the user channel Returns **[String][50]** Channel name ### isBroadcaster Check if user is the channel broadcaster Returns **[Boolean][51]** True if the user is the broadcaster [1]: #twitchchatchannel [2]: #name [3]: #id [4]: #say [5]: #commandoconstants [6]: #clientoptions [7]: #twitchcommandoclient [8]: #enableverboselogging [9]: #connect [10]: #say-1 [11]: #action [12]: #whisper [13]: #registercommandsin [14]: #registerdetaultcommands [15]: #setprovider [16]: #join [17]: #part [18]: #getusername [19]: #getchannels [20]: #isowner [21]: #commandargument [22]: #commandoptions [23]: #twichchatcommand [24]: #run [25]: #twitchchatmessage [26]: #text [27]: #author [28]: #id-1 [29]: #channel [30]: #color [31]: #emotes [32]: #timestamp [33]: #messagetype [34]: #reply [35]: #actionreply [36]: #twitchchatuser [37]: #name-1 [38]: #username [39]: #mod [40]: #badges [41]: #subscriber [42]: #id-2 [43]: #usertype [44]: #turbo [45]: #whisper-1 [46]: #channel-1 [47]: #isbroadcaster [48]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object [49]: #twitchcommandoclient [50]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String [51]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean [52]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array [53]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number [54]: #clientoptions [55]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise [56]: #twitchchatuser [57]: #commandargument [58]: #commandoptions [59]: #twitchchatmessage [60]: #twitchchatchannel [61]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date