Appearance
Class: ChannelService
Represents the current Twitch channel the app is installed on: its identity (id, Twitch account) and its global preferences.
Remarks
Available everywhere via k.channel. You never have to instantiate this service yourself — it is created by the SDK when the app/widget starts, already populated with the channel's data.
Preferences are resynchronized automatically: when the streamer changes them, the service updates preferences and emits EVENTS.PREFERENCES_UPDATED (and EVENTS.LANGUAGE_UPDATED when the language changes).
Example
ts
console.log(`Channel: ${k.channel.twitchUser.display_name}`);
const language = k.channel.getPreference('language');Implements
Properties
bot
ts
bot: ChannelBotData;The channel's chat bot identity: the Twitch account that posts the messages sent via ChatService.say | k.chat.say. It is the global Kappapps bot by default, or the streamer's own account if a custom bot is configured on the channel. null if unavailable.
Example
ts
// Draw an active viewer, excluding the streamer and the bot
const [winner] = k.chat.getActiveUsers({
count: 1,
randomize: true,
excludes: [
{ login: k.channel.twitchUser.login },
{ login: k.channel.bot?.login },
],
});id
ts
id: number;Internal identifier of the channel on the platform.
preferences
ts
preferences: ChannelPreferencesData;twitchUser
ts
twitchUser: TwitchUserData;Twitch account attached to the channel (login, display_name, avatar…).
Methods
getPreference()
ts
getPreference(key): any;Reads a global channel preference.
Parameters
key
keyof ChannelPreferencesData
Name of the preference to read — see ChannelPreferencesData for the list of available keys (command_symbol, language, currency_symbol…).
Returns
any
The value of the requested preference.
Example
ts
const symbol = k.channel.getPreference('currency_symbol');
const prefix = k.channel.getPreference('command_symbol'); // e.g. '!'