我一直在开发一个自定义的不和谐机器人,主要是为了好玩,但也为了一些朋友。每当有人使用该命令时,我都想在语音聊天中流式传输直播 ( https://www.youtube.com/watch?v=5qap5aO4i9A )。!play study
我正在使用 ytdl-core-discord,但我不断收到相同的错误:
Error: Error parsing info: Unable to retrieve video metadata...
网上很多人说解决这个问题的方法就是更新ytdl,但是我今天安装了它并且完全更新了。不用说,这不会向语音频道播放任何音乐,但它会加入频道。
脚.ts:
import {MessageEmbed, Message} from 'discord.js';
import config from '../../GGBot.config.js';
import ytdl from 'ytdl-core-discord';
export default async (msg: Message) => {
if(!msg.member?.voice.channelID){
msg.channel.send(
new MessageEmbed()
.setColor(config.embedColor)
.setTitle('You Must Be In A Voice Channel To Play Audio')
.setThumbnail(msg.author.displayAvatarURL())
.setDescription('Please join a voice channel to play audio')
)
return;
}
const connection = await msg.member.voice.channel?.join();
const stream = await ytdl('w2Ov5jzm3j8', {filter:'audioonly'});
connection?.play(stream, {seek:0, volume:1})
.on('finish', () => msg.member?.voice.channel?.leave());
console.log('playing')
}