Skip to content

Events

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.

1
const voice = new Manager({ ... });
2
3
voice.<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
});

Available Events

1
trackStart
2
trackEnd
3
trackStuck
4
trackPaused
5
trackResumed
6
queueStart
7
queueEnd
8
nodeConnect
9
nodeReconnect
10
nodeDisconnect
11
nodeError
12
nodeDestroy
13
nodeRaw
14
nodeDebug
15
socketClosed
16
playerCreate
17
playerDestroy
18
playerException

Handlers

1
const voice = new Manager({ ... });
2
3
// Load custom music event handlers from a directory. 'false' disables debug logs.
4
voice.loadVoiceEvents('./voice/', false);

Example Event File (in /voice/trackStart.js):

1
module.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
}]