#archive-voice

30636 messages · Page 2 of 31

carmine timber

Try to update to latest dev build .

and then check

wise anchor

works now ty

carmine timber

np

lost lynx

FYI @vocal valley I succeeded in using the adapter, and using this new voiceConnection and play audio succesfully from my system. When I deployed to my host, it still gave an error, but this time I was able to track it to the UDP connection.

So, this means my Hosting provided might be blocking the UDP connection. I'll try to contact them about that...

But ti also means that in the regular Voice module of discord.js (not the new @discord/voice, which is OK), UDP error are not trapped by try/catches.

Anyway, thanks guys for your help! Hopefully my Hosting provided will be receptive... !

vocal valley

no problem!

Good luck with getting that resolved

wise anchor

how can i bassboost a song?

vocal valley

outside the scope of this lib, presumably you could do it with ffmpeg

wise anchor

ight

last mist

Mind if we have a (hopefully) short discussion on how to install the basics and get an audio file to play? I had it working in v12 obviously it is different now. I see the pinned messages. I'm looking at the preview-595 guide as I type. Should I type the npm install line with "libsodium-wrappers" it specifically says "for example" which sounded like I could change that to sodium for "(best performance)". Doing that didn't work the install barked and logged something I had never seen before re: please set your MS VS version before you run install. I see the tip in the doc about "if you are struggling" is this what is meant? and am I correct in assuming that one types in --vs2015 regardless of what version of VS one is using even if it is VS Code?

Oh, the log file BTW mentions "npm config set msvs_version 2015" as a way to set the version do we believe that is more or less equivalent to the TIP instruction?

steel crescent

Don't bother installing sodium on windows.

last mist

okay thanks

I tried the line mentioned in the log, it didn't help as the installer now wanted a copy of VS2015 to be around

libsodium-wrappers worked

the generateDependencyReport report looks reasonable

I seem to have tweetnacl: 1.0.3 automatically because I didn't ask for it

brazen crag

hey all!
i'd like to achieve this kind of flow - a bot which will react on a command (for example !play last-show) which will output a button to the user with a PLAY label on it, and once the user clicks - it will stream the audio from the latest mixcloud's show from my user.
Getting the last show from mixcloud's api is quite straightforward.. i wonder if there's an option to stream its' audio via discord's audio channel or somehow embed mixcloud's widget in the channel itself?

vocal valley
last mist

thanks for that heads up... wasn't worried about having extra mostly about not having enough 🙂

last mist

a few hours later... no errors for the moment and no sounds ... sure is fun 😫

vocal valley
last mist

if you mean the music-bot example then no.

vocal valley

ah ok

if you want, you can send the code you're using and i can take a look tomorrow to see what the issue might be

last mist

that's awfully nice of you... I'm resting and then I'll take another look or two. I've looked at that music-bot code but frankly as an example it is over engineered. Typescript, babel, jest, prettier, linter, some streaming stuff. That might be example two but not the hello world of audio.

I'm putting in more logging to try to determine where the issue may be. I don't see the connection.on events firing for instance.

vocal valley

the basic example might be easier to try and aid with debugging

last mist

I also search for messages here... one error informed me I didn't have the latest version of v13

vocal valley

ah yeah, that's come up a few times today

last mist

Yup 🙂

I wish I could do it but if the things people encounter could be set into a "you're probably going to do this" page it would go a long way.

I was also hoping that someone who distilled it down to "play a single .mp3 file" might post their experiences.

Ah I seem to have overlooked the basic example... what you posted now makes sense... I think I can paste that somewhere into my app without a lot of issues, thanks.

vocal valley
last mist

works well? Hopefully it "beeps" 🙂

thanks

grim fulcrum
last mist I was also hoping that someone who distilled it down to "play a single .mp3 file...

This should work:

const { Client, Intents } = require('discord.js');
const { joinVoiceChannel, createAudioResource, createAudioPlayer, StreamType } = require('@discordjs/voice');

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_VOICE_STATES] });

const player = createAudioPlayer();

client.on('message', async (message) => {
  if (message.content === '!play') {
    const channel = message.member.voice.channel;
    if (!channel) return message.reply('You must be in the voice channel.');
    const resource = createAudioResource('https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3', { inputType: StreamType.Arbitrary, });

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

    player.play(resource);
    connection.subscribe(player);
    await message.reply('Playing now!');
  }
});
void client.login('token here');
last mist

now that is an audio "hello world"...

gracias

last mist

Yahoo that plays... much better when I type the command in my server, in my bot 🙂

Nice music

I can adapt it from here, thanks everyone

grim fulcrum

🎉

last mist

I've been having great success and migrated my little sound demo from v12 to v13 and added that SoundHelix song to the options. Meanwhile it seems that one can only set the volume if the inlineVolume option is set to true. I gather from the docs that this plays through the ffmpeg service which (I'm guessing) is the only one that supports volume, is that correct? The notes about improved performance concerns me a bit has this always been the case with ffmpeg? Volume control seems to be pretty much necessary doesn't it?

"There are only two kinds of programming languages: those people always bitch about and those nobody uses." -- Bjarne Stroustrup

carmine timber
vocal valley
brazen crag
carmine timber

example of mixcloud endpoint

The audio streams are not available through the Mixcloud API. There are two reasons for this.

Firstly, we need to know what has been listened to so that we can report usage, pay royalties and provide features such as 'Suggested Shows'.Secondly, Mixcloud needs to pay the bills! We can't give away the audio for free outside of mixcloud.com simply because it costs us to host and stream the files and pay royalties.

@brazen crag Mixcloud never streams audio

So there is no possible way to stream audio through their api's

brazen crag

And what about their embeddable widgets which can be freely used on html pages? Is it somehow possible to embed them graphically on discord's interface?

carmine timber

interesting question, let me double check 👀

I can't find any way to use that embeddable widgets as Discord don't allow to attach HTML frames in their embeds

brazen crag

ok buddy! thanks for research and answers ❤️

spare wave

Looking at the example, feel like over engineered @.@

carmine timber

👀

spare wave

