streamer-emotes 0.0.5 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,8 @@
1
1
  # streamer-emotes
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+
2
6
  A library to get Twitch, BTTV, FFZ and 7TV emotes for a given Twitch channel.
3
7
 
4
8
  ## Usage
@@ -6,11 +10,56 @@ A library to get Twitch, BTTV, FFZ and 7TV emotes for a given Twitch channel.
6
10
  ```js
7
11
  import { getStreamerEmotes } from "streamer-emotes";
8
12
 
9
- const rubiusEmotes = await getStreamerEmotes("rubius", {
13
+ const emotes = await getStreamerEmotes("rubius", {
14
+ bttv: true, // Get BTTV emotes
15
+ ffz: true, // Get FFZ emotes
10
16
  sevenTV: true, // Get 7TV emotes
11
17
  twitch: { globals: false } // Get Twitch emotes but exclude global ones
12
18
  });
13
19
 
14
- console.log(rubiusEmotes);
20
+ console.info(emotes);
21
+ ```
15
22
 
23
+ ## Output example
24
+ ```jsonc
25
+ {
26
+ "<provider>": { // Provider prop
27
+ "channel": [ // Channel Emotes
28
+ {
29
+ "animated": true,
30
+ "id": "string",
31
+ "images": [
32
+ {
33
+ "url": "string",
34
+ "version": "string"
35
+ }
36
+ ],
37
+ "name": "string",
38
+ "provider": "string",
39
+ "zeroWidth": true // 7TV zero width emotes only
40
+ }
41
+ ],
42
+ "global": [ // Global Emotes
43
+ {
44
+ "animated": false,
45
+ "id": "string",
46
+ "images": [
47
+ {
48
+ "url": "string",
49
+ "version": "string"
50
+ }
51
+ ],
52
+ "name": "string",
53
+ "provider": "string",
54
+ }
55
+ ]
56
+ }
57
+ }
16
58
  ```
59
+
60
+ <!-- Badges -->
61
+ [npm-version-src]: https://img.shields.io/npm/v/streamer-emotes.svg?style=flat
62
+ [npm-version-href]: https://npmjs.com/package/streamer-emotes
63
+
64
+ [npm-downloads-src]: https://img.shields.io/npm/dm/streamer-emotes.svg?style=flat
65
+ [npm-downloads-href]: https://npmjs.com/package/streamer-emotes
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region src/types/index.d.ts
2
- interface StreamerEmotesProps {
2
+ interface StreamerEmotesProps<T> {
3
3
  animated: boolean;
4
4
  id: string;
5
5
  images: {
@@ -7,17 +7,18 @@ interface StreamerEmotesProps {
7
7
  version: string;
8
8
  }[];
9
9
  name: string;
10
- provider: "7tv" | "bttv" | "ffz" | "twitch";
10
+ provider: T;
11
+ zeroWidth?: boolean;
11
12
  }
12
- interface StreamerEmotesProviderResponse {
13
- channel: StreamerEmotesProps[];
14
- global?: StreamerEmotesProps[];
13
+ interface StreamerEmotesProviderResponse<T> {
14
+ channel: StreamerEmotesProps<T>[];
15
+ global?: StreamerEmotesProps<T>[];
15
16
  }
16
17
  //#endregion
17
18
  //#region src/index.d.ts
18
19
  /**
19
20
  *
20
- * @param channelLogin
21
+ * @param channelLogin Twitch channel login.
21
22
  * @param options.bttv Get emotes from BetterTTV if `true`. Defaults to `false`.
22
23
  * @param options.ffz Get emotes from FrankerFaceZ if `true`. Defaults to `false`.
23
24
  * @param options.sevenTV Get emotes from 7TV if `true`. Defaults to `false`.
@@ -31,10 +32,10 @@ declare const getStreamerEmotes: (channelLogin: string, options: {
31
32
  sevenTV?: boolean | StreamerEmotesProviderOptions;
32
33
  twitch?: boolean | StreamerEmotesProviderOptions;
33
34
  }) => Promise<{
34
- bttv?: StreamerEmotesProviderResponse;
35
- ffz?: StreamerEmotesProviderResponse;
36
- sevenTV?: StreamerEmotesProviderResponse;
37
- twitch?: StreamerEmotesProviderResponse;
35
+ bttv?: StreamerEmotesProviderResponse<"bttv">;
36
+ ffz?: StreamerEmotesProviderResponse<"ffz">;
37
+ sevenTV?: StreamerEmotesProviderResponse<"7tv">;
38
+ twitch?: StreamerEmotesProviderResponse<"twitch">;
38
39
  }>;
39
40
  interface StreamerEmotesProviderOptions {
40
41
  globals: boolean;
package/dist/index.mjs CHANGED
@@ -69,7 +69,8 @@ const get7tvEmotes = async (channelLogin, options) => {
69
69
  id: emote.id,
70
70
  images,
71
71
  name: emote.name,
72
- provider: "7tv"
72
+ provider: "7tv",
73
+ zeroWidth: emote.flags === 1 && emote.data.flags === 256
73
74
  };
74
75
  });
75
76
  };
@@ -265,7 +266,7 @@ const getTwitchEmotes = async (channelLogin, options) => {
265
266
  //#region src/index.ts
266
267
  /**
267
268
  *
268
- * @param channelLogin
269
+ * @param channelLogin Twitch channel login.
269
270
  * @param options.bttv Get emotes from BetterTTV if `true`. Defaults to `false`.
270
271
  * @param options.ffz Get emotes from FrankerFaceZ if `true`. Defaults to `false`.
271
272
  * @param options.sevenTV Get emotes from 7TV if `true`. Defaults to `false`.
@@ -278,11 +279,11 @@ const getStreamerEmotes = async (channelLogin, options) => {
278
279
  const { bttv, ffz, sevenTV, twitch } = options;
279
280
  const data = {};
280
281
  let bttvPromise, ffzPromise, sevenTvPromise, twitchPromise;
281
- if (bttv || ffz || sevenTV || twitch) await getTwitchIdByLogin(channelLogin);
282
282
  if (bttv) bttvPromise = getBttvEmotes(channelLogin, { globals: typeof bttv === "boolean" ? true : bttv?.globals ?? true }).catch(() => null);
283
283
  if (ffz) ffzPromise = getFfzEmotes(channelLogin, { globals: typeof ffz === "boolean" ? true : ffz?.globals ?? true }).catch(() => null);
284
284
  if (sevenTV) sevenTvPromise = get7tvEmotes(channelLogin, { globals: typeof sevenTV === "boolean" ? true : sevenTV?.globals ?? true }).catch(() => null);
285
285
  if (twitch) twitchPromise = getTwitchEmotes(channelLogin, { globals: typeof twitch === "boolean" ? true : twitch?.globals ?? true }).catch(() => null);
286
+ await getTwitchIdByLogin(channelLogin);
286
287
  const [bttvEmotes, ffzEmotes, sevenTvEmotes, twitchEmotes] = await Promise.all([
287
288
  bttvPromise,
288
289
  ffzPromise,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "streamer-emotes",
3
3
  "type": "module",
4
- "version": "0.0.5",
4
+ "version": "0.1.1",
5
5
  "description": "A library to get Twitch, BTTV, FFZ and 7TV emotes for a given Twitch channel.",
6
6
  "keywords": [
7
7
  "streamer",
@@ -55,4 +55,4 @@
55
55
  "typescript": "^5.9.3"
56
56
  },
57
57
  "packageManager": "pnpm@10.32.1"
58
- }
58
+ }