How exceptedprism3/hitradio works
Project type and purpose
• HitRadio is a single-process Node.js Discord bot built with Discord.js.
• Purpose: connect to the HitRadio streaming endpoint and relay continuous music into Discord voice channels, while handling slash‐commands and basic state (e.g., uptime, votes).
File structure
• Entry point: hitradio.js
• Configuration: config.json, .env (DISCORD_TOKEN)
• Core logic split into:
• loaders/ – modules that bootstrap the bot (commandLoader, eventLoader)
• commands/ – each slash‐command implementation (play.js, leave.js, etc.)
• events/ – event handlers (ready.js)
• utils/ – shared services (database.js, logger.js, player.js)
• Previews folder holds assets (banner GIF), not part of runtime.
• Package files manage dependencies (Discord.js, any database or streaming libraries).
README for additional insights
• Features: 24/7 streaming, interactive buttons, rotating status messages, auto-join voice channel.
• Uses external streaming URL (HitRadio station) and Discord API (Gateway & REST).
a. Main components
• Discord Gateway & REST API
• Bot Application (Node.js process)
– Entry Point (hitradio.js)
– Loaders (commandLoader, eventLoader)
– Command Handlers (/play, /leave, etc.)
– Event Handlers (ready, others)
– Utilities (player, database, logger)
• External Streaming Service (HitRadio stream URL)
• Persistent Storage (as exposed by utils/database.js)
b. Relationships & interactions
• On start: hitradio.js reads config.json + .env, initializes client.
• Loaders register commands with Discord REST and attach event handlers to the Gateway.
• User issues slash command → Discord Gateway forwards the event → relevant command module runs → may call player.js to open a voice connection.
• player.js pulls raw audio from the external streaming URL and pipes it into Discord voice channel via Discord.js.
• database.js is called by commands/events to store or retrieve bot state (e.g., votes, uptime).
• logger.js captures runtime events/errors to console or log store.
c. Architectural patterns & principles
• Modular separation: command handlers, event handlers, and utilities are decoupled.
• Single responsibility: each utility or module has a focused job (e.g., audio streaming vs. DB operations).
• Layered bootstrapping: entry point → loaders → handlers.
d. Key technologies
• Node.js runtime
• Discord.js library (Gateway + REST + Voice)
• Any streaming library inside utils/player.js (e.g., prism-media or built-in stream)
• Chosen persistence layer (SQLite, JSON file, etc.) abstracted by utils/database.js