import { getConnectUrl } from './core.ts'
import describeTwitchScopes, {
TWITCH_DEFAULT_SCOPES,
TWITCH_MINIMAL_STREAM_SCOPES,
} from './scopes.ts'
import type { TwitchGuideResult } from './types.ts'
/**
* Return Twitch OAuth setup guidance, connect URL, and common task hints.
*/
export default async function twitchGuide(): Promise<TwitchGuideResult> {
const scopeInfo = describeTwitchScopes()
return {
integration: 'twitch',
redirectUri: 'https://kody.codes/connect/oauth',
connectUrl: getConnectUrl(),
scopes: [...TWITCH_DEFAULT_SCOPES],
minimalStreamScopes: [...TWITCH_MINIMAL_STREAM_SCOPES],
scopeCount: TWITCH_DEFAULT_SCOPES.length,
scopeNotes: scopeInfo.notes,
setup: [
'Open the connect URL while signed in to Kody.',
'Create a Twitch app at https://dev.twitch.tv/console/apps if you do not already have one.',
'Register https://kody.codes/connect/oauth as the OAuth redirect URL.',
'Complete the connect wizard with your Twitch Client ID and Client Secret.',
'No extra setup for Client-Id: it comes from the saved integration and is sent on every Helix call.',
'Run the smoke-test export to confirm auth before mutating chat or channel settings.',
'If you already connected with the old minimal scope set, reconnect so the token includes the expanded scopes.',
],
commonTasks: {
checkIfLive: 'Use get-stream with your channel login.',
sendChat: 'Use send-chat-message with broadcasterLogin and message.',
updateTitle: 'Use update-channel-info with title and optional gameName.',
seeWhoIsWatchingChat: 'Use list-chatters for the broadcaster channel.',
inspectScopes: 'Use scopes export for TWITCH_DEFAULT_SCOPES and TWITCH_MINIMAL_STREAM_SCOPES.',
},
openapi: {
specUrl:
'https://raw.githubusercontent.com/DmitryScaletta/twitch-api-swagger/main/openapi.json',
slugs: [
'get_users',
'get_streams',
'send_chat_message',
'get_chatters',
'modify_channel_information',
'search_categories',
],
auth: "integration createAuthenticatedFetch('twitch') + package injects Client-Id from the integration's clientId",
},
}
}