#archive-voice

30636 messages · Page 1 of 31

vocal valley

This channel is for discussing our new voice library: https://github.com/discordjs/voice — we're excited to hear your thoughts and any questions/issues you have! 🎉

📌 What is @discordjs/voice?
This is a new voice library that we're working on that aims to be more reliable, scalable, and offer better playback quality than what we currently offer in Discord.js v12.

📌 What is happening to my existing voice code that uses Discord.js v12?
From v13, we are dropping support for the existing voice codebase to focus on the new voice library instead. The new voice library may look more intimidating, but we have created a thought-out music bot example (see examples below) to help you transition your code. Using our example music player means you'll likely end up writing less voice code in your bot!

📌 How do I use this with libraries that aren't discord.js?
You can use the new voice library anywhere you want by creating your own custom adapter. If you want to use the library with discord.js, there is currently a PR in progress (https://github.com/discordjs/discord.js/pull/5402) to add the required adapters directly to discord.js so you won't have to create them yourself. In the meantime, the examples in the voice repository work with v12.

📌 What about voice receive?
This feature isn't documented in the Voice API by Discord and is prone to breaking quite a lot. We have basic support for it in the voice library currently, but there is still work going on to add utilities to make it easier to work with.

📌 Useful links:

Yes, this is a new channel! But please don't spam otherwise you'll be moderated and restricted 👍

plain vine

are common bugs like having to pause resume pause resume still there? also ty hydra blobreach o/

fervent estuary

all of those are gone

plain vine

great!

next herald

Will this affect me if I'm using erela.js for music? But DJS for the rest of my bot ?

steel crescent

It will affect you as you can’t really detect a users voice state easily anymore

But if you use erela, it wouldn’t matter to much I’d think

Since almost everything is handled by Lavalink anyway by you forwarding the events

(Which we obv still allow)

next herald

Thanks for info!

cold geode

What are the advantages of this innovation?

vocal valley
  • playback quality is improved
  • you can use it with libraries other than discord.js
  • more reliable (in general)
  • you can scale it horizontally, run your voice in a separate process from your bot
cold geode

thank you

faint forge

oh nice

vocal valley

Just updated the pinned message, but if anyone wanted a high level overview of the new voice library, there is a slightly outdated guide available here https://deploy-preview-595--discordjs-guide.netlify.app/voice/. With the exception of voice adapters, everything else should still hold (oh and we are not removing voice receive like that guide says) 🙂

haughty cape

The master branch hasnt yet dropped the in-built support, right?

carmine timber

Ok

I got it

vocal valley

👍

carmine timber
vocal valley 👍

I thought adaptor Creator is not required since join voice channel .ts has nothing to mention in it.

pallid flint

Why did the devs thought to remove guild.member lol

radiant ocean

that's not the question for this channel, and the PR that did that explained why

it is literally nothing more than guild.members.resolve()

vocal valley
warm pebble

question will discordjs/voice be supported for discord.js v12 or is it for v13 only?

carmine timber

Sorry My bad

I got it

LOL

vocal valley
warm pebble

alright thanks!

vocal valley

the idea of this library is that it will work anywhere where you have a discord gateway connection, so it could even work with other libraries such as eris

warm pebble

cool

vocal valley

yep that is the plan, this channel will eventually become the only voice support channel

warm pebble

alright, thanks for the info

vocal valley

np 😄

zealous hearth
vocal valley

oops sorry about that 👀

zealous hearth

Understandable

barren flume

is this compatible with erela?

vocal valley

afaik erela is a way to use lavalink with your discord.js bot? in that case, no, since lavalink handles voice stuff, not @discordjs/voice

if you are using erela this library should not affect you

barren flume

so this is specefically designed for stuff much like ytdl ?

vocal valley

you can definitely use ytdl with this library 🙂 it's more targeted towards people who currently use discord.js v12 voice

barren flume

k thanks 😄

carmine timber

@vocal valley
Now is this ok ??

const { joinVoiceChannel } = require('@discordjs/voice')
const adaptor = require('../util/adaptor')

exports.run = (client, message, args) => {
    const channel = message.channel
    var connection =  joinVoiceChannel({
        channelId: channel.id,
        guildId: channel.guild.id,
        adapterCreator : adaptor.createDiscordJSAdapter(message.member.voice.channel)
    })
    console.log(connection)
}

I get a signalling status but bot never joins vc

vocal valley
carmine timber

What else he needs ??

tulip jackal

you're trying to connect to a text channel

carmine timber

Oh

May be

XD

carmine timber
split cliff

Does the voice in v13 mean we can use voice-recognition?

vocal valley
split cliff

Hmn, okay ty

vocal valley
wind ginkgo

Would this affect any JS Lavalink libraries? I use Lavaclient, so I'm not sure if this will affect anything or not

vocal valley
swift forum

Native, as in.. C or Rust?

carmine timber

Yes I am successful to connect to vc and play a stream with new audio api tachi_smile

vocal valley
vocal valley

discord.js just exposes some of its internals so that you can use it with @discordjs/voice without as much boilerplate code

swift forum

Ah, I see!

carmine timber
vocal valley

this is very nice to hear, thanks for the appreciation 😊

drowsy lynx

it is stage channel thing?

vocal valley

this library does support stage channels, yes

drowsy lynx

oh

subtle granite

whats this about

fervent estuary

check the pinned message

carmine timber
vocal valley

@carmine timber sorry about that, that's one of the outdated parts of that particular documentation

carmine timber

Ok no problem 🙂

vocal valley

you should use audioPlayer.pause() and unpause instead, as you have said

carmine timber

So I have to search for player in connection

vocal valley

so when you call connection.subscribe(player), you get a subscription object which has .player and .connection properties,

you can either save this subscription object somewhere, or do something like this:

if (connection.state.status !== VoiceConnectionStatus.Destroyed) {
  connection.state.subscription?.player.pause();
}

if you are using javascript, you can trim it down a little bit by removing the if() {} around that line of code

vocal valley

yep, i think that is a good way to do it

subtle granite

are there docs for the new voice lib?

vocal valley
subtle granite

thank you so much!

vocal valley

np 😄

vocal cove

what makes djs-voice better than lavalink ?

vocal valley

I would say that @discordjs/voice is easier to integrate into a bot than lavalink and can also run in the same process as your bot, which is good depending on your use case

It also offers the developer more chance to interact with the Voice API at a lower level

vocal cove

My point is more about how would it be better in term of reliability/scalability/performance and load balance

wind ginkgo

I wonder what the performance difference will be if you benchmark the two against each other Thonk

fresh wagon

nice

i want to try this out soon

carmine timber
austere sphinx

are there examples in regular js instead of typescript?

carmine timber
austere sphinx

ok

stark drum

well to get the js version just remove anything that's specific to typescript

carmine timber
steel crescent

Tbf not everyone has the use case to have huge bots playing music at such a capacity. If you want something fast and non-complicated (compared to hosting your own lavalink, setting it up etc) this is def the way to go

We can’t and certainly won’t convince you to use one over the other. If one solution works for you, stick with it 👍

subtle granite

Whats new for voice?

hazy copper

just started converting my old one and i cant seem to be able to create a voice connection? im getting this error

shut path

is the new voice library added to discord.js@zealous hearth?

reeeeeeeeee

carmine timber

Use js version

Then do something like this :

const { joinVoiceChannel } = require('@discordjs/voice')
const adaptor = require('<your adapter file path>')
   
//Use this below command in message event
var connection =  joinVoiceChannel({
        channelId: message.member.voice.channel.id,
        guildId: message.guild.id,
        adapterCreator : adaptor.createDiscordJSAdapter(message.member.voice.channel),
    })
hazy copper

looks like that "fixes the error" but the bot still doesn't join my channel

hazy copper

its as basic as it gets rn

const { joinVoiceChannel } = require('@discordjs/voice');
const adaptor = require('../../bin/adapter');

module.exports = {
    name: 'test',
    description: 'test',
    execute(interaction) {
        const connection = joinVoiceChannel({
            channelId: interaction.member.voice.channel,
            guildId: interaction.guild.id,
            adapterCreator: adaptor.createDiscordJSAdapter(interaction.member.voice.channel)
        });
    },
};

not using my main command yet so i can make this work

carmine timber
fervent jacinth
hazy copper

yes

carmine timber

and then switch to slash

hazy copper

i mean why wouldn't it work with an interaction? it gets the same voice channel object it would get anyway?

carmine timber
hazy copper

i dont think that's the issue, will try it in my message event

carmine timber

Do it and tell me

hazy copper

idk why i even tried this, it does the same exact thing

carmine timber

idiot

See my code

hazy copper

ah it needs it's id? lulw

it should print an error for that

carmine timber

LOL

carmine timber
hazy copper

yeah

why hasn't the adapter been merged yet tho

carmine timber

IDK

vocal valley
carmine timber

Oh

hazy copper
carmine timber
vocal valley
vocal valley
carmine timber
vocal valley
carmine timber

Thanks

carmine timber
vocal valley https://discord.js.org/#/docs/main/master/class/Guild?scrollTo=voiceAdapterCreat...
2021-06-09T17:27:40.526365+00:00 app[worker.1]: /app/node_modules/@discordjs/voice/dist/networking/Networking.js:413
2021-06-09T17:27:40.526401+00:00 app[worker.1]:                 secretbox.methods.close(opusPacket, connectionData.nonceBuffer, secretKey),
2021-06-09T17:27:40.526402+00:00 app[worker.1]:                                   ^
2021-06-09T17:27:40.526402+00:00 app[worker.1]: 
2021-06-09T17:27:40.526403+00:00 app[worker.1]: TypeError: secretbox.methods.close is not a function
2021-06-09T17:27:40.526404+00:00 app[worker.1]:     at Networking.encryptOpusPacket (/app/node_modules/@discordjs/voice/dist/networking/Networking.js:413:35)
2021-06-09T17:27:40.526404+00:00 app[worker.1]:     at Networking.createAudioPacket (/app/node_modules/@discordjs/voice/dist/networking/Networking.js:397:53)
2021-06-09T17:27:40.526404+00:00 app[worker.1]:     at Networking.prepareAudioPacket (/app/node_modules/@discordjs/voice/dist/networking/Networking.js:321:37)
2021-06-09T17:27:40.526405+00:00 app[worker.1]:     at VoiceConnection.prepareAudioPacket (/app/node_modules/@discordjs/voice/dist/VoiceConnection.js:282:33)
2021-06-09T17:27:40.526405+00:00 app[worker.1]:     at /app/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:419:54
2021-06-09T17:27:40.526405+00:00 app[worker.1]:     at Array.forEach (<anonymous>)
2021-06-09T17:27:40.526406+00:00 app[worker.1]:     at AudioPlayer._preparePacket (/app/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:419:19)
2021-06-09T17:27:40.526406+00:00 app[worker.1]:     at AudioPlayer._stepPrepare (/app/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:391:22)
2021-06-09T17:27:40.526406+00:00 app[worker.1]:     at prepareNextAudioFrame (/app/node_modules/@discordjs/voice/dist/DataStore.js:71:31)
2021-06-09T17:27:40.526407+00:00 app[worker.1]:     at audioCycleStep (/app/node_modules/@discordjs/voice/dist/DataStore.js:56:5)

Crashing after update, I think Audio Player is messed up again

vocal valley

could you do this for me:

carmine timber

What ??

vocal valley

import generateDependencyReport from the voice library, and log the value of it after you call it

console.log(generateDependencyReport ())

carmine timber

Ok wait

vocal valley

That error indicates you might be missing sodium, tweetnacl, or libsodium-wrappers (you need at least one)

hazy copper

is selfdeaf supposed to be on by default?

carmine timber

I am getting this

Sorry

That was wrong

vocal valley

Np

carmine timber
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.3.0
- prism-media: 1.2.9

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

Encryption Libraries
- sodium: not found
- libsodium-wrappers: not found
- tweetnacl: 1.0.3

FFmpeg
- version: 2021-01-12-git-ca21cb1e36-full_build-www.gyan.dev
- libopus: yes
--------------------------------------------------
vocal valley

hmm interesting, I will take a look

could you try installing libsodium-wrappers instead

carmine timber

Ok

carmine timber

??

vocal valley

You should be able to, but I want to see if the error is because of tweetnacl

carmine timber

Ok

vocal valley

So if you install libsodium-wrappers and it works I can see what I need to change for tweetnacl 👍

vocal valley

ok that's good, I will try to see why it doesn't work with tweetnacl, thanks for finding this

carmine timber

Which is faster ? libsodium or tweetnacl

vocal valley

Libsodium-wrappers

And even faster is sodium

carmine timber

Ok thanks

torn sinew

Hi,
so with old ones I was trying to write up a thing that would do the following

  1. Play Background music
  2. Receive a command
  3. fade out the background (slowly reduce the volume)
  4. Play a sound
  5. Resume the background with a fade in (slowly increasing the volume)

But it proved troublesome... from a brief look at the docs I see that as a starter the volume is controlled on the resource level not player level, so probably no dice. But man can dream :D.

carmine timber
carmine timber

@vocal valley For some reasons, after installing libsodium-wrappers, it still shows me this :

--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.3.0
- prism-media: 1.2.9

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

Encryption Libraries
- sodium: not found
- libsodium-wrappers: not found
- tweetnacl: 1.0.3

FFmpeg
- version: 2021-01-12-git-ca21cb1e36-full_build-www.gyan.dev
- libopus: yes
--------------------------------------------------

AS Not Found.

vocal valley

hmm

is that even after you restart your bot script?

carmine timber

Yes

vocal valley

how odd

can you show me your package.json?

carmine timber
{
  "name": "vc-check",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@discordjs/opus": "^0.5.0",
    "@discordjs/voice": "^0.3.0",
    "discord.js": "^13.0.0-dev.c6aeebb18d6b969f7c8bdb1b719883d4384dd03e",
    "install": "^0.13.0",
    "libsodium-wrappers": "^0.7.9",
    "npm": "^7.16.0",
    "youtube-sr": "^4.1.4",
    "ytdl-core-discord": "^1.3.0"
  },
  "devDependencies": {},
  "description": ""
}

