Getting Started
Events & Packet Forwarding
Handle Lavalink events and maintain voice state consistency.
This guide covers event wiring and the production checklist to ensure clean state during playback and reconnects.
Listening to Events
Subscribe to manager events using EventNames constants. Key events include node readiness, player creation, and queue completion.
import { , } from 'hoshimi';
declare const : ;
.(., (, ) => {
.(`Node ${.} ready (retry #${})`);
});
.(., () => {
.(`Player created for guild ${.}`);
});
.(., () => {
.(`Queue ended for guild ${.}`);
});
.(., () => {
.(`Player destroyed for guild ${.}`);
});Debug Output
Every internal step emits a debug event tagged with the subsystem it came from, which is the fastest
way to see what Hoshimi is doing with the wire without attaching a debugger.
import { , , } from 'hoshimi';
declare const : ;
.(., (, ) => {
if ( === .) return; // noisy: one line per request
.([], );
});Levels are Manager, Node, Player, Rest, Queue and Test. Node passwords are censored in the
messages, so debug output is safe to log.
Production Checklist
Ensure consistent state across your application:
- Initialization: Call
manager.init(botUser)once after bot ready event. - Packet forwarding: Forward all raw voice packets to
manager.updateVoiceState()(see Setup & Integration). - Session persistence: On
PlayerUpdateevents, save relevant player state (current track, position, loop mode, volume). - Cleanup: On
QueueEndandPlayerDestroy, clear transient storage (message IDs, lyrics subscriptions, feature flags).