javascript - 我在 discord.js 中播放声音时遇到问题
问题描述
因此,当我尝试在 discord.js 上运行声音时遇到问题。
下面是代码:
const Discord = require('discord.js')
const client = new Discord.Client()
const {token,prefix} = require('../../config.json')
const cmd = __filename.slice(__dirname.length + 1, -3).trim()
client.on('message', message => {
function embed(title, content) {
message.channel.send({'embed':{'title': title,'description': content}})
}
if (!message.content.startsWith(prefix)) return
if (message.content.split(' ')[0].slice(prefix.length).trim() != cmd) return
const args = message.content.split(' ').shift()
const voiceChannel = message.member.voice.channel
if (typeof voiceChannel === 'undefined') return embed('Error','You are not in a voice channel.')
voiceChannel.join()
.then(connection => {
console.log(connection)
connection.play('../sfx/sfx_mute.mp3')
});
});
client.login(token)
我得到的错误是:
(node:27912) UnhandledPromiseRejectionWarning: Error: FFmpeg/avconv not found!
at Function.getInfo (C:\Users\-\OneDrive\Desktop\AmongBot\node_modules\prism-media\src\core\FFmpeg.js:130:11)
at Function.create (C:\Users\-\OneDrive\Desktop\AmongBot\node_modules\prism-media\src\core\FFmpeg.js:143:38)
at new FFmpeg (C:\Users\-\OneDrive\Desktop\AmongBot\node_modules\prism-media\src\core\FFmpeg.js:44:27)
at AudioPlayer.playUnknown (C:\Users\-\OneDrive\Desktop\AmongBot\node_modules\discord.js\src\client\voice\player\BasePlayer.js:47:20)
at VoiceConnection.play (C:\Users\-\OneDrive\Desktop\AmongBot\node_modules\discord.js\src\client\voice\util\PlayInterface.js:71:28)
at C:\Users\-\OneDrive\Desktop\AmongBot\src\Commands\init.js:18:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:27912) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:27912) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
我以前在这里看到过以前提出的问题。没有一个答案是简明扼要的,或者它们包含暗示不确定性的词语,而且大多数都不起作用。
解决方案
推荐阅读
- unity3d - unity post 到 api 空数据
- android - 在导航组件中保存片段状态
- authentication - 使用 CSOM 和 Azure AD 进行身份验证的 Azure 函数应用
- javascript - Vue拼接(将数组项移动到数组中的另一个位置)不更新DOM
- python - 如何将此python代码编写为列表理解?
- r - 如何在 R 中停止 foreach 循环中间循环?
- visual-studio - 尝试将 AppleID 添加到 Visual Studio 2019 以进行自动配置时挂起
- python - 我除以零但没有提示“ZeroDivisionError”
- cadence-workflow - 如何在 Cadence 中处理活动工作者故障
- gnuplot - gnuplot 标签中的小数