See this

@vocal valley ??

vocal valley

yep

i'll take a look

carmine timber

Ok

vocal valley

will look into it 👍

carmine timber

👍

crude parcel

:new-voice: 🤔

opal mauve
final harbor

Enable esModuleInterop in the config should do the trick

But it's that flag causing it tho

frosty quartz

Heya , i see that wonderfull new channel for voice and the new api that Hydra made as well and i was wondering : I already have a complete music bot , functioning pretty well and i would like to change from YTDL to djs voice one day or another. Is that possible to do every command that i already have with that api ? ( ping me when answer please i'll be at work so i'll check the message in about 7 hours.) Thanks in advance 😄 ❤️

carmine timber
rancid heart

When should I switch to the new library?

carmine timber
upper flare

i would assume that ytdl is needed regardless.

spring jackal

Have there been any updates to voice? I'm using code that worked in v12 suddenly after the update I keep getting 'VOICE_CONNECTION_TIME" ...

vocal valley
vocal valley
rancid heart When should I switch to the new library?

I would recommend at least having a look at the music bot example now to see what the upgrade will look like and then seeing if you feel comfortable using the examples and documentation to upgrade now. If you are feeling intimidated by the documentation, I'm also writing additional documentation that is a bit more user friendly

vocal valley
spring jackal

