My music Discord bot can’t resume the song when it’s been paused

Asked

Viewed 20 times

0

I am using ytdl-core and when I try to run the Dispatcher.resume() command nothing happens. I searched in several places on the net and did not find a solution. that’s why I’m here asking for help. see the code:

const Discord = require("discord.js"); 
const client = new Discord.Client(); 
const ytdl = require('ytdl-core')
const config = require("./config.json");

const servidores = {
  'server': {
      connection: null,
      dispatcher: null
  }
}

//sorta o sordadin
client.on('message', async (message) => {
     if (message.author.bot) return;
     if (message.channel.type == 'dm') return;
     if (!message.content.toLowerCase().startsWith(config.prefix.toLowerCase())) return;
     if (message.content.startsWith(`<@!${client.user.id}>`) || message.content.startsWith(`<@${client.user.id}>`)) return;
     if (message.member.voice.channel) {
       if (message.content === config.prefix + 'join') {
        servidores.server.connection = await message.member.voice.channel.join()
       }

       if (message.content === config.prefix + 'leave') {
        message.member.voice.channel.leave()
        servidores.server.connection = null
        servidores.server.dispatcher = null
       }
  
       if (message.content.startsWith(config.prefix + 'play')) {
        let audio = message.content.slice(6)
        if (ytdl.validateURL(audio)) {
          servidores.server.dispatcher = servidores.server.connection.play(ytdl(audio))
        } else {
          message.channel.send('Link Inválido!')
        }
       }

       if (message.content === config.prefix + 'pause') {
         servidores.server.dispatcher.pause()
       }

       if (message.content === config.prefix + 'resume') {
         servidores.server.dispatcher.resume()
      }
     }


obg for the help!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.