@livecord/notify
Advanced tools
Comparing version 1.2.1 to 1.2.2
export { LivecordTwitch as Twitch } from './platforms/twitch'; | ||
export { LivecordYoutube as YouTube } from './platforms/youtube'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ export interface Client { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
; |
export { Live } from './live'; | ||
export { Client } from './client'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ export interface Live { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
; |
{ | ||
"name": "@livecord/notify", | ||
"version": "1.2.1", | ||
"description": "Notifier for YouTube and Twitch.", | ||
"main": "./index.js", | ||
"types": "./index.d.ts", | ||
"scripts": { | ||
"test:twitch": "ts-node --transpile-only ./examples/twitch.test.ts", | ||
"test:youtube": "ts-node --transpile-only ./examples/youtube.test.ts", | ||
"build": "tsc --sourceMap false" | ||
}, | ||
"keywords": [ | ||
"notifier", | ||
"youtube", | ||
"twitch", | ||
"typescript", | ||
"backend" | ||
], | ||
"author": "Livecord", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Livecord/notify", | ||
"homepage": "https://livecord.me" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.27.2", | ||
"fs": "^0.0.1-security", | ||
"rss-parser": "^3.12.0" | ||
}, | ||
"devDependencies": { | ||
"ts-node": "^10.8.1", | ||
"typescript": "^4.7.4" | ||
} | ||
"name": "@livecord/notify", | ||
"version": "1.2.2", | ||
"description": "Notifier for YouTube and Twitch.", | ||
"main": "./index.js", | ||
"types": "./index.d.ts", | ||
"scripts": { | ||
"test:twitch": "ts-node --transpile-only ./examples/twitch.test.ts", | ||
"test:youtube": "ts-node --transpile-only ./examples/youtube.test.ts", | ||
"build": "tsc --sourceMap false" | ||
}, | ||
"keywords": [ | ||
"notifier", | ||
"youtube", | ||
"twitch", | ||
"typescript", | ||
"backend" | ||
], | ||
"author": "Livecord", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Livecord/notify", | ||
"homepage": "https://livecord.me" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.27.2", | ||
"fs": "^0.0.1-security", | ||
"rss-parser": "^3.12.0" | ||
}, | ||
"devDependencies": { | ||
"ts-node": "^10.8.1", | ||
"typescript": "^4.7.4" | ||
} | ||
} |
@@ -16,4 +16,5 @@ /// <reference types="node" /> | ||
unfollow(channel: string | string[]): void | string[]; | ||
getUser(userId: string): Promise<any>; | ||
getUser(userLogin: string): Promise<any>; | ||
getLive(userLogin: string): Promise<any>; | ||
static getToken(clientId: string, clientSecret: string): Promise<any>; | ||
} |
@@ -208,9 +208,9 @@ "use strict"; | ||
; | ||
async getUser(userId) { | ||
if (!userId) | ||
throw new Error('LivecordTwitch: userId is required'); | ||
if (typeof userId === 'string') { | ||
async getUser(userLogin) { | ||
if (!userLogin) | ||
throw new Error('LivecordTwitch: userLogin is required'); | ||
if (typeof userLogin === 'string') { | ||
const request = await axios_1.default.request({ | ||
method: "GET", | ||
url: `https://api.twitch.tv/helix/users?id=${userId}`, | ||
url: `https://api.twitch.tv/helix/users?login=${userLogin}`, | ||
headers: { | ||
@@ -224,3 +224,3 @@ "client-id": this.client.id, | ||
else { | ||
throw new Error('LivecordTwitch: userId must be a string'); | ||
throw new Error('LivecordTwitch: userLogin must be a string'); | ||
} | ||
@@ -230,2 +230,22 @@ ; | ||
; | ||
async getLive(userLogin) { | ||
if (!userLogin) | ||
throw new Error('LivecordTwitch: userLogin is required'); | ||
if (typeof userLogin === 'string') { | ||
const request = await axios_1.default.request({ | ||
method: "GET", | ||
url: `https://api.twitch.tv/helix/streams?user_login=${userLogin}`, | ||
headers: { | ||
"client-id": this.client.id, | ||
"Authorization": `Bearer ${this.client.token}` | ||
} | ||
}).then(res => res.data).catch(err => err.response); | ||
return request?.data[0] ? { isLive: true, ...request?.data[0] } : { isLive: false }; | ||
} | ||
else { | ||
throw new Error('LivecordTwitch: userLogin must be a string'); | ||
} | ||
; | ||
} | ||
; | ||
static async getToken(clientId, clientSecret) { | ||
@@ -232,0 +252,0 @@ const request = await axios_1.default.post('https://id.twitch.tv/oauth2/token', { |
@@ -0,0 +0,0 @@ /// <reference types="node" /> |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -48,2 +48,6 @@ # [@livecord/notify](https://npmjs.com/package/@livecord/notify) | ||
}); | ||
// Other Functions | ||
// twitch.getUser('user_login_name'); | ||
// twitch.getLive('user_login_name'); | ||
``` | ||
@@ -50,0 +54,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
25946
514
128