3.0.1 • Published 2 years ago
discord-play v3.0.1
discord-play (DisPlay)
A robust wrapper module for @discordjs/voice, implementing functions and emitting events making it easier to interact with the new voice module.
Features
DisPlayConnection (Voice Connection class)
- Emits voice connection events like
voiceConnectionKick
,voiceConnectionMove
, etc. - Contains utility functions such as
toggleMute
andtoggleDeafen
. - Contains built-in reconnection logic.
- Emits voice connection events like
DisPlayPlayer (Audio Player class)
- Emits audio player events like
audioPlayerStart
,audioPlayerFinish
, etc. - Contains a simplified powerful
play
function which supports playing from local audio files or online audio urls to readable stream of audio data or even a premade Audio Resource. - Contains utility functions such as
togglePause
,toggleMute
.
- Emits audio player events like
Documentation
For any help, feel free to join the discord server and ask.
Installation
Pre-requisites
The following are some required npm packages to be installed (alternatives provided) :
discord.js
v13+- The new voice library -
@discordjs/voice
(Gets automatically installed as dependency) - Opus encoding library -
@discordjs/opus
oropusscript
- FFmpeg -
ffmpeg-static
or ffmpeg installed globally in your system - Encrytion package -
sodium
orlibsodium-wrappers
Importing
import { DiscordPlay, DisPlayEvent } from 'discord-play';
// or
const { DiscordPlay, DisPlayEvent } = require('discord-play');
Basic Usage
import { DisPlayConnection, DisPlayPlayer, DisPlayEvent } from 'discord-play';
// joins the voice channel and attaches all connection logic
const connection = new DisPlayConnection(message.member.voice);
// attaches the premade audio player to the connection created
const player = new DisPlayPlayer(message.guild.id);
// sample connection event
connection.on(DisPlayEvent.VOICE_JOIN, (voiceId) => {
message.reply("Joined the voice channel.");
});
// sample player event
player.on(DisPlayEvent.PLAYING, () => {
message.channel.send("Now playing.");
});
License
This repository uses MIT license.