@mkody/twitch-emoticons 2.5.0 → 2.6.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.
@@ -0,0 +1,135 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+
5
+ <meta charset="utf-8">
6
+ <title>struct/SevenTVEmote.js - 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">toLink</a></li><li data-type='method'><a href="BTTVEmote.html#.toString#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">fetchBTTVEmotes</a></li><li data-type='method'><a href="Channel.html#.fetchFFZEmotes#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="Channel.html#.fetchSevenTVEmotes#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">filter</a></li><li data-type='method'><a href="Collection.html#.find#find">find</a></li><li data-type='method'><a href="Collection.html#.map#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">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">_cacheBTTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheFFZEmote#_cacheFFZEmote">_cacheFFZEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheSevenTVEmote#_cacheSevenTVEmote">_cacheSevenTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheTwitchEmote#_cacheTwitchEmote">_cacheTwitchEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawBTTVEmotes#_getRawBTTVEmotes">_getRawBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawFFZEmotes#_getRawFFZEmotes">_getRawFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawSevenTVEmotes#_getRawSevenTVEmotes">_getRawSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawTwitchEmotes#_getRawTwitchEmotes">_getRawTwitchEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchBTTVEmotes#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchFFZEmotes#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchSevenTVEmotes#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchTwitchEmotes#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">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">toLink</a></li><li data-type='method'><a href="FFZEmote.html#.toString#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">toLink</a></li><li data-type='method'><a href="SevenTVEmote.html#.toString#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">toLink</a></li><li data-type='method'><a href="TwitchEmote.html#.toString#toString">toString</a></li></ul></li></ul>
33
+
34
+ </nav>
35
+
36
+ <div id="main">
37
+
38
+ <h1 class="page-title">struct/SevenTVEmote.js</h1>
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+ <section>
47
+ <article>
48
+ <pre class="prettyprint source linenums"><code>const Emote = require('./Emote');
49
+ const Constants = require('../util/Constants');
50
+
51
+ /** @extends Emote */
52
+ class SevenTVEmote extends Emote {
53
+ /**
54
+ * A 7TV emote.
55
+ * @param {Channel} channel - Channel this emote belongs to.
56
+ * @param {string} id - ID of the emote.
57
+ * @param {data} data - The raw emote data.
58
+ */
59
+ constructor(channel, id, data) {
60
+ super(channel, id, data);
61
+ this.type = '7tv';
62
+ }
63
+
64
+ /**
65
+ * The channel of this emote's creator.
66
+ * Not guaranteed to contain the emote, or be cached.
67
+ * @readonly
68
+ * @type {?Channel}
69
+ */
70
+ get owner() {
71
+ return this.fetcher.channels.get(this.ownerName);
72
+ }
73
+
74
+ _setup(data) {
75
+ super._setup(data);
76
+ this.code = data.name;
77
+
78
+ /**
79
+ * The name of the emote creator's channel.
80
+ * @type {string}
81
+ */
82
+ this.ownerName = data.owner.display_name;
83
+
84
+ /**
85
+ * Available image sizes.
86
+ * @type {string[]}
87
+ */
88
+ this.sizes = data.host.files
89
+ .filter(el => el.format === this.channel.format.toUpperCase())
90
+ .map(el => el.name);
91
+
92
+ /**
93
+ * The image type of the emote.
94
+ * @type {string}
95
+ */
96
+ this.imageType = this.channel.format;
97
+ }
98
+
99
+ /**
100
+ * Gets the image link of the emote.
101
+ * @param {number} size - The size of the image.
102
+ * @returns {string}
103
+ */
104
+ toLink(size = 0) {
105
+ size = this.sizes[size];
106
+ return Constants.SEVENTV.CDN(this.id, size); // eslint-disable-line new-cap
107
+ }
108
+ }
109
+
110
+ module.exports = SevenTVEmote;
111
+ </code></pre>
112
+ </article>
113
+ </section>
114
+
115
+
116
+
117
+
118
+
119
+
120
+ </div>
121
+
122
+ <br class="clear">
123
+
124
+ <footer>
125
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
126
+ </footer>
127
+
128
+ <script>prettyPrint();</script>
129
+ <script src="scripts/polyfill.js"></script>
130
+ <script src="scripts/linenumber.js"></script>
131
+
132
+
133
+
134
+ </body>
135
+ </html>
@@ -14,6 +14,7 @@
14
14
  <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
