Discord.js 播放音频文件错误
Posted
技术标签:
【中文标题】Discord.js 播放音频文件错误【英文标题】:Disocrd.js play an audio file errors 【发布时间】:2021-09-09 21:44:34 【问题描述】:大家好,我想问一下你们是否可以解决以下问题: 我想使语音通道中的音频失败,但我不能,我设法连接到该通道,但是当我必须运行音频文件时崩溃 当我安装模块时,它给了我以下错误:
> ffmpeg-static@4.4.0 install C:\Discord\Jawsbot\node_modules\ffmpeg-static
> node install.js
Downloading ffmpeg 4.4 [||||||||||||||||||||] 100% 0.0s
Failed to download the ffmpeg README.
npm WARN jawsbot@1.0.0 No description
npm WARN jawsbot@1.0.0 No repository field.
+ ffmpeg-static@4.4.0
added 15 packages from 44 contributors, updated 29 packages and audited 44 packages in 7.985s
found 6 vulnerabilities (2 low, 1 moderate, 3 high)
run `npm audit fix` to fix them, or `npm audit` for details
C:\Discord\Jawsbot>npm install @discordjs/opus
> @discordjs/opus@0.5.3 install C:\Discord\Jawsbot\node_modules\@discordjs\opus
> node-pre-gyp install --fallback-to-build
[@discordjs/opus] Success: "C:\Discord\Jawsbot\node_modules\@discordjs\opus\prebuild\node-v83-napi-v3-win32-x64-unknown-unknown\opus.node" is installed via remote
npm WARN jawsbot@1.0.0 No description
npm WARN jawsbot@1.0.0 No repository field.
+ @discordjs/opus@0.5.3
added 45 packages from 90 contributors and audited 89 packages in 20.077s
3 packages are looking for funding
run `npm fund` for details
found 6 vulnerabilities (2 low, 1 moderate, 3 high)
run `npm audit fix` to fix them, or `npm audit` for details
C:\Discord\Jawsbot>npm install opusscript
npm WARN jawsbot@1.0.0 No description
npm WARN jawsbot@1.0.0 No repository field.
+ opusscript@0.0.8
added 1 package from 1 contributor and audited 90 packages in 1.316s
3 packages are looking for funding
run `npm fund` for details```
【问题讨论】:
欢迎来到 Stack Overflow!你能告诉我们你的代码吗? 我没有看到任何错误 【参考方案1】:我发现我不得不放置connection.play而不是频道,但是现在机器人进入并且什么都不做甚至没有给出错误运行文件的代码如下:
var channel = message.guild.channels.cache.get("842859974324518913")
if (!channel) return console.error("The channel does not exist!");
channel.join().then(connection =>
const dispatcher = connection.play('./audios/private.mp3');
dispatcher.on("end", end =>
channel.leave();
);
);
【讨论】:
【参考方案2】:这些只是警告。不是错误。不必惊慌,以后如果你看到这些警告就知道了,99% 的时间都忽略它们,你应该没事的。
【讨论】:
以上是关于Discord.js 播放音频文件错误的主要内容,如果未能解决你的问题,请参考以下文章