Skip to content

Events

Adding Events

1
voice.addEvent(PlayerEvents.eventName);

List of Events

Typings can be found here.

  • trackStart → Emitted whenever a track starts.
  • trackEnd → Emitted whenever a track ends.
  • queueStart → Emitted whenever a queue starts.
  • queueEnd → Emitted whenever a queue ends.
  • audioError → Emitted whenever a audio error occurs.
  • trackPause → Emitted whenever a track pauses.
  • trackResume → Emitted whenever a track resumes.

Using Events

1
const { LoadCommands } = require("aoi.js");
2
3
... // rest of your setup
4
5
const loader = new LoadCommands(client);
6
loader.load(voice.cmds, "./voice/");

This should be the content of your ./voice/<filename>.js:

1
module.exports = [{
2
channel: "$channelID",
3
type: "eventName",
4
code: `code to execute here`,
5
}];

If you don’t want to use handlers, you can use this instead in your main file also known as index.js:

1
voice.cmds["eventName"].set("Name for the command, can be anything", {
2
channel: "$channelID", // Any channel Id, must be valid.
3
code: `The code to execute when the event is triggered.`,
4
});