@mkody/twitch-emoticons

Gets Twitch emotes and BTTV emotes, as well as parsing text to emotes!

Usage no npm install needed!

<script type="module">
  import mkodyTwitchEmoticons from 'https://cdn.skypack.dev/@mkody/twitch-emoticons';
</script>

README

twitch-emoticons

Get a Twitch channel's Twitch emotes, BTTV emotes, and FFZ emotes!

About this fork's 2.3.0+

You must now use a Twitch user ID instead of the username to fetch user's emotes.
You can use this page to quickly grab it.

FFZ still supports names, but usage of the ID is recommended.

About this fork's 2.4.0+

You now need to use the official Twitch API to get emotes. For this you need to provide your client id and client secret. To get a client and secret create a Twitch app here, it's free.

If you are only using BetterTTV and FrankerFaceZ you don't need to provide anything as they are independent from the Twitch API.

Install

npm install @mkody/twitch-emoticons
# or
yarn add @mkody/twitch-emoticons

Example

const { EmoteFetcher, EmoteParser } = require('@mkody/twitch-emoticons');

const clientId = '<your client id>';
const clientSecret = '<your client secret>';

const fetcher = new EmoteFetcher(clientId, clientSecret);
const parser = new EmoteParser(fetcher, {
    type: 'markdown',
    match: /:(.+?):/g
});

fetcher.fetchTwitchEmotes(null).then(() => {
    const kappa = fetcher.emotes.get('Kappa').toLink();
    console.log(kappa);
    // https://static-cdn.jtvnw.net/emoticons/v1/25/1.0

    const text = 'Hello :CoolCat:!';
    const parsed = parser.parse(text);
    console.log(parsed);
    // Hello ![CoolCat](https://static-cdn.jtvnw.net/emoticons/v1/58127/1.0 "CoolCat")!
});

Links

This library uses the following: