Skip to content
Discordjs-NextgenPublic

About

This is an official plugin that allows you to easily record advanced audio features for your Discord bot, such as playback, pause, skipping, and volume control.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

discordjs-nextgen-voice

Turkish Documentation

Native voice plugin for discordjs-nextgen.

Installation

npm install discordjs-nextgen discordjs-nextgen-voice

Quick Usage

import { App, Intents } from 'discordjs-nextgen';
import { VoicePlugin } from 'discordjs-nextgen-voice';

const app = new App({ intents: Intents.ALL });

app.use(new VoicePlugin({
  autoLeave: true,
  defaultVolume: 0.5,
  dave: {
    enabled: true,
    maxProtocolVersion: 1,
  },
}));

The plugin automatically uses the adapter provided by discordjs-nextgen core.

Join a Voice Channel

ctx.voice.join

const joinCommand = {
  name: 'join',
  run: async (ctx, args) => {
    const channelId = args[0];
    if (!channelId) {
      return ctx.reply('Usage: !join <channelId>');
    }

    await ctx.voice.join({ channelId });
    await ctx.reply('Joined the voice channel.');
  },
};

app.voice.join

await app.voice.join({
  guildId: 'GUILD_ID',
  channelId: 'VOICE_CHANNEL_ID',
});

Optional Adapter Customization

app.use(new VoicePlugin({
  adapterProvider: (guildId, ctx) => {
    return undefined;
  },
}));

Play Audio

const playCommand = {
  name: 'play',
  run: async (ctx, args) => {
    const url = args[0];

    await ctx.voice.play(url, {
      title: 'Requested song',
      requestedBy: ctx.user.tag,
      join: {
        channelId: 'VOICE_CHANNEL_ID',
      },
    });

    await ctx.reply('Playback started.');
  },
};

Other Commands

ctx.voice.pause();
ctx.voice.resume();
ctx.voice.skip();
ctx.voice.stop();
ctx.voice.leave();

DAVE Debug

const daveStateCommand = {
  name: 'davestate',
  run: async (ctx) => {
    const state = ctx.voice.getDaveState();
    await ctx.reply(`DAVE phase: ${state.phase}, requiredByServer: ${state.requiredByServer}`);
  },
};

API

  • app.voice.join({ guildId, channelId, adapterCreator })
  • app.voice.play(guildId, source, options?)
  • app.voice.pause(guildId)
  • app.voice.resume(guildId)
  • app.voice.skip(guildId)
  • app.voice.stop(guildId)
  • app.voice.setVolume(guildId, value)
  • app.voice.getQueue(guildId)
  • ctx.voice.join(...)
  • ctx.voice.play(...)
  • ctx.voice.pause()
  • ctx.voice.resume()
  • ctx.voice.skip()
  • ctx.voice.stop()
  • ctx.voice.setVolume(value)
  • ctx.voice.getQueue()

Notes

  • ffmpeg is required for remote URLs or stream sources. The package ships with ffmpeg-static.
  • Your bot needs Connect and Speak permissions.
  • For YouTube support, create a stream via a library like play-dl and pass it to ctx.voice.play(stream).
  • ctx.voice.join() and ctx.voice.play(..., { join: ... }) require a guild context.

License

MIT

About

This is an official plugin that allows you to easily record advanced audio features for your Discord bot, such as playback, pause, skipping, and volume control.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages