Skip to main content

Twitch

@webframp/twitchv2026.07.03.1· 4d agoMODELSWORKFLOWSREPORTS
01README

Twitch Moderation Toolkit — cross-channel moderation visibility for Twitch moderators.

This extension provides a model for interacting with the Twitch Helix API (chatters, bans, mod events, user lookups), a workflow that audits all your moderated channels in parallel, and a report that correlates findings cross-channel to surface suspicious users and ban overlap.

Quick Start

swamp extension pull @webframp/twitch

# Create one model instance per channel you moderate
swamp model create @webframp/twitch mod-drongo \
  --global-arg channel=drongo \
  --global-arg moderatorId=YOUR_TWITCH_USER_ID

# Run the cross-channel audit
swamp workflow run @webframp/twitch-mod-audit

Authentication

Requires a Twitch application with OAuth2 user tokens. Store credentials in vault:

swamp vault set twitch-client-id YOUR_CLIENT_ID
swamp vault set twitch-client-secret YOUR_CLIENT_SECRET
swamp vault set twitch-access-token YOUR_ACCESS_TOKEN
swamp vault set twitch-refresh-token YOUR_REFRESH_TOKEN

To obtain tokens, register an app at dev.twitch.tv/console/apps with redirect URL http://localhost:3000 and category "Chat Bot". Then authorize:

# 1. Open in browser (replace YOUR_CLIENT_ID):
# https://id.twitch.tv/oauth2/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=http://localhost:3000&response_type=code&scope=moderator:read:chatters+moderation:read+moderator:manage:banned_users+user:write:chat+channel:read:editors+moderator:read:suspicious_users+moderator:read:warnings

# 2. Copy the code from the redirect URL, then exchange for tokens:
curl -X POST 'https://id.twitch.tv/oauth2/token' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&code=AUTH_CODE&grant_type=authorization_code&redirect_uri=http://localhost:3000'

# 3. Get your moderator user ID:
curl -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Client-Id: YOUR_CLIENT_ID' \
  'https://api.twitch.tv/helix/users'

The model refreshes expired access tokens automatically using the refresh token.

Scopes

Request all scopes during app registration to avoid re-authorization later.

Scope Used by Purpose
moderator:read:chatters get_chatters List users in chat
moderation:read get_banned_users, get_mod_events Read bans and mod activity
moderator:manage:banned_users ban_user, unban_user Issue bans/timeouts and unban
user:write:chat send_message Send chat messages as your user
channel:read:editors get_channel Read channel metadata
moderator:read:suspicious_users (future) Twitch-flagged suspicious users
moderator:read:warnings (future) Warnings issued to users
02Release Notes

2026.07.03.1

Changed: Added JSDoc documentation to HELIX_BASE, TOKEN_URL, helixApiPaginated (API helpers), and report export for improved deno doc coverage and quality rubric compliance.

2026.06.29.2

Added: README with quick start, authentication guide, method reference, and workflow/report documentation. Apache 2.0 LICENSE. JSDoc on model export.

Quality grade fix — addresses all missing scorer gates (README, code example, license, symbol documentation).

03Models1
@webframp/twitchv2026.07.03.1twitch/mod.ts

Global Arguments

ArgumentTypeDescription
channelstringTwitch channel login name
moderatorIdstringYour Twitch user ID (the moderator performing actions)
clientIdstringTwitch application client ID
clientSecretstringTwitch application client secret
accessTokenstringOAuth2 access token
refreshTokenstringOAuth2 refresh token
fn get_channel()
Get channel information (game, title, tags) for the configured channel
fn get_chatters()
Get the list of current chatters in the configured channel
fn get_user(login: string)
Look up a Twitch user by login and compute account age in days
ArgumentTypeDescription
loginstringTwitch login name to look up
fn get_banned_users()
Get all banned users in the configured channel
fn ban_user(userId: string, reason?: string, duration?: number)
Ban or timeout a user in the configured channel. Omit duration for a permanent ban.
ArgumentTypeDescription
userIdstringTwitch user ID to ban
reason?stringReason for the ban
duration?numberTimeout duration in seconds (omit for permanent ban)
fn unban_user(userId: string)
Remove a ban or timeout for a user in the configured channel
ArgumentTypeDescription
userIdstringTwitch user ID to unban
fn send_message(message: string, replyToMessageId?: string)
Send a chat message in the configured channel (requires user:write:chat scope)
ArgumentTypeDescription
messagestringMessage text to send (max 500 chars)
replyToMessageId?stringMessage ID to reply to (threads the response)
fn get_mod_events()
Get moderator add/remove events for the configured channel (uses legacy endpoint; may return empty on newer channels)

Resources

channel(infinite)— Channel information for a broadcaster
chatters(infinite)— Current chatters in a channel
user(infinite)— Twitch user profile and account age
banned-users(infinite)— Banned users in a channel
ban-result(infinite)— Result of a ban, unban, or timeout action
chat-message(infinite)— Chat message sent to a channel (audit trail)
mod-events(infinite)— Moderator add/remove events in a channel
04Workflows1
@webframp/twitch-mod-audit35fcec1b-a4b7-466e-8a8d-a8c4a7a45220

Cross-channel Twitch moderation audit. Gathers chatters, bans, and channel info from all channel instances in parallel, then flags suspicious users (new accounts, cross-channel ban overlap, multi-channel presence). NOTE: Steps use modelIdOrName: "*" to target all @webframp/twitch model instances. Create one model instance per channel before running this workflow (e.g. swamp model create --type @webframp/twitch --name channel1).

validate-authVerify API credentials and channel resolution before gathering data
1.get-channel-info*.get_channel— Get channel metadata (title, game, tags) — gates subsequent jobs on auth success
gather-channel-dataCollect chatters, bans, and mod events from each channel instance
1.get-chatters*.get_chatters— Get current chatters in the channel
2.get-banned-users*.get_banned_users— Get current bans and timeouts
3.get-mod-events*.get_mod_events— Get recent moderation actions (legacy endpoint, may return empty)
05Reports1
@webframp/twitch-mod-reportworkflow
mod_report.ts

Cross-channel moderation report highlighting suspicious users, ban overlap, and recent mod activity

twitchmoderationaudit
06Previous Versions3
2026.06.29.2Jun 29, 2026

2026.06.29.2

Added: README with quick start, authentication guide, method reference, and workflow/report documentation. Apache 2.0 LICENSE. JSDoc on model export.

Quality grade fix — addresses all missing scorer gates (README, code example, license, symbol documentation).

2026.06.29.1Jun 29, 2026

2026.06.29.1

Fixed: Switched to inline npm:zod@4.4.3 specifier so deno doc --lint resolves the import without an import map (fixes scorer compatibility).

2026.06.27.1Jun 27, 2026
07Stats
A
100 / 100
Downloads
0
Archive size
23.9 KB
  • Has README or module doc2/2earned
  • README has a code example1/1earned
  • README is substantive1/1earned
  • Most symbols documented1/1earned
  • No slow types (deprecated)1/1earned
  • Dependencies pass trust audit2/2earned
  • Has description1/1earned
  • Platform support declared (or universal)2/2earned
  • License declared1/1earned
  • Verified public repository2/2earned
08Platforms
09Labels