@mkody/twitch-emoticons 2.7.0 → 2.8.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.
Files changed (45) hide show
  1. package/.eslintrc.json +143 -143
  2. package/.github/codeql/codeql-config.yml +4 -4
  3. package/.github/workflows/codeql.yml +50 -50
  4. package/.github/workflows/eslint.yml +50 -50
  5. package/.github/workflows/release.yml +22 -0
  6. package/.github/workflows/yarn-test.yml +17 -17
  7. package/.jsdoc.json +39 -39
  8. package/.nvmrc +1 -0
  9. package/LICENSE +22 -22
  10. package/README.md +36 -4
  11. package/docs/BTTVEmote.html +1641 -1319
  12. package/docs/Channel.html +823 -823
  13. package/docs/Collection.html +797 -797
  14. package/docs/Emote.html +906 -801
  15. package/docs/EmoteFetcher.html +3680 -2946
  16. package/docs/EmoteParser.html +811 -811
  17. package/docs/FFZEmote.html +1795 -1473
  18. package/docs/SevenTV.html +1190 -1190
  19. package/docs/SevenTVEmote.html +1705 -1395
  20. package/docs/TwitchEmote.html +1637 -1315
  21. package/docs/index.html +230 -206
  22. package/docs/struct_BTTVEmote.js.html +162 -132
  23. package/docs/struct_Channel.js.html +127 -127
  24. package/docs/struct_Emote.js.html +151 -138
  25. package/docs/struct_EmoteFetcher.js.html +427 -399
  26. package/docs/struct_EmoteParser.js.html +153 -153
  27. package/docs/struct_FFZEmote.js.html +185 -146
  28. package/docs/struct_SevenTVEmote.js.html +178 -141
  29. package/docs/struct_TwitchEmote.js.html +159 -130
  30. package/docs/util_Collection.js.html +150 -150
  31. package/package.json +57 -57
  32. package/src/index.js +12 -12
  33. package/src/struct/BTTVEmote.js +90 -60
  34. package/src/struct/Channel.js +55 -55
  35. package/src/struct/Emote.js +79 -66
  36. package/src/struct/EmoteFetcher.js +355 -327
  37. package/src/struct/EmoteParser.js +81 -81
  38. package/src/struct/EmoteTypeMapper.js +13 -0
  39. package/src/struct/FFZEmote.js +113 -74
  40. package/src/struct/SevenTVEmote.js +106 -69
  41. package/src/struct/TwitchEmote.js +87 -58
  42. package/src/util/Collection.js +78 -78
  43. package/src/util/Constants.js +31 -31
  44. package/test/index.js +482 -174
  45. package/typings/index.d.ts +115 -98
