Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
emotes.forEach(emote => {
const { id, code } = emote
const img = termImg.string(path.join(IMAGES_DIR, `${id}.png`))
map[code] = img
})
})
return stringReplaceAsync(f.text, /(^|\b)([0-9a-z]+[a-z])(\d+)(\b|$)/g, async (match, prefix, type, amount, postfix) => {
if(cheerEmoteList.includes(type)) {
const tier = getCheerTier(type, amount, cheerEmotes);
if(loadImages) {
const emote = await getCheerEmote(type, tier);
return prefix + termImg.string(emote, {
fallback: () => cheers.formatCheer(amount, tier.color)
}) + chalk.bold.hex(tier.color)(amount) + postfix;
}
return prefix + cheers.formatCheer(amount, tier.color) + postfix;
}
return match;
});
}
exports.buffer = async buffer => {
return termImg.string(buffer, {
width: '100%',
height: '100%',
fallback: () => render(buffer)
});
};
const frags = await Promise.all(msg.message.fragments.map(async (f) => {
if(f.emoticon && loadImages) {
const emote = await getEmoticon(f.emoticon.emoticon_id);
return termImg.string(emote, {
fallback: () => f.text
});
}
else if(msg.message.bits_spent) {
return stringReplaceAsync(f.text, /(^|\b)([0-9a-z]+[a-z])(\d+)(\b|$)/g, async (match, prefix, type, amount, postfix) => {
if(cheerEmoteList.includes(type)) {
const tier = getCheerTier(type, amount, cheerEmotes);
if(loadImages) {
const emote = await getCheerEmote(type, tier);
return prefix + termImg.string(emote, {
fallback: () => cheers.formatCheer(amount, tier.color)
}) + chalk.bold.hex(tier.color)(amount) + postfix;
}
return prefix + cheers.formatCheer(amount, tier.color) + postfix;
}
return match;