Discord bot not playing song from an custom mp3 api url

I have this code for the command where the bot suppose to play the audio from the mp3 url which is: https://api.onlyhit.us/play Here is code for the command: https://srcb.in/udqj0lkpDd Currently what happens the bot joins the voice channel and keeps himself defan and doesnot play anything. Can anyone please tell me how can I fix this issue? Thanks in Advance Discord.js: v13.15.1
20 Replies
duck
duck17mo ago
you were previously told to install ffmpeg have you done so?
enligh
enlighOP17mo ago
yes I have installed ffmpeg but I am unsure how to use it to play the url
duck
duck17mo ago
it's already used internally by @discordjs/voice
d.js docs
d.js docs17mo ago
To debug your voice connection and player: - Use debug: true when creating your VoiceConnection and AudioPlayer - Add an event listener to the <VoiceConnection> and the <AudioPlayer>:
// Add one for each class if applicable
<AudioPlayer | VoiceConnection>
.on('debug', console.log)
.on('error', console.error)
// Add one for each class if applicable
<AudioPlayer | VoiceConnection>
.on('debug', console.log)
.on('error', console.error)
- Add an error listener to the stream you are passing to the resource:
<Stream>.on('error', console.error)
<Stream>.on('error', console.error)
Note: The <> represents classes that need to be adapted to their respective name in your code
enligh
enlighOP17mo ago
when I say I have installed ffmpeg I mean the npm package. Not the one you install from a website and setup on env. Also do you have a guide or something for discord.js to steup a basic music bot from an api url?
duck
duck17mo ago
when I say I have installed ffmpeg I mean the npm package. Not the one you install from a website and setup on env.
as long as it's detected when generating a dependency report https://discordjs.guide/voice/#debugging-dependencies
Also do you have a guide or something for discord.js to steup a basic music bot from an api url?
not specifically for that, no the guide covers creating players/resources more generally https://discordjs.guide/voice/audio-player.html https://discordjs.guide/voice/audio-resources.html
enligh
enlighOP17mo ago
hmmn the guides you provided the first one for player here I can see on the resource it passes an mp3 file but in my case I have an mp3 api url. So I am not sure how to play that. Even one time I directly tried passing the url on the resource but it joins the voice channel and stays defan and does not play anything
duck
duck17mo ago
just to confirm, could you generate a dependency report?
enligh
enlighOP17mo ago
how do you create that?
enligh
enlighOP17mo ago
duck
duck17mo ago
looks like you're missing some dependencies in the other categories please install at least one opus encoding and encryption library https://discordjs.guide/voice/#installation
enligh
enlighOP17mo ago
Alright I have installed this 2 @discordjs/opus @discordjs/voice libsodium-wrappers now what?
enligh
enlighOP17mo ago
enligh
enlighOP17mo ago
This are my intents
enligh
enlighOP17mo ago
do I need to add something here?
duck
duck17mo ago
I mean you will want the GUILD_VOICE_STATES intent
enligh
enlighOP17mo ago
I have changed the code and now using this. Looks like the bot joins the voice channel as defan but does not play anything. Also on the command it says application does not reponds, no error on the console code: https://srcb.in/wmjaX0wDtj
enligh
enlighOP17mo ago
I gave the same input to chat gpt here is what it says
enligh
enlighOP17mo ago
is it true? nvm it works now
Want results from more Discord servers?
Add your server