I meant the typescript example, well at least after toasting my brain, able to "downgrade" it to js and make it modular

carmine timber

I know, there is only typescripts examples only 🙂

vocal valley
carmine timber

@vocal valley Is there anything in player like ispaused() like in v12 voice ??

spare wave

is ok, manage to settle it

vocal valley
carmine timber

Oh I forgot about that LOL

spare wave

I wont say it is 100% my code though, since I didn't understand the track and subscription, I shamelessly copied it and import it to my code

vocal valley

I don't think there is anything wrong with that,

carmine timber
vocal valley

The new voice library has a lot of low-level stuff and it makes sense to use something that works and handles edge cases for you

carmine timber

New Voice API is more flexible than old one. You can literally handle any event with connection and audio player separately.

rich flicker

oh, sorry

spare wave

For music bot, what is the recommended RAM size?

I don't plan to make it public though

stark drum
lime gale
Error: Cannot perform IP discovery - socket closed
    at Socket.<anonymous> (D:\Coding\DisTube\DisTube\node_modules\@discordjs\voice\dist\networking\VoiceUDPSocket.js:120:52)
    at Object.onceWrapper (events.js:482:28)
    at Socket.emit (events.js:388:22)
    at socketCloseNT (dgram.js:748:8)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

My connection emitted this, should I ignore it since my connection is not disconnected nor destroyed? It's disconnected and reconnect the vc after that

vocal valley
frosty dawn
                secretbox.methods.close(opusPacket, connectionData.nonceBuffer, secretKey),
                                  ^

TypeError: secretbox.methods.close is not a function

any solution what's happening here?

subtle granite

Is this for music like rythm?

lime gale
frosty dawn

it worked btw

lime gale
carmine timber
carmine timber

@frosty dawn Here it is

vocal valley
subtle granite

How can I use it to get the good sound quality?

vocal valley

as long as you provide it a good quality audio stream, it should be able to play it back reliably

it's much less choppy compared to discord.js v12's voice

frosty dawn

VoiceConnectionStatus.Ready !=="Ready"

will this work?

vocal valley

what are you trying to do

carmine timber

maybe if statement i guess

vocal valley
frosty dawn
carmine timber
vocal valley

you should be doing something like:

voiceConnection.state.status === VoiceConnectionStatus.Ready

to check for the ready state

if you want to listen for it like an event,

const myConnection = createVoiceConnection(...);
await entersState(myConnection, VoiceConnectionStatus.Ready, 30_000);
// ready within 30 secs, otherwise it would have thrown

or

// one option
voiceConnection.on(VoiceConnectionStatus.Ready, () => console.log('Ready'));

// another option
voiceConnection.on('stateChange', (oldState, newState) => {
  if (oldState.status !== VoiceConnectionStatus.Ready && newState.status === VoiceConnectionStatus.Ready) {
    console.log('Ready');
  }
});
// both are equivalent
lime gale

If someone disconnects the bot, the reason of VoiceConnectionDisconnectReason should be EndpointRemoved or WebSocketClose?

vocal valley

hmmm i have not actually tested that

I think it would be WebSocketClose

lime gale
vocal valley

However I made a mistake in the typings that makes it hard to extract the closeCode, will fix that later today

spare snow

How can I get all audio players?

carmine timber
vocal valley

if you have all your voice connections, you can find your audio players that have at least one subscriber

spare snow
spare snow
carmine timber
last mist

So time to move onto YouTube videos... these used to play in v12 but I've tried any number of twists on the code that plays audio files (both from my drive and from a url) and while I see the video image displayed in Discord message the video does not play automatically. Do these operate similar to audio files?

carmine timber
last mist

it is spread out a tiny bit but let me see about gathering the parts. In a nutshell what I've tried was requesting a YouTube video and at the last moment playing a file on my PC. This worked which tells me all the "setup" seems to be present. I then pass the url of the video to the createAudioResource function and the video does not play.

' const resource = createAudioResource(soundFile, { inputType: StreamType.Arbitrary, inlineVolume: true });

audioPlayer.play(resource);

'

how much code do you need this is the resource and playing in the audioPlayer

last mist

soundFile is the url or the path depending

carmine timber
last mist

if I set it to the URL of an audio file it plays, if I set it to a path on my drive it plays

soundFile is string property

last mist

the YouTube video

maybe there is an "actually start it" option?

carmine timber

Download ytdl-core module

last mist

done already

and ffmpeg

carmine timber
last mist

this was running in v12 maybe there is an updated version of those modules?

bet you not

oh I thought you asked if I did

of course I can

carmine timber

So do it

vocal valley
last mist

Yes both the actual string and the url that came back from a call to ytdl.getInfo(args[1]);

vocal valley

Hmmm ok, I'm not sure if you can play that directly as a string

carmine timber
last mist

that will probably work, one moment

vocal valley

also as a rule of thumb now, I don't recommend ytdl-core or ytdl-core-discord for serious music bots because of how error-prone they are to streaming audio (a lot of the time the stream aborts)

if you're making a proof of concept they're fine, but otherwise I'd recommend youtube-dl (the music bot example uses this)

carmine timber

??

carmine timber

Ok

last mist

Ray Parker Jr. is playing on my server!!!

Ghostbusters

vocal valley

🎉

carmine timber

🎉

last mist

I'll look at youtube-dl but this works for now

thank you, thank you

Uh youtube-dl looks like a library specifically for downloading files is that the case? Isn't that overkill and potentially a lot of overhead? I'll read more but it already looks like it runs on your server so I'd have the Windows version during testing and a Linux install in production. That seems like a lot of work. Thanks for the pointer though.

vocal valley

No problem, it can actually be used to stream the video files too rather than download

last mist

okay

spare snow

What happens when maxMissedFrames is reached?

and is it possible to set the bitrate?

spare wave

I got face slapped by the error aborted few times

spare wave

Nvm, just saw the new example, and youtube-dl used, maight try later

vocal valley
vocal valley
carmine timber

@vocal valley The ytdl-core-discord gives us a readable stream, then why we need to pass it through CreateAudioResource ?? Can we pass that directly to player.play ??

vocal valley

