gpt4 book ai didi

ffmpeg - Discord Music Bot 加入语音 channel ,亮绿色但没有任何音频。 2周前效果很好。控制台没有错误

转载 作者:行者123 更新时间:2023-12-04 17:28:01 24 4
gpt4 key购买 nike

我用 node.js 编写了一个机器人。我将 Crawl 的示例用于他的音乐机器人。我所做的一切都与他相似。在我完成构建后,一切正常。所有其他命令和 play命令。但现在 2 周后机器人加入语音 channel ,亮绿色但没有声音。我更新了ffmpeg , @discordjs/opus , ffmpeg-static并从 ffmpeg 下载了完整的版本,但机器人仍然没有音频。 queue , volume , nowplaying , skip , shuffle , loop一切正常。但是在我使用播放命令获得视频或播放列表后,机器人只加入亮绿色但没有音频。所以机器人肯定会得到网址,得到视频,得到他需要玩的一切。但加入后他并没有使用这些信息玩。歌曲结束后他也不会离开语音 channel 。

function play(guild, song) {

try {

const ServerMusicQueue = queue.get(guild.id);

if (!song) {

ServerMusicQueue.textchannel.send(`🎶 Queue ended and left the Voicechannel!`).then(message => message.delete(6000));

ServerMusicQueue.voiceChannel.leave()

queue.delete(guild.id)
return;
}

const dispatcher = ServerMusicQueue.connection.playStream(ytdl(song.url, { filter: 'audioonly', quality: 'highestaudio', highWaterMark: 1 << 25 }))
.on('end', () => {

var loopset = JSON.parse(fs.readFileSync("./rqs/loopset.json", "utf8"))

if (!loopset[message.guild.id]) {
loopset[message.guild.id] = {
loopset: config.loopset
}
}

var loop2 = loopset[message.guild.id].loopset;

if (loop2 === "true") {
play(guild, ServerMusicQueue.songs[0])
return;
}

ServerMusicQueue.songs.shift()

play(guild, ServerMusicQueue.songs[0])

})
.on('error', error => {
console.error(error)
});

dispatcher.setVolumeLogarithmic(ServerMusicQueue.volume / 5);

ServerMusicQueue.textchannel.send(`🎶 Start playing: **${song.title}**`).then(message => message.delete(8000));

} catch (error2) {

console.log(error2)

}

}

async function handleVideo(video, message, voiceChannel, playlist = false) {

const ServerMusicQueue = queue.get(message.guild.id)

const song = {
id: video.id,
title: Util.escapeMarkdown(video.title),
url: `https://www.youtube.com/watch?v=${video.id}`,
duration: video.duration,
requested: message.author.username
};

if(!ServerMusicQueue) {
const queueConstruct = {
textchannel: message.channel,
voiceChannel: voiceChannel,
connection: null,
songs: [],
volume: 5,
playing: true,
};

queue.set(message.guild.id, queueConstruct);

queueConstruct.songs.push(song)

try {

var connection = await voiceChannel.join()

queueConstruct.connection = connection;

play(message.guild, queueConstruct.songs[0])

var loopset = JSON.parse(fs.readFileSync("./rqs/loopset.json", "utf8"))

if(!loopset[message.guild.id]){
loopset[message.guild.id] = {
loopset: config.loopset
}
}

var loop2 = loopset[message.guild.id].loopset;

if(loop2 === "true") {

loopset[message.guild.id] = {
loopset: "false"
}

fs.writeFile("./rqs/loopset.json", JSON.stringify(loopset), (err) => {
if (err) console.log(err)
});
}

} catch (error) {
console.error(`Voicechannel join: ${error}`)
queue.delete(message.guild.id);
message.channel.send("Error with joining the Voicechannel!").then(message => message.delete(5000));
message.delete(4000).catch(console.error);
return;
}

} else {

ServerMusicQueue.songs.push(song);
if(playlist) return undefined;
else return message.channel.send(`🎶 **${song.title}** has been added to the queue!`).then(message => message.delete(5000));

}

return;

}

包.json
"dependencies": {
"@discordjs/opus": "^0.3.2",
"bufferutil": "^4.0.1",
"colors": "^1.4.0",
"discord.js": "^11.6.4",
"discord.js-commando": "^0.10.0",
"discord.js-musicbot-addon": "^13.9.1",
"discordjs-prompter": "^1.3.1",
"ffmpeg-static": "^4.2.2",
"file-system": "^2.2.2",
"html-entities": "^1.3.1",
"m3u8stream": "^0.7.0",
"miniget": "^1.7.0",
"ms": "^2.1.2",
"node-opus": "^0.3.3",
"npm": "^6.14.5",
"simple-youtube-api": "^5.2.1",
"sqlite": "^3.0.3",
"sqlite3": "^4.1.0",
"superagent": "^5.2.2",
"yt-search": "^1.1.2",
"ytdl-core": "^2.1.3"
}

最佳答案

尝试获取 ytdl-core,它可能会解决问题。

npm i ytdl-core
如果这不能解决问题,请尝试获取 Discord-YTDL-Core(确保保持安装 ytdl-core)
npm i discord-ytdl-core

关于ffmpeg - Discord Music Bot 加入语音 channel ,亮绿色但没有任何音频。 2周前效果很好。控制台没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62092474/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com