Skip to main content

Core Types

Platform

Supported streaming platforms.
type Platform = "kick" | "twitch" | "youtube" | "rumble" | "tiktok";
Usage:
import type { Platform } from './types/streamer.js';

const platform: Platform = 'twitch';

Streamer Data

Streamer

Streamer data stored in the database.
interface Streamer {
  id: string;
  platform: Platform;
  username: string;
  displayName?: string;
  channelId: string;
  isLive: boolean;
  lastLiveAt?: string;
  title?: string;
  viewers?: number;
  followers?: number;
  thumbnail?: string;
  profileImage?: string;
  startedAt?: string;
  verified?: boolean;
  bio?: string;
}
Streamer
object
Complete streamer object with all tracking data.
Example:
import type { Streamer } from './types/streamer.js';

const streamer: Streamer = {
  id: 'twitch:xqc',
  platform: 'twitch',
  username: 'xqc',
  displayName: 'xQc',
  channelId: '123456789',
  isLive: true,
  lastLiveAt: '2026-03-01T12:00:00.000Z',
  title: 'VALORANT RANKED',
  viewers: 50000,
  followers: 2000000,
  profileImage: 'https://static-cdn.jtvnw.net/...',
  thumbnail: 'https://static-cdn.jtvnw.net/...',
  startedAt: '2026-03-01T10:30:00.000Z',
  verified: true,
  bio: 'Variety streamer',
};

LiveStatus

Live status returned by platform checkers.
interface LiveStatus {
  isLive: boolean;
  platform: Platform;
  username: string;
  title?: string;
  viewers?: number;
  followers?: number;
  thumbnail?: string;
  profileImage?: string;
  startedAt?: string;
  url: string;
  verified?: boolean;
  bio?: string;
  category?: string;
  categoryIcon?: string;
  tags?: string[];
  language?: string;
  isMature?: boolean;
  error?: string;
}
LiveStatus
object
Live status response from platform checkers.
Example:
import type { LiveStatus } from './types/streamer.js';
import { checkTwitchLive } from './platforms/twitch.js';

const status: LiveStatus = await checkTwitchLive('xqc');

if (status.isLive) {
  console.log(`${status.username} is live!`);
  console.log(`Title: ${status.title}`);
  console.log(`Viewers: ${status.viewers}`);
  console.log(`Game: ${status.category}`);
  console.log(`URL: ${status.url}`);
}

GuildSettings

Guild settings stored in the database.
interface GuildSettings {
  streamers: Streamer[];
}
GuildSettings
object
Settings for a Discord guild.
Example:
import type { GuildSettings } from './types/streamer.js';
import { getGuildSettings } from './database/index.js';

const settings: GuildSettings = getGuildSettings('123456789');

console.log(`Tracking ${settings.streamers.length} streamers`);
settings.streamers.forEach(s => {
  console.log(`  - ${s.username} on ${s.platform}`);
});

Platform Configuration

PlatformChecker

Function signature for platform live status checkers.
type PlatformChecker = (username: string) => Promise<LiveStatus>;
Example:
import type { PlatformChecker } from './types/streamer.js';
import { checkKickLive } from './platforms/kick.js';

const checker: PlatformChecker = checkKickLive;

const status = await checker('trainwreckstv');
console.log(status.isLive);

PlatformConfig

Platform configuration including checker function.
interface PlatformConfig {
  name: string;
  color: number;
  emoji: string;
  urlTemplate: string;
  checker: PlatformChecker;
}
PlatformConfig
object
Complete configuration for a platform.
Example:
import type { PlatformConfig } from './types/streamer.js';
import { getPlatformConfig } from './platforms/index.js';

const config: PlatformConfig = getPlatformConfig('twitch');

console.log(config.name);        // "Twitch"
console.log(config.color);       // 0x9146FF
console.log(config.emoji);       // "🟣"
console.log(config.urlTemplate); // "https://twitch.tv/{username}"

const status = await config.checker('xqc');

Discord Types

Command

Slash command structure.
interface Command {
  data: SlashCommandBuilder | SlashCommandSubcommandsOnlyBuilder | Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">;
  execute: (interaction: ChatInputCommandInteraction) => Promise<void>;
  autocomplete?: (interaction: AutocompleteInteraction) => Promise<void>;
}
Command
object
Discord slash command definition.
Example:
import type { Command } from './types/discord.js';
import { SlashCommandBuilder } from 'discord.js';

const pingCommand: Command = {
  data: new SlashCommandBuilder()
    .setName('ping')
    .setDescription('Replies with Pong!'),
  
  execute: async (interaction) => {
    await interaction.reply('Pong!');
  },
};

StreamerBotClient

Extended Discord client with commands collection.
interface StreamerBotClient extends Client {
  commands: Collection<string, Command>;
}
StreamerBotClient
interface
Discord.js Client extended with command management.
Example:
import type { StreamerBotClient } from './types/discord.js';
import { StreamerBot } from './client/StreamerBot.js';

const client: StreamerBotClient = new StreamerBot();

// Register command
client.commands.set('ping', pingCommand);

// Get command
const command = client.commands.get('ping');

InteractionData

Custom data stored in button/select menu custom IDs.
interface InteractionData {
  action: string;
  streamerId?: string;
  page?: number;
  platform?: string;
  username?: string;
}
InteractionData
object
Data encoded in interaction custom IDs.
Example:
import type { InteractionData } from './types/discord.js';
import { encodeCustomId, decodeCustomId } from './types/discord.js';

const data: InteractionData = {
  action: 'confirm_remove',
  streamerId: 'twitch:xqc',
};

const customId = encodeCustomId(data);
console.log(customId); // JSON string

const decoded = decodeCustomId(customId);
if (decoded) {
  console.log(decoded.action);     // "confirm_remove"
  console.log(decoded.streamerId); // "twitch:xqc"
}

Utility Functions

encodeCustomId()

Encode interaction data into a custom ID string.
function encodeCustomId(data: InteractionData): string
Example:
const customId = encodeCustomId({
  action: 'page_next',
  page: 2,
});

decodeCustomId()

Decode a custom ID string into interaction data.
function decodeCustomId(customId: string): InteractionData | null
Example:
const data = decodeCustomId(interaction.customId);
if (data) {
  console.log(`Action: ${data.action}`);
}

Constants

ButtonIds

Button custom ID prefixes.
export const ButtonIds = {
  CONFIRM_REMOVE: "confirm_remove",
  CANCEL: "cancel",
  PAGE_PREV: "page_prev",
  PAGE_NEXT: "page_next",
  WATCH_STREAM: "watch_stream",
} as const;
Example:
import { ButtonIds } from './types/discord.js';

const button = new ButtonBuilder()
  .setCustomId(ButtonIds.WATCH_STREAM)
  .setLabel('Watch Now');

SelectMenuIds

Select menu custom ID prefixes.
export const SelectMenuIds = {
  CHANNEL_SELECT: "channel_select",
  STREAMER_SELECT: "streamer_select",
  HELP_CATEGORY: "help_category",
} as const;
Example:
import { SelectMenuIds } from './types/discord.js';

const menu = new StringSelectMenuBuilder()
  .setCustomId(SelectMenuIds.CHANNEL_SELECT)
  .setPlaceholder('Select a channel');

Type Exports

All types are re-exported from the main types index:
// From types/index.ts
export * from './streamer.js';
export * from './discord.js';
Import examples:
// Import specific types
import type { Platform, LiveStatus, Streamer } from './types/index.js';

// Import all types
import * as Types from './types/index.js';

const platform: Types.Platform = 'twitch';

Build docs developers (and LLMs) love