Nope, a player only plays audio resources. Creating a resource from an Opus stream doesn't pass the stream anywhere else though, it just wraps the stream as it is, so performance isn't made any worse

carmine timber
vocal valley

although i am fairly sure if it is not being destroyed, then it is due to ytdl-core

mental patio

in docs i saw <VoiceConnection>.subscribe() is let the AudioPlayer can play the stream. but in the djs/voice's "Hello World" i saw it did player.play() first then do connection.subscribe(). Why?

vocal valley

to be honest, it does not matter too much about which way around you do it

doing it a little earlier than .subscribe() means that your audio stream starts to be downloaded faster, so there's less time to wait before actually playing

if you do it too far in advance, depending on where the stream is coming from, it might have disconnected or exited

mental patio

so in that case it is acceptable

vocal valley

yep, that particularly audio source is fine to buffer in advance

and also we're assuming the user will run the example quickly after starting the bot

mental patio

is there any event emitted when the resource is finish playing?

vocal valley

the player transitions to Idle when it finishes playing

carmine timber
vocal valley
player.on('stateChange', (oldState, newState) => {
  if (oldState.status !== AudioPlayerStatus.Idle && newState.status === AudioPlayerStatus.Idle) {
    console.log(`Finished playing ${oldState.resource.metadata.title}`);
  }
});

