Discord.js音乐机器人“ TypeError”,当使用调度程序播放音频时

问题描述 投票:0回答:1

我是Discord.js的新手,我正在尝试让该漫游器加入语音通道并在计算机上播放音频文件。我一直在遵循本指南:https://discord.js.org/#/docs/main/stable/topics/voice。这是Index.js页面:

Colesbot.on('message', message=>{
    if (message.content === '/join') {
        // Only try to join the sender's voice channel if they are in one themselves
        if (message.member.voiceChannel) {
            message.member.voiceChannel.join().then(connection => {
                message.reply('I have successfully connected to the channel!');

                // To play a file, we need to give an absolute path to it
                const dispatcher = connection.playFile('C:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\Assets\Glory.mp3');

                dispatcher.on('end', () => {
                    // The song has finished
                    console.log('Finished playing!');
                  });

                dispatcher.on('error', e => {
                    // Catch any errors that may arise
                    console.log(e);
                  });

                  dispatcher.setVolume(0.5); // Set the volume to 50%
            }).catch(console.log);
    } else {
        message.reply('You need to join a voice channel first!');
      }
    }
 });
exports.run = (client, message, args) => {
    let user = message.mentions.users.first || message.author;
}

FFMPEG已安装,我已经为其设置了环境路径。当我在命令行中键入FFMPEG时,我会得到正确的响应。

有人说我需要安装ffmpeg二进制文件,但是当我运行npm安装ffmpeg-binaries时,我收到一条错误消息that is here

因此,我尝试安装旧版本,现在使用[email protected],但是当我键入/ join时出现错误

[ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object
node.js ffmpeg discord.js dispatcher
1个回答
1
投票

首先,您需要重置令牌,永远不要在线发布令牌,因为其他人可以使用它来访问和控制您的机器人

here is a good answer您的问题

我认为您需要安装FFMPEG并为其设置环境路径,但是,您可以提供更多信息,控制台日志,行为等吗?>

© www.soinside.com 2019 - 2024. All rights reserved.