no I mean I updated to v13 and now I'm getting that error

vocal valley

if you update to the newest version of the Dev release, voice is removed and we use this new library instead (see pinned messages)

spring jackal

Is this how it will work on v13 or is this some kind of test project to implement to v13?

vocal valley

This is how it will work on v13, yep

vocal cove
steel crescent We can’t and certainly won’t convince you to use one over the other. If one solu...

that's like reinventing the wheel, we could just recommend lavalink and spare the long/hard work on djs voice, and just focus on the main djs to make it better.
in the other hand having a djs voice that follow the same rules and conventions like the rest of djs, would be definitely easier for a starter when starting out with djs
my point is, if you're not making it better, don't waste much time and effort on it on remaking it, and waste your users time and effort on upgrading to it
this is just an opinion tho, no offense intended
thanks

sacred cove

this library hasn't got anything to do with @discordjs/opus and it's still required isn't it?

steel crescent
vocal valley
sacred cove

oh I see, and is it required?

no wait that's a stupid question

vocal valley

nope, you could use opusscript instead

sacred cove

oh ok

vocal cove

having various points where discordjs voice score better than lavalink or other libraries would a good way on presenting it

vocal valley

it's not an easy question to give an answer to because atm there are no comparisons that we've made

vocal cove

yea it's still under the work I know

vocal valley

I would definitely recommend @discordjs/voice if you're doing something novel, e.g. making a game with like voiceovers

vocal cove

but it has to be a goal on remaking what is already made

vocal valley

for the typical music bots, no data on that yet

the goal of @discordjs/voice is just to make a good implementation of discord's voice API in Node.js

vocal cove
vocal valley

yes, but that does not mean I have benchmarked it against lavalink

Nor do I have any intention of doing that

I appreciate that you feel that @discordjs/voice is useless because lavalink exists,

vocal cove

but when you remake something, you would have goals in mind ahead, at least in theory

vocal valley

yep, and the goals in this remake were to:

  • improve reliability
  • make voice scalable (d.js V12 voice is arguably not)
  • improve quality

and those have been achieved so far I would say

vocal cove

so it's only compared to the previous V12, maybe it will be compared to other libraries later ?

steel crescent

Nah, we needed to remake it either way, since we were removing built-in support.
And when you are a library of our size, relying on 3rd party for pretty much anything can get very tricky really fast (we had that like 3 times by now), where those components just ended up being unmaintained potentially. And others nor I do really have the motivation to potentially fork something like lavalink and keep maintaining it.

vocal valley

Potentially but that will not be done by us, our only goal is to make a good Node.js implementation of voice

You could make a similar argument of why have a Discord library in XYZ language if it already exists in another

vocal cove

I see what you mean,
don't get me wrong on what I've said, I really do appreciate the effort and dedication, I'm just trying to find a way to convince myself to use it instead of just using what is already existing and working, points like it will eat less ram, it will be maintained by djs already ok, hopefully more points like these arises once it's done and ready to use

steel crescent

I'll be brutally honest

Wait a bit still.

Wait until we have more use cases covered with examples and how to approach things easily

vocal valley

Yep

steel crescent

Especially if you have something working

vocal valley

If all you're looking for is stability, lavalink has been around long enough to have that claim

vocal cove

it won't be released by discordjs v13 ?

steel crescent

Yeah we will release it with v13

That doesn't mean we have 100% the best way to do things and all

vocal valley

if after @discordjs/voice matures and good things come of it, you can always consider switching then if you wanted

vocal cove

that's my issue actually, by then I would need to decide either use it and upgrade all my voice activities and the player i'm using in js, or just switch to something else

or are you saying that the old code for voice would stil work on v13 ?

vocal valley

What is your use case exactly? A music bot?

vocal cove

yea just a music bot

vocal valley

Old voice code will definitely not work on v13

well for a music bot the easiest and most hassle-free way is lavalink at this moment in time

vocal cove

i mean the music bot is a feature part of the a bot with many other features unrelated to voice

tawdry scroll

Eta

steel crescent

most likely by the end of this month

vocal valley

we'll see what people come up with using @discordjs/voice as alternatives to lavalink

tawdry scroll
vocal valley

but honestly if you just want voice for a music bot that you don't want to worry about, then go lavalink at this moment in time

since after all, this is new still and at least lavalink is established

vocal cove

I would have to remake everything either it's lavalink or the new djs voice

steel crescent

Whats your guild count, just curious

vocal cove

but I see what you mean, maybe I should just take the risk and jump in to use djs voice and hope it gets better quickly if i don't wanna remake stuff
my current voice implementation with v12 isn't that bad so far, but it will break on upgrade to 13

