#archive-voice
30636 messages · Page 8 of 31
🙂
Would you need FFMPEG to use this module?
Yes
Okay, thank you.
As in the guide, it says FFMPEG allows you to play multiple formats.
Need more clearly guide for discordjs/voice in v13 tbh
how do i get the subscribed audioplayer through the getConnection metjhod
audioPlayer.on('stateChange', (oldState, newState) => {
if (newState.status === AudioPlayerStatus.Idle && oldState.status !== AudioPlayerStatus.Idle) {
processQueue();
}
})
audioPlayer.on(AudioPlayerStatus.Idle, (oldState, newState) => {
processQueue();
})
Which one is better to check the song finished?
obio the second one, its shorter, no need to ask this
I asked the question because the example was like the code above. Are they in the same way?
yes
Thanks
Even though the song is finish, both codes are not sometimes emitted, so the queue does not go on. What is this problem?
how to make the bot joins a voice channel?
thank you
I checked the phenomenon of moving to idle before the song was finished.
With the new voice package, do i still need the opus package?
ok
I want to see docs for voice, where to find
see pins
Thank u
/home/container/src/commands/Music/skip.js:33
queue.connection.stop();
^
TypeError: queue.connection.stop is not a function
at Object.execute (/home/container/src/commands/Music/skip.js:33:23)
at /home/container/src/events/messageCreate.js:258:12
at /home/container/node_modules/mongoose/lib/model.js:5074:18
at processTicksAndRejections (node:internal/process/task_queues:78:11)
why do i get this error?
you should use queue.connection.destroy()
for a skip command? xd
do you want just skip nowplaying?
yes like skip to the next song in queue
than audioPlayer.stop()
where does audioPlayer come from
Hm...in v13 you should use audioPlayer to play song.
o_0
https://github.com/discordjs/voice/tree/main/examples
see this example 🙂
but like i have this in my play command
const stream = ytdl(song.url, {filter: 'audioonly'});
const player = createAudioPlayer();
let resource = createAudioResource(stream, { inputType: StreamType.Arbitrary });
player.play(resource);
queue.connection.subscribe(player);
player.on(AudioPlayerStatus.Idle, () => {
queue.songs.shift();
play(queue.songs[0]);
});
than player.stop() emit AudioPlayerStatus.Idle than skip the song
Do this if you want to skip :connection.state.subscription.player.stop()
channel.join().then(connection => {
message.channel.send("La richiesta è stata inviata");
const dispatcher = connection.play('audios/private.mp3');
});
i have this piece of code and i need when the bot finishes running the mp3 file to exit the voice channel. how do i do that ?
Go ask this in #archive-djs-v12-voice-deprecated , Not here
Is there something that shows me whats changing in djs v13 ?
https://github.com/discordjs/voice/issues/164
What do you think about that issue? I agree with that issue because I have also suffered a memory loss that has destroyed the stream.
The memory usage lookin good so far with youtube-dl-exec?
In the case of youtube-dl-exec, I need to keep it running longer. I'm not sure yet.
But memory usage is faster before.
how do i set the volume of music?
Can I reduce this size when youtube-dl-exec occupies about 5% of memory while running?
anyone?
audioPlayer.state.resource.volume.setVolume(volume)
so if i do queue.connection.state.subscription.player.pause(); for pausing
then i do queue.connection.state.resource.volume.setVolume(volume); for the volume correct?
audioPlayer.state.resource.volume.setVolume(volume)
audioPlayer is queue.connection.state.subscription.player
also queue.connection.state.subscription.player is player in your code example.
ytdl.raw(this.url, {
o: '-',
q: '',
f: 'best[ext=webm+acodec=opus+asr=44100]/bestaudio',
r: '100K',
}, { stdio:['ignore', 'pipe', 'ignore'] });``` I used asr 44100, it greatly reduce my memory usage using youtube-dl-exec. If using 48000 like in example, the memory rise
Thanks
now I tested the my bot, the memory use amount of the bot process does not decrease even if youtube-dl is normally terminated and the song finishes 😦
It started at 15% and increased very quickly, less than two hours to 37%.
48min song, using process.memoryUsage.rss() to measure
rss: 385437696
heapTotal: 298512384
heapUsed: 282292232
external: 21525979
arrayBuffers: 13167248
result of process.memoryUsage()
367mb 👀
After the bot start, it maintained about 150mb until the song function started.
rss: 408309760
heapTotal: 323153920
heapUsed: 305424776
external: 17495544
arrayBuffers: 10436483
now result of process.memoryUsage()
Is bad, if rising every minute
that's right 😦
CAN ANYONE JOIN MY SERVER
rss: 450826240
heapTotal: 364834816
heapUsed: 343908864
external: 20489840
arrayBuffers: 9121543
MY SERVER NAME IS - WE CODERS
It's not good sign, soon will come memory leak
this isnt printing anything to console only ""
function filter(msg) {
const pattern = /^[0-9]{1,2}(\s*,\s*[0-9]{1,2})*$/;
return pattern.test(msg.content);
}
message.channel.activeCollector = true;
const response = await message.channel.awaitMessages({ filter, max: 1, time: 30000, errors: ["time"] });
const choice = resultsEmbed.fields[parseInt(response.first()) - 1].name;
console.log(`"${choice}"`)
CAN YOU JOIN MY SERVER
oh, it wasn't memory leak?
When I just terminated song, memory usage is down to 13.4%.
I think I should just use upper limit of song's file. how can I do it?
what is your youtube-dl argument? Try changing it to asr 44100
before I was use
{
o: '-',
q: '',
f: 'bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio',
r: '100K',
}
in example
{
o: '-',
q: '',
f: 'bestaudio[filesize<30M+ext=webm+acodec=opus+asr=44100]/bestaudio[filesize<30M]',
r: '100K',
}
now I test this. Is it correct argument?
remove filesize first and see. Because I dont have filesize and memory is ok
Bot is using it on another server now, so we will test it later.
Have you played songs over an hour?
3hrs+ yes, memory usage stay at 84-85mb like screenshot
how can i log if my bot was kicked/disconnected from a voice channel
Okay, then I'll follow your options
Hey i tried to do whatever i can but i can never get to the ready part, throws Did not enter state ready within 10000ms
client.on("interactionCreate", async (interaction) => {
// Reply with comment received
console.log(interaction)
await interaction.reply(`processing`);
let channel = interaction.member.voice.channel
let connection = await joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
})
connection.on("debug", console.log);
connection.on("error", console.error);
await entersState(connection, VoiceConnectionStatus.Ready, 1000 * 10)
console.log("ready")
});
Really appreciate some help, have been brain wracking for about 6 hours now
EDIT: To clarify the bot joins the channel but still no ready from code
My codes are not exactly the same way you are. I'm sorry I didn't help you.
how does seeking work in new discord.js/voice?
seeking?
what is difference about 44100 and 48000?
yeah like playing the song from a specific point
in the v12 version it used to be called seek
Sorry, I don't know how to do that 😦
https://www.izotope.com/en/learn/digital-audio-basics-sample-rate-and-bit-depth.html This explain better than me, but basically 48000 is better but it will eat more memory, 44100 is standard, can tell the difference in discord? I don't think so, at least from my hearing
thanks
oh that's sampling frequency
48000 is the sampling frequency discord uses
The rare yoda appeared. Planning to update the dep this weekend hydrabolt? the typing bug me sometime
i found the answer for this
apparantly i missed this GUILD_VOICE_STATES thing in the intents for the client constructor
I have a lot of this in my code
const voice_connection = client.voice?.connections.find(c => c.voice?.guild.id === guild_object.id);
and I cannot understand what to do with the adapters in djs13, is there anything online to help me ?
Hello everyone, is it possible to make my bot play music for my server. I can't get it to join a vocal Stage
If I just want to receive voiceStateUpdate, I need the library or not ?
its discord.js own event so you don't need additional library
Memory still increases when the song is playing (I used 44100). Also, memory usage in the node(my bot) process increases a lot at a time, especially when the song is finished.
okay so i have a StageChannel and a StageInstance, how can I get my bot to actually join the channel? sorry this is probably very obvious but there's no documentation about Stage Channels on discordjs.guide and nothing I can find in the docs.
Hey, does anybody know how to fix the problem with discordjs / ytdl-core when trying to play an youtube stream?
you haven't told us what the problem is 
Sry, when I playing audio with ytdl and discordjs new voice the bot joins perfectly, plays for 2 seconds (the amout of time I bufferd) or so and then instantly leaves
I tried using ytdl-core-discord just like before but this module doesnt support v13 so that doesnt work this time xD
Does anyone have idea why my bot won't play sound? The path to the resource is correct and I checked to make sure the file is not corrupted or anything.
private static getVoiceChannel(interaction: CommandInteraction) {
const voiceChannel = (interaction.member as GuildMember).voice.channel;
/* This will play a youtube video and should be saved but switching to a .mp3 for clips */
return voiceChannel
}
static connectToChannel(interaction: CommandInteraction): VoiceConnection {
const voiceChannel = this.getVoiceChannel(interaction)
if (!voiceChannel) {
throw new MusicError('Unable to connect to voice channel')
}
const conn = joinVoiceChannel({
channelId: voiceChannel?.id!,
guildId: voiceChannel?.guild.id!,
adapterCreator: voiceChannel?.guild.voiceAdapterCreator as DiscordGatewayAdapterCreator,
})
return conn
}
static playFile(interaction: CommandInteraction, path: string) {
const conn = this.connectToChannel(interaction)
const resource = createAudioResource(path)
const player = createAudioPlayer()
player.play(resource)
player.on(AudioPlayerStatus.Idle, () => {
console.log('The audio player has stopped playing')
})
player.on(AudioPlayerStatus.Playing, () => {
console.log('The audio player has started playing')
})
player.on('error', error => {
console.error(`Error: ${error.message} with resource ${error.resource.metadata}`)
})
conn.subscribe(player)
interaction.reply({content: 'Playing.'})
}
https://discordjs.guide/popular-topics/faq.html#how-do-i-play-music-from-youtube this guide should help 😄
if the guide doesnt help just let me know 🙂
It doesn't look like it helped 😦 I should have specified that it was a path to an mp3 file
you checked that the file isnt currupted. Do you also mean with that, that you can play the audio file and hear anything?
implement these functions and then try playing audio:
connection.on('stateChange', (oldState, newState) => {
console.log(`Connection transitioned from ${oldState.status} to ${newState.status}`);
});
player.on('stateChange', (oldState, newState) => {
console.log(`Audio player transitioned from ${oldState.status} to ${newState.status}`);
});
Yes, the file does play audio
then please implement thes functions I just sent you and then please send the console log
how can I get a bot to join a stage channel with an active StageInstance?
How to seek in the new discord voice
what do you mean with seek?
skip to a specific minute in the song
or the audio playing anyways
that depends more on the lib you use, to play the music
are you on windows or linux?
how can I get a bot to join a stage channel with an active StageInstance? i've searched StackOverflow and asked this twice before lol but does anyone have an answer
sry no idea
the v12 discord.js had a seek option when playing the song
Just join like a normal voice channel, then use VoiceState.setSuppressed(false) to make it a speaker
i'll try that
Hey, does anybody know how to fix the problem with discordjs / ytdl-core when trying to play an youtube stream? When Im playing audio with ytdl and discordjs new voice the bot joins perfectly, plays for 2 seconds (the amout of time I bufferd) or so and then instantly leaves
getting error:
Type 'InternalDiscordGatewayAdapterCreator' is not assignable to type 'DiscordGatewayAdapterCreator'
I use getVoiceConnection to get the voice from the current guild but then when I try voice_connection.channel but it is removed. How can I access the channel my bot is connected too ?
.me.voice.channel
can you type the whole thing ?
Guild.me.voice.channel
<Guild>.me.voice.channel



Getting an error with joinVoiceChannel, here's a big one:
https://sourceb.in/vKFlWAcXrH
Lets stop this before we get kicked for spamming xD
did you set adaptercreator?
dumb question but what does it say if you look at the error of the ide
the exact same
message.member.voice.channel.join() where can i find this in v13?
they changed it in v13, so now you need to install the voice package seperately. https://discordjs.guide/voice/ look at this page
ty for answering me twice xD >.< 
i answered you twice because you asked twice xD
It is a issue of voice module not updated to discord api types @0.22.
so do i nneed to adjust my Code ?? in oder to play stuff or is tis working as it was in the past?
nvm i just saw the extras on that page xD
Hello, can i listen user voice ?
and how can i unmute the bot ?
if (guildMember.voice) will this return boolean if that member is or isn't in a voiceChannel??
why does <VoiceChannel>.bitrate return NaN
Why <VoiceChannel>.bitrate and <VoiceChannel>.userLimit return undefined
error: ReferenceError: member is not defined at Client.<anonymous> (C:\Users\Administrador\Downloads\flyre@lastest (1)\index.js:88:25) at Client.emit (node:events:406:35) at MessageCreateAction.handle (C:\Users\Administrador\Downloads\flyre@lastest (1)\node_modules\discord.js\src\client\actions\MessageCreate.js:23:14) at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Administrador\Downloads\flyre@lastest (1)\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (C:\Users\Administrador\Downloads\flyre@lastest (1)\node_modules\discord.js\src\client\websocket\WebSocketManager.js:345:31) at WebSocketShard.onPacket (C:\Users\Administrador\Downloads\flyre@lastest (1)\node_modules\discord.js\src\client\websocket\WebSocketShard.js:443:22) at WebSocketShard.onMessage (C:\Users\Administrador\Downloads\flyre@lastest (1)\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10) at WebSocket.onMessage (C:\Users\Administrador\Downloads\flyre@lastest (1)\node_modules\ws\lib\event-target.js:132:16) at WebSocket.emit (node:events:394:28) at Receiver.receiverOnMessage (C:\Users\Administrador\Downloads\flyre@lastest (1)\node_modules\ws\lib\websocket.js:970:20) at Receiver.emit (node:events:394:28) at Receiver.dataMessage (C:\Users\Administrador\Downloads\flyre@lastest (1)\node_modules\ws\lib\receiver.js:517:14) at Receiver.getData (C:\Users\Administrador\Downloads\flyre@lastest (1)\node_modules\ws\lib\receiver.js:435:17) at Receiver.startLoop (C:\Users\Administrador\Downloads\flyre@lastest (1)\node_modules\ws\lib\receiver.js:143:22) at Receiver._write (C:\Users\Administrador\Downloads\flyre@lastest (1)\node_modules\ws\lib\receiver.js:78:10)
code:
you still don't define your member
also read guide in pins
i read it but i dont find the error :/
thats mi client.on
if you don't know how to define member you should learn some js #resources
also the new voice module works different than in v12 - see pins
bruh
<Voice channel>.join() isn't a thing
where can i find all these commands ?
dispatcher.resume()
dispatcher.skip()```
guide in pins
things changed in new voice module
searching for exact 3 methods can be painful ... i guess i have to take that
there are lots of changes in the new module so I highly recommend you read the guide
i alredy have it working i just need to implement these commands
well for skip you can just unsubscribe or subscribe the next player
the other two are literally just in the guide: https://discordjs.guide/voice/audio-player.html#pausing-unpausing
ty
i guess this is the problem cause everything else is working as intended any sugestions?
var stream = createAudioResource(`/Playlist/${filemp3}.mp3`)
Is the Playlist directory at the root folder?
yes
Can you try passing in a Readable stream instead?
fs.createReadStream("…")
I found my problem I was running this after the code i provided
const resource = createAudioResource(stream, { inputType: StreamType.Arbitrary })
Ah, that makes sense
is there any way to control the volume ?? as in previous version dispatcher.setVolume(volume);
AudioResource.volume.setVolume
Ik i asked alot but is there a way to seek or is the feature removed?
It was removed
You should seek when getting the stream. Ik ytdl-core gives a seek option
idk how ill search it, Thanks so much
is there any optimize option for youtube-dl-exec?
Does anybody know what this error means? I'm trying to get my bot to play music in a VC, but I keep getting this error:
const timeout = setTimeout(() => reject(new Error(`Did not enter state ${status} within ${maxTime}ms`)), maxTime);
^
Error: Did not enter state ready within 20000ms
did your bot has correct permission or intent?
im trying to have the bot play a youtube link, and it joins the voice channel, but nothing plays, what should i do?
check the intents first, that what I would go first
yea it was the intents, but now when it joins i get this error Error: Cannot play audio as no valid encryption package is installed.
Encryption packages
sodium
(best performance)
libsodium-wrappers
tweetnacl``` installed 1 of this, I recommend libsodium-wrappers
well it worked, but after about 20 seconds it stopped and i got an error saying
node:events:371
throw er; // Unhandled 'error' event
^
AudioPlayerError: aborted
It is ytdl error, not the lib error
help me the play function is not working
no errors though
how can I make the audio quality better?
where can I find user.presence in djs13?
hello is our old codes of music cant work in djs v 13
You can't. Presence is only for members.
No, you need to use the new voice lib. Check pinned message
DiscordAPIError: Unknown Message
.setTitle('Começando a tocar')
.setThumbnail(song.thumbnail)
.setDescription(`
Nome: ${song.title}
Pedido por ${song.requester}
Vizualizações: ${song.views}
Duração: ${timeString}`)
interaction.editReply({
embeds: [noiceEmbed]
})```
not voice related
any way to do seek with v13?
let voice = message.member.voice.channel;
voice.join()
not work 😦 help me, brothers
read the documentation/guide
i can not find
v13 changed everything
need install new library now?
yeh
thanks you
@fervent estuary help me again, please. i not find "needed method". I am english bad, sorry
const connection = await connectToChannel(channel);
connection.subscribe(player);
message.reply('Playing now!')
this?
thanks, i see
@fervent estuary

