我使用的是安装了 Node.js 和 npm 的 Windows(64 位)。在我的项目文件中,我运行了以下命令:
npm init
npm install discord.js --save
npm install ffmpeg --save
Run Code Online (Sandbox Code Playgroud)
现在我刚刚创建了一个基本机器人的代码,这是主要代码。我在这里列出了重要的:
if (message.content === '!play' && message.member.roles.has(message.guild.roles.find("name", config.role_name).id)) {
if (!message.member.voiceChannel) return log("?");
message.member.voiceChannel.join().then(function (connection){
});
}
Run Code Online (Sandbox Code Playgroud)
然后,我在 Discord 中说了以下内容:
[1517932146] Musik bot loaded
(node:35760) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: FFMPEG not found
Run Code Online (Sandbox Code Playgroud)
我已经测试了以下内容:
因此,如果您有任何想法,请告诉我。
npm i ffmpeg-binaries@3.2.2-3
Run Code Online (Sandbox Code Playgroud)