当我想跳过当前歌曲时,我会收到一个错误。我以前在队列中添加了一首歌,当我打印队列时,歌曲就在那里了。但是,当我想跳过时,我会收到以下错误:
E:\JavaScript\privatebot\node_modules\distube\dist\index.js:1330
throw new DisTubeError("CANNOT_RESOLVE_SONG", song);
^
DisTubeError [CANNOT_RESOLVE_SONG]: Cannot resolve undefined to a Song
at DisTubeHandler.resolve (E:\JavaScript\privatebot\node_modules\distube\dist\index.js:1330:11)
at DisTube.play (E:\JavaScript\privatebot\node_modules\distube\dist\index.js:2244:33)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
errorCode: 'CANNOT_RESOLVE_SONG'
}这是我添加到队列的函数:
[...]
const song = event.options.getString("songname");
const voice = event.member.voice.channel;
if (!voice) {
event.reply({content: "You have to be in a voice to do this!", ephemeral: true})
} else {
const result = event.client.DisTube.search(song, {limit: 5, type: "video"});
result.then(res => {
const s = new Song(res[0], {source: "youtube"}); // Creating a Song object for the queue
console.log(res[0]);
// "addToQueue()" is NOT in the documentation of DisTube... But it works??
const q = event.client.DisTube.getQueue(event.guild).addToQueue(s, 1);
})
[...]这是我的跳过功能:
[...]
await event.client.DisTube.skip(event.guild).then((song) => {
console.log(song.name)
});
[...]谢谢你的帮助!
发布于 2022-08-25 10:30:49
我发现了问题,这是事件"finishSong",有代码说,机器人应该播放什么.json文件,但没有另一首歌。所以队列可以工作,但我不明白为什么文档中没有addToQueue() .
https://stackoverflow.com/questions/73473797
复制相似问题