You can listen to various events such as when a track starts, when the player is paused, etc., and respond to them with custom code.
1const voice = new Manager({ ... });2 3voice.<eventName>({ // The event type, e.g., when a track starts playing ('trackStart').4 channel: '$channelId', // The ID of the channel where the event will trigger (can be dynamic or static).5 code: `$songInfo[title]` // The action to take when the event is triggered. Here it will return the title of the song.6});
1trackStart2trackEnd3trackStuck4trackPaused5trackResumed6queueStart7queueEnd8nodeConnect9nodeReconnect10nodeDisconnect11nodeError12nodeDestroy13nodeRaw14nodeDebug15socketClosed16playerCreate17playerDestroy18playerException
1const voice = new Manager({ ... });2 3// Load custom music event handlers from a directory. 'false' disables debug logs.4voice.loadVoiceEvents('./voice/', false);
Example Event File (in /voice/trackStart.js):
/voice/trackStart.js
1module.exports = [{2 channel: '$channelId', // The ID of the channel where the event will trigger (can be dynamic or static).3 type: 'trackStart', // The event type, e.g., when a track starts playing ('trackStart').4 code: `$songInfo[title]` // The action to take when the event is triggered. Here it will return the title of the song.5}]