thanks you very much
👌
is there no way to seek to specific time with v13?
you can use ffmpeg
hmm ok
Who can explain why <AudioPlayer>.on(AudioPlayerStatus.Idle) may be called multiple times?
always when the audioPlayer idles (after a resource ends for example) that is emitted
This is a debug for playing 1 song on repeat (2-3 times)
did it log
to {"status":"playing","missedFrames":0,"playbackDuration":0,"resource":true,"stepTimeout":false}``` at once?
how can i make my bot leave a channel
VoiceConnection.destroy()
without it having a queue
no
<Queue>.connection.destroy()
Do not forget to check the connection status beforehand.
if(<Queue>.connection.state.status === VoiceConnectionStatus.Destroyed) return;
(node:2086588) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 idle listeners added to [AudioPlayer]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2086588) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [AudioPlayer]. Use emitter.setMaxListeners() to increase limit
:(
<AudioPlayer>.setMaxListeners(Infinity)?
you have a memory leak
i guess thats the reason for ur logs looking like that
How can you fix this?
without queue
so youre re-attaching a listener somewhere in a loop
you will have to trace it down urself
ah, okay.
<VoiceConnection>.destroy()
like a leave command
how can i get the voiceconnection tho
getVoiceConnection(guildId)
I can send you a code in DM, can you take a look?
so i can define it like this?
const voice = getVoiceConnection(guildId);
voice.connection.destroy();
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator
});
serverQueue.voiceConnection = connection;
serverQueue.voiceConnection.destroy() in your leave command
like i said you will have to find it urself
getVoiceConnection returns a VoiceConnection
const connection = getVoiceConnection(guildId);
if(connection.state.status === VoiceConnectionStatus.Destroyed) return;
connection.destroy();
so just call voice.destroy with that code
voice.connection isnt a thing
oh ok
TypeError: Cannot read property 'destroy' of undefined
looks like theres no active voiceConnection in that guild
const connection = getVoiceConnection(channel.guild.id); is this correct?
yeah
only if channel is not undefined
ty it works
what is this in v13 serverQueue.connection.dispatcher.streamTime
I can't still find a way to know when the player finished playing like .on("finish") in v12. Is there anyway beside AudioPlayerStatus.Idle
<AudioResource>.playbackDuration
Use <AudioPlayer>.on('stateChange') or <AudioPlayer>.on(AudioPlayerStatus.Idle)
const passedTimeInMS = serverQueue.connection.state.subscription.player.playbackDuration;
const passedTimeInMSObj = {
seconds: Math.floor((passedTimeInMS / 1000) % 60),
minutes: Math.floor((passedTimeInMS / (1000 * 60)) % 60),
hours: Math.floor((passedTimeInMS / (1000 * 60 * 60)) % 24)
};
this isnt working :/
const passedTimeInMS = serverQueue.connection.state.subscription.player.state.resource.playbackDuration;
serverQueue.connection.state.subscription.player is AudioPlayer
Your code takes playbackDuration from<AudioPlayer>
this worked
I experienced that the memory usage of the bot process increased dramatically when the long song (at least an hour) was played and ended. I'm using youtube-dl-exec.
Are there any people who are experiencing the same problem or know how to solve it?
@vocal valley I have done it, now you can test its functionality before merging.
thanks, will take a look today
Ok 👍
what about pausedTime?
Player playbacktime - Resource playbacktime = Paused Time
is there any difference about <AudioPlayer>.stop() and <AudioPlayer>.stop(true) ?
stop() will play 100ms of silence after stopping to stop a weird glitchy sound in the discord client due to the stream stopping unexpectedly
stop(true) will just stop, but you might hear a weird sound in the discord client
what?
serverQueue.connection.state.subscription.player.state.resource.playbackDuration
thanks
That is resource playback without paused time.
serverQueue.connection.state.subscription.player.playbackDuration will include resource playbackduration and paused time.
Is there a way to get a connection's channel?
Also am I the only one who doesn't see anything related to <connection>.state.subscription in the docs?
if(connection.state.status === VoiceConnectionStatus.Destroyed) return;
^
TypeError: Cannot read property 'state' of undefined
connection.joinConfig.channelId will give you its ID
the docs do obscure this a little bit, so the docs say that .state is of type VoiceConnectionState, which is VoiceConnectionSignallingState | VoiceConnectionDisconnectedState | VoiceConnectionConnectingState | VoiceConnectionReadyState | VoiceConnectionDestroyedState
In all of these states except the DestroyedState, subscription exists as a property
so you'd do something like
if (state.status !== VoiceConnectionStatus.Destroyed && state.subscription) {
// state.subscription is defined here
}
the first conditional check is to get typescript to accept that the state can have a subscription property
although if you aren't using TS, it's equally acceptable to just do if (state.subscription)
I could not join the voice channel: TypeError: channel.join is not a function
See pins, specially guide
I gave it a look. I think My Music commands are going to go out of existence
You should be able to also let them work in @discordjs/voice, but it's just way more complicated to do
That's the Point. It too complicated. Tho I'll definitely give a try even Though I know the results
Hey, does anybody know how to fix the problem with discordjs / ytdl-core when trying to play an youtube stream? When Im playing live videos with ytdl and discordjs's new voice the bot joins perfectly, plays for 2 seconds (the amout of time It bufferd) or so and then instantly leaves. (normal youtube videos work perfectly fine)
Do you get any error?
no it just leaves (in the connection debug info it leaves just like the video ended)
how do i do this in v13? im trying to record the vc channel. this is how i did it in v12
const receiver = connection.receiver.createStream(message.member, {
mode: "pcm",
end: "silence",
});```
here i get ``TypeError: Cannot read property 'createStream' of undefined``
AudioRecieve is still in wip. Wait for it to complete
do you know when that will be?
ask hydrabolt for this
can i ping them or nah ?
But only once.
is that a yes ? haha
yes
thanks
@vocal valley do you have any idea regarding how long it will be until AudioReceive will be completed?
I am hoping by the end of today or tomorrow
I'm getting the error Type 'InternalDiscordGatewayAdapterCreator' is not assignable to type 'DiscordGatewayAdapterCreator'. when calling joinVoiceChannel with interaction.guild.voiceAdapterCreator as the adapterCreator, how do I fix this?
thanks :) looking forward to it!
update to 0.5.6
alright, thanks! do I have to uninstall and reinstall or is just updating fine?
npm install @discordjs/voice@latest will do
thank you!
serverQueue.loop = !serverQueue.loop;``` why this cant work
is there a way i can make a user join a channel?
How do I join a voice channel.
Are there any people who are experiencing the same problem or know how to solve it?
Thanks so much!
np 😄
how can i join my discord bot on stage channel
Any idea how I can check the number of users connected to a voice channel?
Do you have the @discordjs/voice library installed?
^
what
Do you have the @discordjs/voice library installed?
yeah
but ı dont understand how i can join my bot on stage
I believe interaction.member.voice includes stage presences.
joinVoiceChannel should work for both Voice and Stage channels.
voiceChannel.members should be a collection of connected users iirc
Interesting. Was it always like that? Thank you.
i think so!
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});```
Sorry but believe me I still don't understand how to use it
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});```
What's the adapterCreator field for?
resource.playStream.once('error', onStreamError);
^
TypeError: Cannot read property 'once' of undefined
um why does the player state changes to autopaused. like it goes from idle to buffering to playing to autopaused in 1 sec
anyone
this gives u the connection
which you will cache
and then subscribe the player
Auto pause happens when the player has no available voice connections to play to
Did you remember to subscribe your voice connection to the player?
yes
well then it means the connection isn't ready
hmm
the bot just plays for one minute then gives me this error
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)```
anyone know why?
Hi, i'm need help. My song don't play but the code is correct i think
await joinVoiceChannel({
channelId: queueConstruct.voiceChannel.id,
guildId: queueConstruct.voiceChannel.guild.id,
adapterCreator: queueConstruct.voiceChannel.guild.voiceAdapterCreator
});
var connection = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
}
});
queueConstruct.connection = connection;
play(message.guild, queueConstruct.songs[0]);
async function play(guild, song) {
const serverQueue = queue.get(guild.id); // On récupère la queue de lecture
if (!song) { // Si la musique que l'utilisateur veux lancer n'existe pas on annule tout et on supprime la queue de lecture
queue.delete(guild.id);
setTimeout(function() {
serverQueue.voiceChannel.leave();
}, 300000)
return;
}
if(serverQueue.loop === true) {
serverQueue.songs.push(song);
}
// On lance la musique
var connection = await getVoiceConnection(serverQueue.voiceChannel.guild.id);
await connection.subscribe(serverQueue.connection);
serverQueue.ressource = await createAudioResource(ytdl(song.url, {filter: "audio", quality: "highestaudio"}), { inlineVolume: true });
serverQueue.ressource.volume.setVolume(1); // On définie le volume
await serverQueue.connection.play(serverQueue.ressource);
serverQueue.connection.on(AudioPlayerStatus.Idle, () => { // On écoute l'événement de fin de musique
serverQueue.songs.shift();
play(guild, serverQueue.songs[0]);
});
serverQueue.connection.on("error", error => console.error(error));
serverQueue.textChannel.send({ content: `Démarrage de la musique: **${song.title}**`});
}
If somebody have the solution ping me please
um do you know on what conditions a connection can't become ready
hello! i am a little bit confused with the new docs.
In v12 i was able to see, if the member who wrote the command was in a voicechannel.
in v13 can i also get the voicechannel from an interaction? like interaction.voicechannel doesn't work
thanks !
interaction.member.voice.channel
how could i be so blind, thank you very much!
np
May i bother you one more time?
The bot is joining and leaving the channel as intented, but he won't play the file
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.member.voice.channel.guildId,
adapterCreator: interaction.member.voice.channel.guild.voiceAdapterCreator,
});
const player = createAudioPlayer();
const resource = createAudioResource(`./audio/gong.mp3`);
player.play(resource);
await new Promise(resolve => setTimeout(resolve, workoutDuration));
connection.destroy();
i honestly think i set the right permissions, and those are my npm packages
├── @discordjs/opus@0.5.3
├── @discordjs/voice@0.5.6
├── discord.js@13.0.1
├── ffmpeg-static@4.4.0
└── libsodium-wrappers@0.7.9
EDIT, i had to subscribe
AudioPlayerError: aborted what is it ?
My bot randomly stops playing audio
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:
at Encoder.onStreamError (D:\! IDE\Discord bots\! Crysto rewrite\node_modules\@discordjs\voice\dist\audio\AudioPlayer.js:213:22)
at Object.onceWrapper (node:events:514:26)
at Encoder.emit (node:events:406:35)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)```
same AudioPlayerError: aborted if someone know what is it 🙏
same
Welcome to the club xD
I'm using ytdl-core-discord instead of ytdl-core if that matters
im using ytdl-core and still same thing soo
ytdl-core/ytdl-core-discord/discord-ytdl-core will all suffer from the same issues
i cannot recommend using any of them until good fixes for it are found
i recommend that people use youtube-dl instead, or ffmpeg with youtube video download URLs
im using ytdl-core and it works perfect fine for me i even mixxed it up with a jukebox but i gotta say it took me a long time and its not finished yet but what i have works perfect
are there any native extractors you would recommend or is ytdl-core as far as it goes in that regard?
node:events:371
throw er; // Unhandled 'error' event
^
AudioPlayerError: Status code: 403
at ClientRequest.<anonymous> (/app/node_modules/miniget/dist/index.js:210:27)
at Object.onceWrapper (node:events:514:26)
at ClientRequest.emit (node:events:394:28)
at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:621:27)
at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
at TLSSocket.socketOnData (node:_http_client:487:22)
at TLSSocket.emit (node:events:394:28)
at addChunk (node:internal/streams/readable:312:12)
at readableAddChunk (node:internal/streams/readable:287:9)
at TLSSocket.Readable.push (node:internal/streams/readable:226:10)
Emitted 'error' event on AudioPlayer instance at:
at OggDemuxer.onStreamError (/app/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:213:22)
at Object.onceWrapper (node:events:514:26)
at OggDemuxer.emit (node:events:406:35)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
resource: <ref *4> AudioResource {
playbackDuration: 0,
started: false,
silenceRemaining: -1,
edges: [
<ref *1> {
type: 'ffmpeg ogg',
to: Node {
edges: [ [Object], [Object], [Object] ],
type: 'ogg/opus'
},
cost: 2,
transformer: [Function: transformer],
from: Node { edges: [ [Object], [Circular *1] ], type: 'arbitrary' }
},
<ref *2> {
type: 'ogg/opus demuxer',
to: Node { edges: [ [Object] ], type: 'opus' },
cost: 1,
transformer: [Function: transformer],
from: Node {
edges: [ [Circular *2], [Object], [Object] ],
type: 'ogg/opus'
}
}
],
playStream: OggDemuxer {
...```
for pure JS extractors, ytdl-core is the only thing im aware of
probably need reconnect, see https://github.com/discordjs/voice/pull/161 and its linked issues
:/ guess I don't really see a way around writing a thread in py to handle extractions.
I am unable to run the code in the link "https://discordjs.guide/popular-topics/faq.html#how-do-i-play-music-from-youtube". comes to the audio channel, does not play music or gives this error
have you tried the examples in the repo?
.eval (async () => {
const ytdl = require('ytdl-core');
const {
AudioPlayerStatus,
StreamType,
createAudioPlayer,
createAudioResource,
joinVoiceChannel,
} = require('@discordjs/voice');
// ...
const connection = joinVoiceChannel({
channelId: message.member.voice.channel.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
});
const stream = ytdl('https://music.youtube.com/watch?v=MLH4IWgWmyE&feature=share', { filter: 'audioonly' });
const resource = createAudioResource(stream, { inputType: StreamType.Arbitrary });
const player = createAudioPlayer();
player.play(resource);
connection.subscribe(player);
player.on(AudioPlayerStatus.Idle, () => connection.destroy());
})();```
I tried to run it with this code but it didn't work
try the code in the examples folder
isn't it the same
where is the examples folder?
pins
@harsh adder i think is that
I'm trying to make a bot that says spoke in the console when a specific person speaks or just makes enough noise (That's why it's comparing id's). I downloaded an external library (discord.js/voice) but it's not detecting my voice. I messed up somewhere and the console keeps telling me creatVoiceReceiver is probably the wrong thing to use.
I think there's a larger issue than creatVoiceReceiver not being defined, I'm probably using the wrong thing altogether. What should I do to get it to hear my voice?
@fallow locust voice receive is being reworked, PR should be ready tomorrow 👀
i wouldnt recommend using voice receive as it is now
for reference, the new receive will look something like:
const connection = joinVoiceChannel(options);
connection.receiver.speaking.on('start', userId => {
const stream = connection.receiver.subscribe(userId);
stream.pipe(somewhere);
console.log(userId, 'started speaking');
});
connection.receiver.speaking.on('end', userId => {
console.log(userId, 'stopped speaking');
});
the new voice receive basically goes back to using user IDs in subscriptions, rather than forcing you to resolve the user ID to a SSRC yourself
@vocal valley
.
@harsh adder please look at https://github.com/discordjs/voice/tree/main/examples
someone else also posted it above
Alright, thanks. Is there anything I can use as a substitute though? I'm just trying to trigger the bot when any noise is made.
atm no 😅 but it should land either tomorrow or tuesday depending on review speed
Cool, thanks
I think this will work for me. Thank you so much.
Np
Hi, my bot join but don't play the music in the channel. My code : ```js
var connection = await getVoiceConnection(serverQueue.voiceChannel.guild.id);
await connection.subscribe(serverQueue.connection);
await ytdl(song.url, {filter: "audio", quality: "highestaudio"}).pipe(fs.createWriteStream("song.mp3"));
serverQueue.ressource = createAudioResource((fs.createReadStream("song.mp3")),{ inlineVolume: true });
serverQueue.ressource.volume.setVolume(1); // On définie le volume
await serverQueue.connection.play(serverQueue.ressource);
serverQueue.connection.on(AudioPlayerStatus.Idle, () => { // On écoute l'événement de fin de musique
serverQueue.songs.shift();
play(guild, serverQueue.songs[0]);
});
serverQueue.connection.on("error", error => console.error(error));
serverQueue.textChannel.send({ content: `Démarrage de la musique: **${song.title}**`});
If someone have the solution, thank you
Do you happen to know of anyone who made voice commands?
is there someone find memory leak after using youtube-dl-exec?
memory usage is increased greatly when I stop the song.
especially it can easily find when I play long song.
just play long song, memory usage is slowly increased and song is stop than greatly increased at once.
so nobody ? pleasse i want die
what's your problem?
what is serverQueue.connection?
maybe it's somethig wrong in your code
serverQueue.connection is the audio player
await joinVoiceChannel({
channelId: queueConstruct.voiceChannel.id,
guildId: queueConstruct.voiceChannel.guild.id,
adapterCreator: queueConstruct.voiceChannel.guild.voiceAdapterCreator
});
var connection = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
}
});
queueConstruct.connection = connection;
play(message.guild, queueConstruct.songs[0]);
playing .mp3 files is "off again". Last time I checked it was working but that was prior to the official release of v13. I see two errors I haven't seen before.Cannot find module 'D:\Repos\tleylanBot\node_modules@discordjs\opus\prebuild\node-v93-napi-v3-win32-x64-unknown-unknown\opus.node'
Cannot find module 'opusscript'
I have never used opusscript before did something change?
um...how about uninstall and reinstall voice module
let me try it
I also reinstalled opus while I was at it. I still have an error which seems to occur in my call to createAudioResource. Also am I correct in assuming that prism-media: 1.3.1 is automatically installed as dependency because I don't explicitly do that.
Ah I see that "reinstall" wasn't directed towards me... in any case no harm
oh my gosh... the documentation changed (or must have). I guess it is somewhat to be expected. Went back to the simplest example and it is working now. Something in the options for the createAudioResource has changed I suspect.
okay not 100% as from this example from the docs but identical except for the mp3 file.
this works:
let resource = createAudioResource(join(__dirname, 'file.mp3'));
this fails:
// Will use FFmpeg with volume control enabled
resource = createAudioResource(join(__dirname, 'file.mp3'), { inlineVolume: true });
resource.volume.setVolume(0.5);
it isn't the options per se because I tried with inputType and that worked fine. Seems related to inlineVolume at this moment.
the exec spawns a child process of ytdl which is python. Child process usage is added to the residential set iirc which can inflate usage pretty high. If you don't properly send a kill signal to child processes, they can stay alive and retain memory usage until you hit a seg fault. That happened to me even though I believe I handled everything properly. I decided to give myself less of a headache and just switched back to ytdl-core
like node, python has a bit of overhead in terms of memory usage. spawning ytdl over and over is also pretty heavy in terms of performance as it would have to compile the regular expressions
But in v13 ytdl-core occured abortes Error in audioplayer
what were you setting for your highWaterMark in ytdl
i used just default
and when I use 1<<25 for highWaterMark, it use so large memory
1<<25 is way too high, yes
defaults should be fine.
I haven't experienced an abort error before though. Abort errors are on Discord.js' internals end anyways.
Should be unrelated to ytdl
I experienced that error when play long song
stream urls can expire after 6h iirc
you'd have to refresh
but it was just 1hour and error occured when about 20m

