skip to Main Content

I am trying to make a Discord Music Bot (discord.js), but everytime the bot connects to the channel to play music it disconnects instantly.

This is the tutorial I have followed: https://gabrieltanner.org/blog/dicord-music-bot

There are not any errors and the ffmpeg is installed.

I am running the bot on a centos 8 VPS, and I have other bots that work fine (not music ones xD)

2

Answers


  1. In the play function, delete the line that contains serverQueue.voiceChannel.leave();.

    function play(guild, song) {
       const serverQueue = queue.get(guild.id);
       if (!song) {
       serverQueue.voiceChannel.leave();
       queue.delete(guild.id);
       return;
       }
    }
    

    The resulting code should like this:

    function play(guild, song) {
       const serverQueue = queue.get(guild.id);
       if (!song) {
       queue.delete(guild.id);
       return;
       }
    }
    
    Login or Signup to reply.
  2. Maybe you can setTimeout for this

    if (!song) {
          setTimeout(function () {
            serverQueue.voiceChannel.leave();
            queue.delete(guild.id);
            return;
          }, 300000);
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search