vocal cove
steel crescent

like... 12?

Or a dozen as in "a lot"

vocal valley

oh, for small bots I would recommend @discordjs/voice

steel crescent

Yeah, for such a small scale you are perfectly fine here then

vocal valley

cause like the overhead is so much smaller compared to lavalink

vocal cove

it's not public yet tho, only on demand service , oh it's about 16 or so i guess

vocal cove

but maybe even at a hundred it would be still ok based on what you're saying, as a hundred is still considered small

vocal valley

yep

I would say so

steel crescent

anything < 10k is small

depending on what you do even < 50k

vocal cove

alrighty, I will take the risk then and bet on you then

tall rain

There's any docs to know anything about new voice lib?

vocal valley

Yep, they're linked on the repos README

I would recommend reading it alongside the examples to try and give a bit more sense to it

vocal cove

btw, would the next examples be on js, or ts ?

i would prefer to see js instead of ts, I know it's not much difference but still, I would need to go through converting even for just testing and play with examples

vocal valley
stoic orbit

also whats diff then the old?

steel crescent

everything 🤔

silk quartz

pls help

vocal cove

member is undefined hmm

is that coming from DM ?

silk quartz

no

vocal cove

it should be available

maybe you're using the wrong message object ?

silk quartz

lemme see

i am using the right one

:/

vocal cove

no idea why would the member be not defined in a message coming from a guild channel

silk quartz

voice is not defined

vocal cove
vocal valley
vocal cove

yea true

vocal cove

btw hydra, by using djs voice, I would still to rely on other library like ytdl ?

vocal valley

i wouldn't be surprised to see in a few days/weeks someone makes an audio player that does this for you, though, since people have already done it for d.js v12 voice

vocal cove

let's say I have a link to mp3 like how you state in the example

how would djs voice stream data to discord ?

using ffmpeg ?

vocal valley

yep

the nice thing is that in the new voice library, we did some optimisation work with ffmpeg,

which makes it a bit faster/more efficient than v12 voice

vocal cove
// Attempt to convert the Track into an AudioResource (i.e. start streaming the video)
            const resource = await nextTrack.createAudioResource();
            this.audioPlayer.play(resource);

so in here where we do the streaming thing, right ?

looks like it would work a bit similar to how it was working for v12

vocal valley

yep 👍

in that specific example, it avoid FFmpeg because it uses ytdl-core-discord

which for most videos it can just skip the ffmpeg step and use the direct audio stream taken from youtube

vocal cove

yea

so it only uses ffmpeg from discord if it's a direct url to the audiofile

vocal valley

it uses ffmpeg in these cases:

  • you pass a string to the createAudioResource function (e.g. URL, file path)
  • you don't say what type of stream your audio stream is, and it cannot be inferred
vocal cove

oh i see

vocal valley

so createAudioResource(createReadStream('myfile.opus')) will still use ffmpeg,

but something like createAudioResource(createReadStream('myfile.opus'), { inputType: StreamType.OggOpus }) will skip ffmpeg

vocal cove

nice

I had issues with v12 about seeking, so i just started new streams with the timestamp needed

vocal valley

ah yes

vocal cove

would that be different on this verison ?

vocal valley

well here we just completely removed support for seeking (at least for now) because it is quite complicated to do with lots of different stream types

so if you want seeking, you can use prism-media for example to make your own FFmpeg encoder stream with the seek argument passed there

vocal cove

I'm using seeking just to keep the song playing from where it was if the bot changes channel

vocal valley

ohh

vocal cove

you think i should go through that just to keep track of timestamp

vocal valley

well actually, the library should do the work for you here anyway

when you create an audioplayer, it defaults to pausing if there is no active voice connection,

vocal cove

so it won't stop playing if the bot switch channel ?

vocal valley

when your bot switches channel, it pauses while it reconnects, then continues playing after reconnecting

vocal cove

that makes it better

vocal valley

yep, definitely a lot nicer now haha

vocal cove

yea i was doing that work for it on the previous version

so many workarounds

glad that things like these will be solved on the new version

vocal valley

(Pause is default, i should document that)

vocal cove

i see

about the idle/pause

what if the bot stays idle for long

does it glitch ?

the old version if the bot stays long on the VC it won't be able to play later unless you reconnect it

vocal valley

so in v12 voice when we put our own time limits on things, it broke for a lot of people cause they have unstable network connections,

so now, if it disconnects for example, you can set your own limits on how long it should take to reconnect before giving up

vocal cove

ohhh like timeouts if if ever dc

I doubt it was connexion issue tho

vocal cove

my servers never dc while it's playing

vocal valley

so in the music bot example, if the bot ever enters a state where it is trying to connect to discord, it's allowed 20 secs to enter the ready state before giving up and destroying

this is one part of the example i think people are safe to copy and paste since it stops them shooting themselves in the foot later

vocal cove

lol

what i meant is, not dc while playing

the glitch only happens when the bot is on idle for a good amount of time

like 6 hours or so

vocal valley

i would say that's no longer an issue in @discordjs/voice,

vocal cove

that's great

vocal valley

it might have been in v12 since basically we didn't check whether we could send audio packets to discord (after some time, it ends up closing off)

steel crescent

youd be surprised how fragile voice actually is, especially with the node event loop. if you run heavy computations that could potentially lock up or clog the event loop, it will drastically affect your music too
and newcomers usually have no idea whats expensive and what not, so those pitfalls get even bigger imo.

vocal valley

but in /voice we do like heartbeats now, where discord echos back the data, if it doesn't echo back after 1 minute, the connection counts as disconnected

vocal valley
vocal cove

my voice server never lag or have anything to do beside doing the audio streaming

vocal valley

a very good idea lol

vocal cove

well, early i did separate only heavy computations about generating graphics and such, but later i just migrated all to be separated to the voice server

I will try out the new djs voice soon, maybe once I start upgrading everything to v13

vocal valley

glad to hear 😄 hopefully by then the nicer high-level doc about the library will be ready too

and maybe even audio player libraries that use @discordjs/voice

vocal cove

I m using my own player even in v12, cuz I do use many customizations either on visuals or the way how it works

I will prolly be doing the same on v13

vocal valley

fair

silk quartz

hey

about that issue befor

if i change my discord.js to v13

would it solve my problem

?

vocal valley
silk quartz

oh ok

vocal valley
silk quartz

thanks

red nest

There is so many new feature in v13

pliant basin
carmine timber
pliant basin

oh i thought you meant you tested the performance of lavalink against @discordjs/voice because the person you were replying to had their message right below a message about the benchmark haha 😅

still, thanks for sharing the results for @discordjs/voice!

carmine timber

