discord-mp v1.0.5
Discord Music Player
Must have Node v8 or higher to work
Discord Music Player is a powerful Node.js module that allows you to easily implement music commands. No api-keys required, everything easy to use.
Installation
npm install discord-mp
Install @discordjs/opus:
npm install @discordjs/opus
Install FFMPEG and you're done! Note: FFMpeg must be added to %PATH%
How to add program to path: -- Windows -- Linux
Features
-- Easy to use -- Realtime filter adding (NightCore, BassBoost, etc.) -- Manage server queues with smple functions -- Multi server support
Getting Started
In code below shown how to setup discord-mp.
Then you can use client.player
everywhere.
const Discord = ('discord.js');
const client = new Discord.Client();
const { Player } = require('discord-mp');
const player = new Player(client);
client.player = player;
client.on('ready', () => {
console.log(`I'm ready !`);
});
const prefix = '+';
client.on('message', async (message) => {
const arr = message.content.split(/\s/g);
const args = arr.slice(1);
const cmd = arr[0].slice(prefix.length);
if(!message.content.startsWith(prefix)) return;
if(cmd == 'play'){
let track = await client.player.play(message.member.voice.channel, args[0], message.member.user.tag);
message.channel.send(`Currently playing ${track.name}! - Requested by ${track.requestedBy}`);
}
});
client.login('SUPER SECRET TOKEN');
Documentation In Work
You will find many examples in the documentation to understand how the package works!
Methods overview
You need to init the guild queue using the play() function, then you are able to manage the queue and the music using the following functions. Click on a function name to get an example code and explanations.
Queue initialization
play(voiceChannel, track, requestedBy)
- play a track in a server
Queue management
isPlaying(guildID)
- check if there is a queue for a specific server
Manage tracks in your queue
getQueue(guildID)
- get the server queueaddToQueue(guildID, track, requestedBy)
- add a track to the server queueclearQueue(guildID)
- clear the server queueremove(guildID, track)
- remove a track from the server queuenowPlaying(guildID)
- get the current track
Manage music stream
skip(guildID)
- skip the current trackpause(guildID)
- pause the current trackresume(guildID)
- resume the current trackstop(guildID)
- stop the current tracksetFilters(guildID, newFilters)
- update filters (bassboost for example)setRepeatMode(guildID, boolean)
- enable or disable repeat mode for the server
Event messages
// Play the music
await client.player.play(message.member.voice.channel, 'Despacito')
// Then add some messages that will be sent when the events will be triggered
client.player.getQueue(message.guild.id)
.on('end', () => {
message.channel.send('There is no more music in the queue!');
})
.on('trackChanged', (oldTrack, newTrack) => {
message.channel.send(`Now playing ${newTrack.name}...`);
})
.on('channelEmpty', () => {
message.channel.send('Stop playing, there is no more member in the voice channel...');
});
Filter list
Note: Will add more soon
- bassboost
- vaporwave
- nightcore
- normalizer