#archive-voice
30636 messages · Page 11 of 31
I think we need a separate package that can handle youtube-dl stuff with efficiency
& without any errors.
@carmine timber
Core Dependencies
- @discordjs/voice: 0.6.0
- prism-media: 1.3.2
Opus Libraries
- @discordjs/opus: 0.6.0
- opusscript: not found
Encryption Libraries
- sodium: not found
- libsodium-wrappers: 0.7.9
- tweetnacl: not found
FFmpeg
- version: 4.4-essentials_build-www.gyan.dev
- libopus: yes
where i can do that
Take a look at the npm page of ytdl.
okay thanks
Install @discordjs/opus
it is latest
its there?
Have u installed ffmpeg statically or globally?
He can create a ffmpeg instance. That's not the issue
Send OggOpus file
slight NSFW warning
Have u followed the guide properly? Just recheck once
I believe I have. The docs seem to be cut into seperate parts but I put them together as best I could
I linked my entire code earlier on pastebin
Your audio is incomplete, so fs is not able to create fully functional stream for that
Try to download a sample from here and run it in voice
https://file-examples.com/index.php/sample-audio-files/sample-ogg-download/
ah wow really? Was just a default export from audacity - how do you tell?
I tried to play it and it kept looping even after 2 seconds. So It is incomplete in my opinion.
Did it work ???
Looking at docs now re-figuring out how to default the audio to ogg and will try the sample file
no.. it only works when adding "inlineVolume: true" to options
Show me code once again
you want to see the entire thing or a snippet where im defining the resource?
where you are defining resource and playing the resource and subscribing player to connection
some of it is slightly unrelated like the interval stuff https://pastebin.com/4LT6qK15
What is playSound() ??
a function that plays dynamic sounds based on button clicks - ignore that, I have the .ogg playing code at the end of VoiceConnectionStatus.Ready
basically when I un-comment the "inlineVolume" line it plays
how can i make my bot join a voice channel then record and when silent he leaves and saves the recorded file as an mp3 or wav
This is unrelated to the above issue but - if im playing many short clips, is it generally better practice to reuse a player with different resources, or create a new player every time and re-subscribe it?
interesting, I am also facing the same issue.
there's basically no difference here, reusing a player has a very slight performance advantage but nothing you'd ever notice
so either options are acceptable
let channel = message.guild.channels.cache.filter(m => m.type === 'GUILD_VOICE').random()
channel.name
channel.join() is not a function
Pls help
Read guide in pins
@carmine timber i'm trying to install @discordjs/opus but what is this err ?
Download this : https://www.npmjs.com/package/windows-build-tools
oh ok
do i need python ?
No, you already have python
k
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
[ ] / reify:resolve: timing reifyNode:node_modules/windows-build-tools/node_modules/ajv Completed in 619ms``` just wait huh ? @carmine timber
nvm
tysm
i known why i cant install because i'm have just install new version of nodejs v16.7.0 but didnt restarting the computer
tysm for helped me
AudioPlayerError: Status code: 410
const ytdl = require('ytdl-core');
const stream = await ytdl("https://www.youtube.com/watch?v=9iQfSz7TJBs", { filter: 'audioonly' });
const channel = message.member.voice.channel;
if(!channel) return message.channel.send('Join a VC!');
const player = voiceDiscord.createAudioPlayer();
const resource = voiceDiscord.createAudioResource(stream);
const connection = voiceDiscord.joinVoiceChannel({
channelId: channel.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
});
player.play(resource)
connection.subscribe(player)
410 errors means the resource u are requesting is permanently deleted
probably from ytdl-core
it's <AudioPlayer>.play
um why is the player state changing from buffering to buffering ?
state format : oldState|newState
nodejs version : 16.6.1
djs version 13.1.0
djs/voice version: 0.5.6
this doesn't make any sense to me 
why the bot doesn't play the song? i cant hear nothing
no errors in the console
How would I make the bot play a song in a stage channel? Creating the resource, playing the player and subscribing still leaves the bot as a Listener
Documentation suggestion for @surreal otter:
VoiceState#setSuppressed()
Suppress/unsuppress the user. Only applicable for stage channels.
player no longer have seek and volume like that
i commented that but it still doesnt work
Where is joinVoiceChannel command ??
I already managed to figured it out, but still thanks. Now I have this problem: (the bot is in a StageChannel)
here, and the i call the function in the screen above
@carmine timber
still doesnt play anything
It is not async, Don't tell wrong things
oh, sorry, I thought it was
the bot join the voice channel. But it doesnt play anything
Maybe you need to await entersState like
https://github.com/discordjs/voice/blob/main/examples/basic/basic-example.ts#L75
where i have to put this?
After joinChannel command is run, make sure to make whole function async first
still doesnt work
i have this
@carmine timber
Show me where did you defined client in main file ..
my main file
Ah, fixed my problem too. Thanks!
You need one more intent.
Intents.FLAGS.GUILD_VOICE_STATE
Maybe spelling may be wrong
invalid bitfield
Intents.FLAGS.GUILD_VOICE_STATES
it works, thanks you soo much!
🙂
last question, is there a "finish" event??? like when the song end
When audio player is changing state to idle
How do i check the state?
<AudioPlayer>.on("stateChange"
event
Is there a state param?
AudioPlayerError: aborted
ytdl-core issue, wait for other package to come
Can you advise which is better than ytdl-core?
distube
getting this error, can anyone help? TypeError: song_queue.connection.play is not a function
is this correct checking for stage channel?
member.voice.channel.permissionsFor(guild.me).has(Discord.Permissions.STAGE_MODERATOR)
play is method of AudioPlayer
how do i play a .mp3 file
Create a resource with the path to the mp3 file
how do i do that
createAudioResource("…")
k
discordjs.guide results:
• Library: Audio Resources
The guide goes more into detail
k
what now
I linked it above
For example, there’s an option to enable inlineVolume (edit volume while music is playing)
m
why doesnt my bot play anything
const connection = discordvoice.joinVoiceChannel({
channelId: "CHANNELID",
guildId: "GUILDID",
adapterCreator: client.guilds.cache.get("GUILDID").voiceAdapterCreator,
});
const resource = discordvoice.createAudioResource('PATH TO MP3');
const player = discordvoice.createAudioPlayer();
player.play(resource);
connection.subscribe(player);
@icy maple
does the createAudioResource accepts YT urls?
No, you need an external library
so how do i fix this
Does it connect to the vc?
yes
and the audio resource is not a null btw
Did you enable the guild voice states intent?
uhh how do i do that
these are my current intents
{ intents: [discord.Intents.FLAGS.GUILDS] }
Add <Intents>.FLAGS.GUILD_VOICE_STATES
k
Invalid bitfield flag or number: undefined.
Does anyone know why my "@discordjs/opus": "^0.5.3" isnt updating to 0.6.0? I already uninnstalled and reinstalled
@icy maple
Prob didn’t spell it correctly. Did you put the S at the end?
at the end of what
npm i @discordjs/opus@latest
how can i get the stream like that in v13? (v12 code : const audioStream = connection.receiver.createStream(user, {mode: "pcm"});)
i have only that in v13: const stream = connection.receiver.subscribe('287876837609046016', {end: {'duration': 1000, 'behavior': voice.EndBehaviorType.AfterSilence}});
no pcm option, only encode
pls node stream and pipe knowers help
so confused, no ideas
omfg im so dumb ty
at the end of what
GUILD_VOICE_STATES
yep
Cannot play audio as no valid encryption package is installed.
@icy maple
(sorry im pinging lol)
You need @discordjs/opus or opusscript
Or actually, that said encryption
sodium, libsodium-wrappers, or tweetnacl
which one is best
sodium
link
discordjs.guide results:
• Getting Started: Installation - Extra Dependencies
thx
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node install.js --preinstall
npm ERR! Please set your Microsoft Visual Studio version before you run npm install
npm ERR! Example for Visual Studio 2015:
npm ERR!
npm ERR! For you user only:
npm ERR!
npm ERR! npm config set msvs_version 2015
npm ERR!
npm ERR! Global:
npm ERR!
npm ERR! npm config set msvs_version 2015 --global
npm ERR!
npm ERR! Supported values are 2010, 2012, 2013, 2015
i have 2019
2019 isn’t supported
See the values on the last line
soo
do i have to install 2015?
just install libsodium-wrappers, sodium is hard to install
wdym by that
ok then
how do i make it leave the voice channel once dont
*done
Prob just had to set the version as described in the error bc installation is automatic according to the package, but ok
<connection>.disconnect()
Would also .destroy() the audio player if ur not reusing it
connection.disconnect();
connection.destroy();
its not disconnecting
Hello, I was looking around and I was wondering if there is still a way to record audio from voice channels in v13?
(can someone link me to the docs or something)
@icy maple
where did you put it
setTimeout(() => {
subscription.unsubscribe();
connection.disconnect();
connection.destroy();
}, 23000)
are you trying to disconnect it once its done playing?
yes
You don't need to create a timeout.
You can just listen for the event Player#AudioPlayerStatus and destroy the connection when it's idle.
how do i do that?
You could do something like this,
player.on(AudioPlayerStatus.Idle, () => {
connection.destroy()
console.log("Finished")
})
thx
@dire cove any idea why
adapterCreator: client.guilds.cache.get("GUILDID").voiceAdapterCreator,
with the error
TypeError: Cannot read property 'voiceAdapterCreator' of undefined
why is it undefined
that means the guild is not in cache but that shouldn't be the case
manually define it, i had the same issue
it was working when in my ready function
how do i do that then?
how i did mine
?
o okie
it looks like you are using a guide i saw XD
interaction is not defined
you aren't using slash commands i assume
yes
what discord.js version?
v13
const connection = discordvoice.joinVoiceChannel({
channelId: "CHANNELID",
guildId: "GUILDID",
adapterCreator: client.guilds.cache.get("GUILDID").voiceAdapterCreator,
});
whats the "discordvoice." For?
what do you think
@discordjs/voice probably as it has the joinVoiceChannel method
There’s nothing wrong with doing it that way
TypeError: Cannot read property 'voiceAdapterCreator' of undefined
so how can i fix it then?
@icy maple
Make sure the guild id is correct
And that ur ina Client event
it sure is
im not and i cant be
how can i get the guild object then without being in a client event
wait i got an idea
Do it in the ready event
Is there any reason it’s not possible?
this may be a dumb question.. but is there a simple way to handle miniget errors? Getting some 410's intermittently
Are you using ytdl-core?
yes
Miniget error is caused by ytdl-core, go to their support server for more info
currently using js player.on('error', error => { interaction.followUp(`oops! I've shit my pants Error: ${error.message}`) }); don't mind the message content, it works, but feels semi spaghetti?
in v12 i use ${message.member.voice.channel.name} to know voice channel name then in v13 what is it ?
Same thing
Make sure you have the guild voice states and guilds intent tho
k
working perfectly now tysm
does the rtc region have to be updated to discordjs v13 ?
if(interaction.member.voice.channel)
Why this isnt working
Make sure you have the guilds & guild voice states intents. Otherwise, that is correct.
Ok
it happens with any video
idk it seems more like ytdl-core / minget issue
It is an issue with ytdl-core/miniget
How can i fix it
do you have GUILD_VOICE_STATES enabled?
What audio file formats can I play with djs-voice ?
technically any as it will pipe it through ffmpeg, but the preferred output is audio only webm opus
How do i let my bot join a vc in the new version?
Im using:
Discord.js V13
Discord.js/opus.
At V12 i did: vc.join() but that function does not exists anymore.
read the guide
Can I play .wav files?
I have that problem as well
i have
connection = await dv.joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
selfMute: false,
selfDeaf: true,
});``` but that doesnt work
it says TypeError: adapterCreator is not a function
You need to add an adapterCreator as parameter
How do i do that
oh i was checking the wrong guide
yes
TypeError: Cannot create property 'audioPlayer' on string 'https://stream.micmusicradio.be/radio/8000/radio.mp3'
what is the problem
(node:35) UnhandledPromiseRejectionWarning: Error [VOICE_CONNECTION_TIMEOUT]: Connection not established within 15 seconds.
Help
(node:1720) UnhandledPromiseRejectionWarning: #<ErrorEvent>
(node:1720) 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:1720) [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.```
how to join voice in discord.js v13
const { joinVoiceChannel } = require('@discordjs/voice'); const connection = joinVoiceChannel({ channelId: channel.id, guildId: channel.guild.id, adapterCreator: channel.guild.voiceAdapterCreator, });
does the player have a finish/end event?
i tried both and neither worked
Idle
'idle' or 'Idle'?
nvm ill test myself
oh thanks 😄
Idk, I just use the AudioPlayerStatus.Idle
Prob "idle"
discord.js v13 has so many changes I can't recognize them all XD
But the discord voice pckage works with discord js v13?
Why is none of the official examples not working ?
Whats wrong with this:
message.reply({content: `Invalid URL!`, ephemeral: true })
ephemeral is only for interaction replies
ahh
It would could be very cool if that would works :)
can i not use createAudioResource();
and directly transfer the link to the song to the player
Example:
const stream = ytdl(song.url, { filter: 'audioonly' });
player.play(stream)
No
const connection = await voiceChannel.join();
^
TypeError: voiceChannel.join is not a function``` can someone help fix this please?
From v13, we are dropping support for the existing voice codebase to focus on the new voice library instead. The new voice library may look more intimidating, but we have created a thought-out music bot example (see examples below) to help you transition your code. Using our example music player means you'll likely end up writing less voice code in your bot!
hey, how to make my bot records a voicechannel where I am and I have this to mp3?
This feature isn't documented in the Voice API by Discord and is prone to breaking quite a lot. We have basic support for it in the voice library currently, but there is still work going on to add utilities to make it easier to work with.
how can I get the bot to join a voice channel? thats all im trying to do
const { joinVoiceChannel } = require('@discordjs/voice');
const channel = client.channels.cache.get(config.voicechanneltojoin);
if (!channel) return console.log("The voice channel to join does not exist!");
let connection = joinVoiceChannel({
channelid: channel.id,
guildid: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
if (connection) {
console.log("Successfully connected to the voice channel!");
}```
this is what I have
Isnt it supposed to be camel case
Should be guild/channelId in their code, but it’s channelid
🤷♀️
but I got this error ._.
Yea, gotta fix the capitalization
Ur supposed to call subscribe with AudioPlayer, not streams
discordjs.guide results:
• Library: Audio Player
The guide goes over how to use the audio player and audio resources
hmmmmm...I have been watching this for about 30m ...but I have no idea how to fix this
djs v12 can use connection.play(xxx) but v13 can't
when i play music why does it lag
Bc music is memory intensive
const connection = await joinVoiceChannel({
channelId: message.member.voice.channel.id,
guildId: message.guild.id,
adapterCreator: message.channel.guild.voiceAdapterCreator,
});
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});
player.play(ytdl(video.url));
connection.subscribe(player);
I'm getting this error
TypeError: Cannot read property 'once' of undefined
at AudioPlayer.play (C:\Users\drangula\Desktop\zivot-mi-je-kurac\node_modules\@discordjs\voice\dist\audio\AudioPlayer.js:221:29)
at module.exports.execute (C:\Users\drangula\Desktop\zivot-mi-je-kurac\drangula.js\commands\music\play.js:42:16)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async module.exports.execute (C:\Users\drangula\Desktop\zivot-mi-je-kurac\drangula.js\events\message\messageCreate.js:25:17)
I want to make music bot but it just join voice don't play track
When the bots are running for around 24 hours, there is a ffmpeg process that remains even though all the songs are finished. What's the cause?
Is voice receiving supported yet with djs voice v13?
Error help...
player.on('error', error => {
console.log(`oops! I've shit my pants Error: ${error.message}`)
});```
so this prints the error as it should, however the bot is still joining the voicechat..
I've tried ```js
player.on('error', error => {
console.log(`oops! I've shit my pants Error: ${error.message}`)
return;
});
It's not stopping at the "return"
How would I go about playing a remote file to a voice channel?
I use this to connect to the voice channel but I'm unsure of how to play an audio file from a remote url (not youtube) to the voice channel since the api changed.
{
joinedVC = connection;
});```
of course djs voice already works with v13
i think he is talking about the audio receive
from https://discordjs.github.io/voice/:
*Audio receive is not documented by Discord so stable support is not guaranteed
Ah I see, thank you
And yes that is what I was talking about
I just can't seem to figure it out how I can simply play an .mp3 file from a remote url to a voice channel. It was pretty simple in the previous api but now it's so complicated
createAudioResource
have you tried looking at the doc for that^?
i would also like help playing an mp3 file
heres what i have so far
const { join } = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { joinVoiceChannel, createAudioResource, createAudioPlayer } = require(`@discordjs/voice`);
module.exports = {
data: new SlashCommandBuilder()
.setName('pop')
.setDescription('pop?'),
async execute(interaction) {
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
const player = createAudioPlayer();
const resource = createAudioResource(join(__dirname, '..', 'SpatialPops.mp3'));
player.play(resource);
const subscription = connection.subscribe(player);
if (subscription) {
setTimeout(() => subscription.unsubscribe(), 120_000)
}
},
};
the bot successfully joins the voice channel but doesnt play the mp3 file
I have not because I didn't know we needed to create a new object for it. I'll look into this, thank-you.
Show me code where you defined client in main file
You are missing GUILD_VOICE_STATES intent probably.
ooh, ty
good reminder to add that, but it doesnt seem to have helped
const neededIntents = new Intents();
neededIntents.add(Intents.FLAGS.GUILDS, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_VOICE_STATES);
const client = new Client({ intents: neededIntents });
heres what i have for that anyways
i wanna force my player into going idle, is there a way to do that?
you just need to make a audio resource from it and play it via a connection and player
nvm player.stop() is good enough
Using regular nodejs, is that a simple process? My process before was more or else: connection.play(request(url));
Connections are no longer responsible for playing music, that would be the job of the AudioPlayer
its a bit more complex that v12 actually, you first gotta make a connection (which is slightly diff in this version so read docs), then make the url to a source via fs and createAudioPlayer, make a player and play the source
then just sub to the player in connection
everything is much easier to understand i the guide
:/ Why did it have to become so much more complicated? That doesn't seem practical all. I've been looking at the docs trying to find exactly what I should be looking at/studying and so far I come up with nothing. Maybe it's the search terms I'm using? ["play", "stream"]
There’s also a guide for voice, it explains things better than the docs
at the top left corner of the guide, theres a seperate section for voice now
if (joinedVC != null)
{
if (typeof joinedVC.dispatcher !== "undefined" && joinedVC.dispatcher != null)
{
joinedVC.dispatcher.pause(true);
joinedVC.dispatcher.destroy();
}
joinedVC.player.streamingData.pausedTime = 0;
var streamOptions = { seek: 0, volume: 0.3 };
var dispatcher = joinedVC.play(msgObj.url, streamOptions);
dispatcher.on("end", onDiscordVoiceEndedEvent);
}
Is there anything wrong with how I have this code setup to play audio from remote URLs? What are the advantages and disadvantages compared to the guide and how the new docs specify? I find this to be similar to how it was before this last major api update and yet it still works (with minor tweaking, now I needed to npm i ffmpeg-static). I find this works for what I'm trying to do but I don't really understand why I'd go through the other more complicated method for the same results??
ClientVoiceManager#adapters
Maps guild ids to voice adapters created for use with @discordjs/voice.
what object do it return ?
as written, guild ids
example?
is there a docs for /voice ?
i dont see it
djs guide have a voice guide
How can I find out how many voice channels my bot is in?
I dont understand the voice manager on docs website
Documentation suggestion for @lofty condor:
ClientVoiceManager#adapters
Maps guild ids to voice adapters created for use with @discordjs/voice.
yes how?
client.voice.adapters
client.voice.adapters.size?
Yes
i need the amount of connections
ok thx
@carmine timber Doesnt work:
always 0
Try client.voice.adapters
What do you get ??
Bot is not connected to any vc, so it is 0
but he was connected
and always Map(0) ...
Then try this one :
let count = 0
client.guilds.cache.each((guild) => {
if(guild.me.voice?.channel) count++
else return
})
console.log(count)
ok Why the ? after voice?
@carmine timber
it works thx, but whats the diff between each and map
guild.me.voice can be null/undefined
and whats happening, if I remove the ?
it will throw error if it's null/undefined with the ? it simply makes the whole statement undefined without going further
Documentation suggestion for @lofty condor:
Optional chaining (?.)
The optional chaining operator (?.) enables you to read the value of a property located deep within a chain of connected objects without having to check that each reference in the chain is valid.
ok thx
@subtle granite #archive-voice message This works but If I disconnect the bot from voice channel. There are not 0 connected channels
still 1
You need GUILD_VOICE_STATES intent too
GuildManager#fetch()
Obtains one or multiple guilds from Discord, or the guild cache if it's already available.
@lofty condor do this before using client.guilds.cache
await client.guilds.fetch()
Ah do you mean:
let fetchguilds = await client.guilds.fetch()
let count = 0
fetchguilds.each((guild) => {
if(guild.me.voice?.channel) count++
else return
})
console.log(count)
Yes that might work
bruh...
let fetchguilds = await client.guilds.fetch()
let count = 0
fetchguilds.each((guild) => {
if(guild.me.voice?.channel) count++
else return
})
return console.log(fetchguilds)
Can you show me where did you defined client in main file ??
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_BANS, Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, Intents.FLAGS.GUILD_INTEGRATIONS, Intents.FLAGS.GUILD_WEBHOOKS, Intents.FLAGS.GUILD_INVITES, Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.DIRECT_MESSAGE_REACTIONS ],
fetchAllMembers: false,
restTimeOffset: 0,
shards: "auto",
restWsBridgetimeout: 100,
//disableEveryone: true,
partials: ["CHANNEL", "GUILD_MEMBER", "MESSAGE", "REACTION", "USER"],
allowedMentions: { parse: ['users', 'roles'], repliedUser: true }
});
how many servers bot is in ??
Try this one now :
await client.guilds.fetch()
let count = 0
client.guilds.cache.each((guild) => {
if(guild.me.voice?.channel) count++
else return
})
console.log(count)
in 15
Okay try above method
one again. Yes I did
It might be connected somewhere
no
Before it was 0 and then 1 and then 1 again whether the bot was not connected
Then IDK why is it not working
but thx
for help
no audio is actually playing, no error is returned
const {
joinVoiceChannel
} = require('@discordjs/voice');
await interaction.reply('Joining your voice channel!')
const connection = await joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guildId,
adapterCreator: interaction.channel.guild.voiceAdapterCreator,
});
const {
createAudioPlayer,
NoSubscriberBehavior,
createAudioResource
} = require('@discordjs/voice');
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});
// Subscribe the connection to the audio player (will play audio on the voice connection)
const subscription = connection.subscribe(player);
const resource = createAudioResource("../music/amazing-grace.mp3");
player.play(resource);
// Play "track.mp3" across two voice connections
connection.subscribe(player);
How to fetch a current connection?
does anybody now how to change volume?
i installed build tools but when trying to run the code, i get error Could not find any Visual Studio installation to use
do i need to download vs studio or just build tools?
Can i do something like:
if(connection){
connection.destroy()
} else return;
to prevent this from happening?
Yes you can do that with
https://discordjs.github.io/voice/modules.html#getvoiceconnection
You need to set msvs_version in npm
Just download windos-build-tools
<AudioResource>.volume.setVolume(0.5)
Do something like this :
const path = require('path')
let file_path = path.resolve("../music/amazing-grace.mp3")
let resource = createAudioResource(file_path)
Great Tysm!!!
@carmine timber
player.on(AudioPlayerStatus.Idle, () => {
try {
setTimeout(() => connection.destroy(), 300000);
} catch (e) {
return;
}
})
This worked too! But this will not be good in the long run right?
You are correct, This is not good in long run when you start creating queue mechanism
will use the getVoiceConnection
as The bot is constantly being used and not destroying the connection will cause memory leaks too
You can use client.voiceStateUpdate event to keep track of users connected to bot vc and see if they leave then run this timeout or if they join you can do
let timer = setTimeout(....)
clearTimeout(timer)
That will never create Memory issues LOL
this?
Not this one.
This one : https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-voiceStateUpdate
yeah i was talking about that one
😅
Yes 🙂
But the sounds can be played through , buttons , slash and messages too
if I destroy connection at one place , the other too throw error! That is why I wanna check if there's a connection before destroying
Then use getVoiceConnection EZ
@vocal valley May you check this alternative. IMO this is best
https://github.com/discordjs/voice/discussions/188
yeah
it returns undefined if there is no connection
that's solves your issue 😄
how do you play 2 audios at once ?
how to record a call?
I have a question regarding the setTopic and edit methods for stage channels. Both methods won't let me programmatically change the stage's topic. I've tried both methods as following:
stage.edit({ topic: "Some topic" }).catch((err) => console.log(err.message));
stage.setTopic("Some topic").catch((err) => console.log(err.message));
Both give back a success result when I log it using .then(channel => console.log(channel.topic). So no errors whatsoever. The bot has manage channels permissions as well for the roles as the channel itself. How can I change the stage topic?
I might have it
I had to create a StageInstance in order to make it able to edit, thanks.
How do I show the "shard" sum of Connected Channels?
how can I play music from url ?
Tysm, but what's that group there, I don't understand that-
Depends, if it's youtube, you could use the ytdl package from Node.js https://www.npmjs.com/package/ytdl-core
Does anyone know why I receive AudioPlayerError: aborted after some time?
The "source" argument must be type of a function, a Stream, Iterable or AsyncIterable.
Your're passing the VoiceConnection in createAudioResource while this function is expecting to be a stream (audio)
I have a similar function, but mines bit complex
can you share video too with djs?
Hey, i have a problem, my bot is playing music from a live radio station (mp3) but after a bit of time the music just freezes, when i make it play again it continues. How to fix that
Im not getting any error
which theme are you using?
Hold on, let me check
@calm steeple it's this one ^
thank you so much* <3
No problem 🙂
Is there a way to set the volume to a fixed level?
There’s setVolumeDecibels
Sweet, i'll check it out
cannot find it in the docs though
volume is handled by Prism-media
how do I make my bot undeafen itself?
AudioPlayerError: aborted
is about ytdl
Is voice receiving possible in DJS v13 as of now?
Hi. Why the bot doesnt reproduce music?
https://media.discordapp.net/attachments/766116919983079434/879162856342433822/unknown.png
https://media.discordapp.net/attachments/766116919983079434/879162889380958218/unknown.png
https://media.discordapp.net/attachments/766116919983079434/879162946050224229/unknown.png
No error in the console
You can make manual api request for YT TOGETHER though
Not djs btw...
Its always not an impossible task
Thats why rythm and mee6 ask you to mute them, so in case the bot get hacked, your privacy is dont
I'm asking because I own a bot which does transcription (voice to text) and I'm looking to upgrade it to DJS v13 soon but I'm not sure if it is even possible.
Yes it is possible.
Awesome, thank you 
What should be put here?
My target is to make the BOT send a message if any moderator disconnects it manually
discordjs.guide results:
• Library: Handling disconnects
• Library: Cheat sheet - Deletion
• Library: Life cycle
.
@carmine timber the play-dl thing looks cool, if the issue with errors after 15-20 mins gets resolved we can recommend this
If you look at the 0.6.0 release notes, there's some examples on receive audio there and also in the examples folder :)
Whats the new method to join a VoiceChannel
Thanks
Yes I am going to solve in 0.5.0. Soon, will let you know once it is released
does changing my file edit the source?
im getting opus encoded audio from yt(resource), then making the audio resource(source), then playing it
if i change the resource, does that change the source and audio?
Anyone knows a solution?
Code will let us know more about your issue
Hello, how to make the bot joins a voice channel in v13?
@subtle granite
oh, thx
Hello, I have a trouble, <AudioPlayer>.play(resource) doesn't work for me. I tried to understand why it doesn't play, and found that <AudioPlayer>.play is called, but <AudioPlayer>._state.status is still idle. Tell me if you need some additional information from me. (ping me in answer)
Probe info, audio resource info, player subscription info
Start playing message is calling before <AudioPlayer>.play(resource), info about subscription after
Why I get this error?
Error: Cannot find module '@discord.js/voice'
I installed discord.js with voice support with cmd npm install discord.js @discordjs/voice
You have installation logs?
omg... its discordjs not discord.js
I mean npm output
Apparently you have full stop after the module
It is @discordjs/voice
Okay, I fixed it, sorry XD
But why the bot doesn't join the vc?
var connection = joinVoiceChannel({
channelId: message.member.voice.channelId,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
});
connection = getVoiceConnection(message.guild.id);
console.log("jo") //works
It was problem with library that I used to get stream. After changing it from discord-ytdl-core to ytdl-core problem was fixed.
Show me your client code in main file
okay
what okay ??
Show me code
I'll show u
const client = new Discord.Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_VOICE_STATES] });
Are you sure it doesn't connect to vc ??
yes, I'm on this vc
Add this code after joinVoiceChannel code :
connection.on(VoiceConnectionStatus.Ready, () => {
console.log('The connection has entered the Ready state - ready to play audio!');
});
Tell me if it comes or not.
It doesn't come
That means something is wrong
console.log(connection) ??
<ref *1> VoiceConnection {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
debug: null,
rejoinAttempts: 0,
receiver: VoiceReceiver {
voiceConnection: [Circular *1],
ssrcMap: SSRCMap {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
map: Map(0) {},
[Symbol(kCapture)]: false
},
speaking: SpeakingMap {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
users: Map(0) {},
speakingTimeouts: Map(0) {},
[Symbol(kCapture)]: false
},
subscriptions: Map(0) {},
connectionData: {},
onWsPacket: [Function: bound onWsPacket],
onUdpMessage: [Function: bound onUdpMessage]
},
onNetworkingClose: [Function: bound onNetworkingClose],
onNetworkingStateChange: [Function: bound onNetworkingStateChange],
onNetworkingError: [Function: bound onNetworkingError],
onNetworkingDebug: [Function: bound onNetworkingDebug],
_state: {
status: 'signalling',
adapter: {
sendPayload: [Function: sendPayload],
destroy: [Function: destroy]
}
},
packets: { server: undefined, state: undefined },
joinConfig: {
selfDeaf: true,
selfMute: false,
group: 'default',
channelId: '879005309534887968',
guildId: '859816599879811082',
adapterCreator: [Function (anonymous)]
},
[Symbol(kCapture)]: false
}
So, why my bot doesn't join my vc?
voice connection not leaving signalling
Hi, hi to all!
I've switched to V 13.1.0 on DJS.. I updated my music commands but when I put a music, it stops in the middle, is it normal?
Error:
node:events:371
throw er; // Unhandled 'error' event
^
AudioPlayerError: aborted
at connResetException (node:internal/errors:691:14)
at TLSSocket.socketCloseListener (node:_http_client:407:19)
at TLSSocket.emit (node:events:406:35)
at node:net:672:12
at TCP.done (node:_tls_wrap:580:7)
Emitted 'error' event on AudioPlayer instance at:
Code :
https://pastebin.com/kKJWTgqQ
Thanks to the person who will help me!
Have a great evening!
it doesn't come from ytdl-core?
Yes it does come from ytdl only
https://github.com/fent/node-ytdl-core/issues/902
Anyone?
Nothing but giving name to bunch of connections
Oh thank you! That's what I thought! I'll look at the issuers, can this be fixed?
I am working on its alternative, I will let you know once it is fully stable
Okay, perfect! What other module can I use in the meantime?
Everything is fine, some issues like Playing long duration songs are still bugged
Module Name : play-dl
https://www.npmjs.com/package/play-dl
Okay, I have to use this module to have no or very few bugs?
I said in my module only 1 thing is bugged, rest no issues
I can confirm this
Ohh, it's your module ?
Yes
Oh okay, i'll look this
Thank you for **answering **my question!
No problem
how to make the bot join a voice channel
cause when i try it returns an error saying it's not a function is it changed at djs v13?
hello?
Yes, now you have to use the @discord.js/voice module
There is no dot in b/w discord and js
It is @discordjs/voice
woops, yeah!
So i can ignore that?
Yeah
Thanks
How to play a file in vc?
dunno about v13
Why youtube together is forever loading?
how to record audio
@carmine timber Can your package download all videos from playlist?
see the 0.6.0 release notes, and the recorder in the examples folder
It is not a downloading software, I will change its tag soon
It is audio playing system for discordjs bots.
If you want to queue all songs from a playlist, then it can do that
My bad, I just wanted the title and url of every video in playlist, not downloading
Yes it can do that

how can i make the .ogg stream into the .mp3 stream
you can use an external tool like ffmpeg
ok
How can a bot join stage
just like you would join a normal voice channel
how to upgrade song quality ?
const e = await message.react('🎙️').catch((e)=>{})
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
let resource = createAudioResource(join(__dirname, 'file.mp3'));
resource = createAudioResource(join(__dirname + '/audio/ahshit.mp3'), { inlineVolume: true });
resource.volume.setVolume(0.2);
player.play(resource);
const subscription = connection.subscribe(audioPlayer);
if (subscription) {
setTimeout(() => subscription.unsubscribe(), 5_000);
}
e.remove().catch(()=>{})
how can i make the player leave
like
player.stop just makes it idle, i wanna leave it, once the player stops playing
https://haste.ntmnathan.com/deburesibi.cs umm, did I do anything wrong?
destroy() or disconnect() on connection
Please ping me if someone can help :))
But how do u rexognise when the Player stopped playing like before u could do
The end or speaking Event but now there are nö events in the docs
i use this player.on(AudioPlayerStatus.Idle
But it will only go on idle if u call stop but idk when i need to call stop
I read the npm docs
Also the code is very messy and parsing 2 variables is not needed
mine goes in idle on song end
Oh
No , destroying the connection stops the connection itselfs
So i just need to do the getvoiceconnection(id) then get Player out of it and then the Status of it then i can see when its idle or not
I need to do subscription.unsubscribe i still dont know why u need to create a connection get the connection cause the creation Returns boolean then create a Player then subscribe with the Player then get the Status of it and then use it
And the docs are really unclear and really Bad to get i needed to do 8 clicks just to get to the docs
And the guide says different things than the docs
... what docs
the voice module doesn't have any docs on discord.js.org
the guide is actually really easy to follow, i got voice working with 1 try lmao
Thanks dude, it wasn't posted already so tyvm
Can some1 give an example of channel join
Play an file
Get the Opus stream connection Event
Emit on stop
And destroy
const channel = joinVoiceChannel({channelId, guildId, adapter}); // i forgot where adapter is taken from
const resource = createAudioResource("./pathto.mp3");
const player = createAudioPlayer();
channel.subscribe(player);
player.play(resource);
player.on("idle", () => {
channel.destroy();
// i forgot how to kill player
})```
wait
I am on confused now
Some explaination tells me that i need to get the voice connection again and destroy the Player as well as the connection and subscription what is right now?!
what he send should be working
Ok thx
is there a way to keep track of a user whenever he joins or leaves a voice channel?
we also have to create a connection right?
A few Questions:
- Is
player.stop()a Promise so i can do:player.stop().catch(console.error); - Is
VoiceConnection.destroy()a Promise so i can do:VoiceConnection.destroy().catch(console.error); - How can i add FFMPEG args
1 and 2 are not promises
3 isnt supported by the lib itself yet. But you can create ur own instance of ffmpeg
how to pause a song?
audioPlayer.pause()
I am trying to play an mp3 file called "SKYPE.mp3" and I have that audio file in the folder I've opened in Visual Studio, but I get this error code when I try to play it.
https://cdn.discordapp.com/attachments/874431116533178459/879407156355551325/unknown.png
Any idea?
This is the code I have.
what d.js version do u use
12.0.2 I think
that is what my package.json says
smh second time moving channel xd
dont ask in channels within the "version 13" category if ure using version 12
does all commands for playing/pausing and stopping music have to be in the same command file or could i have different files for different music commands?
how would i get current song name and how would i build a queue system?
these are not really djs related questions
all of that is possible but i suggest u ask in #useful-servers
but i'm using the djs voice library
thats just a part of your code
a queue system is not related to djs directly
I'm so happy right now 
Hi!
I'm trying to play some audio, however the connection state never goes beyond "signalling".
The code is based on examples, placed inside of a slash command callback, like this:
await interaction.deferReply();
let ch = interaction.member.voice.channel
if (ch) {
let conn = joinVoiceChannel({
channelId: ch.id,
guildId: ch.guild.id,
adapterCreator: ch.guild.voiceAdapterCreator
})
conn.on('stateChange', (oldState, newState) => {
let d = new Date();
console.log(d.toISOString() + ` Connection transitioned from ${oldState.status} to ${newState.status}`);
});
let p = createAudioPlayer();
p.on('stateChange', (oldState, newState) => {
let d = new Date();
console.log(d.toISOString() + ` Audio player transitioned from ${oldState.status} to ${newState.status}`);
});
let r = createAudioResource("https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3", {inputType: StreamType.Arbitrary});
let s = conn.subscribe(p)
p.play(r);
console.log("Hey!")
}
await interaction.editReply("Done")
all I get on console, is:
2021-08-23T18:35:24.996Z Connection transitioned from signalling to signalling
2021-08-23T18:35:25.000Z Audio player transitioned from idle to buffering
Hey!
2021-08-23T18:35:25.335Z Audio player transitioned from buffering to playing
2021-08-23T18:35:25.341Z Audio player transitioned from playing to autopaused
Permissions given for the bot during authorization and on the channel: connect, speak, use voice activity, priority speaker.
Scopes are: bot and applications.commands
@discordjs/voice@0.6.0
discord.js@13.2.0-dev.1629115738.9a833b1
What am I missing?
Well, figured out myself: I was missing
Intents.FLAGS.GUILD_VOICE_STATES
from Client({ intents: [ ]})
In v13, how can I end a currently playing stream without leaving the Voice Channel?
I have the same question and I have searched in the docs but I have not found anything about VoiceConnection
do you having memory leak in your bot ?
i having like a lots of it bc after the player play i want to wait about 30s if user don't call more command then the bot will leave the voicechannel 
Any ideas why/how to solve the new voice system volume adjustment not working correctly?
this is the same sound played 3 times, sometimes the volume spikes for a second for no apparent reason
I am trying to play music but my bot crashes and I get this error:prolog Error: Status code: 410pls help
឴
new discord.js voice is super unrelyable mine crashes randomly withprolog Error: abortedfor no reason
Thats not an error from the voice lib
Seems like an ytd-core error
I have one music bot done, and it's working perfect on my PC
but when I put it on my VPS (debian 20) music is just crashing
Wait if you are using ytdl-core, then you might get memory leak.
ytdl-core wont give u a memory leak if u destroy the stream properly
(node:331) UnhandledPromiseRejectionWarning: Error [VOICE_CONNECTION_TIMEOUT]: Connection not established within 15 seconds.
at VoiceConnection.authenticateFailed (/home/runner/music/node_modules/discord.js/src/client/voice/VoiceConnection.js:303:26)
at /home/runner/music/node_modules/discord.js/src/client/voice/VoiceConnection.js:324:61
at Timeout.<anonymous> (/home/runner/music/node_modules/
discord.js/src/client/BaseClient.js:83:7)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
(node:331) 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:331) [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.
Help
This is v12 voice, use #archive-djs-v12-voice-deprecated
@vocal valley Released 0.5.0 along with 15-20 mins fix
I have tested by playing 25 mins song on latest build. No issues now 🙂
I also tried and played a song for 45mins it seems pretty stable 👍
Quick Note : player.stop() actually stops streaming 🙂
code?
show me code where you defined client in main file ??
I told defining of client in main file. Not Music Subscription
Okay, now it is clear that you have guild Voice State,
Now create Player like this :
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Play,
},
});
if (queue.current) embed.addField("**CURRENT TRACK**", `${queue.current.title.split("[").join("\[").split("]").join("\]").substr(0, 60)} [${track.isStream ? "LIVE STREAM" : format(track.duration).split(" | ")[0]}]\nby: ${queue.current.requester}`);
TypeError: Cannot read property 'isStream' of null
It is related to your track code, nothing related to djs-voice in anyway
You have to make a queue mechanism which will create next resource and play it automatically.
If you already have a queue mechanism, just put the song back to first and play it EZ
Hey, I'm having problems playing audio, everything from the slashcommand to the embed works fine but the audio still doesnt play: https://sourceb.in/fc2WMFUtoC
Hey can you show me where you defined client in main file ??
yeah, sure here is the sourcebin: https://sourceb.in/Et7ClQl4JN
You need Intents.FLAGS.GUILD_VOICE_STATES also
Omg, thanks now it works. Do you also know why it says This Interaction failed, when it started playing?
Maybe ask this in #archive-interactions
ok, I will do thanks 😄
No issue 👍
Just curious, have you tried my package ?? [ play-dl ]
It will never give memory leak like ytdl-core 🙂
i have not
how do i make this, when a user join the voice channel its create the new channel
Thxxx
(event) Client#voiceStateUpdate
Emitted whenever a member changes voice state - e.g. joins/leaves a channel, mutes/unmutes.
Documentation suggestion for @trail belfry:
(event) Client#voiceStateUpdate
Emitted whenever a member changes voice state - e.g. joins/leaves a channel, mutes/unmutes.
I am having this Code, but its not working with Stage Channels, like the bot does connect, but doesnt speak and doesnt disconnect either! HOW CAN I FIX THAT?!?! I want him to speak in stage channels, if possible ofc
let VoiceConnection = joinVoiceChannel({channelId: channel.id,guildId: channel.guild.id,adapterCreator: channel.guild.voiceAdapterCreator});
const resource = createAudioResource(path.join(__dirname + `/audio/${CmdName}.mp3`), {inlineVolume: true});
resource.volume.setVolume(0.2);
const player = createAudioPlayer();
VoiceConnection.subscribe(player);
player.play(resource);
player.on("idle", () => {
try {player.stop();} catch (e) {console.log(String(e).grey.italic.dim)}
try {VoiceConnection.destroy();} catch (e) {console.log(String(e).grey.italic.dim)}
});
show me where did you defined client in main file ??
Oh, I forgot that. I will definitely update that for playlist also
i get TypeError: adapterCreator is not a function when tying to join a voice channel
How does this new system work?
npm i @discordjs/voice@latest
i already have the lastest
Do npm ls @discordjs/voice
i already have the lastest
@ebon trout Just show me this
WHAT
Wait, I changed Video Class, so the property should be changed since getPlaylistVideos return Video[]
this var : let voiceChannel= cmd.message.member.voice.channel
is not updated when i join a channel
i dont undestand why
if you want i can show my code but its long
const client = new Discord.Client({
//fetchAllMembers: false,
//restTimeOffset: 0,
shards: "auto",
//shardCount: 2, //enable if you wanna manually define the Shardcount
disableEveryone: true,
partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
intents: [ Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_MEMBERS,
Discord.Intents.FLAGS.GUILD_BANS,
Discord.Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
Discord.Intents.FLAGS.GUILD_INTEGRATIONS,
//Discord.Intents.FLAGS.GUILD_WEBHOOKS,
Discord.Intents.FLAGS.GUILD_INVITES,
Discord.Intents.FLAGS.GUILD_VOICE_STATES,
Discord.Intents.FLAGS.GUILD_PRESENCES,
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
//Discord.Intents.FLAGS.GUILD_MESSAGE_TYPING,
],
presence: {
activity: {
name: `${config.status.text}`.replace("{prefix}", config.prefix),
type: config.status.type,
url: config.status.url
},
status: "online"
}
});
Wait, does your bot plays music after making him speaker in stage ??
You need GUILD_VOICE_STATES for it to update
He joins in the stage and listens, i want him to be speaker
What happens when you manually make him speaker ?? Does he plays music ??
@subtle granite ??
If that questions answer is yes. Then you need to add one more code
Documentation suggestion for @subtle granite:
VoiceState#setSuppressed()
Suppress/unsuppress the user. Only applicable for stage channels.
how ?
Show me code where you defined client in main file
const bot = new Client(
{
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
}
);
Intents.FLAGS.GUILD_VOICE_STATES add this also
thanks
why is this not working for me
Show me code where you defined client in main file
How can i get the event on("finish") with the new player?
What is otherIntents ??
<AudioPlayer>.on(AudioPlayerStatus.Idle, () => {
//song finished
})
What is channel defined here ??
awesome, thanks!
oh, i forgot, thanks.
Oh LOL
thx
my friend is a subscriber
Guys im having trouble download discord.js/opus
im using distube, and it keeps downloading discord.js/opus. Discord.js/opus is not installing for me. I believe its a arm chip issue.
Hey, I just can't deal with voice-thing right now. What I want is a bot that immediately goes into a voice channel when it is started and plays the music of a m3u-adress or PlS-adress there. That's all the bot should be able to do. I would also be happy if the bot could play on several servers at the same time.
Why does createAudioResource not throw an error when given invalid audio file?
Why does VoiceConnection.receiver.subscribe not throw an error when given invalid userid (such as undefined)?
has anyone got the VoiceReceiver to work btw?
what is the equivalent of connection.receiver.createStream in discordjs/voice?
it's supposed to be VoiceConnection.receiver.subscribe but the stream just gets no data
i tried to do that and write the stream to a file and it does but the file is unusable
huh
how can I get channel.guild.voiceAdapterCreator
Is it possible to uninstall ffmpeg-static in discordjs@voice? I have it installed on heroku but with the extra ffmpeg it doesn't work
└─┬ @discordjs/voice@0.6.0
└─┬ prism-media@1.3.1
└── ffmpeg-static@4.4.0
Prism media first checks if there's an ffmpeg in path and then checks if there's avconf and then checks for ffmpeg-static. If the ffmpeg was in the path, then that ffmpeg is what's causing issues
ffmpeg-static should be fine
Uh sorry im not really understanding. So the ffmpeg there is fine?
I have ffmpeg installed on heroku which worked b4 i installed discordjs@voice
No. If the ffmpeg in path works, then it caches that command to access ffmpeg at a later time. If it doesn't work then it repeats that for avconf and then ffmpeg-static
If ffmpeg on path is successful in getting cached then it'll try to use that first. If that is what's getting cached and that ffmpeg isn't working, then it's an issue with the ffmpeg in the path
Oh so the heroku ffmpeg i installed is not working.
Great ty
most likely. Try with just ffmpeg-static. The performance difference shouldn't be that substantial. Besides, I wouldn't recommend audio processing on a heroku instance
I have it just that normal ffmpeg-static doesn't work on heroku. Ill try again. Thanks for the help tho!
Hi, how to make music commands?
That is possible 🙂 with new voice
Ask distube authors, we don't support 3rd plugins
Are there no docs for this?
Thanks
Have u checked out the example voice recorder?
The receiver doesn't always have user IDs - they sometimes get discovered once users start speaking. Since it has no way of telling whether a user for the given ID actually exists, there isn't much it can do
You should make sure that you pass it a valid ID to avoid this
@vocal valley Did you check out play-dl ??
Is it ready for recommendation ??
What about FFMPEG PR ??
I haven't yet, I work full time during the week and then I have been busy the last few weekends so I haven't had chance to look
Okay no issues, So what about FFMPEG PR ??
I didn't like your tone in the last message so I closed it 🙂
I was waiting for your re-review for so long. That I became impatient at last, so wrote that
I was waiting for your review for more than 10 days.
I thought you never need this. So I first closed it by myself. Then I re-opened it to check if you will review or not.
You need to be a bit more patient, PRs to the main repo can remain open for even longer than 10 days and since not many/any of the main contributors also look after the voice repo, it can take longer
That being said, for your PR specifically, the comment with 3 👍 , I do agree with it, it seems weird to offer properties for some FFmpeg arguments directly, and then others are excluded
Crawl has suggested a good fix is basically to just expose the PCM and OPUS args for others to use
@vocal valley help me #archive-djs-v12-voice-deprecated
I wanna make a music bot in v13 where should I start, you can just send the documentation.
At least, you should have mentioned that It is in progress [ I would have drafted the PR ], just not saying anything about the progress or about the issues leads me to thinking that you don't require anything from the PR. I asked for re-review, you should just have said I got a workaround this problem, I would be satisfied. Just ignoring the work and efforts that I have put, is not a good solution to a problem IMO.
I have not ignored your work and efforts
Closing your PR and then re-opening with a dramatic message is not something i want in this repository
So you should have said I got a workaround this problem
I did not give it any more thought until today
If you'd like your PR to be merged quicker, feel free to start a separate fork of the repo
But as you mentioned, you agree to that 3rd comment, so you should have said when I asked for re-review that This is a valid point and we need to think about it
I agree to the 3rd comment now that I actually read it
It was forked only
This only means that you haven't read for the past 16 days 🙂
And you are saying that you are not ignoring my works and efforts
You are ignoring me repeatedly telling you I'm busy with other commitments
i'm not going to argue on this any more
Okay 👍
Can u set ffmpeg args with the audioresource?
After something is playing for like 10 minutes, it gets aborted, why?
ytdl-core issue
yes
oh ok
Maybe try shifting to other package
how i am using discord-ytdl-core cause the player wont play as soon as i add encoderArgs
Ask authors of discord-ytdl-core not me
I use youtube-dl-exec and simple-youtube-api for fetching track info. Faced no error after then.
Still using youtube-dl HAHA
No i mean how do i add encoderArgs to audioresource
using prism-media FFMPEG instance
and how do i stop the player without disconeccting, like i wanna skip?
thanks mate
player.stop()
Whats the properrtyß?!?!?! i cant find it in the docs
this stops the whole player not just the current track! i have a custom queue system
Do you have any suggestion?
play-dl
All in one package
youtube-sr, or ytsr
SIR you are using a third party package, so better ask these question to their authors. Officially, player.stop() will stop current resource only
dude, i just use discord-ytdl-core to create a stream
const stream = ytdl(song.url, {
inlineVolume: true,
filter: "audioonly",
opusEncoded: true,
encoderArgs: encoderArgstoset,
bitrate: 320,
quality: "highestaudio",
liveBuffer: 40000,
highWaterMark: 1 << 32,
});
let resource = Voice.createAudioResource(stream, {
inlineVolume: true,
metadata: song
});
resource.volume.setVolume(queue.volume / 100);
Where is audioPlayer ??
if(!queue.connection){
const connection = Voice.joinVoiceChannel({
channelId: queue.voiceChannel.id,
guildId: queue.voiceChannel.guild.id,
adapterCreator: queue.voiceChannel.guild.voiceAdapterCreator,
});
queue.connection = connection;
if(!queue.player){
queue.player = Voice.createAudioPlayer();
}
//Connection Ready
queue.connection.on(Voice.VoiceConnectionStatus.Ready, () => {
console.log('The connection has entered the Ready state - ready to play audio!');
const subscription = queue.connection.subscribe(queue.player);
queue.player.play(resource)
});
} else {
queue.player.play(resource)
}
So do queue.player.stop()
https://discordjs.github.io/voice/classes/audioplayer.html#stop
Hello Tomato 
This will stop the bot and double fire the destroy event
Doesn't the @discordjs/voice have it's own queue?
If it double fire the event, so you are attaching a event in a loop somewhere
No, but it has its examples which has queue system.
then why does the player stop when i stop the song
How do you stop the song ??
player.stop();
wait
should i define a player / Guild or just / BOt
What kind of event emit when guild manager deport the bot from the voice channel?
player.pause()
your own package
Yes
what happens when I give it a valid id, but the user with that ID hasn't spoken yet? Will it start receiving their audio once they do? And really it should throw for obviously invalid stuff like undefined
Yes, once they start speaking it should receive
Passing undefined is already disallowed by the type signature of the method tho
It's up to the developer to make sure they're passing the right types of variables
ig its on me for not using typescript
if you use vsc, you can enable checkJS and strict type checking in the settings for JS
player.on(Voice.AudioPlayerStatus.Playing ...
fires tho the player is not playing
What to do?
cause i am doing player.stop()
and it emits playing next song
but it doesnt
player.stop()
to skip^^
player.on(Voice.AudioPlayerStatus.Idle, () => {
if (queue.connection) {
if(queue.songs.length > 0){
if (queue.loop) {
let lastSong = queue.songs.shift();
queue.songs.push(lastSong);
console.log("QUEUE LOOP")
player.play(getResource(queue.songs[0], queue, queue.filters));
} else if (queue.songLoop) {
console.log("SONG LOOP")
player.play(getResource(queue.songs[0], queue, queue.filters));
} else {
queue.songs.shift();
console.log("NO LOOP", queue.songs)
player.play(getResource(queue.songs[0], queue, queue.filters));
}
} else {
try {
queue.connection.destroy();
} catch (e) {
console.log(String(e).grey)
}
if (player) {
try {
player.stop();
} catch (e) {
console.log(String(e).grey)
}
}
client.queue.delete(message.guild.id);
return queue.textChannel.send({
embeds: [new MessageEmbed().setColor(ee.wrongcolor).setFooter(ee.footertext, ee.footericon).setTitle(`:stop_button: **Music queue ended!**`)]
})
.catch((e) => {
console.log(String(e).grey);
})
}
}
});```
my idle event
I am trying since hours now to make the bot join a voice channel and play a local opus file, why the hell is it so complicated ? I used to do that with the dispatcher with v12 but now I am not able to make the bot even join the voice channel, any ideas ? or maybe an example please ? And please do not link the discord.js guide becuase I read it and it did not work out for me
Yeah its really weird
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});```
Hello, I am a begginer and I want to ask, what is this "channel.guild.voiceAdapterCreator"?
const connection = Voice.joinVoiceChannel({
channelId: queue.voiceChannel.id,
guildId: queue.voiceChannel.guild.id,
adapterCreator: queue.voiceChannel.guild.voiceAdapterCreator,
});`
teachnically this builds the connection okay? Aka make the bOt join the talk!
Then u gonna greate a player and once the connection is sublished, u play your source!
const player = Voice.createAudioPlayer();
//Connection Ready
queue.connection.on(Voice.VoiceConnectionStatus.Ready, () => {
console.log('The connection has entered the Ready state - ready to play audio!');
const subscription = queue.connection.subscribe(player);
player.play(resource)
});
Just leave it, idk its just from the guild voice settings, its right as it is
You have to use the guild's adapter creator or write your own adapter to send websocket messages based on your shard.
Sending audio is a bit more tricky since the library makes no assumptions of your environment since it's modular
ok, ty
ty too
const avc = await discordjsvoice.getVoiceConnection(
interaction.member.voice.guild.id
);
avc.play(ytdl(interaction.options.get("mit").value, { filter: "audioonly" }), {
seek: 0,
volume: 1,
})
it throws avc.play is not a function
Examples in the repo
I cant paly with the connection, u need to play with the player
That's deprecated and unreadable cause typscript compilation (a_, b_, c_ ) etc.
we have a basic example
i have ffmpeg and ytdl, how can i do it?
Granted it uses discord.js v12, but you should be able to pick out the voice parts
The basic example is in pure JavaScript
const player = createPlayer();
connection.subscribe(player)
player.play(resource)
Aha, could u explain me, why the skipping doesnt work at all???
Like
Sorry don't have the time to read through it atm :(
I'd suggest comparing it to the example queue code and seeing what's different
I am having this event:
player.on(Voice.AudioPlayerStatus.Idle, () =>
when i am calling:
player.stop() This events fires twice
Why couln't u just write a proper documentation?
I wrote examples, guide, and tsdocs
what else do you need 😭
There are 4 examples too
You are looping this event somewhere.
Maybe when starting next resource
No I am not
i am having trouble skipping as well 😦 will check out the repo
So tell me one thing, it does fire event twice on very 1st song ends ??
no, it fires twice when i am using the player.stop()
If the player is already idle and calling player.stop() causes it to re-emit the idle event, this is a bug
If this is the case you can report it on the issue tracker 👍
This is my src code, which proves i can only have 1 event at the same time
What works for skipping is:
player.stop()
player.play(RESOURCE)
but not using the event
But then error event fires
If you want to skip, you don't have to .stop() first
You can just do .play(resource) and it will play the new resource instead
What now?
People say, i should stop for skip
It depends on your queue logic
If you are following the example code, then yes doing .stop() will work
I am using crawl's Queue System
Where is this?
in voicelink?
He created it back in 2017
in his yt channel
I am now trying to adapt it on my old music bot
I would really suggest just going through the music bot example and seeing how the queue works there, basically:
- add event listener to player, so when it stops playing something, it checks to see what's in the queue and plays that
- to skip, all you have to do is stop() and then the above will take care of playing the next song if there is one
Well i tried, but they dont even start playing the music so i can't use them
If crawls example is from 2017 I'm not sure it would be the best for this library, since it was presumably built around d.js built-in voice
ok, but first just try running the example as it is using the instructions in the examples folder
i did
If that doesn't work, then there is an issue on your end like missing ffmpeg/opus
but youtube-dl-exec fails and the Track Class, no classes are valid
The track class should work
That doesn't look like the exact same example to me
I downloaded typed npm run thats it
I mean cloning voice repo, cd-ing into examples/music-bot and following instructions in the README
I did
wait imma make vid
Ok, let's make a thread
thanks, but how do i create a player, it says its not a function
@carmine timber fwiw voice guide links are now live at https://discordjs.guide/voice/
AudioPlayerError: aborted why i take this error
ytdl-core issues
Ok thanks
oh but what should i do
Switch to other package like play-dl
Does this Package have like a opus stream converter?
thx
Actually, it gets opus streams directly from youtube .
not possible
if u dont download it
Possible, try my package
i've not had a chance to use it myself but a few people have said play-dl is working well for them
Yes 🙂
how did you manage to fix the download issues that ytdl-core has? 👀
I loop the videos longer than 5mins by using range headers and getting data again after 5mins
ahhh
nice
could be worth fixing that in ytdl-core directly too 👀
Yes Then I would not be making a new package then
why should ytdl-core have download issues, i mean what do u download with it?!
And why can't u do anymore:
play(ytdl(url)
why do u need to make a resource out of an opus stream
play(resouce(stream(ytdl(url))))
Moreover, I use a single PassThrough, so if someone does player.stop() It will destroy stream completely. Not like ytdl-core which uses multiple PassThrough and each passthrough should be closed to solve memory issues.
no i am going to cry nothing that i try work, literally
I even tried skipping by my own, either the playing state or the idle state always fires twice
even with the example bot
imma use v12 again
i mean great idea on paper but not great on work, i would understand if it would be beta but it isnt
play-dl is too complicated
What do you mean ??
It is just 2 lines of code to play songs
idk
What do you not understand in play-dl ??
difference between url and text
I dont udnerstand either, how do i create a stream and how do i add highWaterMarks etc.
No need to add highWaterMark,
Just create stream like :
let stream = await youtube.stream(url)
let resource = createAudioResource(stream.stream, {
inputType : stream.type
})
What is difficult here ?? I can't understand
NO there is a need`
{
filter: "audioonly",
opusEncoded: true,
encoderArgs: ['-af', 'dynaudnorm=f=200,gain=50db'],
bitrate: 320,
quality: "highestaudio",
liveBuffer: 40000,
highWaterMark: 1 << 32,
}
I need those exact settings
You can't add those in play-dl. But without those options, you will get best quality streams
Then using FFmpeg is useless
FFMPEG is useful for livestreams only
No
FFMPEG is for audio manipulation aka filters
keep in mind that this is djs-voice support. Not play-dl support
IK AND MY VOICE doesnt WORK
Just pass stream.stream to FFMPEG prism media EZ
for filters
But then i would need to again stop the player and restart it within playing, aka useless
Ok go for ytdl-core.
nah
i will go to discord.js@12.5.3
URL is youtube url
While search is searching on youtube and getting its url
Can any1 finally give me an answer to the Question:
Do you need to define Players Per Guild or GLOBALLY
Per guild:
const players = new Map();
players.set(guildId, player)
Globally
client.player
sound quality of play-dl is better than ytdl-core nice
👍
dont use playin ytdl-core
use discord-ytdl-core
i like this module
yeah, but how?
keep in mind that this is djs-voice support. Not play-dl support
same way then the old way just with the step of resources
create an opus stream pipe, from that craete a resource and use the resource
is there a validateURL method in play-dl like in ytdl-core?
in the documentation, i dont find a way, how to play m3u file
ok, i try... Hope it works
const Discord = require("discord.js");
const client = new Discord.Client({
intents: [Discord.Intents.GUILDS, Discord.Intents.GUILD_VOICE_STATES, Discord.Intents.GUILD_MESSAGES]
});
const { DartVoiceManager } = require("dartjs");
const voiceManager = new DartVoiceManager(client);
const ytdl = require("ytdl-core");
client.on("ready", () => console.log("Bot is online!"));
client.on("messageCreate", message => {
if (message.author.bot) return;
if (message.content === "!play") {
voiceManager.join(message.member.voice.channel)
.then(connection => {
const dispatcher = connection.play(ytdl("https://www.youtube.com/watch?v=dQw4w9WgXcQ"));
dispatcher.on("start", () => message.channel.send("Music started!"));
dispatcher.on("finish", () => {
connection.disconnect();
message.channel.send("Music finished!");
});
});
}
});
client.login("XXX")
``` My rescue!
so i did it like this:
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
const { DartVoiceManager } = require("dartjs");
const voiceManager = new DartVoiceManager(client);
voiceManager.join(client.channels.cache.get("624289094595379215"))
.then(connection => {
const dispatcher = connection.play("http://stream.laut.fm/radiovelbert.m3u");
});
client.login("-----------------");
and i have this error:
Error: Voice channel was not provided!
What can i do?
but i use djs13
I just got told, that its the same way
Who said, connection.play is in v12 ??
i don't know what you mean....
But is there any other command to use in DJS13?
yeah i know, but wich command to play a file? i don't find it in there
ok
thanks
but now i get this error:
throw new Error('FFmpeg/avconv not found!'); ^Error: FFmpeg/avconv not found!
i installen ffmpeg with "npm i ffmpeg"
do i have to import it in any way?
Debug dependencies for me
https://discordjs.guide/voice/#debugging-dependencies
what is the best music player package for djs-voice
it sais
FFmpeg
- not found
But i have ffmpeg and used npm i ffmpeg
You need ffmpeg-static
Do npm i ffmpeg-static
oh
so now i don't get an error,but i also dont hear anything.
This is my code:
client.on("ready", () => {
console.log("joining");
const connection = joinVoiceChannel({
channelId: "624289094595379215",
guildId: "624289094595379211",
adapterCreator: client.guilds.cache.get("624289094595379211").voiceAdapterCreator,
});
console.log("joined! creating audio source");
const resource = createAudioResource('http://stream.laut.fm/radiovelbert.m3u');
console.log("start playing");
player.play(resource);
})
connection.subscribe(player)
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Discord.Intents.GUILD_VOICE_STATES] });
const { DartVoiceManager } = require("dartjs");
const voiceManager = new DartVoiceManager(client);
client.on("ready", () => {
client.channels.fetch("624289094595379215").then(voiceChannel=>{
voiceManager.join(voiceChannel)
.then(connection => {
const dispatcher = connection.play("http://stream.laut.fm/radiovelbert.m3u");
});
}).catch((e)=>{
console.log(e)
})
})
client.login("-----------------");
this is it now:
client.on("ready", () => {
console.log("joining");
const connection = joinVoiceChannel({
channelId: "624289094595379215",
guildId: "624289094595379211",
adapterCreator: client.guilds.cache.get("624289094595379211").voiceAdapterCreator,
});
console.log("joined! creating audio source");
const resource = createAudioResource('http://stream.laut.fm/radiovelbert.m3u');
console.log("start playing");
player.play(resource);
console.log("playing on the server");
connection.subscribe(player)
})
Doesn't work
i dont hear anything
it joins, but i don't hear it
Show me where did you defined client in main file
this is everything:
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
const { joinVoiceChannel, createAudioResource } = require('@discordjs/voice');
const { createAudioPlayer } = require('@discordjs/voice');
const player = createAudioPlayer();
client.on("ready", () => {
console.log("joining");
const connection = joinVoiceChannel({
channelId: "624289094595379215",
guildId: "624289094595379211",
adapterCreator: client.guilds.cache.get("624289094595379211").voiceAdapterCreator,
});
console.log("joined! creating audio source");
const resource = createAudioResource('http://stream.laut.fm/radiovelbert.m3u');
console.log("start playing");
player.play(resource);
console.log("playing on the server");
connection.subscribe(player)
})
client.login("--------");
Add this intent : Intents.FLAGS.GUILD_VOICE_STATES
like this?
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS,Intents.FLAGS.GUILD_VOICE_STATES] });
const { joinVoiceChannel, createAudioResource } = require('@discordjs/voice');
const { createAudioPlayer } = require('@discordjs/voice');
const player = createAudioPlayer();
client.on("ready", () => {
console.log("joining");
const connection = joinVoiceChannel({
channelId: "624289094595379215",
guildId: "624289094595379211",
adapterCreator: client.guilds.cache.get("624289094595379211").voiceAdapterCreator,
});
console.log("joined! creating audio source");
const resource = createAudioResource('http://stream.laut.fm/radiovelbert.m3u');
console.log("start playing");
player.play(resource);
console.log("playing on the server");
connection.subscribe(player)
})
because also with that i don't hear anything
so it joins like every time but also doesn't plays
Is there an event like finish?
the docs seem to indicate that it goes playing -> idle
@vocal valley Did you heard Google-groovy Lawsuit ??
What are your opinions ??
hi, so this is the example from discord.js guide on how to create a connection but what am i actually supposed to give to adapterCreator ? cuz i tried different things but it always says "adapterCreator is not a function". Can anyone help plz ?
thx
ytdl-core issue
how did u know?
scary for music bots, now that discord is getting youtube built-in i think music bots will struggle
but not awful for voice, there is still receive and playing non-youtube audio
yeah
Is it possible to play a radio stream? Like http://stream.laut.fm/cavefm.m3u ?
hi, so this is the example from discord.js guide on how to create a connection but what am i actually supposed to give to adapterCreator ? cuz i tried different things but it always says "adapterCreator is not a function". Can anyone help plz, im lost?
how can i fix it ?
Find a different package for streaming stuff
@carmine timber this problem from discordjs not ytdl bro
AudioPlayerError
You can check out different package and see if problem comes or not
AudioPlayer is also playing a ytdl-core resource, so it is ytdl-core issue
what does dartjs do? ive seen it a few times on people's code when they ask for help
seems to try to take the separated voice lib and make it so using it is similar to how v12 was
hey, my bot doesn't play anything
Code:
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS,Intents.FLAGS.GUILD_VOICE_STATES] });
const { joinVoiceChannel, createAudioResource, createAudioPlayer } = require('@discordjs/voice');
const request = require('request');
const fs = require("fs");
const player = createAudioPlayer();
request('https://radiovelbert.stream.laut.fm/radiovelbert?pl=m3u&t302=2021-08-25_18-28-32&uuid=897b07a2-550b-4b93-8de8-5feccb7a0071').pipe(fs.createWriteStream('live.mp3'));
client.on("ready", () => {
async function play(){
console.log("joining");
const connection = joinVoiceChannel({
channelId: "624289094595379215",
guildId: "624289094595379211",
adapterCreator: client.guilds.cache.get("624289094595379211").voiceAdapterCreator,
});
console.log("joined! creating audio source");
const resource = createAudioResource('live.mp3');
console.log("start playing");
player.play(resource);
console.log("playing on the server");
connection.subscribe(player);
}
play();
})
client.login("---");
He joins into the channel, but doesn't play anything
Console output:
joining
joined! creating audio source
start playing
playing on the server
oh that makes sense now, thanks
@carmine timber i tried in another package 📦
and didn’t work
can someone help me ?
https://cdn.discordapp.com/attachments/824411059443204127/880115584103219211/image0.jpg
Use this 😉
const Discord = require("discord.js");
const ffmpeg = require("ffmpeg");
const opusscript = require("opusscript");
const fs = require('fs');
const request = require('request');
const { joinVoiceChannel, createAudioResource, createAudioPlayer } = require('@discordjs/voice');
request('https://listen.cavefm.eu/main').pipe(fs.createWriteStream('live.mp3'));
exports.run = (client, message, args) => {
const player = createAudioPlayer();
const member = message.member;
if (member.voice.channel) {
const channel = member.voice.channel;
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
message.reply('Connected! Playing..');
const resource = createAudioResource('./live.mp3');
player.play(resource);
connection.subscribe(player);
} else {
message.reply('You are not in a voice channel!');
}
};
But replace cavefm with yours
you also need ffmpeg-static
Which package ??
Maybe try play-dl. That will fix your issues.
hello guys sorry
i had a problem to connecting my bot to my voice channel
i used channel.join() bot it didn't work why?
read the new voice documentation
that has been removed
where is that?
oh i should install @discord/voice right?
yes
yes
there is no built in voice support in discord.js anymore
oh ok tnx a lot


@discordjs/voice
yes dont forget the js
hi, how to make a music bot
i don't understand ts
dude i fixed it but when i give a link for playing my audio it starts playing and after some minutes or secs it stop playing music and i should give link again
why is that?
do anybody know what should i do or why bot act link that?
how can i play a voice in a channel when the bot is ready?
const ffmpeg = require("ffmpeg");
const opusscript = require("opusscript");
const fs = require('fs');
const request = require('request');
const { join } = require('path');
const { createReadStream } = require('fs');
const { joinVoiceChannel, createAudioResource, createAudioPlayer, StreamType } = require('@discordjs/voice');
exports.run = (client, message, args) => {
const player = createAudioPlayer();
const member = message.member;
if (member.voice.channel) {
const channel = member.voice.channel;
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
message.reply('Connected! Playing..');
let resource = createAudioResource(join(__dirname, 'live.mp3'));
resource = createAudioResource(createReadStream(join(__dirname, 'live.webm'), {
inputType: StreamType.WebmOpus,
inlineVolume: true,
}));
player.play(resource);
connection.subscribe(player);
} else {
message.reply('Nu esti pe canal bedboi');
}
};```
I am using this, and the bot connect to the channel, but it's not playing anything
How can I fix that?
is it possible to fetch the audio player outside of the command file and possibly do player.stop() or something?
can someone help me please ?
https://cdn.discordapp.com/attachments/844185086613258290/880049376184131584/image0.jpg
what were you trying to do?
I’m trying to play a yt video in some channels 😐
is it a stream?
if you are using ytdl-core then i heard something about it having problems with playing streams
how can I console.log current VoiceConnectionStatus?
ummm i have asking for their support about this but they tell me its a part of discord.js
@amber epoch
don't know
have you tried just doing console.log(VoiceConnectionStatus) ?
can you show me your code?
nope
const { joinVoiceChannel } = require('@discordjs/voice');
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
})
const play = () => {
const resource = createAudioResource(
ytdl(
'https://youtu.be/M6z0Qql4-qo',
{
filter: 'audioonly',
opusEncoded: true,
encoderArgs: ['-af', 'bass=g=10,dynaudnorm=f=200']
}), {
type: "opus",
bitrate: "auto"
})
player.play(resource)
connection.subscribe(player);
player.on(AudioPlayerStatus.Idle, play)
player.on('error', console.log)
}
play()
@amber epoch
i m not sure but it might be the AudioPlayerStatus part
https://discordjs.guide/voice/audio-player.html#taking-action-within-the-idle-state
bro its playerError
are you using the latest ytdl-core?
yes i swear bro
then i have no idea
try and look at the docs and or the guide maybe you can figure it out
Hi, how to make music commands? ping me
How does one get the remaining duration of the audio resource?
Would it be this property? I struggle to understand what playback duration necessarily means
It’s how long it has been playing
The total time has to be obtained by other means, then you can subtract both of them to get the remaining time
I see. Thank you.
AudioPlayerError: aborted
const queue = client.queue.get(guild.id);
if (!song) {
queue.connection.disconnect();
client.queue.delete(guild.id);
return;
}
const ytDL = ytdl(song.url, {
filter: "audioonly" ,
opusEncoded: true
})
const stream = createAudioResource(ytDL,{
type:"opus",
bitrate:"auto"
})
var p = await queue.player.play(stream, {
seek: 0,
volume: 0.5
})
queue.player.on(stream.ended,()=>{
queue.shift()
play(guild,queue.songs[0])
});
queue.connection.subscribe(queue.player)
queue.tc.send({
embeds: [
new Discord.MessageEmbed({
"color": "#000099",
"description": `Now playing (\`${song.title}\`)!`
})
]
})```
Am I doing something wrong
(Other than stream.ended after some testing, but it appears to cause the error in playing a lot.)
I saw a person mention it could be a ytdl-core error, is there an alternative?
I told you try play-dl
I'll try that alternative, thank you.
search a yt tutorial on it or something, but i prefer you learn js first before continuing, i also recommend you to read djs docs, there's alot of useful stuff in there that could help you out
Your code is also a kinda wrong
Where would it happen to be wrong?
In creating audioResource and Player.play function
TypeError [ERR_INVALID_ARG_TYPE]: The "source" argument must be of type function or an instance of Stream, Iterable, or AsyncIterable. Received an instance of Stream
So it has to be an instance of stream, iterable, asynciterable, or a function; and when I use my stream it doesn't appear to work.
That's an interesting error.
I think I did find the ultimate issue involving it, which was my mistake in code. A tiny typo.
Nevermind.
The error is on this.audioPlayer's line I should clarify
To those wondering: The fix is simple and I forgot to do something involving play-dl's own docs. I was scrolling through my test code which worked fine and comparing it to this code, it turns out I forgot to do .stream after this.dl_stream.
subscribe before u play