Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/macdja38/twitch.js
https://github.com/macdja38/twitch.js
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/macdja38/twitch.js
- Owner: macdja38
- License: mit
- Created: 2018-04-06T05:40:26.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-06T07:28:51.000Z (almost 7 years ago)
- Last Synced: 2024-10-22T09:53:27.751Z (3 months ago)
- Language: JavaScript
- Size: 556 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## About
A new lib for interfacing with twitch api and chat servers## Installation
**Node.js 8.0.0 or newer is required.**
```sh
npm install github:twitch-js/twitch.js --save
```## Example API
```js
const config = { 'Client-ID': 'CLIENT_ID' };
const twitch = require('twitch.js');
const client = new twitch(config);console.log(client.api);
(async () => {
let res;try {
res = await client.api.getUsers(['rosiecode']);
} catch (error) {
console.error(error);
}console.log(`the user-id for ${res.users[0].display_name} is: ${res.users[0]._id}`);
})();```
## Example Chat
```js
const twitch = require('./../index');
const config = { username: '', oauth: 'oauth:' };
const client = new twitch(config);client.on('message', (message) => { console.log(`${message.author} : ${message.content}`); });
client.on('disconnected', () => { console.log('[INFO]', 'DISCONNECTED FROM WS'); });
client.on('debug', (debug) => { console.log(`[DEBUG] ${debug}`); });client.on('JOIN', ({ channel, user }) => { console.log(channel, user); });
client.on('PART', ({ channel, user }) => { console.log(channel, user); });client.on('ready', () => {
console.log('ready!');
client.join('rosiecode'); // Join a channel
});client.connect();
```
## Contributing
have an issue? check current issues before reporting[Documentation](https://twitch-js.github.io/twitch.js/)