streamer-emotes 0.0.1 → 0.0.4

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.
Files changed (2) hide show
  1. package/dist/index.mjs +23 -13
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -190,6 +190,7 @@ const getFfzEmotes = async (channelLogin, options) => {
190
190
  const getTwitchEmotes = async (channelLogin, options) => {
191
191
  channelLogin = channelLogin.toLowerCase();
192
192
  const { globals = true } = options ?? {};
193
+ const channelId = await getTwitchIdByLogin(channelLogin);
193
194
  const emotesFields = [
194
195
  "id",
195
196
  "token",
@@ -211,9 +212,18 @@ const getTwitchEmotes = async (channelLogin, options) => {
211
212
  } },
212
213
  fields: [{ emotes: emotesFields }]
213
214
  };
215
+ const localEmotesQuery = {
216
+ operation: "channel",
217
+ variables: { id: {
218
+ value: channelId,
219
+ type: "ID!"
220
+ } },
221
+ fields: [{ localEmoteSets: [{ emotes: emotesFields }] }]
222
+ };
214
223
  const toQuery = [];
215
224
  if (globals) toQuery.push(globalQuery);
216
225
  toQuery.push(channelQuery);
226
+ toQuery.push(localEmotesQuery);
217
227
  const { data } = await $fetch(providersURL.twitch, {
218
228
  method: "POST",
219
229
  headers: {
@@ -229,15 +239,15 @@ const getTwitchEmotes = async (channelLogin, options) => {
229
239
  id: emote.id,
230
240
  images: [
231
241
  {
232
- url: `https://static-cdn.jtvnw.net/emoticons/v1/${emote.id}/1.0`,
242
+ url: `https://static-cdn.jtvnw.net/emoticons/v2/${emote.id}/default/dark/1.0`,
233
243
  version: "1.0"
234
244
  },
235
245
  {
236
- url: `https://static-cdn.jtvnw.net/emoticons/v1/${emote.id}/2.0`,
246
+ url: `https://static-cdn.jtvnw.net/emoticons/v2/${emote.id}/default/dark/2.0`,
237
247
  version: "2.0"
238
248
  },
239
249
  {
240
- url: `https://static-cdn.jtvnw.net/emoticons/v1/${emote.id}/3.0`,
250
+ url: `https://static-cdn.jtvnw.net/emoticons/v2/${emote.id}/default/dark/3.0`,
241
251
  version: "3.0"
242
252
  }
243
253
  ],
@@ -246,7 +256,7 @@ const getTwitchEmotes = async (channelLogin, options) => {
246
256
  }));
247
257
  };
248
258
  return {
249
- channel: normalizeData(data?.subscriptionProduct?.emotes),
259
+ channel: [...normalizeData(data?.channel.localEmoteSets?.[0]?.emotes), ...normalizeData(data?.subscriptionProduct?.emotes)],
250
260
  ...globals && { global: normalizeData(data?.emoteSet?.emotes) }
251
261
  };
252
262
  };
@@ -267,21 +277,21 @@ const getStreamerEmotes = async (channelLogin, options) => {
267
277
  const { bttv, ffz, sevenTV, twitch } = options;
268
278
  const data = {};
269
279
  let bttvPromise, ffzPromise, sevenTvPromise, twitchPromise;
270
- if (bttv || ffz || sevenTV) await getTwitchIdByLogin(channelLogin);
271
- if (bttv) bttvPromise = getBttvEmotes(channelLogin, { globals: typeof bttv === "boolean" ? true : bttv?.globals });
272
- if (ffz) ffzPromise = getFfzEmotes(channelLogin, { globals: typeof ffz === "boolean" ? true : ffz?.globals });
273
- if (sevenTV) sevenTvPromise = get7tvEmotes(channelLogin, { globals: typeof sevenTV === "boolean" ? true : sevenTV?.globals });
274
- if (twitch) twitchPromise = getTwitchEmotes(channelLogin, { globals: typeof twitch === "boolean" ? true : twitch?.globals });
280
+ 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);
275
285
  const [bttvEmotes, ffzEmotes, sevenTvEmotes, twitchEmotes] = await Promise.all([
276
286
  bttvPromise,
277
287
  ffzPromise,
278
288
  sevenTvPromise,
279
289
  twitchPromise
280
290
  ]);
281
- if (bttv) data.bttv = bttvEmotes;
282
- if (ffz) data.ffz = ffzEmotes;
283
- if (sevenTV) data.sevenTV = sevenTvEmotes;
284
- if (twitch) data.twitch = twitchEmotes;
291
+ if (bttv && bttvEmotes) data.bttv = bttvEmotes;
292
+ if (ffz && ffzEmotes) data.ffz = ffzEmotes;
293
+ if (sevenTV && sevenTvEmotes) data.sevenTV = sevenTvEmotes;
294
+ if (twitch && twitchEmotes) data.twitch = twitchEmotes;
285
295
  return data;
286
296
  };
287
297
  //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "streamer-emotes",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.4",
5
5
  "description": "A library to get Twitch, BTTV, FFZ and 7TV emotes for a given Twitch channel.",
6
6
  "keywords": [
7
7
  "streamer",