Voice Plugin

discordjs-nextgen-voice is the official plugin for playback, pause, skip and voice channel control in your Discord bot.

Installation

Install the plugin with the command below:

1npm i discordjs-nextgen-voice

Quick Usage

Register the plugin with app.use().

1import { App, Intents } from 'discordjs-nextgen';
2import { VoicePlugin } from 'discordjs-nextgen-voice';
3
4const app = new App({ intents: Intents.ALL });
5
6app.use(new VoicePlugin({
7 autoLeave: true,
8 defaultVolume: 0.5,
9 dave: {
10 enabled: true,
11 maxProtocolVersion: 1,
12 },
13}));

Command Examples

Join Voice

1const joinCommand = {
2 name: 'join',
3 run: async (ctx, args) => {
4 const channelId = args[0];
5 if (!channelId) return ctx.reply('Please provide a channel ID.');
6
7 await ctx.voice.join({ channelId });
8 await ctx.reply('Connected to the voice channel!');
9 },
10};

Play Music

1const playCommand = {
2 name: 'play',
3 run: async (ctx, args) => {
4 const url = args[0];
5 if (!url) return ctx.reply('Please provide a URL.');
6
7 await ctx.voice.play(url, {
8 title: 'Requested Track',
9 requestedBy: ctx.user.tag,
10 });
11
12 await ctx.reply('Playing...');
13 },
14};

Control Commands

1ctx.voice.pause();
2ctx.voice.resume();
3ctx.voice.skip();
4ctx.voice.leave();

Important Notes

  • ffmpeg should be installed for remote URL or stream playback.
  • The bot needs Connect and Speak permissions.
  • Voice helpers on ctx require a guild context.