G
G
getaxe2022-03-30 09:51:58
JavaScript
getaxe, 2022-03-30 09:51:58

How can I specify the correct file path for the createAudioResource (@discordjs/voice) function?

In general, almost everything was written in the title.
This lib has docks, obviously, but the path is indicated there if the bot was on the host:

const resource = createAudioResource('/home/user/voice/track.mp3');

I tried to specify for the local folder:
const resource = createAudioResource('./file.mp3');

To which I received an error about the absence of a file:
Uncaught Error Error: FFmpeg/avconv not found!
    at getInfo (e:\musicbot\node_modules\prism-media\src\core\FFmpeg.js:143:11)
    at create (e:\musicbot\node_modules\prism-media\src\core\FFmpeg.js:156:38)
    at FFmpeg (e:\musicbot\node_modules\prism-media\src\core\FFmpeg.js:45:27)
    at transformer (e:\musicbot\node_modules\@discordjs\voice\dist\index.js:8:13814)
    at <anonymous> (e:\musicbot\node_modules\@discordjs\voice\dist\index.js:8:16735)
    at We (e:\musicbot\node_modules\@discordjs\voice\dist\index.js:8:16726)
    at <anonymous> (e:\musicbot\main.js:64:19)
    at emit (node:events:520:28)
    at handle (e:\musicbot\node_modules\discord.js\src\client\actions\MessageCreate.js:26:14)
    at module.exports (e:\musicbot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at handlePacket (e:\musicbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:351:31)
    at onPacket (e:\musicbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
    at onMessage (e:\musicbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
    at onMessage (e:\musicbot\node_modules\ws\lib\event-target.js:199:18)
    at emit (node:events:520:28)
    at receiverOnMessage (e:\musicbot\node_modules\ws\lib\websocket.js:1137:20)
    at emit (node:events:520:28)
    at dataMessage (e:\musicbot\node_modules\ws\lib\receiver.js:528:14)
    at getData (e:\musicbot\node_modules\ws\lib\receiver.js:446:17)
    at startLoop (e:\musicbot\node_modules\ws\lib\receiver.js:148:22)
    at _write (e:\musicbot\node_modules\ws\lib\receiver.js:83:10)
    at writeOrBuffer (node:internal/streams/writable:390:12)
    at _write (node:internal/streams/writable:331:10)
    at Writable.write (node:internal/streams/writable:335:10)
    at socketOnData (e:\musicbot\node_modules\ws\lib\websocket.js:1231:35)
    at emit (node:events:520:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at onStreamRead (node:internal/stream_base_commons:190:23)
    at callbackTrampoline (node:internal/async_hooks:130:17)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
getaxe, 2022-03-31
@getaxe

The reason was that the ffmpeg library is broken and does not work properly, use ffmpeg-static.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question