Skip to content

Class: EmoteService ​

Service for accessing the emotes and badges available on the channel: Twitch emotes (global + channel), Twitch badges, and BetterTTV emotes.

Remarks ​

Available everywhere via k.emotes. You never have to instantiate this service yourself — it is created by the SDK when the app/widget starts.

Example ​

ts
// Fetch all emotes/badges then log the channel's first BTTV emote
const set = await k.emotes.get();
console.log(set.emotes_bttv_channel.channelEmotes[0]?.code);

Implements ​

Methods ​

get() ​

ts
get(): Promise<EmotesSet>;

Fetches the channel's full set of emotes and badges from the backend.

Returns ​

Promise<EmotesSet>

A promise resolved with the complete EmotesSet: global and channel emotes, global and channel badges, and BetterTTV emotes (global and channel).

Remarks ​

Each call fetches fresh data (the endpoint is rate limited). To resolve the badges of chat messages, prefer getBadges / getBadge, which cache the sets internally.

Example ​

ts
const set = await k.emotes.get();
console.log(`${set.emotes_global.length} global emotes available`);

getBadge() ​

ts
getBadge(set_id, version): Promise<ResolvedBadge>;

Resolves a single badge (set_id + version) into its full description: title, description and image URLs (1x/2x/4x). Channel badges (custom subscriber milestones, bits…) take precedence over global ones, like on Twitch.

Parameters ​

set_id ​

string

Badge set identifier (e.g. 'subscriber', 'moderator').

version ​

string

Version within the set (e.g. '1', '3012').

Returns ​

Promise<ResolvedBadge>

The ResolvedBadge, or null if unknown.

Remarks ​

The badge sets are fetched once then cached internally for the whole execution: safe to call on every chat message.

Example ​

ts
const badge = await k.emotes.getBadge('subscriber', '3012');
console.log(badge?.title, badge?.image_url_2x);

See ​

getBadges to resolve all the badges of a message at once.


getBadges() ​

ts
getBadges(source): Promise<ResolvedBadge[]>;

Resolves a list of badges — or directly the badges of a chat message — into displayable badges with title and image URLs.

Parameters ​

source ​

| ChatEvent | TwitchBadge[]

Either a parsed badge list (event.getBadges()) or the ChatEvent itself.

Returns ​

Promise<ResolvedBadge[]>

The resolved badges, in the same order; unknown badges are skipped.

Example ​

ts
k.chat.onMessage(async (user, event) => {
    const badges = await k.emotes.getBadges(event);
    row.innerHTML = badges.map(b => `<img src="${b.image_url_2x}" alt="${b.title}">`).join('');
});

See ​

getBadge for a single badge.