Twitch
Types
TwitchUser
Represents a user on Twitch
Property | Type | Description |
---|---|---|
id | string | ID of the user |
name | string | Name of the user (Username) |
displayName | string | Display name of the user |
profileImageUrl | string | URL of the user profile image |
TwitchFollower
Represents a user following a channel on Twitch
Property | Type | Description |
---|---|---|
id | string | ID of the user |
name | string | Name of the user (Username) |
displayName | string | Display name of the user |
followedAt | Date | Date that the user started following |
Functions
sendChat
Function (message: string) => Promise<void>
Sends a chat message to twitch chat
Argument | Type | Example | Description |
---|---|---|---|
message | string | ”Example message” | The message to send to twitch chat |
sendChatAnnouncement
Function (message: string) => Promise<void>
Sends a chat message to twitch chat
Argument | Type | Example | Description |
---|---|---|---|
message | string | ”Example message” | The message to send to twitch chat |
color Optional | string | ”blue”, “green”, “orange”, “purple”, “primary” | Color of the announcement message |
getUserByUsername
Function (username: string) => Promise<TwitchUser | null>
Attempts to lookup a twitch user by username returns a TwitchUser if one is found otherwise
returns null
Argument | Type | Example | Description |
---|---|---|---|
username | string | ”twitch” | The username of the user to lookup |
shoutout
Function (shoutout: string) => Promise<void>
Triggers a twitch shoutout for the provided user
Argument | Type | Example | Description |
---|---|---|---|
userId | string | The ID of the user to shoutout |
isModerator
Function (userId: string) => Promise<boolean>
Checks if the user with the provided ID is a moderator
Argument | Type | Example | Description |
---|---|---|---|
userId | string | The ID of the user to check moderator status of |
isVip
Function (userId: string) => Promise<boolean>
Checks if the user with the provided ID is a vip
Argument | Type | Example | Description |
---|---|---|---|
userId | string | The ID of the user to check vip status of |
isFollower
Function (userId: string) => Promise<boolean>
Checks if the user with the provided ID is a follower
Argument | Type | Example | Description |
---|---|---|---|
userId | string | The ID of the user to check following status of |
getFollower
Function (userId: string) => Promise<TwitchFollower | null>
Get a follower of the channel by user ID will return a TwitchFollower if the user is following otherwise will return null
Argument | Type | Example | Description |
---|---|---|---|
username | string | ”twitch” | The username of the user to lookup |
getUsernameArg
Function
(rawArg: unknown, validate: boolean = false) => string | null
Attempts to extract a username from the provided argument.
Normalizes the username into a format without @ and without any leading or trailing whitespace, optionally validating that the username is a valid twitch username.
Argument | Type | Example | Description |
---|---|---|---|
username | string | ”twitch” | The username to parse |
validate Optional | boolean | true / false | When enabled the username will be checked ensuring its a valid username |
Invalid username (With validate set to true, unknown symbols will cause null):
isValidUsernameStrict
Function (username: string) => boolean
Validates that the provided username is a valid twitch username. Ensuring that the characters within the username are allowed and that the username is within the expected length requirements
Argument | Type | Example | Description |
---|---|---|---|
username | string | ”twitch” | The username to validate |
Valid username:
Invalid username:
deleteChatMessage
Function (messageId: string) => Promise<void>
Deletes a chat message by ID
Argument | Type | Example | Description |
---|---|---|---|
messageId | string | The ID of the chat message to delete |
deleteAllChatMessages
Function () => Promise<void>
Deletes all messages in the chat (Same as the /clear chat command)
createStreamMarker
Function (description?: string) => Promise<void>
Create a new stream marker
Argument | Type | Example | Description |
---|---|---|---|
description Optional | string | ”Something happened” | Optional description for the marker |