streamer-emotes 0.0.4 → 0.1.0

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
@@ -6,11 +6,12 @@ A library to get Twitch, BTTV, FFZ and 7TV emotes for a given Twitch channel.
6
6
  ```js
7
7
  import { getStreamerEmotes } from "streamer-emotes";
8
8
 
9
- const rubiusEmotes = await getStreamerEmotes("rubius", {
9
+ const emotes = await getStreamerEmotes("rubius", {
10
+ bttv: true, // Get BTTV emotes
11
+ ffz: true, // Get FFZ emotes
10
12
  sevenTV: true, // Get 7TV emotes
11
13
  twitch: { globals: false } // Get Twitch emotes but exclude global ones
12
14
  });
13
15
 
14
- console.log(rubiusEmotes);
15
-
16
+ console.info(emotes);
16
17
  ```
package/dist/index.d.mts CHANGED
@@ -8,6 +8,7 @@ interface StreamerEmotesProps {
8
8
  }[];
9
9
  name: string;
10
10
  provider: "7tv" | "bttv" | "ffz" | "twitch";
11
+ zeroWidth?: boolean;
11
12
  }
12
13
  interface StreamerEmotesProviderResponse {
13
14
  channel: StreamerEmotesProps[];
package/dist/index.mjs CHANGED
@@ -48,14 +48,14 @@ const get7tvEmotes = async (channelLogin, options) => {
48
48
  const channelDataPromise = $fetch(`/users/twitch/${channelId}`, {
49
49
  baseURL: providersURL.sevenTV,
50
50
  method: "GET"
51
- });
51
+ }).catch(() => null);
52
52
  let globalDataPromise;
53
53
  if (globals) globalDataPromise = $fetch("/emote-sets/global", {
54
54
  baseURL: providersURL.sevenTV,
55
55
  method: "GET"
56
56
  });
57
57
  const [channelData, globalData] = await Promise.all([channelDataPromise, globalDataPromise]);
58
- channel.push(...channelData.emote_set.emotes);
58
+ if (channelData) channel.push(...channelData.emote_set.emotes);
59
59
  if (globalData) global.push(...globalData.emotes);
60
60
  const normalizeData = (data) => {
61
61
  if (!data?.length) return [];
@@ -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
  };
@@ -95,14 +96,14 @@ const getBttvEmotes = async (channelLogin, options) => {
95
96
  const channelDataPromise = $fetch(`/cached/users/twitch/${channelId}`, {
96
97
  baseURL: providersURL.bttv,
97
98
  method: "GET"
98
- });
99
+ }).catch(() => null);
99
100
  let globalDataPromise;
100
101
  if (globals) globalDataPromise = $fetch("/cached/emotes/global", {
101
102
  baseURL: providersURL.bttv,
102
103
  method: "GET"
103
104
  });
104
105
  const [channelData, globalData] = await Promise.all([channelDataPromise, globalDataPromise]);
105
- channel.push(...channelData.channelEmotes, ...channelData.sharedEmotes);
106
+ if (channelData) channel.push(...channelData.channelEmotes, ...channelData.sharedEmotes);
106
107
  if (globalData) global.push(...globalData);
107
108
  const normalizeData = (data) => {
108
109
  if (!data?.length) return [];
@@ -149,14 +150,14 @@ const getFfzEmotes = async (channelLogin, options) => {
149
150
  const channelDataPromise = $fetch(`/room/id/${channelId}`, {
150
151
  baseURL: providersURL.ffz,
151
152
  method: "GET"
152
- });
153
+ }).catch(() => null);
153
154
  let globalDataPromise;
154
155
  if (globals) globalDataPromise = $fetch("/set/global", {
155
156
  baseURL: providersURL.ffz,
156
157
  method: "GET"
157
158
  });
158
159
  const [channelData, globalData] = await Promise.all([channelDataPromise, globalDataPromise]);
159
- channel.push(...channelData.sets[channelData.room.set].emoticons);
160
+ if (channelData) channel.push(...channelData.sets[channelData.room.set].emoticons);
160
161
  if (globalData) global.push(...globalData.default_sets.flatMap((setId) => globalData.sets[setId].emoticons));
161
162
  const normalizeData = (data) => {
162
163
  if (!data?.length) return [];
@@ -214,7 +215,8 @@ const getTwitchEmotes = async (channelLogin, options) => {
214
215
  };
215
216
  const localEmotesQuery = {
216
217
  operation: "channel",
217
- variables: { id: {
218
+ variables: { channelId: {
219
+ name: "id",
218
220
  value: channelId,
219
221
  type: "ID!"
220
222
  } },
@@ -278,10 +280,10 @@ const getStreamerEmotes = async (channelLogin, options) => {
278
280
  const data = {};
279
281
  let bttvPromise, ffzPromise, sevenTvPromise, twitchPromise;
280
282
  if (bttv || ffz || sevenTV || twitch) await getTwitchIdByLogin(channelLogin);
281
- if (bttv) bttvPromise = getBttvEmotes(channelLogin, { globals: typeof bttv === "boolean" ? true : bttv?.globals }).catch(() => null);
282
- if (ffz) ffzPromise = getFfzEmotes(channelLogin, { globals: typeof ffz === "boolean" ? true : ffz?.globals }).catch(() => null);
283
- if (sevenTV) sevenTvPromise = get7tvEmotes(channelLogin, { globals: typeof sevenTV === "boolean" ? true : sevenTV?.globals }).catch(() => null);
284
- if (twitch) twitchPromise = getTwitchEmotes(channelLogin, { globals: typeof twitch === "boolean" ? true : twitch?.globals }).catch(() => null);
283
+ if (bttv) bttvPromise = getBttvEmotes(channelLogin, { globals: typeof bttv === "boolean" ? true : bttv?.globals ?? true }).catch(() => null);
284
+ if (ffz) ffzPromise = getFfzEmotes(channelLogin, { globals: typeof ffz === "boolean" ? true : ffz?.globals ?? true }).catch(() => null);
285
+ if (sevenTV) sevenTvPromise = get7tvEmotes(channelLogin, { globals: typeof sevenTV === "boolean" ? true : sevenTV?.globals ?? true }).catch(() => null);
286
+ if (twitch) twitchPromise = getTwitchEmotes(channelLogin, { globals: typeof twitch === "boolean" ? true : twitch?.globals ?? true }).catch(() => null);
285
287
  const [bttvEmotes, ffzEmotes, sevenTvEmotes, twitchEmotes] = await Promise.all([
286
288
  bttvPromise,
287
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.4",
4
+ "version": "0.1.0",
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
+ }