😂

frosty dawn

Error: Did not enter state ready within 60000ms Bot is not entering ready state

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

    try {
        await entersState(connection, VoiceConnectionStatus.Ready, 60e3);
        return connection
    } catch (error) {
        connection.destroy();
        throw error;
    }
}```

here whats i am trying to do its for a stage channel

the bot is entering the channel but throws a error not ready

Can anyone provide a solution?

icy maple
frosty dawn
subtle granite

We’re certain music bot libraries affected with v13? As such, is the new discord voice stuff required? I used to use Lavalink which worked in v12 and and upon switching to v13 and getting things up to date, it fails to transmit any voice or speak.

fervent estuary

lavalink should work with minimal changes. This effects everyone using v12 built in voice

subtle granite

Huh. Maybe I’m doing something wrong then. It just totally fails to play with any of the libraries I’m using

subtle granite
            guild: interaction.guild.id,
            channel: channel.id,
            node: "1"
        });

if (!player)
  return;

await player.play(track);```

I mean its pretty basic code. Nothing crazy, I am using Lavacord, I create the player, it joins the channel and attempts to play the track but no data is transmitted. It used to work like this in v12, but broke in v13. I was just curious if something glaring changed and I needed to adjust or not.
slender sparrow

no need to change if you use lavalink

carmine timber
carmine timber
slender sparrow

he should change from lavacord to other client

lavacord not maintained for a long time

carmine timber

Yes

subtle granite

Any recommended other clients? I’ve seen a few.

slender sparrow

shoukaku, erela.js

carmine timber
subtle granite

Alright I’ll give them a shot.

Thanks for the help

merry igloo

If I have a file like an .mp4, will I be able to do player.play(musicfile.mp4)?

Assuming everything else like the player and connection is already set up

carmine timber
merry igloo

Thank you

carmine timber
merry igloo Thank you

Sorry, You need to create Audio Source first for that and then include that source in player

merry igloo

Oh ok, thanks again

gritty pasture

just a question, can you use js to code discord.js@voice cuz the library is made with ts

stark drum
vocal valley
carmine timber
stark drum

I've got a question about how the library is designed
Is it possible, or would it be possible, by its nature to use it to make a separate voice server? Something like Lavalink but a bit more customizable?

vocal valley

The music bot example actually has typescript compilation, you could take a look like that

vocal valley
carmine timber
vocal valley

So you could host this somewhere else separate to your bot, like lavalink

vocal valley
carmine timber

Ok

Thanks

stark drum

Oh great, looks promising 😄
Congrats to the team btw!

vocal valley

Np

gritty pasture
vocal valley

np

carmine timber

@vocal valley Can we use new voice API with lavalink ??

vocal valley

This library isn't really related to lavalink

you can still use lavalink with discord.js v13 though

carmine timber

I know that

vocal valley

but you can't use lavalink with @discordjs/voice, since lavalink uses lavaplayer as its backend

carmine timber

Ok I got it

carmine timber

Will new Voice API release on v13 launch date?? Since it is very close and moreover, proper docs are not available still yet.

steel crescent

Yes

carmine timber

Oh, Then all music bot developers on v12 voice needs to update to this soon 😂

steel crescent

Yep 👍

subtle granite

This sounds interesting

quick question

do u allow opus encoder args or not

if not then do it then your module / addition to v13 is AMAZING

Because the Docs are so weird to read, you need to click everything and go back and forth all the time I won't spend the time to read it through everything

And if you allow spawning ffmpeg things, then do u do it with child_process? if not, do it with it, otherwise lags and slow-

carmine timber
sacred cove

when support will end for the current voice system in v12, will it still be usable or will we have to immediately switch to the new library? Because I think most people (including me) need some time to update their code for the new library, which is almost finished, but still not yet, so I doubt people will update at this time

carmine timber
sacred cove

but the library isn't finished yet, it might be that they change something and then I'd need to update again

carmine timber
sacred cove

obviously I don't mean that it's incomplete the same way as djs is, just saying that it's a brand new library, and as they said it's still in development no wait didn't get what you said in the first place lol

yes, the library is indeed almost complete

but also without the docs it's not that easy to update

carmine timber
rustic temple

Btw, it's still installing, is it ok? XD

subtle granite

Do i still need @discordjs/opus for this to work?

sacred cove
carmine timber

it is optional

echo bone

I don't unterstand how i can join a vc with the new library...

Err:

(node:27024) UnhandledPromiseRejectionWarning: TypeError: adapterCreator is not a function

Code:

const MemberVoiceChannel = Interaction.member.voice.channel;
const VoiceSubscription = await DiscordVoice.joinVoiceChannel(MemberVoiceChannel);
carmine timber

it is mandatory in v13

echo bone

And how can I do it?

carmine timber

Wait let me show u

echo bone

Thanks

carmine timber
var connection = getVoiceConnection(message.guild.id)
  if (connection?.state.status !== VoiceConnectionStatus.Destroyed){
    connection =  joinVoiceChannel({
        channelId: message.member.voice.channel.id,
        guildId: message.guild.id,
        adapterCreator : message.guild.voiceAdapterCreator,
        selfDeaf : false,
        selfMute : false
  })}
carmine timber
echo bone

@carmine timber Yeeesss, thanks. It works now... ❤️

carmine timber

❤️

echo bone

I don't unterstand the err... Got IT

echo bone

I found the first error, but now I got another error by @discordjs/voice

TypeError: secretbox.methods.close is not a function
  at Networking.encryptOpusPacket (/home/disgroup/DisBot/node_modules/@discordjs/voice/dist/networking/Networking.js:413:35)
    at Networking.createAudioPacket (/home/disgroup/DisBot/node_modules/@discordjs/voice/dist/networking/Networking.js:397:53)
    at Networking.prepareAudioPacket (/home/disgroup/DisBot/node_modules/@discordjs/voice/dist/networking/Networking.js:321:37)
    at VoiceConnection.prepareAudioPacket (/home/disgroup/DisBot/node_modules/@discordjs/voice/dist/VoiceConnection.js:282:33)
    at /home/disgroup/DisBot/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:419:54
    at Array.forEach (<anonymous>)
    at AudioPlayer._preparePacket (/home/disgroup/DisBot/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:419:19)
    at AudioPlayer._stepPrepare (/home/disgroup/DisBot/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:391:22)
    at prepareNextAudioFrame (/home/disgroup/DisBot/node_modules/@discordjs/voice/dist/DataStore.js:71:31)
    at audioCycleStep (/home/disgroup/DisBot/node_modules/@discordjs/voice/dist/DataStore.js:56:5)

And this keeps crashing my whole node process

subtle granite