(since Idle is the only state of an audio player that doesn't have a resource, the above works nicely)

mental patio

oof okay i think i got it

so both this code works

carmine timber

🎉

Yes

mental patio

oof nice thx for helping

carmine timber

np

carmine timber

And the music that I play now (2nd code) is soo good and without any disconnects (Tested on local PC)

mental patio

wait so the creatAudioResource() can have a youtube link as parameter

carmine timber

One thing, I want to ask , I can get yt-stream link in the format

container: 'webm',
codecs: 'opus',

So Can I use StreamType.WebmOpus while creating audio source in this case ??

vocal valley

wait

carmine timber

It is a link and not a file

vocal valley

if you are passing a link, it will get passed to ffmpeg and turn into an Ogg opus file automatically

carmine timber

Thanks

vocal valley

Np, it will be a little bit worse performance-wise than compared to using youtube-dl

Since it converts the stream for no reason

carmine timber
vocal valley

If it works then it's good I guess, even in that case the performance penalty shouldn't be too much since it's just changing the container of the file for you

mental patio
carmine timber
vocal valley

If you are using a link, the stream type is ignored

carmine timber

LOL

vocal valley

since create resource function will automatically use the correct format to understand what ffmpeg gives back 😅

carmine timber
vocal valley
carmine timber

npm i @discordjs/voice is installing 0.3.1

Not 0.4.0

But I managed to install with npm i @discordjs/voice@latest

hazy copper

have all these random crashes been taken care of? i just updated and it looks like im not getting them anymore?

hazy copper

like the thing would stop working on ytdl

nvm, it still gets them

carmine timber
vocal valley

The music bot example has been updated to use youtube-dl instead, which doesn't have the "random crashes"

spare wave

Any idea or direction if I wanted to do repeat function/command

vocal valley

to replay a song?

spare wave

yeah

vocal valley

make a new audio resource from the same song, and then play that again

spare wave

roger, will look into the documentation, btw any plan making the documentation more friendly like discordjs?

vocal valley
spare wave
spare snow

Hey again @vocal valley, I just found out that, for some reason, the memory leak doesn't happen on windows but does on linux. I have tested it multiple times with same code and nodejs version on 2 windows machines and 2 linux machines and I wish if anyone can reproduce this

vocal valley

is this when using ytdl-core?

spare snow

yep

vocal valley

could you try the latest example that uses youtube-dl instead?

spare snow

I tried it on linux and it was leaking as well, but slowly because I didn't pass a highWaterMark

vocal valley

🤔 thats interesting

spare snow

on windows I can literally see the stream getting garbage collected

vocal valley

are you running the example as it is? or did you make changes

vocal valley

and how do you know that it is leaking exactly? does the youtube-dl process stay alive after the song has finished playing?

spare snow

I was monitoring process.memoryUsage, on windows, when I skip a song it goes down to the idle usage but on linux it just keeps piling up

vocal valley

ok after you skip a song, if you wait a minute or two and then check memory usage again, does it go down?

e.g. for me, i have ~60mb to start,

playing a song takes it to about 70mb

skipping takes it to about 80mb but then it drops back down to 70mb

and then when it finishes, after a few seconds it goes back to ~60mb

steel crescent
spare wave

Yeah, the subscription and track is from example

spare snow
vocal valley

ok 👍

sometimes it just takes time for GC to kick in

spare snow

It never does

vocal valley

if after skipping/stopping and some time it drops back to 60/70, it means that there isnt a memory leak

could you try this:

$ node --expose-gc yourbot.js

and then whenever a song finishes, can you run global.gc()

if this reduces your memory usage, it means it's not a memory leak

steel crescent

a memory leak means you constantly gain

its as simple as that, stop checking your memory all the time lmao

if you go from 50 to 100 to 80 to 120 to 50 to 80 to 100

thats not a memory leak

You also need to test a considerably longer time for this to establish to be a memory leak

just so we are on the same page for example

this isnt a leak

spare snow
steel crescent

Over which period of time?

And yeah thats fine, I just want us to be on the same page. because people claim something to be a memory leak rather fast around here

and its increasingly annoying to deal with that when they instantly jump to conclusions

spare snow

I'm just saying that is behaves differently on windows, when I skip a stream it instantly gets gc and never does on linux

radiant ocean

how long is never

spare snow

days

steel crescent

is this on a rather big public bot

or some test bot on 1 guild

spare snow
spare snow
vocal valley
carmine timber

I think, my code will fix his errors 🤔

vocal valley

maybe but he says he is also getting this issue with youtube-dl

spare snow
carmine timber

As I ran that code over 15 minutes and memory was still at 60

vocal valley
spare snow

yup, It only frees when another stream replaces it

vocal valley

so if a song naturally comes to an end, and then you play another song after, the memory from the first song isnt freed?

but if you enqueue a song while one is playing, and then skip, it does get freed?

spare snow

I thinks it's a @discordjs/opus issue but not sure

vocal valley

🤔

steel crescent

You aren't making sense

vocal valley

so under which circumstance is it not freed

spare snow
vocal valley

that doesn't sound like a memory leak then

since it does go back down

carmine timber

Yup

That's not a memory leak

spare snow

yeah that's what I am saying! on linux it's piling up

just try to reproduce this

vocal valley
carmine timber

So you mean ytdl has no garbage remover right .

vocal valley

and on linux it keeps going higher and higher and doesnt come down at all?

vocal valley

ok, you're using the youtube-dl example right?

spare snow

ytdl-core-discord

carmine timber

Oh LOL

XD

vocal valley

ok,

one sec let me do something

spare snow

with highWaterMark: 1 << 25 to make the leak clearer

carmine timber

We were thinking about youtube-dl whole time and he is using ytdl-core-discord 😂

steel crescent

we just need to stop recommending this lib

OMEGALUL

vocal valley

using highWaterMark is not a good solution

ok so

spare snow
vocal valley

can you go to node_modules/ytdl-core/lib/index.js, and around line 180, change stream._destroy = () => ... to this:

  stream._destroy = () => {
    console.log('destroying stream');
    stream.destroyed = true;
    req.destroy();
    req.end();
  };
spare wave

using the youtube-dl it is within expected memory usage, on raspi pi 4 8GB

vocal valley

and then try running your bot again, when you skip or whatever on linux, it should say "destroying stream"

vocal valley

so it's not really streaming, more of "download this entire video into memory as quick as you can and then stream that"

the problem is when you have longer videos, e.g. that are more than 33MB

spare snow
carmine timber

hydrabolt, did you checked my discussion yet ??

vocal valley

highWaterMark is more of a bandaid fix, rather than a fix of something wrong in ytdl-core's reconnect logic i assume

vocal valley
vocal valley
spare snow
vocal valley

that will help us narrow down where the error is

vocal valley
carmine timber
vocal valley

i just want to be sure that is what is happening,

carmine timber

ok

steel crescent

have you tried with opusccript

the opus library doesnt even allocate memory, so how would it keep something in memory

lol

carmine timber

lol

spare snow
steel crescent

so you dont know

just say that instead of pointing the finger somewhere else

you should try youtube-dl or opusscript

carmine timber

He could even manage that without youtube-dl and opusscript also

vocal valley
spare snow

@vocal valley good news, on windows it does free the memory when I stop the player, just needed some time. (I just found out about the windows thing don't roast me)
but still, on linux it never does

vocal valley

ok but on linux, does it print out the destroyed thing

spare snow

I just stopped the player and I'll wait to see if it gets gc, it's sitting at 150mb already

I hate my ocd, I just could ignore it..

spare snow
vocal valley

how high can you get the memory to go on linux, could you test that

spare wave

about this memory thing, is this only affect ytdl-core? Because using youtube-dl, an it behave like it supposed to be

memory().heapUsed btw

vocal valley
spare wave

My short test earlier. The first song is quite long, 32min

wary forge

Hello, sorry for the dumb question, if I'm using lavalink, do I still need to install this package or its dependencies?

carmine timber

If you have lavalink, then don't install this

wary forge

the lavalink takes care of it on its own right

carmine timber

yes

wary forge
carmine timber
spare wave

youtube-dl

spare snow
carmine timber
spare wave youtube-dl

I think, I had a fix with ytdl-core itself, but I don't know whether hydrabolt will accept that or not

spare snow

260mb for 3 players and so on..

spare wave

ytdl-core always faceslap me with econReset or something those line

carmine timber
carmine timber

wanna try ??

spare wave

sure, though it will be later or tmrw

half gaming, hafl discord atm

carmine timber

Ok wait

function filter(format) {
    var results = []
    format.forEach((ele) => {
        if(ele.codecs === 'opus' && ele.container === 'webm' && ele.audioSampleRate === '48000'){
            results.push(ele)
        }
    })
    return results
}

//Below Code : Under message event
    let connection = await join_vc(message);
    const info = await ytdl.getInfo(<your - url>)
    let stream = filter(info.formats)[0].url
    var source = createAudioResource(stream, { inputType: StreamType.Opus , inlineVolume : true })
    var player = createAudioPlayer()
    player.play(source)
    connection.subscribe(player)

@spare wave

spare snow
carmine timber

and then tell me if memory still goes up or not

vocal valley
carmine timber
spare snow
vocal valley
spare snow
vocal valley

Yep, either try Youtube-dl example or the example above

spare wave

well, yeah, it climb up because the song is long

vocal valley

and then, once a song ends or you've skipped a few songs

Can you see how many ffmpeg (for the example @carmine timber posted) processes are running, or how many youtube-dl (for example on repo) processes stay running

spare snow
vocal valley

hm that is good, it would suggest there isn't actually a memory leak

carmine timber
vocal valley

No

If the process was alive after the song finished, that would suggest there's a memory leak

spare snow
steel crescent

just dont use ytdl-core

vocal valley

just see if your process runs out of memory after long usage

if it does, then you probably do have a memory leak

It also could just be d.js cache build up

a lot of factors here

carmine timber
stark drum

Windows and Linux don't manage memory the same way
You will always encounter differences between the two systems (even for how node allocates/free memory itself)

As long as it does not grab more and more memory over time it's fine
Make your bot in C if memory usage is a critical point

vocal valley

the developer of it has tried their best to fix it for discord.js so props to them

steel crescent

its time to start writing voicelink

vocal valley

But it still doesn't work great with d.js and people attribute their ytdl errors to discord.js

carmine timber
vocal valley

I think it's ok to use FFmpeg? but honestly I just trust youtube-dl to download the video cause that's why it exists

carmine timber

Oh

vocal valley

maybe there is some reconnection logic youtube-dl has that ffmpeg doesn't

carmine timber
grim fulcrum

I don't understand what it is, but there is no sound.

carmine timber
grim fulcrum
carmine timber
grim fulcrum

Example

carmine timber
stark drum
carmine timber
grim fulcrum
stark drum

Why would it print what it seems to be audio data then, also you'd get an error from discord.js at some point too

vocal valley

Can you send the full output of the console to us

carmine timber

It would be great

These are reconnect args which allow ffmpeg to reconnect once disconnected by itself

Just tell me if you will add or not

vocal valley

I think I will

carmine timber
grim fulcrum
vocal valley Can you send the full output of the console to us

That's all I could find.

.......��6����ވ;^E_���yؙ_ǝF���>    �5�Ǵ����n�:��r�7⟴�չt�#�F��������L,�J))��=�@��Fq
                                       ��������1�G�?3�����j��Db�WW2#l�-pRN�̬{%'c�ue�<�1`Ƿd��xy�����ű�LV/y��-�V������h
                                    cH�+ä����@�������T�������h������u��'ġ��|���
    at makeError (/Users/penguingl/Documents/example/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/Users/penguingl/Documents/example/node_modules/execa/index.js:118:26)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  shortMessage: 'Command failed with exit code 1: /Users/penguingl/Documents/example/node_modules/youtube-dl-exec/bin/youtube-dl https://www.youtube.com/watch?v=VBKNoLcj8jA -o - -q true -f bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio -r 100K',
  command: '/Users/penguingl/Documents/example/node_modules/youtube-dl-exec/bin/youtube-dl https://www.youtube.com/watch?v=VBKNoLcj8jA -o - -q true -f bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio -r 100K',
  escapedCommand: '"/Users/penguingl/Documents/example/node_modules/youtube-dl-exec/bin/youtube-dl" "https://www.youtube.com/watch?v=VBKNoLcj8jA" -o - -q true -f "bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio" -r 100K',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: `\x1AEߣ�B��\x01B��\x01B�\x04B�\bB��webmB��\x04B��.......
  
      tts: false,
      nonce: undefined,
      embeds: undefined,
      components: undefined,
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: 0,
      message_reference: [Object],
      attachments: undefined
    },
    files: []
  }
}
vocal valley

meguFace

huh

could you try running your bot and piping it's output to a file?

node bot.js > debuglog.txt

and then once the error occurs, send the debuglog.txt? annoyingly the top of the error is cut off

but doing this allows us to capture the whole thing

grim fulcrum
vocal valley

that is so odd 🤔

ill take a look at the youtube dl npm wrapper we use maybe there is an issue there

what node.js version are you using?

and are you on windows?

@grim fulcrum what do you get if you run this in a terminal:

/Users/penguingl/Documents/example/node_modules/youtube-dl-exec/bin/youtube-dl --version
grim fulcrum
vocal valley

ok, can you try this:

vocal valley
/Users/penguingl/Documents/example/node_modules/youtube-dl-exec/bin/youtube-dl https://www.youtube.com/watch?v=VBKNoLcj8jA -o - -q true -f bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio -r 100K

what happens if you run that?

grim fulcrum
...����(̳�i����U�`.6�3��V�
ERROR: u'true' is not a valid URL. Set --default-search "ytsearch" (or run  youtube-dl "ytsearch:true" ) to search YouTube
�       ճ��[���Th��v��...
vocal valley

ok, what about this:

/Users/penguingl/Documents/example/node_modules/youtube-dl-exec/bin/youtube-dl https://www.youtube.com/watch?v=VBKNoLcj8jA -o - -q true -f "bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio" -r 100K

it might still give you nonsense in the console

but if there's no error it's good

grim fulcrum

same error

ERROR: u'true' is not a valid URL. Set --default-search "ytsearch" (or run youtube-dl "ytsearch:true" ) to search YouTube

vocal valley

🤔

oh

/Users/penguingl/Documents/example/node_modules/youtube-dl-exec/bin/youtube-dl "https://www.youtube.com/watch?v=VBKNoLcj8jA" -o - -q true -f "bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio" -r 100K

now?

steel crescent

what are you passing true here for?

isnt -q enough to activate silent mode

vocal valley

ohh shit

grim fulcrum
vocal valley

thats a youtube-dl-exec bug crawl is right

on linux it doesnt pass the true 🤔

steel crescent

i mean it might not be wrong

I just thought its unneeded

vocal valley

you are right i think

carmine timber
vocal valley

on linux, running youtube-dl-exec with options {q: true} just yields -q iirc

on windows it must be doing -q true

Thonk

grim fulcrum
carmine timber

Oh

steel crescent

hmm

vocal valley

@grim fulcrum try this:

change line 52 in examples/music-bot/src/music/track.ts:

- q: true,
+ q: '',
steel crescent

yeah I tried it on debian

removing the true seems to work

vocal valley

thats so odd

it converts the args object into a list in JS, i thought that'd be platform-independent

steel crescent

might just be a quirk in the youtube-dl args parser

not expecting a value for -q so it poops itself

spare wave

on ubuntu, q:true all working good

vocal valley

🤨

guess i'll go with empty string

works in both

steel crescent

I only pasted the command from above, didn't try the actual bot

so theres that

spare wave

actual bot here

spare wave

what q parameter do though? have not read the youtube-dl docs

vocal valley

means "quiet", stops youtube-dl printing unnecessary info

spare wave

changing q:'' work too for ubuntu

vocal valley

@carmine timber i decided against adding reconnect options to ffmpeg at least for now since they might not be the optimal values for each user

carmine timber
viscid sable

should i only have discordjs/voice or do i also need to install discord.js for it?

vocal valley
viscid sable

(currently getting the error that the module dosen't exists)

vocal valley

i can't plan for every user's setup, instead they should do this themselves

vocal valley
viscid sable

i somehow always get the error Error: Cannot find module '/home/container/node_modules/@discordjs/voice/dist/index.js'. when i try to start it

vocal valley

did you run npm run build?

wait

did you install the library from npm?

viscid sable

yes

vocal valley

can you do ls /home/container/node_modules/@discordjs/voice and send the output here?

viscid sable

only this is in the folder

steel crescent

did u run npm build before the publish hydra mmLol

vocal valley

🤔

i did

i am sure i did

viscid sable

on my local pc i have the folder node_modules but nothing more

vocal valley

when i run npm i @discordjs/voice i get the dist folder

so im not really sure what's going on here

viscid sable

and npm says it installed it without any errors

carmine timber
vocal valley

but that is a subjective change

carmine timber
vocal valley

some people might just want the resource to die after a few seconds of delay

not all users will think 5 minutes is acceptable

carmine timber

Default to be 5

steel crescent

just do it yourself lol

carmine timber

Then that's ok for all users

vocal valley

i'll consider it but that is the same reason i removed seek from createAudioResource

because it only applies if you use ffmpeg

createAudioResource is not guaranteed to use ffmpeg

carmine timber

Oh

steel crescent

id hate to have an option forced onto me

especially because I never had any voice connection problems ever lol

vocal valley

the ffmpeg option we have so far does the bare basics of just turning the stream into an opus stream, that's all

steel crescent

so it would be totally useless for me

viscid sable

after doing npm remove discordjs/voice and redownloading it i now got the dist folder but somehow not on the host machine keyboardsmash

steel crescent

bruh

vocal valley

sounds like a cursed setup

britneyzoom

steel crescent

that sounds like you install from github

vocal valley

oh yeah

steel crescent

npm i @discordjs/voice

the @ is important

viscid sable

its what i did

carmine timber

@vocal valley Did you check out my research ??

steel crescent

lol

carmine timber

XD

viscid sable

i removed it and redownloaded it with npm

carmine timber
viscid sable

now i got a dist folder on the host machine Thonk

carmine timber

and show me result

viscid sable

i sadly can't run commands on the host machine, its just allows me to connect with FTP and install npm packages

(as its a docker container runned by Pterodactyl)

carmine timber
viscid sable
carmine timber
viscid sable
carmine timber

🎉

viscid sable

now i only need to rework some stuff because the example is in ts and im using js keyboardsmash

carmine timber

ExtraOptions will be just an extra argument that users want to supplement in ffmpeg.

chrome sundial

can i just tsignore

or it will make me some problems in future

vocal valley

should be fixed on 0.4.0

vocal valley

e.g. people will then think the stream they pass will have reconnect set for them

if people want to use custom FFmpeg arguments, they should just spawn their own FFmpeg instance, it's not too hard

and at least then they are being explicit about using FFmpeg

chrome sundial
bold cairn

Where’s the documentation for “new-voice”?

rustic temple
mental adder

Anyone can help me?

rustic temple

Are you sure it'll be executed in a guild?

And not a DM

mental adder

The code

rustic temple

Mmh you should make them required, not optional I guess

carmine timber
mental adder The code

Change this to something like :

joinVoiceChannel({
        channelId: voiceChannel.id,
        guildId: guild.id,
        adapterCreator : guild.voiceAdapterCreator,
        selfDeaf : true
})
rustic temple

They're using typescript, it's often unhappy when params are optional and you try to use them where they're not optional

proud spindle

will joinVoiceChannel also support stage channels?

vocal valley

It already does @proud spindle

proud spindle

probably just me needing an update, thanks!

oh wait, I meant the createDiscordJSAdapter in the example

vocal valley

Ohh

The type needs updating to include stagechannel, but besides that it will work

proud spindle

Great, thanks!

covert sky

hey

please client for voice code

proud spindle
covert sky

no no i mean client like this'

const Discord = require('discord.js');
const client = new Discord.Client();

but for voice

rustic temple

I don't think client changes Thonk

proud spindle

No, you use your existing client from djs with the new voice package. Apart from some methods, nothing really requires changes

covert sky

am trying to join my bot an voice channel

woah

grim fulcrum

This library does not have a client.

covert sky

catcry

hallow pumice

Any good tutorials or sources on how to use this thing? I don't fkin understand it... My smol brain

icy maple

There’s the guide linked above and examples linked in the pin

hallow pumice

examples are in ts... And the guide just straight up sucks, or I'm stupid

Probably the second one

icy maple

Just ignore the types and it becomes js

hallow pumice

When you ignore the types it becomes just script... Ok ok jk, I'll try looking at the examples

hallow pumice
icy maple Just ignore the types and it becomes js

const { NoSubscriberBehavior, StreamType, createAudioPlayer, createAudioResource, entersState, AudioPlayerStatus, VoiceConnectionStatus, joinVoiceChannel } = require('@discordjs/voice'); When using this, this doesn't work const player = createAudioPlayer(); It says it's not a function and I fully understand that it's not. I think the problem is that in the example it's import, because of ts, and here it's different. How to change it?

wind echo

Is there any way to invite bot to voice channel on v13? Previous it works like message.member.channel.join() but on v13 it doesn't. I'm not ready yet to use new voice library.

steel crescent

Nope

V13 already removed all that code

wind echo

oh damn

okey thanks to answer

grim fulcrum
covert sky
const Discord = require('discord.js');
const client = new Discord.Client();
(message.content.startsWith('!join'))
voiceChannel.join()
  .then(connection => console.log('Connected!'))
  .catch(console.error);```

no respone

whats the problem?

upper storm
covert sky
upper storm
covert sky how??
const Discord = require('discord.js');
const client = new Discord.Client();

if (message.content.startsWith('!join')) {
let voiceChannel = client.channels.cache.get("VC ID");

voiceChannel.join()
  .then(connection => console.log('Connected!'))
  .catch(console.error);
}

Also you forgot an if

covert sky

wow

upper storm

And

covert sky

then?

summer needle

So, I tried looking at the docs about AudioResource, but I am still confused.

const resource = voice.createAudioResource(play);

play is a ReadableStream, but It throws this error:
"stream.on is not a function"

upper storm

You forgot the client.on("message“) @covert sky

covert sky

what if client.on("message“) not found@upper storm

upper storm

Uff

covert sky

meguFace

upper storm
const Discord = require('discord.js');
const client = new Discord.Client();

client.on("message", async message => {
if (message.content.startsWith('!join')) {
let voiceChannel = client.channels.cache.get("VC ID");

voiceChannel.join()
  .then(connection => console.log('Connected!'))
  .catch(console.error);
   }
});

Her you go

Read the docs bro

steel crescent

This doesn't work in v13 anymore.

🤔

upper storm
steel crescent

no but people in here are using it

its the "new" voice channel

upper storm

Yeah Ik say this to him 😂

summer needle
covert sky
covert sky
summer needle
grim fulcrum
summer needle

@grim fulcrum yes

Yeah, i dont know. This is weird

carmine timber
carmine timber
summer needle

Oh I'm just using Readable.from(buffer), how would I give it events support?

carmine timber

show me

summer needle

In not on my PC right now, I'll show you later.

carmine timber
carmine timber
summer needle
carmine timber

I just gave an example

carmine timber
mental adder

Can someone help me? I uploaded my bot to my host, but it doesn't play there, on my computer it does

mental adder

Nop

carmine timber
mental adder Nop

Can you run this on your host ??

const { generateDependencyReport } = require('@discordjs/voice');

console.log(generateDependencyReport());
mental adder

It looks like this on the voice channel, but no audio

carmine timber

Ok

mental adder

Wait a minute, I'm using the docker, I'll publish it real quick here and I'll send it

carmine timber

Ok

mental adder

wtf, My dependencies updated and now it's giving an error here

chrome sundial

What d.js version are you in

mental adder

^13.0.0-dev.1ac9a2eb5bfef6d009de7c54d3fac5e3d4a5afdc

carmine timber
mental adder

But now is on my pc the error

carmine timber
mental adder

ok

wait

@carmine timber same error

carmine timber
mental adder
async join (): Promise<VoiceConnection> {
    const connection = await joinVoiceChannel({
      channelId: this.voiceChannel.id,
      guildId: this.guild.id,
      selfDeaf: true,
      adapterCreator: this.guild.voiceAdapterCreator
    })

    await entersState(connection, VoiceConnectionStatus.Ready, 30e3)

    return connection
  }```
mental adder

I can't even compile or anything, forever on this error

carmine timber
chrome sundial

That's weird can you try to use npm i in latest discord.js commit

carmine timber

then comment

mental adder

@carmine timber

carmine timber

??

mental adder
mental adder
carmine timber

??

mental adder

same on npm

carmine timber

Ok

carmine timber
mental adder

ok, wait

I'll clear the yarn cache first

carmine timber

Ok

carmine timber
mental adder

ok

Okay, maybe I'm unlucky, add an error and double up

carmine timber
mental adder

Ok

carmine timber

Fixed ??

mental adder

Yes

now i'm going to test on my host

carmine timber

😄

carmine timber

It will tell me about your dependencies that you have on your host

mental adder

put it in the bot's ready event, is there a problem?

carmine timber

np

wise anchor
carmine timber
wise anchor

Your audioplayer is having issues while sending packets to voice channel

carmine timber
wise anchor

im not hosting it anywhere

only on my pc

carmine timber

I know

This is your internet issue

wise anchor

no? i have really good internet

carmine timber
wise anchor

ight i restarted the bot

now he joins

then leaves

no error

carmine timber
wise anchor
carmine timber
wise anchor

In joinVoiceChannel, add debug : true
and then after that add a line queue.connection.on('debug', (data) => {console.log(debug)})

wise anchor

okay

mental adder

@carmine timber ```

Core Dependencies

  • @discordjs/voice: 0.4.0

  • 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

--------------------------------------------------```

carmine timber
mental adder

Does it have something to do with my Dockerfile?

carmine timber

NO

mental adder

I'm using node:14-alpine

carmine timber
mental adder

Same thing, it enters and stays like that, but no audio

WAIT

WTF

I write in pt

carmine timber
mental adder

is a webradio link here in Brazil, can I send it here?

carmine timber
wise anchor
carmine timber
mental adder

Live radio

Can I send it for you to see?

carmine timber
mental adder

I changed the stremtype so it's all right, the bot on my computer plays normally

mental adder
async play (url: string): Promise<AudioPlayer> {
    const player = createAudioPlayer()
    const resource = createAudioResource(url, {
      inputType: StreamType.WebmOpus
    })

    player.play(resource)

    await entersState(player, AudioPlayerStatus.Playing, 30e3)

    return player
  }```
carmine timber
mental adder

ok, wait

carmine timber
mental adder

StreamType.Opus, right?

wise anchor

that's in my code

like if there is no song playing it will disconnect

and if i remove the disconnect part it will just play nothing

carmine timber
carmine timber
wise anchor

nope

no error apart from the debug part

carmine timber

So what's your issue now ??

wise anchor
carmine timber
wise anchor
mental adder
carmine timber
carmine timber
wise anchor
carmine timber
wise anchor

wait i think i know what is the problem

carmine timber
carmine timber
wise anchor

First of all, ytdl has memory leak issues and secondly, I will choose ytdl-core-discord at any point of time

ytdl-core has many issues

mental adder

@carmine timber nothing sad

wise anchor

the filters are the problem i think

carmine timber
mental adder

What if I install this tweetnacl when I build it?

carmine timber
carmine timber
mental adder
carmine timber

Ok

carmine timber
mental adder

it's because i'm learning to program with ts, for me it was a mess, but now it's starting to fit

@carmine timber ```JS

Core Dependencies

  • @discordjs/voice: 0.4.0

  • 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: 1.0.3

FFmpeg

--------------------------------------------------```

In my host

and again, nothing

carmine timber
mental adder

Alpine

wise anchor
carmine timber
mental adder

@carmine timber I'll try without Alpine

carmine timber

??

mental adder
carmine timber
carmine timber
mental adder

ok

carmine timber
mental adder

Yes

i tested now

without alpine works

carmine timber

Oh

That means alpine is your problem

subtle granite

Is it possible to use this module on v12?

carmine timber
mental adder

I've been trying to solve this for hours, thank you very much @carmine timber PepeHappy

carmine timber

😄

carmine timber

This is not place to ask, but the error says that you are converting a null to a string

Which is not possible

Show me what is there in play.js at line 55

wise anchor
carmine timber

Yes that's what's causing you the issue

Can you show me the message collector code

??

Where is the message(used in client.player.play) defined

??

wise anchor
carmine timber

You should have used message.content, I guess

You are playing a message class

Not sending any string

wise anchor

wait lemme show you my play function

it uses the message so it gets the message guild's queue

carmine timber

ok

wise anchor
carmine timber

ADS

WTF

@keen plaza Ban him

For me personally, I can't find any errors. Maybe ask more knowledgeable person

wise anchor

ight

thx for the help tho

carmine timber

😄

bold cairn

Can new-voice listen to more than 1 user at a time?

carmine timber

I think you can

steel crescent

Voice receive is not implemented yet

carmine timber
steel crescent

No

steel crescent

That’s far from done

carmine timber

I know that

But it is present

That's what I am saying

It is not complete but it is present

steel crescent

Doesn’t really matter if you can’t use it

vocal valley

its present but awful

carmine timber
vocal valley

I did, it is quite similar to ytdl-core-discord but there are a few pain points

  • some videos may not have an opus 48000 format and will have to be transcoded (not handled by your example code)
  • { inputType: ... } is ignored, so I would remove inputType

really it does the same thing as youtube-dl, except it has no fallback in case there is no opus/48000Hz format

carmine timber
vocal valley

i guess i can update the typings to show that inputType is not allowed with a string-based resource

wind echo

Can I play m3u8 format audio?

vocal valley

yes, via ffmpeg

all you'll need to do is install ffmpeg and it should just work

wind echo

oh good

carmine timber
vocal valley

yep but there is also /bestaudio fallback

in case that the opus format doesnt exist

carmine timber

Oh

What is function of entersState ??

hallow pumice
hallow pumice
grim fulcrum
carmine timber

Try typing this npm i @discordjs/voice@latest

jolly mason

is there a way to go forward/backwards in audio while its being played

like skip some seconds

?

carmine timber
wise anchor

hello, i keep getting this error when I try to play music FFmpeg/avconv not found!

rustic temple

Are you on windows?

wise anchor

Yes

rustic temple

Do npm i ffmpeg-static

wise anchor

Did that

Nothing changed

rustic temple

Mmh

Idk

Are you using the new voice module

wise anchor

Yes

wise anchor
vocal valley

how does your npm get so corrupted

eyesButFaster

wise anchor

but still

ffmpeg/avconv not found

vocal valley

can you use generateDependencyReport and send the output?

example of using it is in the guide in the pinned messages

wise anchor

@vocal valley

vocal valley

yep

idk what to say to be honest, if it's not finding ffmpeg it must just not be installed in the right place

where are you installing it

wise anchor
vocal valley

is it in the example directory?

wise anchor

no...?

i used npm install so i assume in

node_modules

vocal valley

but where did you run the command

wise anchor

in my bot folder

carmine timber
vocal valley

npm i ffmpeg-static, right

wise anchor
carmine timber

Without that nothing is possible

vocal valley

ok, in your bot folder do this in a terminal:

wise anchor
vocal valley
node
> require('ffmpeg-static');

what gets printed

carmine timber
wise anchor
carmine timber
wise anchor
vocal valley

how odd 🤔

carmine timber
vocal valley

but thats not the issue

if ffmpeg-static is installed, it should get resolved

wise anchor
carmine timber
vocal valley

in node_modules/prism-media, is there another node_modules folder?

wise anchor

lemme check

vocal valley

🤔

im really not sure why it's not resolving, all prism does is require('ffmpeg-static')

so if you can require it from your bot's root directory, it should work in prism too

carmine timber
wise anchor

wait

carmine timber

not media-prism

wise anchor
wise anchor
wise anchor
vocal valley

that will fix it yes, but it still doesnt explain why the module isnt getting imported in node.js

carmine timber
wise anchor
carmine timber
wise anchor

oh

now?

carmine timber

WTF

is this your ffmpeg-static

??

wise anchor

yes

wait

i ran node install.js

now it appeared

carmine timber
wise anchor

now it detects it

carmine timber
wise anchor

ight

jolly mason

How to know if what the player is playing has ended or not?

is it done by player.on(AudioPlayerStatus.Idle, () => {}

carmine timber
wise anchor

how can i get the time that passed since it was playing

like let's say i have a song of 3 mins

i want to get the current time that it is at

wise anchor

ty

steel crescent

no, javascript is for losers

just remove the types and its javascript

not that hard

fervent bloom

Ummmm
So
When I ask it to join the stage
it joins as a listener
The bot
How do I make it join as a speaker?

fervent bloom

C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\@discordjs\voice\dist\networking\Networking.js:413
                secretbox.methods.close(opusPacket, connectionData.nonceBuffer, secretKey),
                                  ^

TypeError: secretbox.methods.close is not a function
    at Networking.encryptOpusPacket (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\@discordjs\voice\dist\networking\Networking.js:413:35)
    at Networking.createAudioPacket (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\@discordjs\voice\dist\networking\Networking.js:397:53)
    at Networking.prepareAudioPacket (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\@discordjs\voice\dist\networking\Networking.js:321:37)
    at VoiceConnection.prepareAudioPacket (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\@discordjs\voice\dist\VoiceConnection.js:282:33)
    at C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\@discordjs\voice\dist\audio\AudioPlayer.js:426:54
    at Array.forEach (<anonymous>)
    at AudioPlayer._preparePacket (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\@discordjs\voice\dist\audio\AudioPlayer.js:426:19)
    at AudioPlayer._stepPrepare (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\@discordjs\voice\dist\audio\AudioPlayer.js:398:22)
    at prepareNextAudioFrame (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\@discordjs\voice\dist\DataStore.js:71:31)
    at audioCycleStep (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\@discordjs\voice\dist\DataStore.js:56:5)

What is this error?

I tried to make it join a stage but it flipped with this message

Plus it joined the listeners

How do I make it join speakers?

carmine timber

There has been some issues with tweetnacl

fervent bloom

Oh jesus

How do I install it?

carmine timber

I think this error got patched in latest PR

carmine timber

to 0.4.0

fervent bloom

This is the latest version of discord/voice, I literally installed it minutes ago