@livecord/notify
Advanced tools
Comparing version 1.2.2 to 1.2.3
{ | ||
"name": "@livecord/notify", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Notifier for YouTube and Twitch.", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -18,3 +18,11 @@ /// <reference types="node" /> | ||
getLive(userLogin: string): Promise<any>; | ||
getFollowers(userId: string): Promise<{ | ||
total: any; | ||
data: any; | ||
}>; | ||
getFollows(userId: string): Promise<{ | ||
total: any; | ||
data: any; | ||
}>; | ||
static getToken(clientId: string, clientSecret: string): Promise<any>; | ||
} |
@@ -248,2 +248,42 @@ "use strict"; | ||
; | ||
async getFollowers(userId) { | ||
if (!userId) | ||
throw new Error('LivecordTwitch: userLogin is required'); | ||
if (typeof userId === 'string') { | ||
const request = await axios_1.default.request({ | ||
method: "GET", | ||
url: `https://api.twitch.tv/helix/users/follows?to_id=${userId}`, | ||
headers: { | ||
"client-id": this.client.id, | ||
"Authorization": `Bearer ${this.client.token}` | ||
} | ||
}).then(res => res.data).catch(err => err.response); | ||
return { total: request?.total, data: request?.data }; | ||
} | ||
else { | ||
throw new Error('LivecordTwitch: userId must be a string'); | ||
} | ||
; | ||
} | ||
; | ||
async getFollows(userId) { | ||
if (!userId) | ||
throw new Error('LivecordTwitch: userId is required'); | ||
if (typeof userId === 'string') { | ||
const request = await axios_1.default.request({ | ||
method: "GET", | ||
url: `https://api.twitch.tv/helix/users/follows?from_id=${userId}`, | ||
headers: { | ||
"client-id": this.client.id, | ||
"Authorization": `Bearer ${this.client.token}` | ||
} | ||
}).then(res => res.data).catch(err => err.response); | ||
return { total: request?.total, data: request?.data }; | ||
} | ||
else { | ||
throw new Error('LivecordTwitch: userId must be a string'); | ||
} | ||
; | ||
} | ||
; | ||
static async getToken(clientId, clientSecret) { | ||
@@ -250,0 +290,0 @@ const request = await axios_1.default.post('https://id.twitch.tv/oauth2/token', { |
@@ -52,2 +52,4 @@ # [@livecord/notify](https://npmjs.com/package/@livecord/notify) | ||
// twitch.getLive('user_login_name'); | ||
// twitch.getFollowers('user_id'); | ||
// twitch.getFollows('user_id'); | ||
``` | ||
@@ -54,0 +56,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
27763
562
130