Discord music bot not working

Ok, I have two solutions for you. This first one is a block of code I have used and I can say it works from experience.

It requires ffmpegopusscript and ytdl:

function play(connection, message){
    var server = servers[message.guild.id];

    server.dispatcher = connection.playStream(ytdl(server.queue[0], {filter: 
"audioonly"}));

server.queue.shift();

server.dispatcher.on("end", function() {
    if(server.queue[0]) play(connection, message);
    else connection.disconnect();
});
}

This second option which I would highly recommend is a node module that has many more advanced features that are hard to implement such as:

  • musichelp [command]: Displays help text for commands by this addon, or help for a specific command.
  • play |: Play audio from YouTube.
  • skip [number]: Skip a song or multi songs with skip [some number],
  • queue: Display the current queue.
  • pause: Pause music playback.
  • resume: Resume music playback.
  • volume: Adjust the playback volume between 1 and 200.
  • leave: Clears the song queue and leaves the channel.
  • clearqueue: Clears the song queue.
  • owner: Various owner commands/actions. (W.I.P)

It is easy to install and get started, here is the node page with all the information about installation etc.

Leave a Comment