parseBadges

Convert a map of badges into a list of badge images

Example

import { parseBadges } from "emotettv";

const parsedBadges = await parseBadges(
    {
        broadcaster: "1",
        subscriber: "12",
        turbo: "1",
    },
    "doceazedo911",
    { channelId: "98776633" }
);
const badgesArr = parsedBadges.toArray();
console.log(badgesArr);

API

parseBadges(...)

parseBadges: (
    badges: BadgeVersions | null,
    username?: string | null,
    _options?: Partial<ParserOptions> | null
): Promise<{
    toArray: () => ParsedBadges;
    toHTML: (scale?: number, inlineStyles?: boolean) => string;
}>

Parse badges and return multiple methods to manage the results.

Returns: Promise<{toArray(), toHTML(...)}>

.toArray()

toArray: () => ParsedBadges;

Converts parsed badges into an array of badges info.

Returns: ParsedBadges

.toHTML(...)

toHTML: (scale?: number, inlineStyles?: boolean) => string;

Converts parsed badges into a ready-to-use HTML string.

Returns: string

Types

BadgeVersions

This is the same type used by TMI.js when returning badges, so you can use it directly when needed.

Object map of:

ParsedBadges

Array of:

ParserOptions

Providers

You can also add any providers you create. See custom emotes/badges guide for more information.

Last updated