Skip to content

Commit

Permalink
7TV Emotes 1.4.23
Browse files Browse the repository at this point in the history
* Added: A new option to select between WEBP and AVIF for the emote file format (Thanks to daviirodrig)
  • Loading branch information
daviirodrig authored Aug 6, 2024
1 parent 5a4f4a5 commit 6380d0a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/7tv-emotes/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main",
"clips"
],
"version": "1.4.22",
"version": "1.4.23",
"short_name": "7TV",
"name": "7TV Emotes",
"author": "Melonify",
Expand All @@ -14,5 +14,5 @@
"website": "https://7tv.app",
"settings": "add_ons.7tv_emotes",
"created": "2021-07-12T23:18:04.000Z",
"updated": "2024-03-29T22:03:31.676Z"
"updated": "2024-08-06T06:04:34.114Z"
}
36 changes: 27 additions & 9 deletions src/7tv-emotes/modules/emotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ export default class Emotes extends FrankerFaceZ.utilities.module.Module {
}
});

this.settings.add('addon.seventv_emotes.emote_format', {
default: 'WEBP',
ui: {
path: 'Add-Ons > 7TV Emotes >> Emotes',
title: 'Emote Format',
description: 'The file format of the emotes to be used.',
component: 'setting-select-box',
data: [
{ value: 'WEBP', title: 'Webp' },
{ value: 'AVIF', title: 'Avif' },
],

},
});

this.settings.add('addon.seventv_emotes.unlisted_emotes', {
default: false,
ui: {
Expand All @@ -52,6 +67,8 @@ export default class Emotes extends FrankerFaceZ.utilities.module.Module {

onEnable() {
this.on('settings:changed:addon.seventv_emotes.global_emotes', () => this.updateGlobalEmotes());
this.on('settings:changed:addon.seventv_emotes.emote_format', () => this.updateGlobalEmotes());
this.on('settings:changed:addon.seventv_emotes.emote_format', () => this.updateChannelSets());
this.on('settings:changed:addon.seventv_emotes.channel_emotes', () => this.updateChannelSets());
this.on('settings:changed:addon.seventv_emotes.unlisted_emotes', () => this.updateChannelSets());

Expand All @@ -74,7 +91,7 @@ export default class Emotes extends FrankerFaceZ.utilities.module.Module {
for (const emote of globalSet.emotes) {
const convertedEmote = this.convertEmote(emote);
if (!convertedEmote) continue;

ffzEmotes.push(convertedEmote);
}

Expand Down Expand Up @@ -306,17 +323,18 @@ export default class Emotes extends FrankerFaceZ.utilities.module.Module {
const emoteHostUrl = emote?.data?.host?.url;
if (!emoteHostUrl) return null;

const webpEmoteVersions = emote.data.host.files.filter((value => value.format === 'WEBP'));
if (!webpEmoteVersions.length) return null;

const emoteUrls = webpEmoteVersions.reduce((acc, value, key) => {
const format = this.settings.get('addon.seventv_emotes.emote_format');
const formatEmoteVersions = emote.data.host.files.filter((value => value.format === format));
if (!formatEmoteVersions.length) return null;

const emoteUrls = formatEmoteVersions.reduce((acc, value, key) => {
acc[key + 1] = `${emoteHostUrl}/${value.name}`;
return acc;
}, {});

let staticEmoteUrls;
if (emote.data.animated) {
staticEmoteUrls = webpEmoteVersions.reduce((acc, value, key) => {
staticEmoteUrls = formatEmoteVersions.reduce((acc, value, key) => {
acc[key + 1] = `${emoteHostUrl}/${value.static_name}`;
return acc;
}, {});
Expand All @@ -332,8 +350,8 @@ export default class Emotes extends FrankerFaceZ.utilities.module.Module {
urls: emoteUrls,
modifier: this.isZeroWidthEmote(emote.flags),
modifier_offset: '0',
width: webpEmoteVersions[0]?.width,
height: webpEmoteVersions[0]?.height,
width: formatEmoteVersions[0]?.width,
height: formatEmoteVersions[0]?.height,
click_url: this.api.getEmoteAppURL(emote),
SEVENTV_emote: emote
};
Expand All @@ -349,4 +367,4 @@ export default class Emotes extends FrankerFaceZ.utilities.module.Module {
isEmoteUnlisted(emote) {
return !emote.data.listed;
}
}
}

0 comments on commit 6380d0a

Please sign in to comment.