Anyone use erelajs with v13? Got recommended to use it. Switched my project to it, it connects to the node, and attempts to the play the track, but nothing is transmitted in the channel. (works fine on v12)

Seems that there is no sessionId or anything like it doesnt attempt to do voiceUpdate with Discord at all.

vocal valley
vocal valley
sacred cove

that'll be easier then, good to know

echo bone
vocal valley

Sodium is best, then libsodium-wrappers, then tweetnacl

Sodium can be quite a pain to install though

fiery blade

are there types for this lib?

carmine timber
slender sparrow

why instant finished?

carmine timber
slender sparrow

nvm fixed, i was using discord-ytdl-core instead ytdl-core-discord, looks like @discordjs/voice didnt support discord-ytdl-core

slender sparrow
carmine timber

Oh nvm

subtle granite

how do i leave a voice channel

carmine timber
subtle granite

oh okay

thanks :>

vocal valley
vocal valley
fiery blade
vocal valley

Ah, you need to enable skipLibCheck in your tsconfig

fiery blade

oh okay

subtle granite
carmine timber
vocal valley

yep, it is fixed on GitHub, will be included in next release

Basically the dependency report doesn't look far enough for each modules package.json file, which is why it couldn't find a version ^

now fixed though 👍

subtle granite

oh okay

boreal solstice

would this ever support video streaming with bots 😔

vocal valley
grim fulcrum

Hi, how I change a playback volume?
resource.volume = 0.5 doesn’t work.

vocal valley

@grim fulcrum did you enable inline volume?

const resource = createAudioResource(uri, { inlineVolume: true });
resource.volume.setVolume(0.5);

that should work

vocal valley

np 😄

vernal ibex

Hi, everyone. I'm new to this server, nice to meet you all. Had a question about Discord API - I know with the voice API you can send voice messages. Is there anyway that I can subscribe to other users' voice stream (for purposes like transcribing)? with djs or not with djs. Thx

vocal valley

@vernal ibex yep this is possible!

dusty needleBOT
vocal valley

you can subscribe to users with this

specifically for our new voice library @discordjs/voice, voice receive is a little rough around the edges still, but should be improved soon

vernal ibex
carmine timber

Do sodium requires VS 2010 - 2015 windows build tools ??

steel crescent

2015/2017/2019

but good luck on windows

oh

its outdated af

good luck

carmine timber
steel crescent

use libsodium-wrappers or so

fuck sodium

esp on windows

carmine timber

XD

carmine timber
steel crescent

?

its basically sodium but in pure JS

nothing about it is outdated

carmine timber

But We can't compile it

That's what matters

steel crescent

What?

libsodium-wrappers is webassembly

carmine timber

I am unable to install npm i sodium

steel crescent

yes don't use that

carmine timber

Ok

steel crescent

use it on linux or so

but not when on windows

carmine timber

Ok got it

honest shuttle

So what has better performance? libsodium-wrappers or sodium?

Or tweetnacl maybe?

rustic temple

Iirc use sodium in Linux and libsodium in windows (idk actually)

steel crescent

Tweetnacl performs the worst though

mossy flower

is this the end of lavalink? 👀

next thicket

How to detect which voice channel I'm in? In v13?

mossy flower

<Guild>.voice.channel I think (yeah i am pretty sure thats it)

next thicket

need to fix, ¯_(ツ)_/¯

steel crescent

Is this actually concerning the new voice module

next thicket

Yea ik

steel crescent

Or just old v12 voice

next thicket
steel crescent
next thicket
console.log (song.url);
const dispatcher = queue. connection
.play(ytdl(song.url, { filter:
"'audioonly" }))
``` then I failed suffering v13
steel crescent

V13 is very different from that if you check the pins

subtle granite

how do you specify bitrate?

snailthonk

silver sleet

Thonk

vocal valley
jolly mason

Pls help
TypeError: adapterCreator is not a function

const connection = joinVoiceChannel({
    channelId: message.member.voice.channel.id,
    guildId: message.channel.guild.id,
    adapterCreator: message.guild.voiceAdapterCreator,
})```
vocal valley
jolly mason
vocal valley

you need to use a more recent of dev

jolly mason

oh ok

jolly mason

is there any example that shows playing audio from ytdl-core to a voice channel using new library in javascript?

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

