【问题标题】:Discord.js - Music Bot . It plays any video, but not Copyrighted MusicDiscord.js - 音乐机器人。它播放任何视频,但不播放受版权保护的音乐
【发布时间】:2020-03-16 12:02:48
【问题描述】:

此命令可以播放任何视频,但如果是视频音乐或带有音乐的内容,则不会播放任何内容 我该怎么办?

const ytdl = require('ytdl-core')

module.exports.run = async (client, message, args) => {

   if (!message.member.voiceChannel) return message.channel.send('Please connect to a voice channel to play music.')
   if (message.guild.me.voiceChannel) return message.channel.send('Bot is already connected.')
   if (!args[0]) return message.channel.send('Please put a working Youtube Link.')

   let validate = await ytdl.validateURL(args[0])

   if (!validate) return message.channel.send('The link is not working.')


   let connection =  await message.member.voiceChannel.join()
   let stream = ytdl(args[0], {filter: 'audioonly'})
   let dispatcher = await connection.playStream(stream)
   dispatcher.on('end', _end => {message.member.voiceChannel.leave()})
}
module.exports.help = {
    name: 'music',
    aliases: []
}

【问题讨论】:

    标签: youtube discord discord.js audio-player


    【解决方案1】:

    尝试删除您的过滤器:

    let stream = ytdl(args[0])
    

    这看起来可能过滤了错误的东西。

    https://www.npmjs.com/package/ytdl-core

    filter - 用来决定下载什么格式。可以是audio和video来过滤格式 包含视频和音频的视频,用于过滤包含视频的格式的视频,或 videoonly 适用于包含视频且没有附加音轨的格式。也可以是 音频或仅音频。您可以提供一个过滤函数,该函数会被每种格式调用 可用的。这个函数的第一个参数是格式对象,并且应该 如果格式更可取,则返回 true。

    如果不是这样,YouTube 本身可能会有所作为。

    【讨论】:

      猜你喜欢
      • 2021-05-05
      • 1970-01-01
      • 1970-01-01
      • 2021-05-28
      • 2021-10-25
      • 2022-01-04
      • 2020-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多