voice

How do i make the bot play audio from yt?
10 Replies
d.js docs
d.js docs3y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Shaurya
ShauryaOP3y ago
Oh, but how do i play any audio?
d.js docs
d.js docs3y ago
_Suggestion for @shauryachauhan:guide Getting Started: Introduction read more
Shaurya
ShauryaOP3y ago
There's nothing in it.... Hmm
//Defer the reply
await i.deferReply();

//Checks
if (!i.member.voice.channel) {...};

//Create a connection
const connection = joinVoiceChannel({
channelId: i.channel.id,
guildId: i.guild.id,
adapterCreator: i.channel.guild.voiceAdapterCreator,
});

//Create the player
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});

//Get the song name
const songName = i.options.getString('name');

//Find the song
const songPath = `../../assets/music/${songName}.mp3`;

// Play the song
const song = createAudioResource(songPath);
player.play(song);
connection.subscribe(player);
//Defer the reply
await i.deferReply();

//Checks
if (!i.member.voice.channel) {...};

//Create a connection
const connection = joinVoiceChannel({
channelId: i.channel.id,
guildId: i.guild.id,
adapterCreator: i.channel.guild.voiceAdapterCreator,
});

//Create the player
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});

//Get the song name
const songName = i.options.getString('name');

//Find the song
const songPath = `../../assets/music/${songName}.mp3`;

// Play the song
const song = createAudioResource(songPath);
player.play(song);
connection.subscribe(player);
No error but the song isn't playing the directory is right, it's according to the play command yes, i have ffmpeg installed I tried to replace it with just a one song and playing it:
const songPath = `../../assets/music/faster.mp3`;
const songPath = `../../assets/music/faster.mp3`;
but still it doesn't play it no error is there now, but the bot isn't playing the song, what do i do? yea i have those things properly Also, the
const connection = joinVoiceChannel({
channelId: i.channel.id,
guildId: i.guild.id,
adapterCreator: i.channel.guild.voiceAdapterCreator,
});
const connection = joinVoiceChannel({
channelId: i.channel.id,
guildId: i.guild.id,
adapterCreator: i.channel.guild.voiceAdapterCreator,
});
maked the bot join the vc right? but the bot doesn't even join the vc wdym by absolute path?
const songPath = fs.readFileSync(`./assets/music/${songName}.mp3`);
const songPath = fs.readFileSync(`./assets/music/${songName}.mp3`);
will this be absolute if i use fs?
d.js docs
d.js docs3y ago
node **[path.join([...paths])](<https://nodejs.org/docs/latest-v16.x/api/path.html#path_path_join__paths>)**__ The path.join() method joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.
Shaurya
ShauryaOP3y ago
did this:
const songPath = path.join(__dirname, `../../assets/music/${songName}.mp3`);
const songPath = path.join(__dirname, `../../assets/music/${songName}.mp3`);
but still same, no error but bot not playing audio yea do i need the exact versions of them? i also got a npm warn that discordjs voice isn't supported anymore
d.js docs
d.js docs3y ago
guide Getting Started: Debugging Dependencies read more
Shaurya
ShauryaOP3y ago
got this now:
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.11.0
- prism-media: 1.3.4

Opus Libraries
- @discordjs/opus: 0.7.0
- opusscript: not found

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.10
- tweetnacl: 0.14.5

FFmpeg
- version: 4.4.1-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.11.0
- prism-media: 1.3.4

Opus Libraries
- @discordjs/opus: 0.7.0
- opusscript: not found

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.10
- tweetnacl: 0.14.5

FFmpeg
- version: 4.4.1-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------
but still not playing when i do npm i sodium, i get this:
~/Nightfang$ npm i sodium

> [email protected] preinstall /home/runner/Nightfang/node_modules/sodium
> node install.js --preinstall

Static libsodium was not found at /home/runner/Nightfang/node_modules/sodium/deps/build/lib/libsodium so compiling libsodium from source.
libtool is required, but wasn't found on this system
Makefile:61: recipe for target 'libsodium' failed
make: *** [libsodium] Error 1
/home/runner/Nightfang/node_modules/sodium/install.js:293
throw new Error(cmdLine + ' exited with code ' + code);
^

Error: make libsodium exited with code 2
at ChildProcess.<anonymous> (/home/runner/Nightfang/node_modules/sodium/install.js:293:19)
at ChildProcess.emit (node:events:526:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm WARN [email protected] No repository field.
~/Nightfang$ npm i sodium

> [email protected] preinstall /home/runner/Nightfang/node_modules/sodium
> node install.js --preinstall

Static libsodium was not found at /home/runner/Nightfang/node_modules/sodium/deps/build/lib/libsodium so compiling libsodium from source.
libtool is required, but wasn't found on this system
Makefile:61: recipe for target 'libsodium' failed
make: *** [libsodium] Error 1
/home/runner/Nightfang/node_modules/sodium/install.js:293
throw new Error(cmdLine + ' exited with code ' + code);
^

Error: make libsodium exited with code 2
at ChildProcess.<anonymous> (/home/runner/Nightfang/node_modules/sodium/install.js:293:19)
at ChildProcess.emit (node:events:526:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm WARN [email protected] No repository field.
what do i do to fix that? i did that already and i got
~/Nightfang$ npm install --global --production --add-python-to-path windows-build-tools
npm WARN deprecated [email protected]: Node.js now includes build tools for Windows. You probably no longer need this tool. See https://github.com/felixrieseberg/windows-build-tools for details.
~/Nightfang$ npm install --global --production --add-python-to-path windows-build-tools
npm WARN deprecated [email protected]: Node.js now includes build tools for Windows. You probably no longer need this tool. See https://github.com/felixrieseberg/windows-build-tools for details.
below that i got this too:
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"win32","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS: win32
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: linux
npm ERR! notsup Actual Arch: x64
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"win32","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS: win32
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: linux
npm ERR! notsup Actual Arch: x64
i have windows 7 i have everything else required though, just not able install that one what do i do then? i have all other packages though idk, i just have a computed which is windows 7 confusedBecel is replit shell uh.. but i have all the required dependencies, and one of the encryption librairied as said in guide bruh i don't even get any errors and i literally gave it more than 2 hrs
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
souji
souji3y ago
has been addressed and redirected into playing audio through the discordjs/voice, which is it's sole purpose
Want results from more Discord servers?
Add your server