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
duck2y ago
you were previously told to install ffmpeg have you done so?
Enlighted
EnlightedOP2y ago
yes I have installed ffmpeg but I am unsure how to use it to play the url
duck
duck2y ago
it's already used internally by @discordjs/voice
d.js docs
d.js docs2y 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
Enlighted
EnlightedOP2y 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
duck2y 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
Enlighted
EnlightedOP2y 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
duck2y ago
just to confirm, could you generate a dependency report?
Enlighted
EnlightedOP2y ago
how do you create that?
Enlighted
EnlightedOP2y ago
duck
duck2y 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
Enlighted
EnlightedOP2y ago
Alright I have installed this 2 @discordjs/opus @discordjs/voice libsodium-wrappers now what?
Enlighted
EnlightedOP2y ago
Enlighted
EnlightedOP2y ago
This are my intents
Enlighted
EnlightedOP2y ago
do I need to add something here?
duck
duck2y ago
I mean you will want the GUILD_VOICE_STATES intent
Enlighted
EnlightedOP2y 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
Enlighted
EnlightedOP2y ago
I gave the same input to chat gpt here is what it says
Enlighted
EnlightedOP2y ago
is it true? nvm it works now

Did you find this page helpful?