twurple / twurple

Interact with Twitch's API, chat and subscribe to events via PubSub and EventSub.
MIT License
637 stars 104 forks source link

Eventsub flatmap error #511

Closed zThana closed 10 months ago

zThana commented 1 year ago

Error occurred on application's startup.

Bug Report

[2023-05-25T13:30:14.606Z] twurple:eventsub ERROR Subscription stream.online.49661719 failed to subscribe: scopesToCompare.flatMap is not a function
[2023-05-25T13:30:14.606Z] twurple:eventsub ERROR Subscription stream.offline.49661719 failed to subscribe: scopesToCompare.flatMap is not a function
[2023-05-25T13:30:14.607Z] twurple:eventsub ERROR Subscription channel.follow.49661719.49661719 failed to subscribe: scopesToCompare.flatMap is not a function
/node_modules/@twurple/auth/es/helpers.mjs:206
        const scopes = new Set(scopesToCompare.flatMap(scope => { var _a; return [scope, ...((_a = scopeEquivalencies.get(scope)) !== null && _a !== void 0 ? _a : [])]; }));
                                               ^
TypeError: scopesToCompare.flatMap is not a function
    at compareScopes (/node_modules/@twurple/auth/es/helpers.mjs:206:48)
    at compareScopeSets (/node_modules/@twurple/auth/es/helpers.mjs:224:9)
    at RefreshingAuthProvider._fetchUserToken (/node_modules/@twurple/auth/es/providers/RefreshingAuthProvider.mjs:352:21)
    at TokenFetcher._executor (/node_modules/@twurple/auth/es/providers/RefreshingAuthProvider.mjs:68:95)
    at TokenFetcher.fetch (/node_modules/@twurple/auth/es/TokenFetcher.mjs:56:32)
    at RefreshingAuthProvider.getAccessTokenForUser (/node_modules/@twurple/auth/es/providers/RefreshingAuthProvider.mjs:282:30)
    at ApiClient.callApi (/node_modules/@twurple/api/es/client/BaseApiClient.mjs:110:52)
    at HelixPaginatedRequestWithTotal._fetchData (/node_modules/@twurple/api/es/utils/pagination/HelixPaginatedRequest.mjs:107:35)
    at HelixPaginatedRequestWithTotal.getTotalCount (/node_modules/@twurple/api/es/utils/pagination/HelixPaginatedRequestWithTotal.mjs:15:92)
    at updateFollowerCount (twitch/twitchbot.ts:198:103)

Code

async function updateFollowerCount() {
    const broadcaster = await getHelixBroadcaster(twitchAPIClient);
    const helixFollows = await twitchAPIClient.channels.getChannelFollowersPaginated(broadcaster).getTotalCount();
    (client.channels.cache.get('x') as VoiceChannel).setName(helixFollows + " flowers 🌸");
}

Environment

iProdigy commented 1 year ago

See https://github.com/twurple/twurple/issues/469#issuecomment-1474863824

d-fischer commented 1 year ago

Could be similar to #469 but not sure before I see some more code, especially how the AuthProvider is instantiated, since I can't reproduce this with a proper auth setup. Additionally, the code presented does not have anything to do with EventSub.

d-fischer commented 10 months ago

As this has been discussed on Discord and identified as user error, I'm closing this issue.