Skip to content
← Public packages

@kentcdodds/twitch

Monitor Twitch streams, send chat, and update channel settings.

AGENTS.md

106 lines · 3.0 KB · Markdown

@kentcdodds/twitch — agent notes

Human setup and intent live in README.md. This file is for agents: imports, smoke checks, snippets, and edge cases. Secrets / integration ids by name only — never paste token values. Do not disable live webhooks or jobs.

Auth / integration

NameKindNotes
twitchOAuth integrationAuthorization + Client-Id for Helix

Reconnect: /connect/oauth?provider=twitch. Host: api.twitch.tv. Package constant: TWITCH_INTEGRATION = "twitch".

Import paths

ExportImport
overviewkody:@kentcdodds/twitch
get-mekody:@kentcdodds/twitch/get-me
get-streamkody:@kentcdodds/twitch/get-stream
list-chatterskody:@kentcdodds/twitch/list-chatters
send-chat-messagekody:@kentcdodds/twitch/send-chat-message
update-channel-infokody:@kentcdodds/twitch/update-channel-info
requestkody:@kentcdodds/twitch/request
smoke-testkody:@kentcdodds/twitch/smoke-test
guidekody:@kentcdodds/twitch/guide
scopeskody:@kentcdodds/twitch/scopes
typeskody:@kentcdodds/twitch/types

Prefer static kody:@kentcdodds/twitch/... imports from execute. Do not lead with packages.invoke.

Smoke test (read-only)

import smokeTest from 'kody:@kentcdodds/twitch/smoke-test'

export default async function main() {
	return await smokeTest()
	// => { ok: true, login, displayName, stream: { isLive, ... } }
}

Optional read-only follow-ups:

import getMe from 'kody:@kentcdodds/twitch/get-me'
import getStream from 'kody:@kentcdodds/twitch/get-stream'

export default async function main() {
	const me = await getMe()
	const [stream] = await getStream({ login: me.login })
	return { me, stream }
}

Common snippets

Send chat (mutates — only when explicitly requested):

import sendChatMessage from 'kody:@kentcdodds/twitch/send-chat-message'

export default async function main() {
	return await sendChatMessage({
		broadcasterLogin: 'kentcdodds',
		message: 'Hello chat!',
	})
}

Update title / game (mutates):

import updateChannelInfo from 'kody:@kentcdodds/twitch/update-channel-info'

export default async function main() {
	return await updateChannelInfo({
		title: 'Building with Kody',
		gameName: 'Software and Game Development',
	})
}

Raw Helix escape hatch:

import request from 'kody:@kentcdodds/twitch/request'

export default async function main() {
	return await request({ path: '/users', throwOnError: true })
}

Edge cases

  • Chat messages must be non-empty and ≤500 characters.
  • list-chatters needs moderator:read:chatters (included in default scopes).
  • Default connect scopes are broad (TWITCH_DEFAULT_SCOPES); fall back to TWITCH_MINIMAL_STREAM_SCOPES via ./scopes / getConnectUrl({ scopes }) if Twitch rejects breadth.
  • Prefer ./smoke-test or ./get-me before any chat or channel mutation.
  • Never paste OAuth token values into chat or logs.