15
  <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
16
  <script src="scripts/nav.js" defer></script>
17
+
17
18
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
19
  </head>
19
20
  <body>
@@ -27,7 +28,9 @@
27
28
 
28
29
  <nav >
29
30
 
30
- <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></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#_cacheTwitchEmote">_cacheTwitchEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawBTTVEmotes">_getRawBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawFFZEmotes">_getRawFFZEmotes</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#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="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>
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">toLink</a></li><li data-type='method'><a href="BTTVEmote.html#.toString#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">fetchBTTVEmotes</a></li><li data-type='method'><a href="Channel.html#.fetchFFZEmotes#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="Channel.html#.fetchSevenTVEmotes#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">filter</a></li><li data-type='method'><a href="Collection.html#.find#find">find</a></li><li data-type='method'><a href="Collection.html#.map#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">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">_cacheBTTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheFFZEmote#_cacheFFZEmote">_cacheFFZEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheSevenTVEmote#_cacheSevenTVEmote">_cacheSevenTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheTwitchEmote#_cacheTwitchEmote">_cacheTwitchEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawBTTVEmotes#_getRawBTTVEmotes">_getRawBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawFFZEmotes#_getRawFFZEmotes">_getRawFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawSevenTVEmotes#_getRawSevenTVEmotes">_getRawSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawTwitchEmotes#_getRawTwitchEmotes">_getRawTwitchEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchBTTVEmotes#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchFFZEmotes#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchSevenTVEmotes#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchTwitchEmotes#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">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">toLink</a></li><li data-type='method'><a href="FFZEmote.html#.toString#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">toLink</a></li><li data-type='method'><a href="SevenTVEmote.html#.toString#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">toLink</a></li><li data-type='method'><a href="TwitchEmote.html#.toString#toString">toString</a></li></ul></li></ul>
33
+
31
34
  </nav>
32
35
 
33
36
  <div id="main">
@@ -108,7 +111,7 @@ module.exports = TwitchEmote;
108
111
  <br class="clear">
109
112
 
110
113
  <footer>
111
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
114
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
112
115
  </footer>
113
116
 
114
117
  <script>prettyPrint();</script>
@@ -162,12 +162,19 @@ h6 {
162
162
  }
163
163
 
164
164
 
