Just for anyone interrested on this this is what playing got me and some research with cladue (TBH never used gql so was difficult)
const _7TV_PLATFORM_MAP = {
twitchUserId: 'TWITCH',
kickUserId: 'KICK',
youtubeUserId: 'GOOGLE',
};
async function _fetch7TV() {
const cfg = CONFIG.emotes;
const connections = [];
for (const [cfgKey, gqlPlatform] of Object.entries(_7TV_PLATFORM_MAP)) {
const id = cfg[cfgKey];
if (id && gqlPlatform) connections.push({ cfgKey, gqlPlatform, id });
}
const channelFragments = connections.map((c, i) =>
`u${i}: userByConnection(platform: ${c.gqlPlatform}, platformId: "${c.id}") { emoteSets { emotes(perPage: 500) { items { alias emote { id } } } } }`
).join('\n ');
const query = `{
emoteSets {
global {
emotes(perPage: 200) {
items { alias emote { id } }
}
}
}
${connections.length ? `users {\n ${channelFragments}\n }` : ''}
}`;
const res = await fetch('https://7tv.io/v4/gql', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query }),
});
const json = await res.json();
if (json.errors?.length) console.warn('[7TV] GQL partial errors:', json.errors);