package/docs/index.html CHANGED
@@ -1,207 +1,231 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
-
5
- <meta charset="utf-8">
6
- <title>Home - Documentation</title>
7
-
8
-
9
- <script src="scripts/prettify/prettify.js"></script>
10
- <script src="scripts/prettify/lang-css.js"></script>
11
- <!--[if lt IE 9]>
12
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
13
- <![endif]-->
14
- <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
- <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
- <script src="scripts/nav.js" defer></script>
17
-
18
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
19
- </head>
20
- <body>
21
-
22
- <input type="checkbox" id="nav-trigger" class="nav-trigger" />
23
- <label for="nav-trigger" class="navicon-button x">
24
- <div class="navicon"></div>
25
- </label>
26
-
27
- <label for="nav-trigger" class="overlay"></label>
28
-
29
- <nav >
30
-
31
-
32
- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BTTVEmote.html">BTTVEmote</a><ul class='methods'><li data-type='method'><a href="BTTVEmote.html#toLink">toLink</a></li><li data-type='method'><a href="BTTVEmote.html#toString">toString</a></li></ul></li><li><a href="Channel.html">Channel</a><ul class='methods'><li data-type='method'><a href="Channel.html#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="Channel.html#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="Channel.html#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li></ul></li><li><a href="Collection.html">Collection</a><ul class='methods'><li data-type='method'><a href="Collection.html#filter">filter</a></li><li data-type='method'><a href="Collection.html#find">find</a></li><li data-type='method'><a href="Collection.html#map">map</a></li></ul></li><li><a href="Emote.html">Emote</a><ul class='methods'><li data-type='method'><a href="Emote.html#toString">toString</a></li></ul></li><li><a href="EmoteFetcher.html">EmoteFetcher</a><ul class='methods'><li data-type='method'><a href="EmoteFetcher.html#_cacheBTTVEmote">_cacheBTTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheFFZEmote">_cacheFFZEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheSevenTVEmote">_cacheSevenTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheTwitchEmote">_cacheTwitchEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawBTTVEmotes">_getRawBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawFFZEmoteSet">_getRawFFZEmoteSet</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawFFZEmotes">_getRawFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawSevenTVEmotes">_getRawSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawTwitchEmotes">_getRawTwitchEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchTwitchEmotes">fetchTwitchEmotes</a></li></ul></li><li><a href="EmoteParser.html">EmoteParser</a><ul class='methods'><li data-type='method'><a href="EmoteParser.html#parse">parse</a></li></ul></li><li><a href="FFZEmote.html">FFZEmote</a><ul class='methods'><li data-type='method'><a href="FFZEmote.html#toLink">toLink</a></li><li data-type='method'><a href="FFZEmote.html#toString">toString</a></li></ul></li><li><a href="SevenTVEmote.html">SevenTVEmote</a><ul class='methods'><li data-type='method'><a href="SevenTVEmote.html#toLink">toLink</a></li><li data-type='method'><a href="SevenTVEmote.html#toString">toString</a></li></ul></li><li><a href="TwitchEmote.html">TwitchEmote</a><ul class='methods'><li data-type='method'><a href="TwitchEmote.html#toLink">toLink</a></li><li data-type='method'><a href="TwitchEmote.html#toString">toString</a></li></ul></li></ul>
33
-
34
- </nav>
35
-
36
- <div id="main">
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
- <section class="package">
47
- <h3>@mkody/twitch-emoticons 2.7.0</h3>
48
- </section>
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
- <section class="readme usertext">
63
- <article><h1>twitch-emoticons</h1>
64
- <p>Gets Twitch, BTTV, FFZ and 7TV emotes as well as parsing text to emotes!</p>
65
- <h3>Migrating from upstream</h3>
66
- <p>You must now use a Twitch user ID instead of the username to fetch user's emotes.<br>
67
- You can use <a href="https://s.kdy.ch/twitchid/">this page to quickly grab it</a>.</p>
68
- <p>To fetch Twitch emotes you need to get a client and secret from Twitch <a href="https://dev.twitch.tv/console/apps/create">here</a>, it's free.<br>
69
- If you are only using BetterTTV, FrankerFaceZ and 7TV you don't need to provide Twitch app keys as they are independent from the Twitch API.</p>
70
- <h3>Install</h3>
71
- <pre class="prettyprint source lang-sh"><code>npm install @mkody/twitch-emoticons
72
- # or
73
- yarn add @mkody/twitch-emoticons
74
- </code></pre>
75
- <h3>Examples</h3>
76
- <h4>Basic Twitch emote parsing</h4>
77
- <pre class="prettyprint source lang-js"><code>// With ESM import
78
- import TwitchEmoticons from '@mkody/twitch-emoticons';
79
- const { EmoteFetcher, EmoteParser } = TwitchEmoticons;
80
- // ... or require()
81
- const { EmoteFetcher, EmoteParser } = require('@mkody/twitch-emoticons');
82
-
83
- // Your Twitch app keys
84
- const clientId = '&lt;your client id>';
85
- const clientSecret = '&lt;your client secret>';
86
-
87
- const fetcher = new EmoteFetcher(clientId, clientSecret);
88
- const parser = new EmoteParser(fetcher, {
89
- type: 'markdown',
90
- match: /:(.+?):/g
91
- });
92
-
93
- fetcher.fetchTwitchEmotes(null).then(() => {
94
- const kappa = fetcher.emotes.get('Kappa').toLink();
95
- console.log(kappa);
96
- // https://static-cdn.jtvnw.net/emoticons/v2/25/default/dark/1.0
97
-
98
- const text = 'Hello :CoolCat:!';
99
- const parsed = parser.parse(text);
100
- console.log(parsed);
101
- // Hello ![CoolCat](https://static-cdn.jtvnw.net/emoticons/v2/58127/default/dark/1.0 &quot;CoolCat&quot;)!
102
- });
103
- </code></pre>
104
- <h4>All providers, global + channel, custom template and match pattern</h4>
105
- <pre class="prettyprint source lang-js"><code>const { EmoteFetcher, EmoteParser } = require('@mkody/twitch-emoticons');
106
-
107
- // Your channel ID
108
- const channelId = 44317909;
109
-
110
- // Your Twitch app keys
111
- const clientId = '&lt;your client id>';
112
- const clientSecret = '&lt;your client secret>';
113
-
114
- const fetcher = new EmoteFetcher(clientId, clientSecret);
115
- const parser = new EmoteParser(fetcher, {
116
- // Custom HTML format
117
- template: '&lt;img class=&quot;emote&quot; alt=&quot;{name}&quot; src=&quot;{link}&quot;>',
118
- // Match without :colons:
119
- match: /(\w+)+?/g
120
- });
121
-
122
- Promise.all([
123
- // Twitch global
124
- fetcher.fetchTwitchEmotes(),
125
- // Twitch channel
126
- fetcher.fetchTwitchEmotes(channelId),
127
- // BTTV global
128
- fetcher.fetchBTTVEmotes(),
129
- // BTTV channel
130
- fetcher.fetchBTTVEmotes(channelId),
131
- // 7TV global
132
- fetcher.fetchSevenTVEmotes(),
133
- // 7TV channel
134
- fetcher.fetchSevenTVEmotes(channelId),
135
- // FFZ global
136
- fetcher.fetchFFZEmotes(),
137
- // FFZ channel
138
- fetcher.fetchFFZEmotes(channelId)
139
- ]).then(() => {
140
- const globalEmotes = parser.parse('EZ Clap way too easy LUL now for the last boss monkaS LaterSooner');
141
- console.log(globalEmotes);
142
- // &lt;img class=&quot;emote&quot; alt=&quot;EZ&quot; src=&quot;https://cdn.7tv.app/emote/63071b80942ffb69e13d700f/1x.webp&quot;> &lt;img class=&quot;emote&quot; alt=&quot;Clap&quot; src=&quot;https://cdn.7tv.app/emote/62fc0a0c4a75fd54bd3520a9/1x.webp&quot;> way too easy &lt;img class=&quot;emote&quot; alt=&quot;LUL&quot; src=&quot;https://static-cdn.jtvnw.net/emoticons/v2/425618/default/dark/1.0&quot;> now for the last boss &lt;img class=&quot;emote&quot; alt=&quot;monkaS&quot; src=&quot;https://cdn.betterttv.net/emote/56e9f494fff3cc5c35e5287e/1x.webp&quot;> &lt;img class=&quot;emote&quot; alt=&quot;LaterSooner&quot; src=&quot;https://cdn.frankerfacez.com/emote/149346/1&quot;>
143
-
144
- const channelEmotes = parser.parse('KEKW that was 3Head TeriPoint');
145
- console.log(channelEmotes);
146
- // &lt;img class=&quot;emote&quot; alt=&quot;KEKW&quot; src=&quot;https://cdn.betterttv.net/emote/5e9c6c187e090362f8b0b9e8/1x.webp&quot;> that was &lt;img class=&quot;emote&quot; alt=&quot;3Head&quot; src=&quot;https://cdn.frankerfacez.com/emote/274406/1&quot;> &lt;img class=&quot;emote&quot; alt=&quot;TeriPoint&quot; src=&quot;https://cdn.7tv.app/emote/61dc299b600369a98b38ebef/1x.webp&quot;>
147
- }).catch(err => {
148
- console.error('Error loading emotes...');
149
- console.error(err);
150
- });
151
- </code></pre>
152
- <h4>7TV formats</h4>
153
- <p>7TV v3 delivers emotes in either WEBP or AVIF.<br>
154
- By default we'll return WEBP emotes but you can override this.</p>
155
- <pre class="prettyprint source lang-js"><code>const { EmoteFetcher } = require('@mkody/twitch-emoticons');
156
- const fetcher = new EmoteFetcher();
157
-
158
- // Fetch global emotes in AVIF (channel id has to be `null` for global)
159
- fetcher.fetchSevenTVEmotes(null, 'avif');
160
-
161
- // Fetch 0kody's emotes with the package's default format (WEBP)
162
- fetcher.fetchSevenTVEmotes(44317909);
163
-
164
- // ... which is currently the same as
165
- fetcher.fetchSevenTVEmotes(44317909, 'webp');
166
-
167
- // Fetch Anatole's emotes in AVIF
168
- fetcher.fetchSevenTVEmotes(24377667, 'avif');
169
- </code></pre>
170
- <h3>Links</h3>
171
- <ul>
172
- <li><a href="https://github.com/mkody/twitch-emoticons">Github</a></li>
173
- <li><a href="https://mkody.github.io/twitch-emoticons/">Documentation</a></li>
174
- <li><a href="https://github.com/mkody/twitch-emoticons/releases">Changelog</a></li>
175
- </ul>
176
- <p>This library uses the following:</p>
177
- <ul>
178
- <li><a href="https://twurple.js.org/">Twurple</a> and the <a href="https://dev.twitch.tv/">Twitch API</a></li>
179
- <li><a href="https://betterttv.com/developers/api">BetterTTV API</a></li>
180
- <li><a href="https://api.frankerfacez.com/docs/">FrankerFaceZ API</a></li>
181
- <li><a href="https://7tv.io/">7TV API</a></li>
182
- </ul></article>
183
- </section>
184
-
185
-
186
-
187
-
188
-
189
-
190
-
191
-
192
- </div>
193
-
194
- <br class="clear">
195
-
196
- <footer>
197
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
198
- </footer>
199
-
200
- <script>prettyPrint();</script>
201
- <script src="scripts/polyfill.js"></script>
202
- <script src="scripts/linenumber.js"></script>
203
-
204
-
205
-
206
- </body>
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+
5
+ <meta charset="utf-8">
6
+ <title>Home - Documentation</title>
7
+
8
+
9
+ <script src="scripts/prettify/prettify.js"></script>
10
+ <script src="scripts/prettify/lang-css.js"></script>
11
+ <!--[if lt IE 9]>
12
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
13
+ <![endif]-->
14
+ <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
+ <script src="scripts/nav.js" defer></script>
17
+
18
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
19
+ </head>
20
+ <body>
21
+
22
+ <input type="checkbox" id="nav-trigger" class="nav-trigger" />
23
+ <label for="nav-trigger" class="navicon-button x">
24
+ <div class="navicon"></div>
25
+ </label>
26
+
27
+ <label for="nav-trigger" class="overlay"></label>
28
+
29
+ <nav >
30
+
31
+
32
+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BTTVEmote.html">BTTVEmote</a><ul class='methods'><li data-type='method'><a href="BTTVEmote.html#toLink">toLink</a></li><li data-type='method'><a href="BTTVEmote.html#toObject">toObject</a></li><li data-type='method'><a href="BTTVEmote.html#toString">toString</a></li><li data-type='method'><a href="BTTVEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="Channel.html">Channel</a><ul class='methods'><li data-type='method'><a href="Channel.html#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="Channel.html#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="Channel.html#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li></ul></li><li><a href="Collection.html">Collection</a><ul class='methods'><li data-type='method'><a href="Collection.html#filter">filter</a></li><li data-type='method'><a href="Collection.html#find">find</a></li><li data-type='method'><a href="Collection.html#map">map</a></li></ul></li><li><a href="Emote.html">Emote</a><ul class='methods'><li data-type='method'><a href="Emote.html#toObject">toObject</a></li><li data-type='method'><a href="Emote.html#toString">toString</a></li></ul></li><li><a href="EmoteFetcher.html">EmoteFetcher</a><ul class='methods'><li data-type='method'><a href="EmoteFetcher.html#_cacheBTTVEmote">_cacheBTTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheFFZEmote">_cacheFFZEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheSevenTVEmote">_cacheSevenTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheTwitchEmote">_cacheTwitchEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawBTTVEmotes">_getRawBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawFFZEmoteSet">_getRawFFZEmoteSet</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawFFZEmotes">_getRawFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawSevenTVEmotes">_getRawSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawTwitchEmotes">_getRawTwitchEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_setupChannel">_setupChannel</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchTwitchEmotes">fetchTwitchEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fromObject">fromObject</a></li></ul></li><li><a href="EmoteParser.html">EmoteParser</a><ul class='methods'><li data-type='method'><a href="EmoteParser.html#parse">parse</a></li></ul></li><li><a href="FFZEmote.html">FFZEmote</a><ul class='methods'><li data-type='method'><a href="FFZEmote.html#toLink">toLink</a></li><li data-type='method'><a href="FFZEmote.html#toObject">toObject</a></li><li data-type='method'><a href="FFZEmote.html#toString">toString</a></li><li data-type='method'><a href="FFZEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="SevenTVEmote.html">SevenTVEmote</a><ul class='methods'><li data-type='method'><a href="SevenTVEmote.html#toLink">toLink</a></li><li data-type='method'><a href="SevenTVEmote.html#toObject">toObject</a></li><li data-type='method'><a href="SevenTVEmote.html#toString">toString</a></li><li data-type='method'><a href="SevenTVEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="TwitchEmote.html">TwitchEmote</a><ul class='methods'><li data-type='method'><a href="TwitchEmote.html#toLink">toLink</a></li><li data-type='method'><a href="TwitchEmote.html#toObject">toObject</a></li><li data-type='method'><a href="TwitchEmote.html#toString">toString</a></li><li data-type='method'><a href="TwitchEmote.html#.fromObject">fromObject</a></li></ul></li></ul>
33
+
34
+ </nav>
35
+
36
+ <div id="main">
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+ <section class="package">
47
+ <h3>@mkody/twitch-emoticons 2.8.0</h3>
48
+ </section>
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+ <section class="readme usertext">
63
+ <article><h1>twitch-emoticons</h1>
64
+ <p>Gets Twitch, BTTV, FFZ and 7TV emotes as well as parsing text to emotes!</p>
65
+ <h3>Migrating from upstream</h3>
66
+ <p>You must now use a Twitch user ID instead of the username to fetch user's emotes.<br>
67
+ You can use <a href="https://s.kdy.ch/twitchid/">this page to quickly grab it</a>.</p>
68
+ <p>To fetch Twitch emotes you need to get a client and secret from Twitch <a href="https://dev.twitch.tv/console/apps/create">here</a>, it's free.<br>
69
+ If you are only using BetterTTV, FrankerFaceZ and 7TV you don't need to provide Twitch app keys as they are independent from the Twitch API.</p>
70
+ <h3>Install</h3>
71
+ <pre class="prettyprint source lang-sh"><code>npm install @mkody/twitch-emoticons
72
+ # or
73
+ yarn add @mkody/twitch-emoticons
74
+ </code></pre>
75
+ <h3>Examples</h3>
76
+ <h4>Basic Twitch emote parsing</h4>
77
+ <pre class="prettyprint source lang-js"><code>// With ESM import
78
+ import TwitchEmoticons from '@mkody/twitch-emoticons';
79
+ const { EmoteFetcher, EmoteParser } = TwitchEmoticons;
80
+ // ... or require()
81
+ const { EmoteFetcher, EmoteParser } = require('@mkody/twitch-emoticons');
82
+
83
+ // Your Twitch app keys
84
+ const clientId = '&lt;your client id>';
85
+ const clientSecret = '&lt;your client secret>';
86
+
87
+ const fetcher = new EmoteFetcher(clientId, clientSecret);
88
+ const parser = new EmoteParser(fetcher, {
89
+ type: 'markdown',
90
+ match: /:(.+?):/g
91
+ });
92
+
93
+ fetcher.fetchTwitchEmotes(null).then(() => {
94
+ const kappa = fetcher.emotes.get('Kappa').toLink();
95
+ console.log(kappa);
96
+ // https://static-cdn.jtvnw.net/emoticons/v2/25/default/dark/1.0
97
+
98
+ const text = 'Hello :CoolCat:!';
99
+ const parsed = parser.parse(text);
100
+ console.log(parsed);
101
+ // Hello ![CoolCat](https://static-cdn.jtvnw.net/emoticons/v2/58127/default/dark/1.0 &quot;CoolCat&quot;)!
102
+ });
103
+ </code></pre>
104
+ <h4>Bring your own <code>@twurple/api</code></h4>
105
+ <p>If you already use <a href="https://twurple.js.org/">Twurple</a> in your project and manage authentification<br>
106
+ (i.e. with user tokens), you can reuse it in this project by skipping the first two paramters and<br>
107
+ setting <code>apiClient</code> with your <a href="https://twurple.js.org/reference/api/classes/ApiClient.html">ApiClient</a> object.</p>
108
+ <pre class="prettyprint source lang-js"><code>const fetcher = new EmoteFetcher(null, null, {
109
+ apiClient: yourOwnTwurpleApiClientHere
110
+ });
111
+ </code></pre>
112
+ <h4>All providers, global + channel, custom template and match pattern</h4>
113
+ <pre class="prettyprint source lang-js"><code>const { EmoteFetcher, EmoteParser } = require('@mkody/twitch-emoticons');
114
+
115
+ // Your channel ID
116
+ const channelId = 44317909;
117
+
118
+ // Your Twitch app keys
119
+ const clientId = '&lt;your client id>';
120
+ const clientSecret = '&lt;your client secret>';
121
+
122
+ const fetcher = new EmoteFetcher(clientId, clientSecret);
123
+ const parser = new EmoteParser(fetcher, {
124
+ // Custom HTML format
125
+ template: '&lt;img class=&quot;emote&quot; alt=&quot;{name}&quot; src=&quot;{link}&quot;>',
126
+ // Match without :colons:
127
+ match: /(\w+)+?/g
128
+ });
129
+
130
+ Promise.all([
131
+ // Twitch global
132
+ fetcher.fetchTwitchEmotes(),
133
+ // Twitch channel
134
+ fetcher.fetchTwitchEmotes(channelId),
135
+ // BTTV global
136
+ fetcher.fetchBTTVEmotes(),
137
+ // BTTV channel
138
+ fetcher.fetchBTTVEmotes(channelId),
139
+ // 7TV global
140
+ fetcher.fetchSevenTVEmotes(),
141
+ // 7TV channel
142
+ fetcher.fetchSevenTVEmotes(channelId),
143
+ // FFZ global
144
+ fetcher.fetchFFZEmotes(),
145
+ // FFZ channel
146
+ fetcher.fetchFFZEmotes(channelId)
147
+ ]).then(() => {
148
+ const globalEmotes = parser.parse('EZ Clap way too easy LUL now for the last boss monkaS LaterSooner');
149
+ console.log(globalEmotes);
150
+ // &lt;img class=&quot;emote&quot; alt=&quot;EZ&quot; src=&quot;https://cdn.7tv.app/emote/63071b80942ffb69e13d700f/1x.webp&quot;> &lt;img class=&quot;emote&quot; alt=&quot;Clap&quot; src=&quot;https://cdn.7tv.app/emote/62fc0a0c4a75fd54bd3520a9/1x.webp&quot;> way too easy &lt;img class=&quot;emote&quot; alt=&quot;LUL&quot; src=&quot;https://static-cdn.jtvnw.net/emoticons/v2/425618/default/dark/1.0&quot;> now for the last boss &lt;img class=&quot;emote&quot; alt=&quot;monkaS&quot; src=&quot;https://cdn.betterttv.net/emote/56e9f494fff3cc5c35e5287e/1x.webp&quot;> &lt;img class=&quot;emote&quot; alt=&quot;LaterSooner&quot; src=&quot;https://cdn.frankerfacez.com/emote/149346/1&quot;>
151
+
152
+ const channelEmotes = parser.parse('KEKW that was 3Head TeriPoint');
153
+ console.log(channelEmotes);
154
+ // &lt;img class=&quot;emote&quot; alt=&quot;KEKW&quot; src=&quot;https://cdn.betterttv.net/emote/5e9c6c187e090362f8b0b9e8/1x.webp&quot;> that was &lt;img class=&quot;emote&quot; alt=&quot;3Head&quot; src=&quot;https://cdn.frankerfacez.com/emote/274406/1&quot;> &lt;img class=&quot;emote&quot; alt=&quot;TeriPoint&quot; src=&quot;https://cdn.7tv.app/emote/61dc299b600369a98b38ebef/1x.webp&quot;>
155
+ }).catch(err => {
156
+ console.error('Error loading emotes...');
157
+ console.error(err);
158
+ });
159
+ </code></pre>
160
+ <h4>7TV formats</h4>
161
+ <p>7TV v3 delivers emotes in either WEBP or AVIF.<br>
162
+ By default we'll return WEBP emotes but you can override this.</p>
163
+ <pre class="prettyprint source lang-js"><code>const { EmoteFetcher } = require('@mkody/twitch-emoticons');
164
+ const fetcher = new EmoteFetcher();
165
+
166
+ // Fetch global emotes in AVIF (channel id has to be `null` for global)
167
+ await fetcher.fetchSevenTVEmotes(null, 'avif');
168
+
169
+ // Fetch 0kody's emotes with the package's default format (WEBP)
170
+ await fetcher.fetchSevenTVEmotes(44317909);
171
+
172
+ // ... which is currently the same as
173
+ await fetcher.fetchSevenTVEmotes(44317909, 'webp');
174
+
175
+ // Fetch Anatole's emotes in AVIF
176
+ await fetcher.fetchSevenTVEmotes(24377667, 'avif');
177
+ </code></pre>
178
+ <h4>Export and import emote data</h4>
179
+ <p>This can be useful to save the emotes in a cache or for offline content.<br>
180
+ (For offline content, you'll still need to download emotes and proxy their URLs.)</p>
181
+ <pre class="prettyprint source lang-js"><code>const { EmoteFetcher } = require('@mkody/twitch-emoticons');
182
+ const fetcher = new EmoteFetcher();
183
+
184
+ // First fetch some emotes
185
+ await fetcher.fetchSevenTVEmotes(null, 'avif');
186
+
187
+ // Then you can use .toObject() on an `Emote` to export its data.
188
+ // Here's a map to get them all in a single array.
189
+ const emotes = fetcher.emotes.map(emote => emote.toObject());
190
+
191
+ // Later, with or without a fresh `EmoteFetcher`, you can use .fromObject() on the fetcher.
192
+ fetcher.fromObject(emotes);
193
+ </code></pre>
194
+ <h3>Links</h3>
195
+ <ul>
196
+ <li><a href="https://github.com/mkody/twitch-emoticons">Github</a></li>
197
+ <li><a href="https://mkody.github.io/twitch-emoticons/">Documentation</a></li>
198
+ <li><a href="https://github.com/mkody/twitch-emoticons/releases">Changelog</a></li>
199
+ </ul>
200
+ <p>This library uses the following:</p>
201
+ <ul>
202
+ <li><a href="https://twurple.js.org/">Twurple</a> and the <a href="https://dev.twitch.tv/">Twitch API</a></li>
203
+ <li><a href="https://betterttv.com/developers/api">BetterTTV API</a></li>
204
+ <li><a href="https://api.frankerfacez.com/docs/">FrankerFaceZ API</a></li>
205
+ <li><a href="https://7tv.io/">7TV API</a></li>
206
+ </ul></article>
207
+ </section>
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+ </div>
217
+
218
+ <br class="clear">
219
+
220
+ <footer>
221
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
222
+ </footer>
223
+
224
+ <script>prettyPrint();</script>
225
+ <script src="scripts/polyfill.js"></script>
226
+ <script src="scripts/linenumber.js"></script>
227
+
228
+
229
+
230
+ </body>
207
231
  </html>