@livecord/notify
Advanced tools
Comparing version 1.1.0 to 1.1.2
const { Twitch } = require('../src/index'); | ||
const twitch = new Twitch({ | ||
client: { | ||
id: "0w3w9kd3xgome2t3kybau47z9lhza9", | ||
token: "xgo7bj4lydp649bgl8qmw02ozcusas" | ||
id: "", | ||
token: "" | ||
}, | ||
@@ -11,2 +11,3 @@ useDatabase: true, | ||
twitch.on('ready', (ready) => { | ||
@@ -18,2 +19,3 @@ twitch.follow('rraenee'); | ||
twitch.on('live', channel => { | ||
console.log(channel) | ||
console.log(channel.user_name + " is live!"); | ||
@@ -20,0 +22,0 @@ }); |
@@ -14,3 +14,4 @@ const { YouTube } = require('../src/index'); | ||
youtube.on('upload', video => { | ||
console.log(video) | ||
console.log('Youtube uploaded video'); | ||
}); |
@@ -1,1 +0,1 @@ | ||
{"channels":["clqu_","jrokezftw","rraenee"]} | ||
{"channels":["clqu_","rraenee"]} |
@@ -1,1 +0,1 @@ | ||
{"videos":[],"channels":["UCaZGQt419Ptsdk_lh2mz9lQ"]} | ||
{"videos":["yt:video:YvrtiAp5JD0"],"channels":["UCaZGQt419Ptsdk_lh2mz9lQ"]} |
{ | ||
"name": "@livecord/notify", | ||
"version": "1.1.0", | ||
"version": "1.1.2", | ||
"description": "Notifier for Youtube and Twitch.", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -20,7 +20,7 @@ # [@livecord/notify](https://npmjs.com/package/@livecord/notify) | ||
```js | ||
const { Twitch } = require('@livecord/notify'); | ||
const { Twitch } = require("@livecord/notify"); | ||
const twitch = new Twitch({ | ||
client: { | ||
id: 'YOUR_CLIENT_ID', // Your client ID | ||
token: 'YOUR_TOKEN_HERE', // https://dev.twitch.tv/docs/authentication/getting-tokens | ||
id: "YOUR_CLIENT_ID", // Your client ID | ||
token: "YOUR_TOKEN_HERE", // https://dev.twitch.tv/docs/authentication/getting-tokens | ||
}, | ||
@@ -30,15 +30,15 @@ interval: 60000 // check channels every (optional) (default: 60000 [60 seconds]) | ||
twitch.on('ready', (ready) => { | ||
twitch.follow([ 'clqu_' ]); | ||
twitch.unfollow([ 'clqu_' ]); | ||
twitch.on("ready", (ready) => { | ||
console.log('Twitch connected at: ', ready); | ||
twitch.follow([ "clqu_" ]); | ||
twitch.unfollow([ "clqu_" ]); | ||
console.log("Twitch connected at: ", ready); | ||
}); | ||
twitch.on('live', channel => { | ||
twitch.on("live", channel => { | ||
console.log(channel.user_name + " is live!"); | ||
}); | ||
twitch.on('offline', channel => { | ||
twitch.on("offline", channel => { | ||
console.log(channel.user_name + " is offline!"); | ||
@@ -50,3 +50,3 @@ }); | ||
```js | ||
const { Twitch } = require('@livecord/notify'); | ||
const { Twitch } = require("@livecord/notify"); | ||
@@ -59,2 +59,21 @@ Twitch.getToken("CLIENT_ID", "CLIENT_SECRET").then(token => { | ||
``` | ||
#### Data of Channel | ||
```json | ||
{ | ||
"id": "", | ||
"user_id": "", | ||
"user_login": "", | ||
"user_name": "", | ||
"game_id": "", | ||
"game_name": "", | ||
"type": "live", | ||
"title": "", | ||
"viewer_count": 0, | ||
"started_at": "", | ||
"language": "", | ||
"thumbnail_url": "", | ||
"tag_ids": [ "" ], | ||
"is_mature": true | ||
} | ||
``` | ||
@@ -64,3 +83,3 @@ ## Youtube | ||
```js | ||
const { YouTube } = require('@livecord/notify'); | ||
const { YouTube } = require("@livecord/notify"); | ||
const youtube = new YouTube({ | ||
@@ -71,18 +90,28 @@ interval: 60000, // check channels every 1000ms (1 second) (optional) (default: 60000 [60 seconds])]) | ||
youtube.on('ready', (ready) => { | ||
youtube.subscribe('UC00_j4mtyaMbWX62JWBMmWA'); // Subscribe to a another channel | ||
// For multiple: youtube.subscribe(['', '']); | ||
youtube.on("ready", (ready) => { | ||
youtube.subscribe("UC00_j4mtyaMbWX62JWBMmWA"); // Subscribe to a another channel | ||
// For multiple: youtube.subscribe(["", ""]); | ||
youtube.unsubscribe('UC00_j4mtyaMbWX62JWBMmWA'); // Unsubscribe to any added channels | ||
// For multiple: youtube.unsubscribe(['', '']); | ||
youtube.unsubscribe("UC00_j4mtyaMbWX62JWBMmWA"); // Unsubscribe to any added channels | ||
// For multiple: youtube.unsubscribe(["", ""]); | ||
console.log('Youtube connected at: ', ready); | ||
console.log("Youtube connected at: ", ready); | ||
}); | ||
youtube.on('upload', video => { | ||
console.log('Youtube new video!', video); | ||
youtube.on("upload", video => { | ||
console.log("Youtube new video!", video); | ||
}) | ||
``` | ||
#### Data of Video | ||
```json | ||
{ | ||
"title": "", | ||
"link": "", | ||
"pubDate": "", | ||
"author": "", | ||
"id": "", | ||
"isoDate": "" | ||
} | ||
``` | ||
--- | ||
<h6 align="center">Developed with ❤️ by Livecord</h6> |
@@ -28,2 +28,3 @@ const EventEmitter = require('events'); | ||
this.lives = []; | ||
this.client = client; | ||
this.useDatabase = useDatabase; | ||
@@ -140,2 +141,18 @@ if (useDatabase) { | ||
} | ||
async getUser(userId) { | ||
if (!userId) throw new Error('LivecordTwitch: userId is required'); | ||
if (typeof userId === 'string') { | ||
const request = await axios.request({ | ||
method: "GET", | ||
url: `https://api.twitch.tv/helix/users?id=${userId}`, | ||
headers: { | ||
"client-id": this.client.id, | ||
"Authorization": `Bearer ${this.client.token}` | ||
} | ||
}).then(res => res.data).catch(err => err.response); | ||
return request?.data[0]; | ||
} else { | ||
throw new Error('LivecordTwitch: userId must be a string'); | ||
} | ||
} | ||
}; | ||
@@ -142,0 +159,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19782
344
111