Skip to content

Commit

Permalink
Update docs and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
mkody committed May 6, 2021
1 parent 1579a0d commit 1a21adc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
16 changes: 8 additions & 8 deletions docs/EmoteFetcher.html
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ <h4 class="name" id="_cacheBTTVEmote"><span class="type-signature">(private) </s

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line103">line 103</a>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line112">line 112</a>
</li></ul></dd>


Expand Down Expand Up @@ -581,7 +581,7 @@ <h4 class="name" id="_cacheFFZEmote"><span class="type-signature">(private) </sp

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line149">line 149</a>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line158">line 158</a>
</li></ul></dd>


Expand Down Expand Up @@ -758,7 +758,7 @@ <h4 class="name" id="_cacheTwitchEmote"><span class="type-signature">(private) <

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line63">line 63</a>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line72">line 72</a>
</li></ul></dd>


Expand Down Expand Up @@ -935,7 +935,7 @@ <h4 class="name" id="_getRawBTTVEmotes"><span class="type-signature">(private) <

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line83">line 83</a>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line92">line 92</a>
</li></ul></dd>


Expand Down Expand Up @@ -1110,7 +1110,7 @@ <h4 class="name" id="_getRawFFZEmotes"><span class="type-signature">(private) </

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line122">line 122</a>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line131">line 131</a>
</li></ul></dd>


Expand Down Expand Up @@ -1421,7 +1421,7 @@ <h4 class="name" id="fetchBTTVEmotes"><span class="type-signature"></span>fetchB

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line184">line 184</a>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line193">line 193</a>
</li></ul></dd>


Expand Down Expand Up @@ -1596,7 +1596,7 @@ <h4 class="name" id="fetchFFZEmotes"><span class="type-signature"></span>fetchFF

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line199">line 199</a>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line208">line 208</a>
</li></ul></dd>


Expand Down Expand Up @@ -1750,7 +1750,7 @@ <h4 class="name" id="fetchTwitchEmotes"><span class="type-signature"></span>fetc

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line168">line 168</a>
<a href="struct_EmoteFetcher.js.html">struct/EmoteFetcher.js</a>, <a href="struct_EmoteFetcher.js.html#line177">line 177</a>
</li></ul></dd>


Expand Down
5 changes: 5 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ <h3>About this fork's 2.3.0+</h3>
<p>You must now use a Twitch user ID instead of the username to fetch user's emotes.<br>
You can use <a href="https://s.kdy.ch/twitchid/">this page to quickly grab it</a>.</p>
<p><em>FFZ still supports names, but usage of the ID is recommended.</em></p>
<h3>Note about Twitch emotes</h3>
<p>We've seen twitchemotes.com's API returning &quot;channel not found&quot; at multiple occasions (as of early May 2021).<br>
A fallback system to a static json for the global emotes is in place, but if their service is down or not working you will not be able to fetch the list of emotes from a specific channel.<br>
If you have an alternative API or some quick code to get them from Twitch directly, feel free to share in Issue #8.</p>
<p>BetterTTV and FrankerFaceZ are still working fine.</p>
<h3>Install</h3>
<pre class="prettyprint source lang-sh"><code>npm install @mkody/twitch-emoticons
# or
Expand Down
27 changes: 18 additions & 9 deletions docs/struct_EmoteFetcher.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ <h1 class="page-title">struct/EmoteFetcher.js</h1>
const Collection = require('../util/Collection');
const Constants = require('../util/Constants');
const FFZEmote = require('./FFZEmote');
const request = require('request-promise');
const got = require('got');
const TwitchEmote = require('./TwitchEmote');

const options = {
json: true
responseType: 'json'
};

class EmoteFetcher {
Expand Down Expand Up @@ -94,7 +94,16 @@ <h1 class="page-title">struct/EmoteFetcher.js</h1>
? Constants.Twitch.Global
: Constants.Twitch.Channel(id); // eslint-disable-line new-cap

return request({ uri: endpoint, ...options });
return got(endpoint, options)
.then(req => req.json())
.catch(err => {
if (!id) {
// If fetching global didn't work, try with fallback
return got(Constants.Twitch.GlobalFallback, options).json();
} else {
throw err;
}
});
}

/**
Expand Down Expand Up @@ -129,11 +138,11 @@ <h1 class="page-title">struct/EmoteFetcher.js</h1>
? Constants.BTTV.Global
: Constants.BTTV.Channel(id); // eslint-disable-line new-cap

return request({ uri: endpoint, ...options }).then(body => {
return got(endpoint, options).then(req => {
// Global emotes
if (body instanceof Array) return body;
if (req.body instanceof Array) return req.body;
// Channel emotes
return [...body.channelEmotes, ...body.sharedEmotes];
return [...req.body.channelEmotes, ...req.body.sharedEmotes];
});
}

Expand Down Expand Up @@ -172,10 +181,10 @@ <h1 class="page-title">struct/EmoteFetcher.js</h1>
endpoint = Constants.FFZ.ChannelName(id); // eslint-disable-line new-cap
}

return request({ uri: endpoint, ...options }).then(body => {
return got(endpoint, options).then(req => {
const emotes = [];
for (const key of Object.keys(body.sets)) {
const set = body.sets[key];
for (const key of Object.keys(req.body.sets)) {
const set = req.body.sets[key];
emotes.push(...set.emoticons);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mkody/twitch-emoticons",
"version": "2.3.0",
"version": "2.3.1",
"description": "Gets Twitch emotes and BTTV emotes, as well as parsing text to emotes!",
"main": "src/index.js",
"typings": "typings/index.d.ts",
Expand Down

0 comments on commit 1a21adc

Please sign in to comment.