165
- tt, code, kbd, samp {
165
+ tt, code, kbd, samp, pre {
166
166
  font-family: Consolas, Monaco, 'Andale Mono', monospace;
167
167
  background: #f4f4f4;
168
+ }
169
+
170
+ tt, code, kbd, samp{
168
171
  padding: 1px 5px;
169
172
  }
170
173
 
174
+ pre {
175
+ padding-bottom: 1em;
176
+ }
177
+
171
178
  .class-description {
172
179
  font-size: 130%;
173
180
  line-height: 140%;
@@ -242,6 +249,10 @@ nav h3 {
242
249
  color: #000;
243
250
  }
244
251
 
252
+ nav h3.collapsed_header {
253
+ cursor: pointer;
254
+ }
255
+
245
256
  nav ul {
246
257
  font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
247
258
  font-size: 100%;
@@ -762,4 +773,4 @@ html[data-search-mode] .level-hide {
762
773
  font-weight: 300;
763
774
  font-style: normal;
764
775
 
765
- }
776
+ }
@@ -76,4 +76,5 @@
76
76
  ol.linenums {
77
77
  margin-top: 0;
78
78
  margin-bottom: 0;
79
+ padding-bottom: 2px;
79
80
  }
@@ -14,6 +14,7 @@
14
14
  <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
15
  <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
16
  <script src="scripts/nav.js" defer></script>
17
+
17
18
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
19
  </head>
19
20
  <body>
@@ -27,7 +28,9 @@
27
28
 
28
29
  <nav >
29
30
 
30
- <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></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#_cacheTwitchEmote">_cacheTwitchEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawBTTVEmotes">_getRawBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawFFZEmotes">_getRawFFZEmotes</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#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="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>
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">toLink</a></li><li data-type='method'><a href="BTTVEmote.html#.toString#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">fetchBTTVEmotes</a></li><li data-type='method'><a href="Channel.html#.fetchFFZEmotes#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="Channel.html#.fetchSevenTVEmotes#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">filter</a></li><li data-type='method'><a href="Collection.html#.find#find">find</a></li><li data-type='method'><a href="Collection.html#.map#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">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">_cacheBTTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheFFZEmote#_cacheFFZEmote">_cacheFFZEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheSevenTVEmote#_cacheSevenTVEmote">_cacheSevenTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._cacheTwitchEmote#_cacheTwitchEmote">_cacheTwitchEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawBTTVEmotes#_getRawBTTVEmotes">_getRawBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawFFZEmotes#_getRawFFZEmotes">_getRawFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawSevenTVEmotes#_getRawSevenTVEmotes">_getRawSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#._getRawTwitchEmotes#_getRawTwitchEmotes">_getRawTwitchEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchBTTVEmotes#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchFFZEmotes#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchSevenTVEmotes#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#.fetchTwitchEmotes#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">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">toLink</a></li><li data-type='method'><a href="FFZEmote.html#.toString#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">toLink</a></li><li data-type='method'><a href="SevenTVEmote.html#.toString#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">toLink</a></li><li data-type='method'><a href="TwitchEmote.html#.toString#toString">toString</a></li></ul></li></ul>
33
+
31
34
  </nav>
32
35
 
33
36
  <div id="main">
@@ -134,7 +137,7 @@ module.exports = Collection;
134
137
  <br class="clear">
135
138
 
136
139
  <footer>
137
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
140
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
138
141
  </footer>
139
142
 
140
143
  <script>prettyPrint();</script>
package/package.json CHANGED
@@ -1,18 +1,20 @@
1
1
  {
2
2
  "name": "@mkody/twitch-emoticons",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Gets Twitch, BTTV and FFZ emotes as well as parsing text to emotes!",
5
5
  "main": "src/index.js",
6
6
  "typings": "typings/index.d.ts",
7
7
  "keywords": [
8
- "better",
8
+ "7tv",
9
+ "bettertwitchtv",
9
10
  "bttv",
10
- "emoji",
11
- "emote",
12
- "emoticon",
11
+ "emotes",
12
+ "emoticons",
13
13
  "ffz",
14
+ "frankerfacez",
14
15
  "parse",
15
- "tv",
16
+ "seventv",
17
+ "twitch-api",
16
18
  "twitch"
17
19
  ],
18
20
  "author": "MKody <gh@kdy.ch> (André Fernandes)",
@@ -23,17 +25,17 @@
23
25
  ],
24
26
  "license": "MIT",
25
27
  "dependencies": {
26
- "@twurple/api": "^5.1.7",
27
- "@twurple/auth": "^5.1.7",
28
- "got": "^11.8.5"
28
+ "@twurple/api": "^5.2.7",
29
+ "@twurple/auth": "^5.2.7",
30
+ "got": "^11.8.6"
29
31
  },
30
32
  "devDependencies": {
31
- "docdash": "^1.2.0",
32
- "eslint": "^8.20.0",
33
- "jsdoc": "^3.6.11"
33
+ "docdash": "^2.0.0",
34
+ "eslint": "^8.29.0",
35
+ "jsdoc": "^4.0.0"
34
36
  },
35
37
  "scripts": {
36
- "docs": "jsdoc --configure .jsdoc.json --verbose --package ''",
38
+ "docs": "jsdoc --configure .jsdoc.json --verbose",
37
39
  "test": "node test/index.js",
38
40
  "lint": "eslint ./src ./test"
39
41
  },
package/src/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  module.exports = {
2
2
  BTTVEmote: require('./struct/BTTVEmote'),
3
3
  Channel: require('./struct/Channel'),
4
+ Collection: require('./util/Collection'),
5
+ Constants: require('./util/Constants'),
4
6
  Emote: require('./struct/Emote'),
5
7
  EmoteFetcher: require('./struct/EmoteFetcher'),
6
8
  EmoteParser: require('./struct/EmoteParser'),
7
9
  FFZEmote: require('./struct/FFZEmote'),
8
- TwitchEmote: require('./struct/TwitchEmote'),
9
- Collection: require('./util/Collection'),
10
- Constants: require('./util/Constants')
10
+ SevenTVEmote: require('./struct/SevenTVEmote'),
11
+ TwitchEmote: require('./struct/TwitchEmote')
11
12
  };
@@ -4,9 +4,9 @@ class Channel {
4
4
  /**
5
5
  * A Twitch channel.
6
6
  * @param {EmoteFetcher} fetcher - The emote fetcher.
7
- * @param {string} name - The name of the channel.
7
+ * @param {int} id - ID of the channel.
8
8
  */
9
- constructor(fetcher, name) {
9
+ constructor(fetcher, id) {
10
10
  /**
11
11
  * The emote fetcher.
12
12
  * @type {EmoteFetcher}
@@ -14,11 +14,11 @@ class Channel {
14
14
  this.fetcher = fetcher;
15
15
 
16
16
  /**
17
- * The name of this channel.
18
- * For the global channel, the name will be null.
19
- * @type {?string}
17
+ * The ID of this channel.
18
+ * For the global channel, the ID will be null.
19
+ * @type {?int}
20
20
  */
21
- this.name = name;
21
+ this.channel_id = id;
22
22
 
23
23
  /**
24
24
  * Cached emotes belonging to this channel.
@@ -32,7 +32,7 @@ class Channel {
32
32
  * @returns {Promise<Collection<string, BTTVEmote>>}
33
33
  */
34
34
  fetchBTTVEmotes() {
35
- return this.fetcher.fetchBTTVEmotes(this.name);
35
+ return this.fetcher.fetchBTTVEmotes(this.id);
36
36
  }
37
37
 
38
38
  /**
@@ -40,7 +40,15 @@ class Channel {
40
40
  * @returns {Promise<Collection<string, FFZEmote>>}
41
41
  */
42
42
  fetchFFZEmotes() {
43
- return this.fetcher.fetchFFZEmotes(this.name);
43
+ return this.fetcher.fetchFFZEmotes(this.id);
44
+ }
45
+
46
+ /**
47
+ * Fetches the 7TV emotes for this channel.
48
+ * @returns {Promise<Collection<string, SevenTVEmote>>}
49
+ */
50
+ fetchSevenTVEmotes() {
51
+ return this.fetcher.fetchSevenTVEmotes(this.id);
44
52
  }
45
53
  }
46
54
 
@@ -33,7 +33,7 @@ class Emote {
33
33
 
34
34
  /**
35
35
  * The type of this emote.
36
- * Either `twitch`, `bttv`, or `ffz`.
36
+ * Either `twitch`, `bttv`, `ffz`, or '7tv'.
37
37
  * @type {string}
38
38
  */
39
39
  this.type = null;
@@ -3,6 +3,8 @@ const Channel = require('./Channel');
3
3
  const Collection = require('../util/Collection');
4
4
  const Constants = require('../util/Constants');
5
5
  const FFZEmote = require('./FFZEmote');
6
+ const SevenTVEmote = require('./SevenTVEmote');
7
+
6
8
  const got = require('got');
7
9
  const TwitchEmote = require('./TwitchEmote');
8
10
  const { ApiClient } = require('@twurple/api');
@@ -44,7 +46,7 @@ class EmoteFetcher {
44
46
  }
45
47
 
46
48
  /**
47
- * The global channel for both Twitch and BTTV.
49
+ * The global channel for Twitch, BTTV and 7TV.
48
50
  * @readonly
49
51
  * @type {?Channel}
50
52
  */
@@ -55,7 +57,7 @@ class EmoteFetcher {
55
57
  /**
56
58
  * Gets the raw Twitch emotes data for a channel.
57
59
  * @private
58
- * @param {int} id - Name of the channel.
60
+ * @param {int} id - ID of the channel.
59
61
  * @returns {Promise<Object[]>}
60
62
  */
61
63
  _getRawTwitchEmotes(id) {
@@ -73,15 +75,15 @@ class EmoteFetcher {
73
75
  /**
74
76
  * Converts and caches a raw twitch emote.
75
77
  * @private
76
- * @param {string} name - Name of the channel.
78
+ * @param {int} channel_id - ID of the channel.
77
79
  * @param {Object} data - Raw data.
78
80
  * @returns {TwitchEmote}
79
81
  */
80
- _cacheTwitchEmote(name, data) {
81
- let channel = this.channels.get(name);
82
+ _cacheTwitchEmote(channel_id, data) {
83
+ let channel = this.channels.get(channel_id);
82
84
  if (!channel) {
83
- channel = new Channel(this, name);
84
- this.channels.set(name, channel);
85
+ channel = new Channel(this, channel_id);
86
+ this.channels.set(channel_id, channel);
85
87
  }
86
88
 
87
89
  const emote = new TwitchEmote(channel, data.id, data);
@@ -113,15 +115,15 @@ class EmoteFetcher {
113
115
  /**
114
116
  * Converts and caches a raw BTTV emote.
115
117
  * @private
116
- * @param {string} name - Name of the channel.
118
+ * @param {int} channel_id - ID of the channel.
117
119
  * @param {Object} data - Raw data.
118
120
  * @returns {BTTVEmote}
119
121
  */
120
- _cacheBTTVEmote(name, data) {
121
- let channel = this.channels.get(name);
122
+ _cacheBTTVEmote(channel_id, data) {
123
+ let channel = this.channels.get(channel_id);
122
124
  if (!channel) {
123
- channel = new Channel(this, name);
124
- this.channels.set(name, channel);
125
+ channel = new Channel(this, channel_id);
126
+ this.channels.set(channel_id, channel);
125
127
  }
126
128
 
127
129
  const emote = new BTTVEmote(channel, data.id, data);
@@ -133,17 +135,11 @@ class EmoteFetcher {
133
135
  /**
134
136
  * Gets the raw FFZ emotes data for a channel.
135
137
  * @private
136
- * @param {(number|string)} id - ID or name of the channel.
138
+ * @param {int} id - ID of the channel.
137
139
  * @returns {Promise<Object[]>}
138
140
  */
139
141
  _getRawFFZEmotes(id) {
140
- let endpoint;
141
-
142
- if (typeof id === 'number') {
143
- endpoint = Constants.FFZ.Channel(id); // eslint-disable-line new-cap
144
- } else {
145
- endpoint = Constants.FFZ.ChannelName(id); // eslint-disable-line new-cap
146
- }
142
+ const endpoint = Constants.FFZ.Channel(id); // eslint-disable-line new-cap
147
143
 
148
144
  return got(endpoint, options).then(req => {
149
145
  const emotes = [];
@@ -159,15 +155,15 @@ class EmoteFetcher {
159
155
  /**
160
156
  * Converts and caches a raw FFZ emote.
161
157
  * @private
162
- * @param {string} name - Name of the channel.
158
+ * @param {int} channel_id - ID of the channel.
163
159
  * @param {Object} data - Raw data.
164
160
  * @returns {FFZEmote}
165
161
  */
166
- _cacheFFZEmote(name, data) {
167
- let channel = this.channels.get(name);
162
+ _cacheFFZEmote(channel_id, data) {
163
+ let channel = this.channels.get(channel_id);
168
164
  if (!channel) {
169
- channel = new Channel(this, name);
170
- this.channels.set(name, channel);
165
+ channel = new Channel(this, channel_id);
166
+ this.channels.set(channel_id, channel);
171
167
  }
172
168
 
173
169
  const emote = new FFZEmote(channel, data.id, data);
@@ -176,50 +172,110 @@ class EmoteFetcher {
176
172
  return emote;
177
173
  }
178
174
 
175
+ /**
176
+ * Gets the raw 7TV emotes data for a channel.
177
+ * @private
178
+ * @param {int} [id=null] - ID of the channel.
179
+ * @returns {Promise<Object[]>}
180
+ */
181
+ _getRawSevenTVEmotes(id) {
182
+ const endpoint = !id
183
+ ? Constants.SEVENTV.Global
184
+ : Constants.SEVENTV.Channel(id); // eslint-disable-line new-cap
185
+
186
+ return got(endpoint, options).then(req => req.body);
187
+ }
188
+
189
+ /**
190
+ * Converts and caches a raw 7TV emote.
191
+ * @private
192
+ * @param {int} channel_id - ID of the channel.
193
+ * @param {Object} data - Raw data.
194
+ * @param {string} format - The type file format to use (webp/avif).
195
+ * @returns {SevenTVEmote}
196
+ */
197
+ _cacheSevenTVEmote(channel_id, data, format) {
198
+ let channel = this.channels.get(channel_id);
199
+ if (!channel) {
200
+ channel = new Channel(this, channel_id);
201
+ channel.format = format;
202
+ this.channels.set(channel_id, channel);
203
+ }
204
+
205
+ const emote = new SevenTVEmote(channel, data.id, data);
206
+ this.emotes.set(emote.code, emote);
207
+ channel.emotes.set(emote.code, emote);
208
+ return emote;
209
+ }
210
+
179
211
  /**
180
212
  * Fetches the Twitch emotes for a channel.
181
213
  * Use `null` for the global emotes channel.
182
- * @param {int} [id=null] - ID of the channel.
214
+ * @param {int} [channel=null] - ID of the channel.
183
215
  * @returns {Promise<Collection<string, TwitchEmote>>}
184
216
  */
185
- fetchTwitchEmotes(id = null) {
186
- return this._getRawTwitchEmotes(id).then(rawEmotes => {
217
+ fetchTwitchEmotes(channel = null) {
218
+ return this._getRawTwitchEmotes(channel).then(rawEmotes => {
187
219
  for (const emote of rawEmotes) {
188
- this._cacheTwitchEmote(id, { code: emote.name, id: emote.id });
220
+ this._cacheTwitchEmote(channel, { code: emote.name, id: emote.id });
189
221
  }
190
222
 
191
- return this.channels.get(id).emotes.filter(e => e.type === 'twitch');
223
+ return this.channels.get(channel).emotes.filter(e => e.type === 'twitch');
192
224
  });
193
225
  }
194
226
 
195
227
  /**
196
228
  * Fetches the BTTV emotes for a channel.
197
229
  * Use `null` for the global emotes channel.
198
- * @param {string} [name=null] - Name of the channel.
230
+ * @param {int} [channel=null] - ID of the channel.
199
231
  * @returns {Promise<Collection<string, BTTVEmote>>}
200
232
  */
201
- fetchBTTVEmotes(name = null) {
202
- return this._getRawBTTVEmotes(name).then(rawEmotes => {
233
+ fetchBTTVEmotes(channel = null) {
234
+ return this._getRawBTTVEmotes(channel).then(rawEmotes => {
203
235
  for (const data of rawEmotes) {
204
- this._cacheBTTVEmote(name, data);
236
+ this._cacheBTTVEmote(channel, data);
205
237
  }
206
238
 
207
- return this.channels.get(name).emotes.filter(e => e.type === 'bttv');
239
+ return this.channels.get(channel).emotes.filter(e => e.type === 'bttv');
208
240
  });
209
241
  }
210
242
 
211
243
  /**
212
244
  * Fetches the FFZ emotes for a channel.
213
- * @param {string} name - Name of the channel.
245
+ * @param {int} channel - ID of the channel.
214
246
  * @returns {Promise<Collection<string, FFZEmote>>}
215
247
  */
216
- fetchFFZEmotes(name) {
217
- return this._getRawFFZEmotes(name).then(rawEmotes => {
248
+ fetchFFZEmotes(channel) {
249
+ return this._getRawFFZEmotes(channel).then(rawEmotes => {
218
250
  for (const data of rawEmotes) {
219
- this._cacheFFZEmote(name, data);
251
+ this._cacheFFZEmote(channel, data);
252
+ }
253
+
254
+ return this.channels.get(channel).emotes.filter(e => e.type === 'ffz');
255
+ });
256
+ }
257
+
258
+ /**
259
+ * Fetches the 7TV emotes for a channel.
260
+ * @param {int} [channel=null] - ID of the channel.
261
+ * @param {('webp'|'avif')} [format='webp'] - The type file format to use (webp/avif).
262
+ * @returns {Promise<Collection<string, SevenTVEmote>>}
263
+ */
264
+ fetchSevenTVEmotes(channel = null, format = 'webp') {
265
+ return this._getRawSevenTVEmotes(channel).then(rawEmotes => {
266
+ if ('emotes' in rawEmotes) {
267
+ // From an emote set (like "global")
268
+ for (const data of rawEmotes.emotes) {
269
+ this._cacheSevenTVEmote(channel, data.data, format);
270
+ }
271
+ } else {
272
+ // From users
273
+ for (const data of rawEmotes.emote_set.emotes) {
274
+ this._cacheSevenTVEmote(channel, data.data, format);
275
+ }
220
276
  }
221
277
 
222
- return this.channels.get(name).emotes.filter(e => e.type === 'ffz');
278
+ return this.channels.get(channel).emotes.filter(e => e.type === '7tv');
223
279
  });
224
280
  }
225
281
  }