diff --git a/src/main.ts b/src/main.ts index 5bfc087..5bf85d2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2393,7 +2393,7 @@ interface PublicProfileQueryResult { displayName: string; description: string | null; profileImageURL: string | null; - broadcasterType: string | null; + roles?: { isPartner: boolean; isAffiliate: boolean } | null; followers?: { totalCount: number } | null; } | null; } @@ -2405,6 +2405,13 @@ async function fetchPublicStreamerProfile(login: string): Promise<{ broadcasterType: '' | 'partner' | 'affiliate'; followerCount: number | null; } | null> { + // The public (unauthenticated) GQL schema does NOT expose + // `broadcasterType` directly — querying it returns an errors[] response + // which the upstream helper treats as a complete failure (null data), + // which in turn left the avatar empty and the user's whole profile + // fell through to the fallback letter tile. Use `roles{isPartner + // isAffiliate}` instead, which the public schema does expose, and + // derive broadcasterType locally. const data = await fetchPublicTwitchGql( `query($login: String!) { user(login: $login) { @@ -2413,19 +2420,22 @@ async function fetchPublicStreamerProfile(login: string): Promise<{ displayName description profileImageURL(width: 150) - broadcasterType + roles { isPartner isAffiliate } followers { totalCount } } }`, { login } ); if (!data?.user) return null; - const bt = (data.user.broadcasterType || '').toLowerCase(); + const roles = data.user.roles; + const broadcasterType: '' | 'partner' | 'affiliate' = roles?.isPartner + ? 'partner' + : (roles?.isAffiliate ? 'affiliate' : ''); return { displayName: data.user.displayName || login, avatarUrl: data.user.profileImageURL || '', description: data.user.description || '', - broadcasterType: (bt === 'partner' || bt === 'affiliate') ? bt : '', + broadcasterType, followerCount: typeof data.user.followers?.totalCount === 'number' ? data.user.followers.totalCount : null }; }