:(
thanks for share your experience
is there a way to get every voice channel the bot is in (in the cache) and leave it?
bruh lmao
well, install sodium, libsodium-wrappers or tweetnacl like it says in the error
it's working now
im noticing a pattern
?
const process = ytdl.raw(this.url, {
o: '-',
q: '',
f: 'best[ext=webm+acodec=opus+asr=44100]/bestaudio',
r: '100K',
}, { stdio:['ignore', 'pipe', 'ignore'] });
if (!process.stdout) {
reject(new Error('No readable stream'));
return;
}
const stream = process.stdout;
const onError = (error) => {
if (!process.killed) {process.kill();}
stream.resume();
reject(error);
};
process
.on('spawn', () => {
audio.demuxProbe(stream)
.then((probe) => resolve(audio.createAudioResource(probe.stream, { metadata: this, inputType: probe.type })))
.catch(onError);
});
});``` this is what I do for youtube-dl-exec which basically almost same like example, but minor changes
oh okay, thanks!
a quick repo made, but as this is only quick repo, expect something not so perfect
:)
only objective is to see the memory
💯 👍
Any news with audio receive ? 👀
It is in working state. I hope it will be completed by tomorrow.
anyone knows about lavalink ?
This is not a place to talk about lavalink, go to #archive-offtopic
How can I make the bot just join the voice channel 
the adapter creator stuff is screwing me over 
Just keep in mind that it is basic join command nothing to think about adapter creator.
I updated to v13 and my code stopped working. What should I do to update it?
client.on("voiceStateUpdate", (oldMember, newMember) => {
const channel = client.channels.cache.get(newMember.channelID);
if (newMember.id === "277484746265722881") {
if (!channel) return console.error("The channel does not exist.");
channel.join().then(connection => {
console.log("Successfully connected");
}).catch(e => {
console.error(e);
});
}
});
You need to update this : ```
channel.join().then(connection => {
console.log("Successfully connected");
}).catch(e => {
console.error(e);
});
guys i need help. I cant download @discordjs/opus
hello
my play command cant working
#djs-help-v14 also saying "not working" is not helpful
why my bot dont join the voice channel
with await channel.join()```
error?
yeah channel.join is not a function
but in previous version of discord.js its worked
i can help you
the v12 voice is deprecated, check d.js guide for the new ways of using voice
ya
i cant find the new one (:
help me (:
first install js @discordjs/voice
then (:
we cant do spoon share
thnx bro
no need
ya
Is there any way to add custom FFmpeg args, or a custom transform stream to the pipeline?
is you use heroku
hey
No.
dispatcher.setVolumeLogarithmic(queue.volume / 100);```
why this cant work in djs v13
What is dispatcher? You need access to resource.volume
yes for volume command
Yes, It is in PR : https://github.com/discordjs/voice/pull/161
Mmm, yeah, I saw that. Just curious if there was a way before that. Thanks.
Good timing though, I was about to wrap the libs myself before I saw that lol.
Yes there is a way:
const prism_media = require('prism-media')
const FFMPEG_OPUS_ARGUMENTS = [
'-analyzeduration',
'0',
'-loglevel',
'0',
'-acodec',
'libopus',
'-f',
'opus',
'-ar',
'48000',
'-ac',
'2',
];
let ffmpeg_instance = new prism_media.FFmpeg({
args : ['Your custom args here' ,'-i', url, ...FFMPEG_OPUS_ARGUMENTS ]
})
Thank you good sir.
Welcome 😄
Why if I install Discord Voice using npm instal @discordjs/voice gives me this error?
code: 'MODULE_NOT_FOUND',
path: 'C:\Users\user\Discord Bot\node_modules\@discordjs\voice\package.json',
requestPath: '@discordjs/voice'
Type npm init -y and then npm install @discordjs/voice
it works, thx
@carmine timber i'll re-review your PR once voice receive is done
Hi everyone,
I'm trying to play audio in a voice channel in response to a slash command. This is my play command handler. I'm out of ideas about what I'm doing wrong. Anyone has a hint ?
The voice connection works, the player and resource don't generate any error but the audio playback never starts. The player goes from buffering to playing, and from playing to idle state instantaneously.
Okay No issues 👍
BTW, when will voice receive be completed ??
Can you send sound.url (example) ??
i hope today!
i believe all that is left to add some documentation, a nice example, and then time for review
Can you test one thing ??
const prism_media = require('prism-media')
const FFMPEG_OPUS_ARGUMENTS = [
'-analyzeduration',
'0',
'-loglevel',
'0',
'-acodec',
'libopus',
'-f',
'opus',
'-ar',
'48000',
'-ac',
'2',
];
//Put above code at top.
let ffmpeg_instance = new prism_media.FFmpeg({
args : ['-reconnect', '1', '-reconnect_streamed', '1', '-reconnect_delay_max', '5','-i', sound.url, ...FFMPEG_OPUS_ARGUMENTS ]
})
let resource = createAudioResource(ffmpeg_instance)
Nice 👍
i tried debugging the connection
it gets ready then sends a heartbeat
after that the state changes to op 6 and ws becomes false
and even entersState doesn't throw anything
which is kinda confusing me
It doesn't seem to change much. This happens instantly :
PLAYER idle => buffering
PLAYER buffering => playing
PLAYER playing => idle
Log connection.state() before creating audio resource and tell me is it in ready condition ??
state() is not a function but connection.state.status is "ready"
Docs are really misleading 😦 https://discordjs.github.io/voice/classes/voiceconnection.html#state-1
npm list @discordjs/voice ??
it says get
getter are always used as method not method()
It returns VoiceConnectionStatus
@discordjs/voice@0.5.5
Update it to latest
ik, just sayin that if u have get state()
it is to be used as state and not state()
Okay thanks
It didn't solve the issue. the player is still going through 'idle', 'buffering', 'playing' and 'idle' states in a blink
Ok Can you console.log(audioResource) ??
I just want to see edges of the resource
edges: [
{
type: 'ffmpeg ogg',
to: [Node],
cost: 2,
transformer: [Function: transformer],
from: [Node]
},
{
type: 'ogg/opus demuxer',
to: [Node],
cost: 1,
transformer: [Function: transformer],
from: [Node]
}
],
This was from FFMPEG ??
What about simple url ??
I'm testing with a hardcoded sound.url that is equal to 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3'
No just do createAudioResource(sound.url) and then console.log this and show me edges .
I printed my sound.url and it was equal to https://cdn.discordapp.com/attachments/775079047197491210/776185677724516383/OSS117_le_mambo.wav in this example
This console.log() of the resource was done right before the 'player.play(resource)' line
Try swapping the position of connection.subscribe and player.play in main file
Change it to like this :
player.play(resource);
connection.subscribe(player)
Still the same behavior
Oh un français mdr
6hrs in, with repeated song duration 1hrs, 48min, 3hrs+
oh it's very stable
I still on repeating the song
👍 thanks
another 9hrs to repeat the songs
how do you get the list of users that joined a voice channel?
is there a way to get every voice channel the bot is in (in the cache) and leave it?
@turbid hedge
Make sure you have Move Members Permission
Hi, my bot join the channel but don't play music and i don't have error. my code : ```js
await joinVoiceChannel({
channelId: queueConstruct.voiceChannel.id,
guildId: queueConstruct.voiceChannel.guild.id,
adapterCreator: queueConstruct.voiceChannel.guild.voiceAdapterCreator
});
var connection = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
}
});
queueConstruct.connection = connection;
play(message.guild, queueConstruct.songs[0]);
async function play(guild, song) {
const serverQueue = queue.get(guild.id); // On récupère la queue de lecture
if (!song) { // Si la musique que l'utilisateur veux lancer n'existe pas on annule tout et on supprime la queue de lecture
queue.delete(guild.id);
setTimeout(function() {
if(!serverQueue) {
var connection = getVoiceConnection(serverQueue.voiceChannel.guild.id);
connection.destroy();
}
}, 300000)
return;
}
if(serverQueue.loop === true) {
serverQueue.songs.push(song);
}
// On lance la musique
var connection = await getVoiceConnection(serverQueue.voiceChannel.guild.id);
await ytdl(song.url, {filter: "audio", filter: format => format.container === "webm", quality: "highestaudio"}).pipe(fs.createWriteStream("song.webm"));
serverQueue.ressource = createAudioResource("../song.webm",{
inlineVolume: true,
inputType: StreamType.WebmOpus
});
serverQueue.ressource.volume.setVolume(1); // On définie le volume
await serverQueue.connection.play(serverQueue.ressource);
await connection.subscribe(serverQueue.connection);
serverQueue.connection.on(AudioPlayerStatus.Idle, () => { // On écoute l'événement de fin de musique
serverQueue.songs.shift();
play(guild, serverQueue.songs[0]);
});
serverQueue.connection.on("error", error => console.error(error));
serverQueue.textChannel.send({ content: `Démarrage de la musique: **${song.title}**`});
}
Sounds good thank you
Your path is a relative path and Voice module never play song from relative path
You should use :
const path = require('path')
let path = path.resolve('../song.webm')
serverQueue.ressource = createAudioResource(path,{
inlineVolume: true,
inputType: StreamType.WebmOpus
});
Okay i go try thx
sorry im new, is that voicechannel.members or vc id 123432(...).members?
I got it working with this basic code :
const connection = joinVoiceChannel({
channelId : message.member.voice.channel.id,
guildId : message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator
})
var url = 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3'
let resource = createAudioResource(url)
let player = createAudioPlayer()
player.play(resource)
connection.subscribe(player)
message.member.voice.channel.members
there is no message involved or is it mandatory?
Not mandatory, you just need class VoiceChannel from somewhere and then do
<VoiceChannel>.members
This will return a Collection, Then you need to figure out a way to get all members ids or name from that
This was not a issue of ytdl-core, actually he never waited for garbage collector in node js.
don't work
thanks
always no sound
when i use the link in your exemple isn't work too
Can you show me where you defined client in main file ??
You are missing GUILD_VOICE_STATES intents
oh
We can active all intents ?
That's a bad practice.
okay ty
Worked ??
i will try
Yeah he worked finally
thanks very much
If you use asr 44100 ytdl will pick the m4a format which will require ffmpeg to re-encode the audio to opus. More cpu usage but less memory.
And the memory leak doesn't get fixed because ffmpeg is doing the job now.
Also there's an issue where ffmpeg disconnects and ends the audio stream early iirc
No Problem 🙂
There is no such issue with ffmpeg, it is with your code probably.
Hi people, why is it doing this
I didn't experience the issue myself but it's known here.
Can you quote someone who had this issue ??
Code ??
that memory usage is not accurate at all, each player will spawn a ffmpeg and youtube-dl processes which use more than 100 mb ram combined
const serverQueue = this.client.songs.get(guild);
// if there is more music
if (!song) {
serverQueue.timeout = setTimeout(() => {
serverQueue.connecttion.destroy();
}, 10000);
return;
}
// create stream
const stream = ytdl(song.url, {
filter: "audioonly",
});
/**
* resource url ytb
*/
const resource = createAudioResource(stream, {
inlineVolume: true,
inputType: StreamType.Arbitrary
});
// play resource
serverQueue.player.play(resource);
// add event
serverQueue.player.on(AudioPlayerStatus.Idle, () => {
song.loop !== true ? serverQueue.songs.shift() : null;
this._play(message, guild, serverQueue.songs[0]);
});
The thing is when I used 48000, it will go up and when song off, it drop? How do you explain that?
And it the same thing I measure i used?
Then it is because ytdl - core has aborted stream so the error occured
Nothing related to djs-voice module
how can I make it not interrupted ?
Ask ytdl-core authors
I asked to developers in their server
What did they said ??
nothing x)
XD
nobody reply
but i know the problem it's with Node because the solution is to downgrade node to lts version
But the lts version don't match with discord.js v13
What is the exact problem with Node higher versions ??
for nodejs v16, you need to specify highWaterMark for ytdl-core
that i don't know just the solution is the downgrade
So I installed the voice extension, how do I get the bot to connect to a voice channel now?
See pins
I agree with the fact that youtube-dl uses FFMPEG but only as a Post Processor. (Not with all urls.)
Thanks y’all are such a great team! I appreciate it!
That's what I've been trying to figure out for months now, it happens when I use an opus/webm stream and not with ffmpeg
Yeah added the necessary packages, but the code for joining a voice channel, I need that.
I think prism spawns the ffmpeg process not youtube-dl
Yes, That spawn ffmpeg instance only
Well that just gave me a really complicated error.
And if you saying it pass on cpu, My cpu usage doesn't seem to budge. at 11am, I restarted my vps, and when I started the song marathon too
um what can be the reasons for which a connection can't become ready
Try using that in production 
I just switched to lavalink a while ago
Bad internet / the bot doesn't have permission to join the channel / firewall issues..
Guild_Voice_States Intent not present mainly.
well just for testing I added all intents
Then bad internet, firewall issues etc...
firewall issue hmm
welp idk
because my bot can't seem to join the vc for 3 days for some reason
hello
idk how bad internet affect it tho
You IP might be banned for abuse as well.
is this thing change in djs v13 js message.client.queue.delete(message.guild.id);

IDK why but this format download video for me using youtube-dl.
Try it Ayeven.
does even queue existed in client class in V12 ?
any one say pls
wait lavalink still works for me tho 
Never 🙂
thought so
How much time did u give it to enter ready state?
Not djs related, that's a custom implementation
30sec
Show me where you defined client in main file
Just wanted to be sure
its just simple
const client = new Discord.Client({
intents: ["GUILDS","GUILD_MESSAGES","GUILD_VOICE_STATES"],
})
client.login(token)
Ok, then show me join code
async joinVc(channel,debug=false){
const d = {channelId:channel.id,
guildId:channel.guildId,
adapterCreator:channel.guild.voiceAdapterCreator ,
debug:debug // group:this.client.user.id
}
console.log(d)
const connection = joinVoiceChannel(d)
connection.on("debug", console.log)
connection.on('error', console.error)
await entersState(connection,VoiceConnectionStatus.Ready,10000)
this.servers.set(channel.guild.id,new ServerManager({connection, channel,voice: this}))
/* catch(error){
connection.destroy()
AoiError.consoleError("joinVoiceChannelError",error)
}*/
}```
channel is voice channel ??
yes member.voice.channel
tbh I don't have any clue why it doesnt work
it used to work with master branch tho
¯_(ツ)_/¯https://github.com/Ayeven/music/blob/master/slash/music/music.js with my code it should budge my cpu usage
Maybe Try doing npm update and try again
I deleted node_modules 4 times already then reinstalled every package
Your format download a video for me.
no idea, all good here
i will check it with a different host to see if it's a ip issue or not
In example also, it states bestaudio[conditions]. IDK why you are getting video from best condition.
youtube-dl default to best if no stated
I know that
and no, I tested, restarted my bot, no any file downloaded
But you can't play video through discord bot, so you are just wasting data in getting video.
It didnt download video, how you download video idk
there, no video
I am talking about format problem.
Try this code and see the result yourself :
youtube-dl -f best[ext=webm+acodec=opus+asr=44100]/bestaudio https://www.youtube.com/watch?v=V_jHc_n0p9c
image
I am not talking about discord audio playback, I am talking about youtube-dl format argument that you supplied
It gets video
it is youtube-dl argument
So I am just saying that you are passing a video stream which uses a lot of data as compared to audio counterpart of that file.
for live video, it is used
nope it still dies
hey it related js
hello one probleam happen
message.client.queue.delete(message.guild.id);``` this cant work in my codes
@subtle granite As said by him, we can't help you ^^
Yeah, the queue is attached to client variable itself not the actual client
If u are using command handler pls take client as args in execute function and then use it
That's incorrect for the latter part i think, message.client is same as client in args execute functions
yeah but if u declare client.queue
u cant get that queue in message.client, you have to get that client var through which it got attached
You can, if you attached something to the client anywhere it replicates
if (!message.member.voice.channel) return message.reply("🛑 Ah, you need to first join a voice channel for that.");
even if i am in vc it shows me the message
how to fix it
You need GUILD_VOICE_STATES intent
okay thanx
I think you mean GUILD_VOICE_STATES
Yep, exactly, sorry for the error lol
const resource = createAudioResource(await ytdl(music.url), {
inputType: StreamType.WebmOpus
});
resource.volume.setVolume(guildMusicQueue.volume / 100);
player.play(resource);
it shows error Cannot read property 'setVolume' of undefined
add inlineVolume: true
I want my discord bot to join the stage channel and give live music 24/7. How can I do it
check the music example in pins
@carmine timber dm ma pls help kar da bhie
DOESN'T WORK THIS IS HOPELESS
TRYING TO EXECUTE THIS JUST RETURNS AN ERROR WITH THE CHANNEL ID BECAUSE ITS NOT DEFINED, NOT GIVING ANYONE THE PROPER HELP.
Show some code instead of yelling
const { MessageReaction, Permissions, ClientVoiceManager } = require('discord.js');
const { joinVoiceChannel } = require('@discordjs/voice');
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
const config = require('../config.json');
const ytdl = require('ytdl-core');
module.exports = {
name: "yt",
commands: ["yt", "play"],
description: "Play Music From YouTube.com",
callback: (message, arguments, text, Discord, client) => {
connection.joinVoiceChannel()
}
}```
You dont even define channel????
I had to start from scratch thanks to V13.
You can’t just copy it and expect it to work like that, define channel.
It is meant to join the channel that the user running the command is joining. How tf do I do that?!
Pls learn basic js, I’m not going to argue. You don’t define channel anywhere in the code.
Sorted that, I'm doing so badly today.
Happens
nvm I think I might know what I'm doing, I'm checking the guide.
Does anyone know a simple way to get the discordjs voicechannel that the bot is currently connected to? (I do NOT mean the voiceConnection)
I want to find this so that i can check if the bot is alone in a channel. The only way i currently know how to do it is through doing some magic with the 'voiceStateUpdate' event.
nvm, I was wrong, I still need help.
Get class Guild from somewhere and then do this :
<Guild>.me.voice.channel
@carmine timber thank you very much! This is exactly something i was looking for !
How to determine the status of an audio player? e.g. if paused
audioPlayer.state.status will return an AudioPlayerStatus. @honest shuttle https://discordjs.github.io/voice/modules.html#audioplayerstate
Thanks
how to join to a voice channel
i dont see any guide
I can help you
uhhh ok, how can i join to a voice channel
I'll use a snippet and explain the code:```js
const voice = require('@discordjs/voice');
voice.joinVoiceChannel({ guildId: message.guild.id, channelId: message.member.voice.channelId, adapterCreator: message.guild.voiceAdapterCreator, debug: true /has more options like selfDeaf and selfMute - they are default of true/});
and whats voiceAdapterCreator
And "debug" is optional default is false
I don't know that much i found it on discordjs website but I found that
since /voice is a standalone library, you need adapters to connect it to libraries like discord.js/eris
;-;
discord.js v13 provides an adapter for /voice to use, so that when discord.js receives an event that /voice needs, the adapter can pass it on
or if /voice needs to send a message on the main discord gateway, it can use the adapter
There's a typo in docs, selfMute defaults to false.
https://discordjs.github.io/voice/interfaces/joinvoicechanneloptions.html#selfmute
ty, you can either PR it or i'll remember to add it to my voice receive PR
I used message you may change that
?
Like <client>.guilds.cache.get('specified guild id').voiceAdapterCreator
joinVoiceChannel({
guildId: message.guild.id,
channelId: canalvoz.id,
adapterCreator: message.guild.adapterCreator,
selfDeaf: true,
debug: true,
})
whats bad, why that error .-.
returned an anonymous function
I think canalvoz = channel
Yes it returns... we need that to connect to the voice channel
yea,
let canalvoz = message.member.voice.channel;
So you can do canalvoz.guild.adapterCreator
guildId is the same thing <channel>.guild.id
ok lemme try
still the error
A type error look adapterCreator instead voiceAdapterCreator
what?
im still getting that error
You wrote canalvoz.guild.adapterCreator but that is canalvoz.guild.voiceAdapterCreator
ok works, but now my .then doesnt works
Because it is not a promise you can't use await and then
my bot cant join stage channel and voice channel on discordjs v13
i cant understand new updates
Discord v13 not support an audio library?
Can you help me? I tried following the guide and it won't even join and no error is showing
const { generateDependencyReport, joinVoiceChannel, getVoiceConnection, createAudioPlayer, createAudioResource } = require('@discordjs/voice');
module.exports = {
name: 'join',
description: 'Make the bot join voice chat',
options: [{
name: 'channel_id',
type: 3,
description: 'voice chat id',
required: true,
}],
async execute(interaction, client) {
try {
console.log(interaction.options.getString('channel_id'));
console.log(interaction.guild.id);
let channel = client.channels.cache.get(interaction.options.getString('channel_id'));
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator
});
console.log(channel);
await interaction.reply({content: 'The bot has joined the channel'});
} catch (error) {
console.log(error);
}
}
};
If you write a text channel it wont work without errors
so like I need to make it so it gets it from the message? Not from the channel itself?
wait.. you just defined connection
you can use join without making an variable and filter the channels before joining to prevent joining to text channels
I am putting a voice channel id in it, and I imported the actual function so it is like the code you used as an example
I just want my bot to enter the voice channel and play a link when the bot is running, but I haven't even figured out how to enter the voice in the v13 version, can you help?
That is what I am trying to do & I followed the guide
I've been trying since morning
can't u use member.voice.channel instead
Hello, does anyone here knows what means 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) {
resource: AudioResource {
playbackDuration: 65940,
started: true,
silenceRemaining: -1,
edges: [ [Object] ],
playStream: WebmDemuxer {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 5,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: true,
_remainder: null,
_length: 1064960,
_count: 1064758,
_skipUntil: null,
_track: [Object],
_incompleteTrack: {},
_ebmlFound: true,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: [Function: bound onwrite]
},
metadata: {
name: 'Дайте танк (!) – Бесы',
url: 'https://www.youtube.com/watch?v=EspTHhWkWEA',
thumbnail: 'https://i.ytimg.com/vi/EspTHhWkWEA/hqdefault.jpg?sqp=-oaymwEjCOADEI4CSFryq4qpAxUIARUAAAAAGAElAADIQj0AgKJDeAE=&rs=AOn4CLBmvBDk6Jcq3z_59LWAeIWakOjzpQ',
duration: 141000,
request: [Object]
},
silencePaddingFrames: 5,
audioPlayer: AudioPlayer {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
subscribers: [Array],
_state: [Object],
behaviors: [Object],
debug: [Function (anonymous)],
[Symbol(kCapture)]: false
}
}
}
```If you ask, I'll enable debugging to get more info. Ping if you'll answer me.
You can't use <voiceChannel>.join() so you need to install additional module @discordjs/voice
How can I simply create a link and put my bot into sound with the link, I couldn't succeed in any way, believe me, I'm about to go crazy :D
Error: FFmpeg/avconv not found!
I have avconv installed, i cant install FFmpeg-static for some reason at all
@wintry lily can you look at that code
@rough pawn @wintry lily It was a Intent missing 🤣 
I just added them all at this point
I am dead on the inside
..
Do you have this intent Intents.FLAGS.GUILD_VOICE_STATES ?
I added that and now it works
yeah i already added
Check your bots permission on the channel I think that might be it
looks like your bot doesnt have access to create slash commands in that guild
Idk
^ it says missing access so either access to the command or the permission on the voice chat
and uh... anyone?
const connection = await joinVoiceChannel({voiceChannel});
const stream = ytdl(args[0], { filter: 'audioonly' });
connection.play(stream, { seek: 0, volume: 1 }).on('finish', () => {
connection.destroy({ timeout: 120000 });
});```
returns this error `TypeError: adapterCreator is not a function` and I'm unsure how to remedy this
have all the acces
you need the application.commands scope when u invited ur bot to the server. admin changes nothing
You need to get guild's voice adapter creator by <guild>.voiceAdapterCreator property and you can look at my code above @golden path
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.5.6
- prism-media: 1.3.1
Opus Libraries
- @discordjs/opus: not found
- opusscript: not found
Encryption Libraries
- sodium: not found
- libsodium-wrappers: 0.7.9
- tweetnacl: 1.0.3
FFmpeg
- not found
--------------------------------------------------
PS Path/To/Something> npm ls
+-- ffmpeg@0.0.4
Why?
The npm package is called ffmpeg-static
The thing is, ffmpeg-static wont install
it hangs and freezes, only ffmpeg will...
You can also install the ffmpeg executable from the official site
The ffmpeg you installed is not an option
Hmm. I was wanting it to be installed and installable in my package.json since i wont be hosting the bot on my PC
Where are you hosting?
Just on my local pc atm, going to host on a vps
I mean where will you be hosting it?
With who?
I mean, its just pterodactyl servers, someones VPS
Some hosts have it installed by default
If you can run commands, you can check using ffmpeg
https://rufus.has-no-bra.in/56EYWiinO Everytime i go to install it with -static it does this. Just hangs
I can't. Highly doubt it either, its just my friends VPS
Ask ur friend to install it
you can always just install it with like apt-get install ffmpeg
Hm
Oh, you need windows build tools… i was stuck on this for 3 hours …. Install latest node + windows build tools
okay, I'm getting this now Package subpath './voice' is not defined by "exports" in /app/node_modules/discord.js/package.json and I've already defined discord.js/voice in dependencies "@discordjs/voice": "^0.5.5",
you have to import @discordjs/voice, not discord.js/voice
thanks 😅
np
@spare wave Hey, sorry for pinging you, but I tried the code you posted earlier today and I removed the asr filter. Surprisingly there's no memory leaks, even without FFMPEG and I have absolutely no idea why, everything looks the same as the music-bot example but the memory usage is way more stable.
If you can give me a hint on anything you changed from the example I'd really appreciate it!
windows build tools?
This seems to happen everytime I disconnect my bot from the voice channel. Any ideas why this could be occuring?
I only have a ReadableStream, how can I make a Readable out of it?
ReadableStream and Readable are the same thing
So I can just cast one to another?
if you mean pipe yes
nah, i meant cast my ReadAbleStream to a Readable, you certainly cannot pipe from one readable to another
where exactly are you getting the "ReadableStream"
from an older library
naudiodon
I'll see if it works
and which one do u need to cast that into?
@void wadiwas able to run the voice join command
I set up the new voice channel stuff at the top of my code to define joinVoiceChannel.
async execute(message, args) {
voice.joinVoiceChannel({
guildId: message.guild.id,
channelId: message.member.voice.channelId,
adapterCreator: message.guild.voiceAdapterCreator
});
I can get the bot to join the vc but I get this error:
2021-08-09T20:43:42.613424+00:00 app[Worker.1]: const connection = await joinVoiceChannel({voiceChannel});
2021-08-09T20:43:42.613425+00:00 app[Worker.1]: ^
I have a raw audio stream and I want to let my bot play that stream. But it instantly crashes with the error Premature close. Could be that the Audio Player completed the stream for now and just shut off?
There is a way to make sure that the bot connects as an stage speaker instead of an stage audience?
how to check if the bot is in voice channel?
hey has the audio receive function pr been approved ? :D
https://srcb.in/sLK8JKEBcI why does this error come when trying to play a song https://srcb.in/stX2rR31Z1 (play command)
i have @discordjs/opus(0.5.3), ffmpeg-static(4.4.0), libsodium-wrappers(0.7.9)
I've heard I need to update my code. Can someone tell me what needs to change with this?
channel.join().then(connection => {
console.log("Successfully connected");
}).catch(e => {
console.error(e);
});
is there a function that skips the current playing song?
stop the current player
<AudioPlayer>.stop()
Already got it thanks anyway
What's going on ytdl-core that causes it to abort randomly? I realize this isn't strictly DJS voice-related but it's pretty parallel to it.
It is with stream creation issue with ytdl-core, I will recommend either you switch to FFMPEG or youtube-dl-exec.
For more info : https://github.com/fent/node-ytdl-core/issues/902
Ty ty. Dunno why I didn't check there.
Simple Fix for that :
Confirmed, setting ytdl-core highWatermark option to 32MiB on Node.js v16 (16.5.0) fixes the problem, so the workarounds are use Node v14.x or play with the highWatermark settings, not sure if this will apply to everyone.
You need to download one more dependency : @discordjs/opus
Try doing npm i @discordjs/opus
It is completely changed
https://deploy-preview-595--discordjs-guide.netlify.app/voice/voice-connections.html#creation
<Guild>.me.voice?.channel
Everything is ready but approval is still pending here :
https://github.com/discordjs/voice/pull/136
Thx men
Why the "?"
That checks if voice is not undefined along with checking channel.
You mean if true then equals true, if false or undefined then equals false?
This is native to node.js?
^
@vocal valley Review my pr as VoiceRecieve is almost done.
Hey, just switched to v13, and I don't fully understand how voice works, my connection is stuck signalling. I'm trying to have the bot join the VC and then play a sound.
Code:
const Discord = require("discord.js");
const voice = require("@discordjs/voice");
console.log(voice.generateDependencyReport());
var audioPlayer = voice.createAudioPlayer({
behaviors: {
noSubscriber: voice.NoSubscriberBehavior.Play,
},
});
const confirm = voice.createAudioResource("../assets/sounds/confirm.mp3");
/** @type {voice.VoiceConnection} */
var connection;
/**
*
* @param {Discord} Discord
* @param {Discord.Client} Client
* @param {Discord.ButtonInteraction} interaction
*/
async function joinVC(Discord, Client, interaction) {
if (interaction.member.voice.channel) {
connection = voice.joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
connection.on(voice.VoiceConnectionStatus.Ready, async () => {
audioPlayer.play(confirm);
connection.subscribe(audioPlayer);
await interaction.editReply("Done!");
await interaction.deleteReply();
});
} else
return interaction.editReply(
"Sorry, you can't do that! \n`Error Code: 2 | NO_VC`"
);
}
This is in a small module that gets required into the main index.js file.
Thanks for any help!
Show me where you defined client in index.js file
//Line 5
const Discord = require("discord.js");
const Client = new Discord.Client({
intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES],
});
I need a voice intent?
Yes you need GUILD_VOICE_STATES intent also
That helps a ton, thanks
NP 👍
So, once the connection is ready, do I subscribe first, or play first?
connection.on(voice.VoiceConnectionStatus.Ready, async () => {
audioPlayer.play(confirm);
connection.subscribe(audioPlayer);
await interaction.editReply("Done!");
await wait(5000)
await interaction.deleteReply();
});
Your choice. It works both ways
Hmm, I'm not hearing anything either way
Show me audioResource you are creating ??
const confirm = voice.createAudioResource("../assets/sounds/confirm.mp3");
Core Dependencies
- @discordjs/voice: 0.5.6
- prism-media: 1.3.1
Opus Libraries
- @discordjs/opus: 0.5.3
- opusscript: not found
Encryption Libraries
- sodium: not found
- libsodium-wrappers: 0.7.9
- tweetnacl: not found
FFmpeg
- version: 4.4-static https://johnvansickle.com/ffmpeg/
- libopus: yes
That path is wrong. That is relative path and voice module never accepts relative path
aah, I'll go with path.join then
@grizzled wadi Use this one
Appriciate
can someone help me with this? I'm having a lot of trouble with this code:
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: 32767 })
const Command = require("./src/Structures/Command.js");
var Discord = require('discord.js');
var isReady = true;
if (command === "!call") {
var VC = message.member.voiceChannel;
if (!VC)
return message.reply("MESSAGE IF NOT IN A VOICE CHANNEL")
VC.join()
.then(connection => {
const dispatcher = connection.playFile('C:/Users/Claudiu/Desktop/Customer Service/open.mp3');
dispatcher.on("end", end => {VC.leave()});
})
.catch(console.error);
};```
the error is:
throw err;
^
Error: Cannot find module './src/Structures/Command.js'
Require stack:
- C:\Users-\UrGud's Bot\src\Commands\call-functionality.js
- C:\Users-\UrGud's Bot\src\Structures\Client.js
- C:\Users-\UrGud's Bot\index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at Object.<anonymous> (C:\Users\Claudiu\UrGud's Bot\src\Commands\call-functionality.js:3:17)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
It can't find your module
As error says, it can't find command.js file
./src/Structures/Command.js doesn't exist
it does tho
You're requiring it from a different folder
Where is the file that you posted?
Remove src folder from there
EZ fix
but the src folder has all of my commands and stuff in there
Main file is located outside src folder ??
yeah
You aren't requiring it from the main file though
it's just these:
/** @format */
console.clear();
const Client = require("./src/Structures/Client.js");
const config = require("./src/Data/config.json");
const client = new Client();
client.start(config.token);```
Then you can try this :
const path = require('path')
let actual_path = path.resolve('./src/Structures/Command.js')
const Command = require(actual_path)
lmao still no audio
You are requiring it from call-functionality.js tho
Show me code again
..so what does that mean?
It's in a different folder?
Yes you are correct
const Discord = require("discord.js");
const voice = require("@discordjs/voice");
const path = require("path")
const wait = require("util").promisify(setTimeout);
console.log(voice.generateDependencyReport());
var audioPlayer = voice.createAudioPlayer({
behaviors: {
noSubscriber: voice.NoSubscriberBehavior.Play,
},
});
const filePath = path.resolve("../assets/sounds/confirm.mp3")
const confirm = voice.createAudioResource(filePath);
/** @type {voice.VoiceConnection} */
var connection;
/**
*
* @param {Discord} Discord
* @param {Discord.Client} Client
* @param {Discord.ButtonInteraction} interaction
*/
async function joinVC(Discord, Client, interaction) {
if (interaction.member.voice.channel) {
connection = voice.joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
connection.on(voice.VoiceConnectionStatus.Ready, async () => {
audioPlayer.play(confirm);
connection.subscribe(audioPlayer);
await interaction.editReply("Done!");
await wait(5000)
await interaction.deleteReply();
});
} else
return interaction.editReply(
"Sorry, you can't do that! \n`Error Code: 2 | NO_VC`"
);
}
exports.joinVC = joinVC;
exports.connection = connection;
wrong reply, sorry
bruh
So require it from ./Structures/Command.js probably, you already are in the src directory
the same error
I can't see well on mobile, is call-functionality.js in the Commands directory?
yeah
Then ../Structures/Command.js
are you kidding, still the same error
const resource = createAudioResource(`./records/Paris.mp3`);
const player = createAudioPlayer();
connection.subscribe(player);
player.play(resource);
i get no errors but doesnt work ..........
Planning on releasing 0.6.0 of the library today which features voice receive!
@carmine timber your PR will make it into 0.6.1, i need to write tests still and address some comments on the PR
Okay.
@velvet rock This will help you resolve the problem.
hello, please help me
The code :
module.exports = {
name: 'play',
aliases: ['p'],
category: 'Music',
utilisation: '{prefix}play [name/lien]',
run: async (client, message, args, cmduser, text, prefix)=> {
if (!message.member.voice.channel) {
const embed1 = new MessageEmbed()
.setDescription(` ${client.emotes.error} - Tu n'est pas dans un salon vocal. !`)
.setColor('#9b9b9b')
return message.channel.send({ embeds: [embed1] }) }
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) {
const embed2 = new MessageEmbed()
.setDescription(` ${client.emotes.error} - Je suis deja dans un salon vocal`)
.setColor('#9b9b9b')
return message.channel.send({ embeds: [embed2] }) }
if (!args[0]) {
const embed3 = new MessageEmbed()
.setDescription(` ${client.emotes.error} - Merci d'indiquer le son`)
.setColor('#9b9b9b')
return message.channel.send({ embeds: [embed3] }) }
client.player.play(message, args.join(" "), { firstResult: true });
},
};
The error :
We can't help for third party modules. Ask the module owner for the help.
@vocal valley I have added 2 tests for FFMPEG.
Thx men
@carmine timber i guess u didn't quite get that i have @discordjs/opus installed (i literally listed the dependencies)
Sorry my bad, I read it discordjs/voice instead of discordjs/opus.
Can you tell what is in this folder ??
C:\Users\David\OneDrive\Documents\Shavel\node_modules\@discordjs\opus\prebuild\
2 min
And also tell the exact path of your bot's index/main file.
dist/index.js
I got your problem
Can you make a new folder and then type npm init -y and then install packages again (like discord.js, @discordjs/voice, opus, libsodium-wrappers etc) ??
Your problem will be solved 😄
create a folder where and for what?
dist is just the compiled code
Can you show me index.js in same manner of this photo ??
Ok, so in this folder do
npm init -y
npm install <all packages again as mentioned above>
Ah I see thanks :)
why did that work...
and is there a way i can fix this for the main dir?
Did it actually work ??
the audio played but interaction still failed which i will fix
@carmine timber
installing all those dependencies fixes it
but the audio is so fucking choppy
Yes there is a way,
Type this :
npm uninstall @discordjs/opus -g
And then make sure there is no folder in ``C:\Users\David\OneDrive\Documents\Shavel\node_modules@discordjs\opus\prebuild`
After that, just do :
npm install @discordjs/opus -g
Code please
My audioPlayer just emit stateChange twice
And both state are same, is that normal?
./mutils/track what is in it
the Track class
What track class?
Did you use examples from voice github ??
it's nearly the same from the example bot with some modification
So basically, if audio is choppy then it is your internet issue. Since there is no issue with youtube-dl
I tried use youtube-dl (With youtube-dl-exec), but it play normally after fresh restart, after 6~7 hours it just become no sound
how can i force move a user to a channel when he presses a button??
there is no way my internet is in question i have 300 upload 300 download 😄
300Kbps or 300Mbps 
Mbps
That is not normal . You are listening to listeners twice somewhere in loop
I pretty sure i have removedListener
o wait I saw it
Then may be try different modules to create audio resource
I know it's bad practice, but I download what I'm going to be playing to a file, then stream from that
That is very Wrong, it takes a lot of time to play a song
I'm only downloading the audio, and it's only for my personal server, so it's 3 seconds at most
I have tried these but I still can't play music after my bot online for several hours
State changed to playing but no any sound
Tried:
- ytdl-core
- youtube-dl-exec
- HLS stream
All source will be convert to opus using prism-media
What about live streams ??
Code ??
Wait a sec i send my player class
I don't use them, although I don't have a filter for them
Nice 😄
nobody has requested them lmao
LMAO
I wonder what would happen
Lifecycle:
add song using method add(), then use method start()
@carmine timber Here is song data when using method add()
[
{
"url": "Youtube url",
"title": "Video title",
"duration": "Video duration",
"thumbnail": "Video thumbnail",
"type": "song",
"by": "Who queued this song"
}
]
I got more issues with more audio, the only difference here is that I'm making the resource right before I play it
async function playVideo(info, interaction) {
if (!connection) {
console.log(connection)
return interaction.editReply(
"Sorry, you can't do that! \n`Error Code: 2 | NO_VC`"
);
} else {
const videoPath = path.resolve("./download/video.mp3")
const video = voice.createAudioResource(videoPath)
audioPlayer.play(video)
interaction.deleteReply()
}
}
i remember you can just pass path into it
without reslove it
Just curious, can you console.log(this.audioResource) and then show me edges
I plan to use it on another PC than the one I'm writing it on
and this is just easier to understand in the moment
No error currently
No you can't pass a relative path in audio resource
Does it play song ??
O wait error appeared, let me prepare debugger
conection.subscribe() ????

👀
Yeah, that's not there
but why ??
uhh... I'm not sure
Did you do connection.subscribe anywhere ???
Yeah, earlier up, in another function
when it joined the vc
What's the issue now ??
I added it, still not playing audio
Looks like devtool cannot show audioPlayer, i can explain how does it happended
async function playVideo(info, interaction) {
if (!connection) {
console.log(connection)
return interaction.editReply(
"Sorry, you can't do that! \n`Error Code: 2 | NO_VC`"
);
} else {
const videoPath = path.resolve("./download/video.mp3")
const video = voice.createAudioResource(videoPath)
sub = connection.subscribe(audioPlayer)
audioPlayer.play(video)
interaction.deleteReply()
}
}
Do you await for connection being ready ??
I figured it would already be ready, as I made it earlier, in the join function, and I've been using the same variable, connection is declared at top level
@carmine timber
When it is bugged, every guild cannot play any song
State change: buffering => playing
But no any sound playing, only restart can break this error, but it will bugged again
Recreate conenction, audioPlayer, audioResource doesnt work
AudioResource#playbackDuration always 0
How many guilds do your bot is in ??
266 now
Can you console.log(videoPath)
Already did, it's the correct path
and the connection is ready, just checked
266 and using class is not a way to go
Since then you will be creating 266 objects classes into memory and that will lead to memory leaks. So I guess when that bugs occur, you have memory leaks issues.
So I think you should monitor your memory and see if there is memory leak or not.
That's only possible error that I can think of
Console.log(video) ??
But there wont 266 guild play music at the same time
Max 4~5 guild will play music at same time
And about memory leak, my bot use 150~160 MB ram
Can you show me the code where you used this player class
You can just ignore chinese string...
No error, nothing in console
pastebin better
true, but I'm kinda lazy
@carmine timber can i dm you
aah
poor dude, so busy, got 3 people on him
XD
Hey, does anybody know how to fix the problem with discordjs / ytdl-core when trying to play an youtube stream? When Im playing live videos with ytdl and discordjs's new voice the bot joins perfectly, plays for 2 seconds (the amout of time It bufferd) or so and then instantly leaves. (normal youtube videos work perfectly fine)
@carmine timber https://pastebin.com/R3t2DERk audioResource if you think its important
Rule 1
help plz
Error seems pretty self-explanatory. the channel is full
Yes, but I want a solution
check voicechannel.full before joining
It's not full but the bot can't enter it
I want a solution, instead of the robot crashing, it says I can't get room voice
i this way exists to seek to duration on audioResource
im using local audio files