Discord.js | Bot 不加入 VC 并且不报错

Discord.js | Bot doesn't join VC and doesn't give error

所以基本上当我在 VC 中用我想要的歌曲执行我的播放命令时,我的机器人不会响应它并且不会给出任何错误但是如果我只是键入播放而没有我想要的歌曲,我得到了我的 Please provide song 回应。

这是主文件

const distube = require('distube');
client.distube = new distube(client, { searchSongs: true, emitNewSongOnly: true })

client.distube
    .on('playSong', (message, queue, song) => message.channel.send(
        `Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user}\n${status(queue)}`,
    ))
    .on('addSong', (message, queue, song) => message.channel.send(
        `Added ${song.name} - \`${song.formattedDuration}\` to the queue by ${song.user}`,
    ))
    .on('error', (message, e) => {
        message.channel.send(`An error occured: ${e}`)
    })

这是播放命令:

const distube = require("distube");

module.exports = {
    name: 'play',
    aliases: ['p'],
    description: 'play a song!',
    async execute(client, message, args) {
        
        const VC = message.member.voice.channel;
        if(!VC) return message.reply('Join VC or no music!');

        const music = args.join(" ");
        if(!music) return message.reply("Please provide me a song name");

        await client.distube.play(message, music);

    }
}

我使用的包是:

npm i distube
npm i @discordjs/opus
npm i ffmpeg-static

作为参考,这些是我看过的东西:

https://distube.js.org/guide/example-bot.html
https://www.youtube.com/watch?v=tbPqM6JcGA4&t=883s

这也不是我第一次收到此错误。我之前尝试过使用不同的包,但仍然没有用。当我提供我想要的歌曲时,他们都没有回应。基本上,我唯一的问题是机器人没有加入 VC。有谁知道如何解决这个问题?

为了运行 distube,您的软件包库中还需要 ytdl-core,您可以像往常一样使用相同的 npm install 命令安装它。

这是因为您启用了 searchSongs 但没有监听 searchResult 事件。

只需在您的 DisTube 构造函数中编辑 searchSongs: false 即可解决此问题。