const player = createAudioPlayer()
let resource = createAudioResource(await ytdl(ytLink))
await player.play(resource)```

Bot isn't playing any audio  after updating to new library code and showing no errors, pls help 

Debugging libraries:
```prolog
Core Dependencies
- @discordjs/voice: 0.3.1
- prism-media: 1.2.9

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.3.2-2021-02-27-essentials_build-www.gyan.dev
- libopus: yes```

?

vocal valley

@jolly mason you need to subscribe your connection to the player

we have a typescript example with YouTube, and if you remove all the type annotations and interfaces you see, it becomes JavaScript

there will be some actual JS examples too however

south lark

Is receiving voice from users on web browsers causing the bot to completely crash still an issue with this new voice stuff?

analog tundra

Can i use this Voice Library with Lavalink and Erela?

ignore this ^^

carmine timber

How to change volume of playing song in new voice api ??

vocal valley
carmine timber

Thnx

vocal valley

I need to collect some data to fix the problem, and it's a bit hard since I'm unable to replicate

carmine timber

Is playbackDuration excluding pauses or including pauses ??

vocal valley

interesting question let me double check 👀

vocal valley
carmine timber

Ok

carmine timber

It is completely different as compared to v12

See pins

icy maple

Just read the guide

carmine timber

Nothing got removed, instead whole new library was created in a new way

You no longer can do <GuildMember>.voice.channel.join() in this

split cliff

What are the new features for voice if 13.0.0 cones out?

carmine timber

First you need to join a channel and then play something

wise anchor

joinVoiceChannel().play doesn't work

wise anchor
carmine timber
carmine timber

code

wise anchor
carmine timber
wise anchor

yes it joins the vc

carmine timber

For playing you need to something like :

            var source = createAudioResource(<ytdl stream>)
            var player = createAudioPlayer()
            player.play(source)
            connection.subscribe(player) // For you connection = queue.connection
wise anchor

also another question

carmine timber

ask

If you don't update your djs

Then possible 🙂

wise anchor

oh

now i have to change a lot of code

carmine timber

Yes

carmine timber
wise anchor

wdym

carmine timber
wise anchor

yes i need to be able to change the volume of the video

carmine timber

So do this :

var source = createAudioResource(<ytdl stream>, { inlineVolume : true })
            var player = createAudioPlayer()
            player.play(source)
            connection.subscribe(player) // For you connection = queue.connection

Then only you will be able to use volume controller

split cliff
subtle granite

Do I still need to install @discordjs/opus and ffmpeg?

subtle granite

Oh did not know this new guide exists

carmine timber

You could have seen pins

wise anchor
carmine timber

Where is .set ??

wise anchor

nowhere

carmine timber

??

wise anchor

sure

vocal valley

what version of d.js do you have installed?

you'll need one of the latest dev versions (as in last day or so)

carmine timber

Type npm list discord.js

wise anchor
vocal valley

can you log your guild object for me?

maybe it is a partial guild

wise anchor

ight

carmine timber

Why are you extending channel ID so long

??

wise anchor
carmine timber

@vocal valley , he has some mistakes in joinVoiceChannel

Nothing else

distant osprey

client.guilds.cache.get().channels.get().guild.xxx

vocal valley

the joinVoiceChannel looks a bit verbose, but i think it's correct

rustic temple

They're string, not number

wise anchor

ight

same error

vocal valley

can you console.log the guild you get

carmine timber
wise anchor
carmine timber

Sorry

wise anchor

i have 29 lines

vocal valley

seems to be failing on this line in d.js:

this.client.voice.adapters.set(this.id, methods);

which is odd

carmine timber
vocal valley

hmm ok, this might be an issue in d.js dev, i'll take a look now

there was a PR that removed unused voice code, maybe it accidentally touched some of the new adapter code

cannot replicate on latest dev release 🤔

can you also log guild.client.voice

wise anchor

okay

wise anchor
vocal valley

before should work i think

wise anchor
vocal valley

🤔

how on earth

can you uninstall discord.js and try reinstalling it

wise anchor

okay

vocal valley

im not really sure how this has happened, but that is v12 voice code

meguFace

this is so cracked umm

i think your node_modules might be a bit messed up

or your npm install

wise anchor
vocal valley

i have no clue tbh 😬 maybe reinstall nodejs?

carmine timber
wise anchor

okay

carmine timber

and then install modules separately

hazy copper

i keep getting this error most of the time on playback using this AudioPlayerError: aborted

hazy copper

error gets emitted by the error event

its just a stream being played over a player

const connection = joinVoiceChannel({
    channelId: interaction.member.voice.channel.id,
    guildId: interaction.guild.id,
    adapterCreator: interaction.guild.voiceAdapterCreator,
    //selfDeaf: false
});

const ytdlstream = ytdl(url, { filter: 'audioonly' });
const stream = createAudioResource(ytdlstream);


const player = createAudioPlayer({
    behaviors: {
        noSubscriber: NoSubscriberBehavior.Pause
    }
});
player.play(stream);

const subscription = connection.subscribe(player);
wise anchor

same error but i fixed the corruption issue

hazy copper

just testing this new module before replacing my old one

carmine timber

and then tell if error persists or not

hazy copper

you mean remove the object from it?

carmine timber

just for testing purposes

hazy copper

aight will leave it playing for a minute to see if i get it

carmine timber

Ok

carmine timber
wise anchor
carmine timber

to check any issues

wise anchor

Okay

So now what do i do?

carmine timber

Show me once again

wise anchor

Do i run the command

Again

Okay i will do that but im not at home atm

vocal valley

it uses youtube-dl instead of ytdl-core

carmine timber

Page Not Found for me @vocal valley

WTF

vocal valley

oops

wrong one

try now

hazy copper

yeah i was thinking of moving to that as well, it returns a webm stream by default right? avoiding ffmpeg convertions

vocal valley

the only difference is that youtube-dl downloads the video rather than ytdl-core

so far ive not experienced any streams that end early with youtube-dl

hazy copper

where is the example exactly? the one i found uses ytdl-core?

vocal valley

it will use ytdl-core but only to get the video info

this uses ytdl-core to get video info, but youtube-dl to actually stream the video

hazy copper

will try this rn

never done typescript before so give a sec to my slow brain lul

vocal valley

np!

just try to ignore the type annotations

carmine timber

What to do ??

vocal valley

so npm run build in the /voice dir, then cd into the example and try again

vocal valley

not too long 😆

hazy copper

hmm i cant run this example bot

saying it cant find @discordjs/voice but i just did an npm i

vocal valley

might need to reinstall discord.js@dev

and then also npm run build on the root repo

hazy copper

aight just did the build

yep it printed ready

carmine timber

node <file>.ts ??

hazy copper

getting this whenever i try to play something

carmine timber
hazy copper

just use the start script

npm start

carmine timber

ok

vocal valley
hazy copper
vocal valley

amazing 😁

let me know if you run into any errors

hazy copper

i will leave this running for 5mins

that was how long i was running it to get the error on the other one

vocal valley

👍

hazy copper

are there any advantages when using TS over JS?

vocal valley

it's mainly just avoiding making type errors imo

you can still get the intellisense of @discordjs/voice when you use JS

But it's easier to be confident in the code when you know it has been type checked too

hazy copper

i see, haven't gotten any errors yet

vocal valley

😁

hazy copper

wouldn't this use more bandwidth?

vocal valley

I don't think it would?

hazy copper

well as soon as i spoke

got the same error

vocal valley

Can you send a screenshot of the error in your console

👀

hazy copper
vocal valley

just to be sure, can you send me your dist/music/track.js file

hazy copper

could it be my node version by any chance? im on the latest one

yep i got you fam give me a sec

vocal valley

oh, I meant like the compiled .js file

hazy copper

oh ye my bad haha

vocal valley

Ahh seems like it hasn't been recompiled

are you definitely on the right branch?

hazy copper

its the one you sent me idk

vocal valley

if you are, could you try deleting the dist folder inside examples and trying again

hazy copper

try building again?

vocal valley

try deleting dist and recompiling, in that same file, it should import ytdl-core, not ytdl-core-discord

yep

And branch should be feat/probing

hazy copper

i will redownload the branch to make sure

that's correct right?

vocal valley

I think so,

hazy copper

oh yep i was on the wrong branch

vocal valley

you can double check if it's right by going to src/utils, there should be a demuxProbe.ts file

ahhh

hazy copper

download folder

haha

vocal valley

Lol

hazy copper

sorry for wasting your time on this lulw

vocal valley

it's ok np

hazy copper

i got to npm i everything again 1sec

vocal valley

yeah np

It is a pain, I've had the same annoyances with it when making it

I think I messed up the tooling somewhere

carmine timber

What to do ??

vocal valley

can you try npm i again?

carmine timber

Ok

Now it worked 😄

vocal valley

😁 nice

hazy copper

is that because youtube-dl isn't installed?

vocal valley

yep I think so

the README has installation instructions if you have python and pip

Otherwise there's a link where you can install it elsewhere

hazy copper

yep 1 second my python install is scuffed i think

alright fixed it now

vocal valley

👍

Is it working now?

hazy copper

song is playing now, will leave it running

vocal valley

Nice 😁

Fingers crossed

ping me if it breaks or anything, or if it works

hazy copper

yep, i just hope it doesn't use much bandwidth because im self hosting this on a raspberry pi

vocal valley

I think it should be fine, but unsure

Ooh you can apparently set a download speed limit on the song

If you want a guarantee on bandwidth cap, you could try that

hazy copper

sounds good, i guess this would use less bandwidth overall since it downloads it and then it doesn't download anything for the rest of the stream

grim fulcrum

Example bot in feat/probing branch ends playback without starting it, with no any errors.

vocal valley

👀

can you try the very latest commit

and then run this:

npm i && rm -rf dist && npm run build && cd examples/music-bot && rm -rf dist && npm i && npm start

and also double check that youtube-dl is installed

if it still does the same thing after that, can you ping me with your node.js version and os

hazy copper

@vocal valley have been running it since my last message, looks like this doesn't get any errors

vocal valley

amazing! 🎉

very happy to hear that

wise anchor
vocal valley

can you send node_modules/src/structures/Guild.js

wise anchor

okay

vocal valley

oh actually not that

send node_modules/discord.js/src/client/voice/ClientVoiceManager.js

wise anchor
vocal valley

yep, that's the outdated voice file

wise anchor
vocal valley

can you cd to the Workroom folder

then npm i discord.js@13.0.0-dev.02693bc02f45980d8165820a103220f0027b96b7

wise anchor

okay

vocal valley

oops

try now 😅

wise anchor

done

vocal valley

i am confused why only one of the files seems to be outdated

ok, can you send the new file at that location

wise anchor

okay

vocal valley

what the heck

hazy copper

@vocal valley you have any idea why ytdl-core is having these issues?

vocal valley
wise anchor
vocal valley

im guessing some faulty reconnect logic

vocal valley
wise anchor

okay

vocal valley

make sure in package.json discord.js is pinned to 13.0.0-dev.02693bc02f45980d8165820a103220f0027b96b7

then try installing all your modules again

wise anchor

okay

vocal valley

also delete a lockfile if you have it

maybe that's screwing stuff eyes_sus

wise anchor
vocal valley

yep that's fine

wise anchor

okay done

i deleted node modules and package-lock.json file

vocal valley

ok, now if you reinstall, hopefully the file should be different and a lot smaller

wise anchor

what do i run?

npm install?

vocal valley

yep

wise anchor

ight

steel crescent

just always run npm i --force

it will refetch

grim fulcrum
wise anchor

what the bruh

i am getting this again...

vocal valley

and also can you send the video URL that is causing you the issue of the bot starting and stopping immediately

grim fulcrum
vocal valley

oh huh

are you in a georestricted region maybe?

steel crescent

just pick a random video yourself instead of taking the one hydra gave you

steel crescent

What doesn't work?

And what video did you try?

grim fulcrum
wise anchor

ight i fixed the corruption issue

grim fulcrum
vocal valley

nice! should work now 😄

wise anchor
vocal valley

np

wise anchor

and it doesn't play anything

vocal valley

try npm install libsodium-wrappers

and make sure you're using the latest commit on that branch

wise anchor

thx

vocal valley

np 😄

wise anchor

a few questions

so how do i get the "dispatcher"

for example in old system you could do

let dispatcher = connection.play(...)

and then you could set the volume and stuff

how do i do that?

vocal valley

so volume:

const resource = createAudioResource('thing.mp3', { inlineVolume: true });
resource.volume.setVolume(0.5);

as for the "dispatcher", the concept of a dispatcher is gone and it's more of just a player (AudioPlayer) and a resource (AudioResource)

to move onto the next song:

player.on('stateChange', (oldState, newState) => {
  if (newState.status === AudioPlayerStatus.Idle) {
    player.play(getNextResourceFromSomewhere());
  }
});

whenever an audio player enters the idle state, it means it has finished playing something

if you want i think it's also good to copy the state transition logic in the music bot example since it is known to work

wise anchor

ight

grim fulcrum

The problem with youtube-dl is solved. The bot from the example works. yayy

vocal valley

great 😄

how did you fix your issue with youtube-dl out of curiosity?

wise anchor

how do i pause a song? what about resuming?

grim fulcrum

I just reinstalled pip and youtube-dl 😅

vocal valley
vocal valley
carmine timber

Come there

wise anchor
vocal valley

atm it doesn't support seeking since it was half broken on v12 anyway, you can enable it yourself like this:

const prism = require('prism-media');
const { createAudioResource, StreamType } = require('@discordjs/voice');

// These are arguments used to convert the input to a format suitable for @discordjs/voice
const FFMPEG_ARGUMENTS = [
    '-analyzeduration', '0',
    '-loglevel', '0',
    '-f', 's16le',
    '-ar', '48000',
    '-ac', '2',
];

// An audio stream starting from 10mins onwards in myfile.mp3
const stream = new prism.FFmpeg({
    args: ['-ss', '00:10:00', '-i', 'myfile.mp3', ...FFMPEG_ARGUMENTS],
});

const resource = createAudioResource(stream, { inputType: StreamType.Raw });
wise anchor

and another question

i used to do queue.dispatcher.destroy()

how do i do that now

vocal valley

if you want to stop playing a song on an audio player, player.stop()

carmine timber
wise anchor

ight

there was also channel property to dispatcher

how can i get that now

vocal valley

connection.joinConfig.channelId

wise anchor

ight ty

i am now getting this queue.connection.channel.leave() is not a function

wise anchor

this used to be

wise anchor

okay ty

lost lynx

Can I 'simply' use this module with discordjs v12?

carmine timber
lost lynx

@discordjs/voice

carmine timber

Idk

@vocal valley

vocal valley
carmine timber
vocal valley

examples/basic is designed to work with v12

the only difference is adapter, yep

carmine timber

file also

lost lynx

I want to see if the error I get still occurs if I migrate my simple code to this lib. First steps first, I get a "adapterCreator is not a function" from new VoiceConnection so...

vocal valley
carmine timber

😄

vocal valley

and instead of guild.voiceAdapterCreator, it'd be createDiscordJSAdapter(channel)

wise anchor

now i have to remake the pause and stop and resume

carmine timber

👍

vocal valley
vocal valley

np

wise anchor

oh and is this still a thing?

wise anchor

so i need to get it from the AudioResource and not from the connection?

vocal valley

you can either get it from the player or audio resource, the one from the player includes any silence packets that are played

resource is probably better for your use case

wise anchor

ight

adapterCreator is not a function

carmine timber
wise anchor

Are you using it in message event or interaction event ??

wise anchor
carmine timber
wise anchor

normal

carmine timber
wise anchor

discord.js@13.0.0-dev.fdad14099779e61cb84dcd1cb2497e0e853a6144