#archive-voice

30636 messages · Page 9 of 31

humble gate
joinChannel(channel) {
    return new Promise((resolve, reject) => {
      if (!channel.joinable) {
        throw new Error('VOICE_JOIN_CHANNEL', channel.full);
      }```

I want it instead of stopping working
He writes "I can't get in"

carmine timber

I was not able to read 😦

last mist

my bot has been acting up since the release of v13. Note that everything worked in pre-release. I created a new test bot peeling out enough to play an .mp3 file. In some cases it plays in others it throws seemingly odd errors. I would happily try again if someone can point me to a "this is it how it works" example. I'm following the one in the guide and I get the error using it. It will play a simple "hello.mp3" if I create a resource using just the file path. If I pass along a second parameter it will play if I set the inputType but it will fail if try to set inlineVolume. Tells me it can't find module node-opus and opuscript neither of which have I installed directly. @discordjs/opus is 0.5.3, voice is 0.5.5, discord.js is 13.0.1 Has anyone seen a) a similar error or b) a working example? Thanks.

carmine timber
last mist

`
const getTestReply = function(msg) {

logger.debug('messageHandler.getTestReply');

if(!voiceChannel)
    voiceChannel = msg.member.voice.channel;

if(!voiceConnection) {
    const permissions = voiceChannel.permissionsFor(msg.client.user);

    if (!permissions.has("CONNECT") || !permissions.has("SPEAK")) {
        return msg.channel.send("I can't join your voice channel");
    }

    voiceConnection = joinVoiceChannel({
        channelId: voiceChannel.id,
        guildId: voiceChannel.guild.id,
        adapterCreator: voiceChannel.guild.voiceAdapterCreator,
    });
}

if(!audioPlayer) {
    audioPlayer = createAudioPlayer();
    voiceSubscription = voiceConnection.subscribe(audioPlayer);
}

const cmd = 'test';

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

// const args = getCommandArgs(msg, cmd);

// let volume = parseFloat(args);
// volume = isNaN(volume) ? 1.0 : volume;
// volume = isValueBetween(volume, 0.1, 1.0) ? volume : 1.0;

// resource.volume.setVolume(volume);

audioPlayer.play(resource);
return 'test';

}
`

i can reduce it some if I remove my logger, some of the checks and the function that gets the file path but they all work everywhere. This version would fail due to it having the inlineVolume setting even though I don't access it. The commented line above would work because it doesn't have that option.

last mist

I simplified the code a tiny bit if that is too much to look at but it won't change the way it works. I've essentially followed the example in the guide https://discordjs.guide/voice/audio-resources.html#creation but as I mentioned the inlineVolume parameter makes it fail. I see the comment says // Will use FFmpeg with volume control enabled perhaps it is the version of FFmpeg I have?

ffmpeg version 2021-05-12-git-175f675f7b-essentials_build-www.gyan.dev

carmine timber
last mist

I have that as a built in admin command for my bot `--------------------------------------------------
Core Dependencies

  • @discordjs/voice: 0.5.6
  • prism-media: 1.3.1

Opus Libraries

  • @discordjs/opus: 0.5.3
  • opusscript: not found

Encryption Libraries

  • sodium: not found
  • libsodium-wrappers: 0.7.9
  • tweetnacl: not found

FFmpeg

  • version: 4.4-essentials_build-www.gyan.dev
  • libopus: yes
    --------------------------------------------------`
carmine timber
last mist

it won't work but I tried it... I think I found the error

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

Error: Error: Cannot find module 'D:\Repos\testBot\node_modules\@discordjs\opus\prebuild\node-v93-napi-v3-win32-x64-unknown-unknown\opus.node'

`

That's generated when I include either of the inlineVolume examples

carmine timber
last mist

Excellent. I renamed node_modules and just reinstalled everything and this time the folder is present and it works! The old folder had something named this: node-v83-napi-v3-win32-x64-unknown-{libc_version}

pure pewter

how do I join or leave a voicechannel in v13

last mist

A rule to live by when in doubt reinstall node_modules... thanks for your help it is much appreciated.

rose helm

npm ci exists

dreamy wind

how to destroy an AudioPlayer? there's no destroy() function

fervent estuary

you can use stop()

fallow linden

Is voice receive in a working state?

wintry lily

How can I get my bot into the stage channel every time the bot is ready?

new updates is very difficult

vocal valley
fallow linden

oh perfect! thanks

wintry lily
vocal valley
fallow linden

Looking at the example, it shouldn't be too bad to replace recording while someone is talking to playing an audio file right?

vocal valley

As in, you want to play audio while recording a user at the same time?

fallow linden

Even without recording the user, checking when they're talking and then playing something during

vocal valley

ohh

yes that should be easy,

if you want to play something while someone is talking, you could use receiver.speaking.on('start/stop', userId => ...

so when they start speaking, you start playing your resource

and when they stop speaking, you stop playing your resource

fallow linden

ah that makes sense

Hmm

voiceConnection.receiver.speaking.on('stop', userId => console.log(`User ${userId} stopped speaking`));

isn't firing when stopping speaking

the started speaking is though

vocal valley

britneyzoom

do you have video enabled at the same time or?

fallow linden

Nope

    const connection = joinVoiceChannel({
        channelId: channel.id,
        guildId: channel.guild.id,
        selfDeaf: false,
        selfMute: false,
        adapterCreator: channel.guild.voiceAdapterCreator,
    });
    connection.receiver.speaking.on('start', userId => console.log(`User ${userId} started speaking`));

    connection.receiver.speaking.on('stop', userId => console.log(`User ${userId} stopped speaking`));
vocal valley

ah, it's end not stop

will update the release lol

fallow linden

aha all good tyty

vocal valley

start/stop probably made more sense but oh well

fallow linden

Is there a way to loop a resource? If I load outside of my join function I can't reuse it, but if I create it inside, it takes about a half second to load and play

oh I'm blind, I see playing opus streams on the docs now

vocal valley

@fallow linden is it a long resource?

fallow linden

very short - 8 seconds or so

vocal valley

i have a cool and good idea

oh actually nvm it might be harder than i thought lol

fallow linden

Essentially looking for it to start from the beginning every time the start function runs

vocal valley

my idea would have been to first read your stream into a buffer, and then make a generator over that buffer, and when it reaches the end of the buffer, it just starts from the beginning, and then you could just create a readable stream from the generator and it should be a looped audio stream then

i think that could still work

but dont have the time to test it

fallow linden

all good! I'll see if I can give that a go

vocal valley

good luck!

fallow linden

you know what, actually just moving into using opus it loads extremely quick now anyway, I can just define the resource in the start function and it's pretty much instant

vocal valley

ah nice ok, no worries then 😄

golden path

Why am I getting TypeError: adapterCreator is not a function?
Here's how I set up my connection:

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

Make sure you're using discord.js v13

golden path
vocal valley

Try to debug and check that message.guild.voiceAdapterCreator isn't actually undefined

golden path

it returned this:

 methods => {
       this.client.voice.adapters.set(this.id, methods);
       return {
         sendPayload: data => {
           if (this.shard.status !== Status.READY) return false;
           this.shard.send(data);
           return true;
         },
         destroy: () => {
           this.client.voice.adapters.delete(this.id);
         },
       };
     }```
fallow linden

What message are you using in your connection?

golden path

wdym

fallow linden

adapterCreator: message.guild.voiceAdapterCreator

golden path

the one the user sends

fallow linden

shouldn't this be adapterCreator: channel.guild.voiceAdapterCreator

golden path

if a user sends a message in a guild, does it make a difference?

fallow linden

It probably shouldn't

golden path

or do you have to specify it's in a channel in a guild?

fallow linden

I was having the same issue like 2 hours ago but I forget exactly what I did

golden path

shouldn't it be adapterCreator: message.channel.guild.voiceAdapterCreator then

what do you have?

fallow linden
        channelId: channel.id,
        guildId: channel.guild.id,
        selfDeaf: false,
        selfMute: false,
        adapterCreator: channel.guild.voiceAdapterCreator,
    });``` 
But i'm passing in the channel the user is in
golden path
fallow linden

If you don't want it deafened yeah add selfDeaf false

golden path

👍

still get TypeError: adapterCreator is not a function

velvet rock

Error: No known SSRC for taget

fallow linden
fallow linden
golden path

could it be an intent issue?

that doesn't make sense though

icy maple

You didn’t provide an adapter for the joinVoiceChannel function

fallow linden

try adding Intents.FLAGS.GUILD_VOICE_STATES

golden path
golden path
icy maple

adapterCreator: <Guild>.voiceAdapterCreator

golden path

is this not the guild? adapterCreator: message.channel.guild.voiceAdapterCreator

fallow linden

yeah you have that, I tried the exact same thing and it worked

this is my client and intents const Discord = require('discord.js'); const client = new Discord.Client({ intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES, Discord.Intents.FLAGS.GUILD_VOICE_STATES] });

golden path

could it be a command handler issue?

golden path

should I send my main.js file?

fallow linden

sure, i can give it a go

fallow linden

using your main and play files it still worked

golden path
{
  "name": "omex",
  "version": "1.0.0", 
  "engines": {
    "node": "16.6.x"
  },
  "description": "Discord bot",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "FallenHero",
  "license": "ISC",
  "dependencies": {
    "@discordjs/opus": "^0.5.3",
    "@discordjs/voice": "^0.5.5",
    "discord.js": "^13.0.0",
    "ffmpeg-static": "^4.4.0",
    "yt-search": "^2.10.0",
    "ytdl-core": "^4.9.1"
  }
}
fallow linden

wait one last thing

did you pick any scopes with oauth2?

golden path

nope

should I pick bot?

fallow linden

I did bot, builds upload, and builds read

golden path

what about rpc.voice.write?

fallow linden

I didn't add it, but toss it in there for now

golden path

it says please enter a redirect uri

I think it should be url

fervent estuary

for a bot the only ones u really need are bot and now for slash-commands application.commands

golden path

still get TypeError: adapterCreator is not a function

fallow linden

try updating to 0.6, but I don't think it'll change it

fervent estuary

update @discordjs/voice to 0.6 and djs to 13.0.1

fallow linden

everythings working for me with your code

fervent estuary

see if that resolves

golden path

how do you install a specific version?

is it npm install discord.js 13.0.1?

fallow linden

I think it should be npm install discord.js@13.0.1

golden path

and npm install discord.js/voice@0.6.0, right?

golden path

should I get npm install @discordjs/voice libsodium-wrappers?

nope, same error

oh well

my node version isn't an issue, right?

16.6.1

vocal valley

That should be fine

Are you able to run the music bot example in the repo @golden path?

vocal valley

it should just be the examples folder on the repo homepage

should be in pinned messages

golden path

yup, I see it

golden path

I defined it with const {joinChannel} = require('@discordjs/voice')

icy maple

It’s joinVoiceChannel

I don’t think the example nor the guide uses joinChannel

golden path

I've tried reinstalling numerous times and that hasn't changed anything

icy maple

You should really read the guide. I believe the voice connections section covers this

golden path
icy maple

Show ur code then

golden path
icy maple

You have another joinVoiceChannel on line 54 missing the adapter

wintry lily

can i join the bot in the stage channel with djs v12 .d i dont understand v13 , really

icy maple

No

wintry lily

oh so how can i join my bot with v13

icy maple

Use the voice package (guide in pins)

golden path
wintry lily
icy maple

Do you still have ur code?

wintry lily

i only have a blank v13 code

icy maple

I mean, it’s pretty much written out for you

You call the joinVC function with the shown parameters

golden path
icy maple

I’d actually remove the first joinVC

golden path

yeah

what do I define createAudioResource with?

ReferenceError: createAudioResource is not defined

wait, nvm. I got it

Which one of these should I use? Install sodium, libsodium-wrappers, or tweetnacl.

sodium it is

icy maple

sodium is recommended

Any will work tho

golden path

do I need to add anything to my file?

icy maple

No, dependencies are auto-detected

golden path

I get the same error again even after installing sodium.

should I throw something in package.json?

icy maple

Run npm ls sodium

I assumed you installed it using the npm i command

Is it not in there already?

golden path

I used npm install node-gyp -g

undone forge

How would I go about playing local audio files in a voice channel and then automatically playing the next one after its finished?

icy maple

That’s node-gyp tho

golden path

I'm also running my bot off a server, not from my terminal

npm install sodium gave an error

icy maple

You can’t ssh into the server?

golden path

secure shell?

icy maple

Yea

golden path

I just use the command prompt on heroku

icy maple

Oh, ur using heroku

golden path

is that an issue?

icy maple

What error does it give?

golden path
icy maple

Heroku doesn’t have libtool installed?

golden path

should I use heroku create --buildpack https://github.com/jedisct1/libsodium.git?

I could install libtool then try sodium

icy maple

I was gonna say, seems like heroku lets you install libtool via Stacks

golden path

how?

icy maple

It’s actually supposed to alr be installed

Which heroku stack are you using?

heroku-16, 18, or 20

golden path

Ubuntu 20.04

icy maple

Should be in the 2.4.6-14 version of that stack then

Only available during build time tho

golden path

any idea how to fix that?

wait, how do I check which stack I'm using? I just looked at the default one on the website

icy maple

I think the install has to happen when you deploy it, can’t install it via Heroku cli

golden path

I only created it like less than a month ago

before that, I was running off a different server

I'd assume it'd be the most recent version

icy maple

Normally, you’d have a separate server or use ur computer for development, then once ready, you’d push it to a GitHub and Heroku would pull, build, and run

golden path

yeah, that's what I currently do

wait, a separate server for development?

I should probably do that 😅

icy maple

Well, Heroku isn’t meant to be used for development/testing

golden path

true

I can figure that out later

icy maple

Guess ur gonna have to manually add sodium to the package.json

golden path

yeah, I did that for discord.js/opus and voice

icy maple

No

golden path

got it

icy maple

That looks like a different package

Installation should work fine, seems like Heroku has everything it needs

golden path

I just installed libsodium

wait, that didn't do anything

I got this trying to install libtool

fallow locust

Someone told me my intents aren't being used. How do I do that?

const { Client, Intents } = require('discord.js');
const { joinVoiceChannel } = require('@discordjs/voice');
const Discord = require('discord.js');
const myIntents = new Intents();
myIntents.add(Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_MESSAGES);

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

client.once('ready', () => {
    console.log('Online');
});

client.on("voiceStateUpdate", (oldMember, newMember) => {
        console.log(newMember);
        if(oldState.speaking !== newState.speaking) {
              console.log("Spoke");
            }
    const channel = client.channels.cache.get(newMember.channelID);
    if (newMember.id === "277484746265722881") {
        if (!channel) return console.error("The channel does not exist.");

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

    }
});
red nest
fallow linden

you want const client = new Client({ intents: myIntents });

carmine timber
golden path
carmine timber
fallow locust

This code is spamming my console. Does anyone know why?

    console.log(newMember.id);
    const channel = client.channels.cache.get(newMember.channelId);
    console.log(channel.id);
    const connection = joinVoiceChannel({
        channelId: channel.id,
        guildId: channel.guild.id,
        adapterCreator: channel.guild.voiceAdapterCreator,
    })
    if (newMember.id === "277484746265722881") {
    }
    if (!channel) return console.error("The channel does not exist.");
});```
```Bot Online
main.js:9
277484746265722881
main.js:13
836998244147396668
main.js:15
873763407487189003
main.js:13
836998244147396668
main.js:15
873763407487189003
main.js:13
836998244147396668
main.js:15
873763407487189003
main.js:13
836998244147396668
main.js:15
873763407487189003
main.js:13
836998244147396668
main.js:15
873763407487189003
main.js:13
836998244147396668
main.js:15
873763407487189003
main.js:13
836998244147396668
main.js:15
873763407487189003
main.js:13
836998244147396668```
glacial turret
fallow locust

When I disconnect from a voicechannel and my bot can't find my channel.id it crashes, how do I add a fail-safe?

    const channel = client.channels.cache.get(newMember.channelId);
    if (!channel) {
        console.error("The channel does not exist.");
        client.destroy();
    }
    if (newMember.id === "277484746265722881") {
        const connection = joinVoiceChannel({
            channelId: channel.id,
            guildId: channel.guild.id,
            adapterCreator: channel.guild.voiceAdapterCreator,
        })
        if (!channel.id) console.error("The channel does not exist.");
        console.log(channel.id);
    }
});```
```            channelId: channel.id,
                               ^

TypeError: Cannot read property 'id' of undefined```

I used to have

//            console.error(e);
//            if (!channel) return console.error("The channel does not exist.");
//        });```
but that doesn't work here
carmine timber
carmine timber
fallow locust

Thank you!

glacial turret

It took me awhile too to get used to DJS passing around fully-linked objects like that. It's pretty efficient in some sense...definitely developer friendly.

fallow locust

it looks like client.destroy turns the bot off all together, is there a way to just disconnect it from the voicechannel it's in?

glacial turret

Yep. voiceConnection.destroy() @fallow locust Obviously you need to get a reference to the existing voice connection from somewhere 🤡

fallow locust

I'm guessing I'm doing it wrong

        connection.destroy();```
I did that but the console keeps saying myVoiceChannel is not defined. Sorry I'm bad at this I just started with bots 😕
carmine timber
fallow locust

That disconnected it correctly but the bot crashes after in the console

                   ^

TypeError: Cannot read property 'destroy' of undefined```
carmine timber
glacial turret

??? How could it disconnect from the channel but also not be defined?

fallow locust

Thank you guys so much

solid nebula

hello, i want to know is @discordjs/voice better than @discordjs/opus now?

glacial turret

Those are not the same thing

solid nebula

oh what are those then i misunderstood i thought they're same

glacial turret

Voice is for managing voice-related aspects of Discord.js basically. Opus is just bindings to the system's copy of libopus.

carmine timber
glacial turret

@carmine timber Why do you need to use PCM with inline volume?

solid nebula

alright got it ty

carmine timber
glacial turret

Thanks. Kinda weird though, I wonder why that is.

summer crow

hi, i have used the example music bot in pins and rewote it exactly into simple js... fixed few errors.. now it shows track enqueued and i see green circle around the bot in vc but i cant hear music...i have checked the volume... no errors also showing. pls help

glacial turret
glacial turret

Can you show me your processQueue? Or whatever you called the function handling the queue.

If the green circle is lighting up, something is coming over...hmm

summer crow
fallow locust

hey guys how do I undeafen my bot? it's on self-deafen

glacial turret

@fallow locust In joinVoiceChannel pass selfDeaf: false

subtle granite

@summer crow I didn't know Pablo was only working on chuck e cheese.

fallow locust
glacial turret
subtle granite

Belooga

eugene- i meant

glacial turret
carmine timber
fallow locust

Is there a way to make the bot detect when someone speaks?

vocal valley
carmine timber
vocal valley

I found a bug yesterday that needs to be fixed

carmine timber
vocal valley

Oh sorry it's not your PR, it's for receive

carmine timber

😦

vocal valley

Your pr will come soon enough

It's just that receive takes priority since users can't add that themselves

carmine timber

Okay

glacial turret

I think you can easily set the volume of an Opus decoder...but not encoder. Prism hasn't built it in but it's a simple addition. 🤔

zenith tiger

Hello how do i make my bot automatically Server mute itself

the old method im using is not working anymore

dusty needleBOT

Documentation suggestion from @late osprey:
_ VoiceState#setMute()
Mutes/unmutes the member of this voice state.

glacial turret
zenith tiger

thanks

glacial turret

guild.me.voice.setMute(true)

@zenith tiger Sorry

zenith tiger

no problem

cosmic prawn

Error: aborted with resource what's this err, please help,
It was working fine before but suddenly it disconnected and thrown this error,

carmine timber
glacial turret

I had it occur even with it set higher. I'd recommend use Node 14 if you insist on using ytdl-core.

carmine timber
glacial turret

Ahhh fack you are right

spare wave

Voice itself soon going for v16 as well because of adding in AbortController

cerulean dock

I'm trying to make a thing that if a user isn't in a voice channel, it reutrns an error.
Here's the code i'm with

if(!interaction.member.voice.channel) return interaction.reply({ content: `Vous devez être dans un salon vocal pour pouvoir utiliser cette commande`, ephemeral: true });

But the thing it's that it will always return the error even if i'm in a voice channel

carmine timber
carmine timber
cerulean dock
carmine timber
cerulean dock

my bad

carmine timber

And then tell me what you get ??

cerulean dock

the first is when i'm in a voice channel is when i'm in a vc and second one no

carmine timber
carmine timber
cerulean dock Still...

Add one more line before if condition console.log(interaction.isCommand())

Then show me console log

cerulean dock

it logs true

carmine timber
cerulean dock

it logs false

icy maple
carmine timber
wooden vine

how can i set volume?

icy maple
icy maple
carmine timber
wooden vine

whats default?

icy maple

The intent to receive voice state updates

carmine timber
vast magnet

How to make the bot join a voice channel where the member is?

icy maple

But it’s not updating

Hence, he’s not receiving voice state updates

carmine timber

Yeah

icy maple
carmine timber
wooden vine

how can i change volume after

carmine timber
wooden vine
    setTimeout(() => { player.pause(); }, 5_000)
    setTimeout(() => { player.unpause(); }, 15_000)
    setTimeout(() => {
        resource.volume.setVolume(0.75)
    }, 20_000);```

```js
        resource.volume.setVolume(0.75)
                        ^

TypeError: Cannot read property 'setVolume' of undefined```
carmine timber
icy maple

@cerulean dock Log !channel and channel before the if statement, and smth inside of the if statement before the return (e.g. "member not in channel")

cerulean dock
cerulean grove

Hello my bot is not playing ytdl streams

it just skips the entire video

carmine timber
cerulean grove

but it plays other streams without problem

for instance, a stream parsed from an attachment

carmine timber
cerulean grove

i dont think its ytdl problem because i can still convert its stream into file

carmine timber
cerulean dock

@icy maple It was the intents. Thank you both of you tho @carmine timber

carmine timber

Okay 👍

vast magnet

if you want to play the audio in 2 channels on 2 servers you have to do sharding?

cerulean grove
cinder edge

What's the event name for when an audio finishes playing? Something like this? .on("finish", () => {}I can't find anything on docs

icy maple

The audio player goes back to idle

cinder edge

Thank you

flat vector

@carmine timber
Thanks for your help the other day. I finally figured out what was happening. Turns out ffmpeg-static silently segfaulted on my machine. Using the system ffmpeg solved the issue. I used the -report option on the ffmpeg instance to generate a log file in which was the actual ffmpeg command that gets executed. Trying this command in a terminal resulted in a segfault.

finite wraith

How to make bot join the Stage

cinder edge
let resource = createAudioResource(ytdl(...));
player.play(resource);
```Bot ain't outputting any audio. I got `GUILD_VOICE_STATES` intent but nada.
carmine timber
cinder edge

Ahh. Thanks

carmine timber

👍

winged adder

help me piz
I installed all 3 encriptiong thingy but I still get the same error

icy maple

Check with npm ls sodium

winged adder

throw new Error(`Cannot play audio as no valid encryption package is installed.
^

Error: Cannot play audio as no valid encryption package is installed.

fervent estuary

install sodium or libsodium-wrappers

carmine timber

Type npm list sodium

carmine timber
fervent estuary

doesnt look like so according to the error

winged adder

I also gt this error

npm ERR! path /home/container/node_modules/sodium
npm ERR! command failed
npm ERR! command sh -c node install.js --preinstall
npm ERR! /bin/sh: 1: make: not found
npm ERR! /home/container/node_modules/sodium/install.js:293
npm ERR!             throw new Error(cmdLine + ' exited with code ' + code);
npm ERR!             ^
npm ERR! 
npm ERR! Error: make libsodium exited with code 127
npm ERR!     at ChildProcess.<anonymous> (/home/container/node_modules/sodium/install.js:293:19)
npm ERR!     at ChildProcess.emit (node:events:394:28)
npm ERR!     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/container/.npm/_logs/2021-08-11T12_00_58_346Z-debug.log```
carmine timber
winged adder

I am on a pannel so this happens

carmine timber
winged adder
    "@discordjs/opus": "^0.5.3",
    "@discordjs/voice": "^0.6.0",
    "buttube": "^0.4.1",
    "discord.js": "^13.0.1",
    "ffmpeg": "^0.0.4",
    "ffmpeg-static": "^4.4.0",
    "opusscript": "^0.0.8",
    "ytdl-core": "^4.9.1"
  }```
icy maple

That is a very odd dependency conflict

carmine timber
icy maple

buttube is conflicting with voice for some reason

winged adder
icy maple

So ur saying that the package is dependent on itself?

icy maple

Bc you have buttube in the dependencies

carmine timber

Leave it, he has some 3rd party stuffs

winged adder

I am the creator of that package

icy maple

What’s the name in the package.json?

winged adder

it is bcs distube requires @discordjs/voice v5 and I installed v6

winged adder
icy maple

You can’t name the project the same thing as one of its dependencies

brisk roost

channel.join is not a function at Object.execute (C:\Users\96655\Desktop\v13+\ser\command\play.js:128:55) at runMicrotasks (<anonymous>) at processTicksAndRejections (node:internal/process/task_queues:96:5) C:\Users\96655\Desktop\v13+\ser\command\play.js:134 await channel.leave() ; TypeError: channel.leave is not a function

const { channel } = member.voice.channel; queueConstruct.connection = await channel.join() await queueConstruct.connection.voice.setSelfDeaf(true); play(queueConstruct.songs[0], message); } catch (error) { console.error(error) message.client.queue.delete(message.guild.id); await channel.leave();

icy maple

You have to use the new voice package to join vc (guide in pins)

brisk roost

It has been downloaded but is there a modification because there is an error s\96655\Desktop\v13+\ser\command\play.js:16
const { channel } = member.voice.channel ^ReferenceError: member is not defined

icy maple

It appears that member isn’t defined

Kinda weird since you didn’t get that error previously. Did you accidentally delete its definition?

brisk roost

No, I did not delete it, but I did not find any modifications to a member on the site

carmine timber
brisk roost
velvet rock

how to get a readable stream from the voiceconnection class in v13?

i used to that in v12 like you see in the screenshot.

icy maple
red nest

Is there any one have suggestion for large bot's queue system?

plucky basin

apparently in v13 bots can join stages??
How do i make it join bc making it join like a regular vc doesnt work for me

i also installed the voice package

subtle granite
plucky basin

damn this is a lot different

This is on creation of voice connection

never seen it and no idea what it is

icy maple

It’s just internal stuff

dusty needleBOT

_ Guild#voiceAdapterCreator
The voice state adapter for this guild that can be used with @discordjs/voice to play audio in voice and stage channels.

plucky basin
icy maple

Leave it

thin basalt
icy maple

You need the guild voice states intent

Voice states aren’t related to the voice package

thin basalt
summer crow
thin basalt
sharp gull

is there any better way to seek in audio without using a new prism media ffmpeg stream because at the moment i spin up 2 different ffmpeg processes for one connection this is not efficient i think

Please ping me if you have a response

carmine timber
sharp gull

one that discordjs's and one for my seeking

carmine timber
sharp gull

idk probly for encoding to opus

i didnt look to discord.js/voice codes

carmine timber

If you are using inLineVolume with seek better to convert seeking FFMPEG to transcode for PCM, it is a better solution

sharp gull

nope im not using inline volume

carmine timber
sharp gull
    let ffmpegArgs = ["-ss", seek.toString(), "-i", this.currentAudioPath, "-f", "wav"];
    this.prismFfmpegStream = new prism.FFmpeg({ args: ffmpegArgs });
    this.audioResource = createAudioResource(this.prismFfmpegStream);
    this.audioPlayer.play(this.audioResource);
carmine timber
sharp gull

how i can fix that

by changing the format ?

to opus or something?

i tried both wav and opus, wav worked faster idk why

carmine timber
sharp gull how i can fix that
const FFMPEG_OPUS_ARGUMENTS = [
        '-analyzeduration',
        '0',
        '-loglevel',
        '0',
        '-acodec',
        'libopus',
        '-f',
        'opus',
        '-ar',
        '48000',
        '-ac',
        '2',
    ];

const ffmpeg_instance = new FFmpeg({
        args: ["-ss", seek.toString(), "-i", this.currentAudioPath, ...FFMPEG_OPUS_ARGUMENTS]
    });
carmine timber
sharp gull

thanks 🙂

still two tho

carmine timber
sharp gull

ffmpeg ogg and ogg/opus demuxer

carmine timber
rain flare

why is this guy stuck for 15 minutes right over here????

[..................] \ idealTree:new code: sill idealTree buildDeps```
carmine timber
rain flare
carmine timber
rain flare
carmine timber

No problem

oak pawn

how can i know audio play is end?

cinder edge

How to stop the current audio without destroying anything else? .stop() stops the audio and destroys. I'm aiming to just skip the current audio

shut verge

how can i join the vc with eval command

tame raft

how to join voice on v13?

cinder edge
cinder edge

Thank you

tame raft

play on stage ?

visual wyvern

Hello, with @discordjs/voice, can I disconnect my bot with connection.disconnect() ?

junior mantle

Does anyone know if @discordjs/opus is supported on ARM Mac's?

south lark

Does anyone know when voice receiving will be supported or if it currently is? Will it be released in the 13.1 update? Will there be an announcement when it releases?

icy maple

Support was added yesterday

See pins for example

cinder edge

Am I doing anything wrong?```js
let player = createAudioPlayer();
player.play(createAudioResource(ytdl(url, {filter: "audioonly"}), {config.musicSettings}));
getVoiceConnection(message.guild.id).subscribe(player);

player.on("error", () => {...})

Well it doesn't crash. It keeps going to error event. The song plays but then midway, it triggers the error event

void wadi

I'm sorta having a similar problem, where like I have a few songs queued and in the idle event it skips to the next song

cinder edge

Thank goodness for that. Thought it was just me. Guess it could be a library issue

Oh never mind

plucky basin

How do i make my bot set itself as speaker?

nevermind

hexed stone

Hi, just a quick question: Is it possible to change the volume of a playing sound from the PlayerSubscription? I want to change the volume via a different command from a different file but I don't know how to access the resource volume from there.

halcyon lark
resource.playStream.once('error', onStreamError);
                            ^

TypeError: Cannot read property 'once' of undefined

Why i get this error when i will start playing music?

void wadi

because .once doesn't exist for .playStream

you want to put the error listener on player.on if you want to listen for an error on your music

halcyon lark

But i get this error from my node_modules i don't use this

hexed stone

U got node 16 installed?

halcyon lark

Yes

plucky basin

how do i get the bot to play an mp3 stream from a custom link?
ytdl wont work in this case sadly

halcyon lark

Oh

spark hinge

Is it possible to change "selfDeaf" or "selfMute" without creating a new VoiceConnection?

void wadi

is it possible to get the player from a specific connection via the

getVoiceConnection(myVoiceChannel.guild.id);

or do I need to create a new one each time I play a new song?

spark hinge
void wadi
cobalt jolt

Any docs to learn how to begin with this new library?

plucky basin
civic notch
plucky basin
void wadi

we cannot help with just the debug, show code. It looks like you are legit just putting a string inside the method

plucky basin
plucky basin
frank night
channel.join().then(connection => {

Issue: So basically i'm using this in a interval. So I join the vc, user the command that has this code, but when I leave the voice channel, the bot will send a error saying that the bot can not join the vc.

Ping me with the answer please

thorn bough

Hey are you available?

carmine timber
carmine timber
thorn bough
carmine timber

Yes

thorn bough

But the thing is, my code is not single file

carmine timber
thorn bough

Everything is in different directory

carmine timber
thorn bough

Yep

Keeping everything in 1 file is mess

carmine timber
frank night
thorn bough

Js

carmine timber
frank night

Sorry about this

carmine timber
thorn bough Js

Then I think you can attach player to client class in main file like :

client.player = createAudioPlayer()

And then in ready event just do :

client.player.play(resource)

In main command file, you can do :

connection.subscribe(client.player)
thorn bough

Can you come to dm I'll send you my current code because it kinda feels similar to my implementation

high elk

Is there a alternative function for VC.join for discord.js v13?

fallow locust

My bot connects to my voice channel when I do and disconnects when I do, but when it's disconnected it stays disconnected. I want to make it so my bot comes back to the voice channel if it's disconnected and I'm still in it. How would I do that?

    const channel = client.channels.cache.get(newMember.channelId);
    console.log(oldMember.id);
    if (oldMember.id === "277484746265722881") {
        if (!channel) {
            console.error("The channel does not exist.");
            const connection = getVoiceConnection(oldMember.guild.id);
            if(connection) connection.destroy();
            return
        }
        const connection = joinVoiceChannel({
            channelId: channel.id,
            guildId: channel.guild.id,
            adapterCreator: channel.guild.voiceAdapterCreator,
            selfDeaf: false,
        })
    }
});```

I'm assuming I'd have to add some sort of if statement to jump fromif (!channel) { to const connection = joinVoiceChannel({ but I'm not sure how to do that.

thorn bough

Don't make the same mistake as me check the examples for music bot

thorn bough

Any idea?

Not in cache also

It's only happening with my bot and my other bots are working fine

silver obsidian

what are you getting at here?

thorn bough

Even my another bot which is running on same code runs fine

silver obsidian

you're just posting a bunch of out-of-context eval screenshots

thorn bough
silver obsidian

did you enable the voice state intent?

thorn bough

Even I'm in vc

thorn bough
carmine timber
thorn bough

Ok

@carmine timber

carmine timber
thorn bough

Well it is

carmine timber
thorn bough

Wait

    let memberVoice = msg.member.voice.channel;

    if (!memberVoice) return this.client.send(msg.channel.id, {
      embed: {
        color: this.client.util.color.error,
        description: `${this.client.util.emoji.error} | You must be in a voice channel to use this command!`
      }
    });
sharp gull

does anyone know why is -af "volume=0.5" argument is not working while working with prism ffmpeg

while im trying directly in console it works but not in prism

vocal valley

Maybe remove the speech marks

sharp gull

tried that too nothing changed

[
  '-i',
  'C:\\Users\\Armagan\\Desktop\\v13-music\\tmp\\media\\817408899904438282\\1628750072049.mp3',
  '-af',
  '"volume=0.50"',
  '-acodec',
  'libopus',
  '-f',
  'opus',
  '-ar',
  '48000',
  '-ac',
  '2'
]

arguments I giving

instantly goes to idle state

Mention me if someone wants to help me

carmine timber

I think you are doing something wrong.

sharp gull
  async playFromFile(filePath, seek = 0, volume = this.lastVolume) {
    this.lastAudioPath = filePath;
    this.audioPlayer.pause(true);
    try { this.prismFfmpegStream.destroy() } catch { };
    let ffmpegArgs = ["-i", filePath, "-b:a", this.bitrate.toString()];
    if (seek) ffmpegArgs.unshift("-ss", seek.toFixed(2));
    if (volume != 1) ffmpegArgs.push("-af", `"volume=${volume.toFixed(2)}"`);
    ffmpegArgs.push(...FFMPEG_OPUS_ARGUMENTS);
    this.lastSeek = seek;
    this.prismFfmpegStream = new prism.FFmpeg({ args: ffmpegArgs });
    console.log(ffmpegArgs);
    this.audioResource = createAudioResource(this.prismFfmpegStream, {
      inputType: StreamType.OggOpus,
    });
    this.audioPlayer.play(this.audioResource);
  }
``` ^^

does something wrong?

carmine timber
sharp gull ```js async playFromFile(filePath, seek = 0, volume = this.lastVolume) { t...

Add some more lines before this code :

const path = require('path')


  async playFromFile(filePath, seek = 0, volume = this.lastVolume) {
    let actual_path = path.resolve(filePath)
    this.lastAudioPath = actual_path;
    this.audioPlayer.pause(true);
    try { this.prismFfmpegStream.destroy() } catch { };
    let ffmpegArgs = ["-i", actual_path, "-b:a", this.bitrate.toString()];
    if (seek) ffmpegArgs.unshift("-ss", seek.toFixed(0));
    if (volume != 1) ffmpegArgs.push("-af", `"volume=${volume.toFixed(2)}"`);
    ffmpegArgs.push(...FFMPEG_OPUS_ARGUMENTS);
    this.lastSeek = seek;
    this.prismFfmpegStream = new prism.FFmpeg({ args: ffmpegArgs });
    console.log(ffmpegArgs);
    this.audioResource = createAudioResource(this.prismFfmpegStream, {
      inputType: StreamType.OggOpus,
    });
    this.audioPlayer.play(this.audioResource);
  }
sharp gull

path is already resolved

async playFromFile(filePath, seek = 0, volume = this.lastVolume) {
    this.lastAudioPath = path.resolve(filePath);
    this.audioPlayer.pause(true);
    try { this.prismFfmpegStream.destroy() } catch { };
    let ffmpegArgs = ["-i", this.lastAudioPath, "-b:a", this.bitrate.toString()];
    if (seek) ffmpegArgs.unshift("-ss", seek.toFixed(2));
    if (volume != 1) ffmpegArgs.push("-af", `"volume=${volume.toFixed(2)}"`);
    ffmpegArgs.push(...FFMPEG_OPUS_ARGUMENTS);
    this.lastSeek = seek;
    this.prismFfmpegStream = new prism.FFmpeg({ args: ffmpegArgs });
    this.audioResource = createAudioResource(this.prismFfmpegStream, {
      inputType: StreamType.OggOpus,
    });
    this.audioPlayer.play(this.audioResource);
  }
carmine timber
sharp gull path is already resolved

Ok then do this :

  async playFromFile(filePath, seek = 0, volume = this.lastVolume) {
    this.lastAudioPath = filePath;
    this.audioPlayer.pause(true);
    try { this.prismFfmpegStream.destroy() } catch { };
    let ffmpegArgs = ["-i", filePath];
    if (seek) ffmpegArgs.unshift("-ss", seek.toFixed(2));
    if (volume != 1) ffmpegArgs.push("-af", `"volume=${volume.toFixed(2)}"`);
    ffmpegArgs.push(...FFMPEG_OPUS_ARGUMENTS);
    this.lastSeek = seek;
    this.prismFfmpegStream = new prism.FFmpeg({ args: ffmpegArgs });
    console.log(ffmpegArgs);
    this.audioResource = createAudioResource(this.prismFfmpegStream, {
      inputType: StreamType.OggOpus,
    });
    this.audioPlayer.play(this.audioResource);
  }

Testing purpose only removing bitrate

sharp gull

ok wait

carmine timber
sharp gull
const FFMPEG_OPUS_ARGUMENTS = [
  '-analyzeduration',
  '0',
  '-loglevel',
  '0',
  '-acodec',
  'libopus',
  '-f',
  'opus',
  '-ar',
  '48000',
  '-ac',
  '2',
];

``` the arguments you sent before

same not working

carmine timber

Okay

carmine timber
sharp gull

ok

--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.5.6
- prism-media: 1.3.2

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: 2021-07-04-git-301d275301-full_build-www.gyan.dev
- libopus: yes
--------------------------------------------------
sharp gull

hmm

carmine timber

@vocal valley Please review fast, it would be lot easy to just tell someone to use createFFMPEGResource function

sharp gull

sure i can wait for that

vocal valley

I'm reviewing at the speed I can

I have a lot of other commitments besides discord.js

sharp gull

uh, no problem

vocal valley

and it's not a critical PR, the functionality can still be achieved outside the library

carmine timber

But sometimes it is very difficult for someone to setup FFMPEG args

carmine timber
sharp gull

Actually, I don't need to do this. After all, the arguments used are the same, the volume will probably not work again.

@carmine timber Am I right?

vast magnet

const resource = createAudioResource('/home/user/voice/track.mp3');
so can i put ytdl-core stuff in the path so it plays audio from youtube video?

glacial turret

When you wanna seek something currently playing (via manual FFmpeg), do you just...recreate the stream with the seek args and drop it into .play?

icy maple

Yes

glacial turret
carmine timber
sharp gull

you are tested with volume right?

carmine timber
sharp gull

huh

odd

sharp gull

i just updated my ffmpeg and still same sadge

carmine timber
sharp gull

tried nothing changed

tried pcm stream too

glacial turret

Does it work with a remote resource? Not some local file? If so it's your pathing or resolving.

sharp gull

nope directly just plays blank audio

carmine timber
sharp gull tried nothing changed

Run new CMD and do run this :

ffmpeg -i "C:\\Users\\Armagan\\Desktop\\v13-music\\tmp\\media\\817408899904438282\\1628750072049.mp3" -af "volume=0.50" -acodec libopus -f opus -ar 48000 -ac 2 test.opus
sharp gull

that works

yep i alredy tired that

not working only when using prism

tried piping on console too that works too

carmine timber
sharp gull

huh ok

carmine timber
sharp gull

btw plays without volume argument

with volume arguemnt evrything breaks

glacial turret
sharp gull

im using that

-af jsut a shortcut for filters:a

stark delta

Can I kick and move users without having the voice module installed?

stark delta

Alr thanks

runic remnant

Hey, can someone help me pls ?
Error :

Error: TypeError: channel.join is not a function

code :

const channel = message.member.voice.channel;
        try {
            const connection = await channel.join()
            queueConstruct.connection = connection;
            play(queueConstruct.songs[0]);
        } catch (error) {
            console.error(`Je ne peux pas rejoindre le salon vocal.\nError: ${error}`)
            bot.queue.delete(message.guild.id)
            // await channel.leave()
            return message.channel.send(`Je ne peux pas rejoindre le salon vocal.\nError: ${error}`)
        }

I already install @discordjs/voice@^0.6.0

runic remnant

Ping me

runic remnant

Hey can someone tell me why i have this error ?
Error :

ERROR: FFMPEG is not installed. Install with "npm install ffmpeg-static" or download it here: https://ffmpeg.org/download.html.

I'm on Windows ans I already npm install ffmpeg-static

carmine timber
runic remnant

I looked on youtube and it said put ffmpeg.exe in its bot folder

fervent estuary

u need to add it to path

runic remnant

Ok i try

runic remnant
fervent estuary
runic remnant

i don't understand....

npm install ffmpeg-static

up to date, audited 193 packages in 2s

18 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

subtle granite

audio player keeps going to autopaused.

carmine timber
carmine timber
subtle granite

and I've got no sound.

I have declared NoSubscriberBehaviour in the constraint for discordjs/voice

carmine timber
subtle granite
carmine timber

Ok XD

subtle granite
            const { createAudioPlayer, createAudioResource } = require('@discordjs/voice');
            const connection = joinVoiceChannel({
                channelId: channel.id,
                guildId: guild,
                adapterCreator: channel.guild.voiceAdapterCreator,
            })
                //create Audio Player and Audio Resource
                const player = createAudioPlayer({
                    behaviors: {noSubscriber: NoSubscriberBehavior.Play}
                });
                connection.subscribe(player)
                const resource = createAudioResource(ytdl(youtubeLink, {filter: 'audioonly'}));
                player.play(resource)
                interaction.reply({content: "Playback Started, run `/yt-stop` to stop playback." })
                        player.on('stateChange', (oldState, newState) => {
                            console.log(`Audio player transitioned from ${oldState.status} to ${newState.status}`);
                            if(player.state.status == 'idle'){
                                 connection.destroy()
                                 interaction.reply("Playback has ended.")
                                 return;
                            }
                    });
                    
                    
            
        }
        else {
            interaction.reply("You have not provided a valid YouTube link. Try Again.")
        }
    }
}```

should probably make this a thread.

plucky basin
carmine timber
plucky basin
carmine timber

Okay

vast magnet
    channelId: channel.id,
    guildId: channel.guild.id,
    adapterCreator: channel.guild.voiceAdapterCreator,
});
const resource = createAudioResource('/home/user/voice/track.mp3');
player.play(resource);
connection.subscribe(player);```
so is this how to play audio and join voice channel
carmine timber

Player was created or not ??

If yes, then code is right

vast magnet

yes the player was created

carmine timber
plucky basin
carmine timber
plucky basin

im just playing a link that broadcasts a live audio stream

or i want to at least

carmine timber
plucky basin

how exactly?'

void wadi

most bots that uses other sources links actually just takes the info from spotify then looks up on youtube for the audio source

void wadi

what source?

plucky basin

its just a audio broadcast from a radio station

void wadi

is it.mp3, ogg, what format what source?

plucky basin

pretty sure its mp3

carmine timber
void wadi

^

plucky basin

i see its a lil different

carmine timber
plucky basin

ik i realized just now
i am looking at the discord.js guide site and seeing why i shouldnt do that

assuming I got it a little bit correct, is it supposed to look somewhat like this?

const resource = createAudioResource(url('url here'))
    player.play(resource)```

@carmine timber

carmine timber
plucky basin

oh ok

plucky basin

nevermind

carmine timber
plucky basin

oh yea

void wadi

CatJam

plucky basin

galaxybrain

cobalt jolt

Any guides to begin with this library?

cobalt jolt

Okay thanks

velvet rock

how am i able to set the mode for audio output in AudioReceiveStream

cobalt jolt

how do you get a user's voice channel?

elfin lynx

anyone have problem with joining the channel will reset a shard ?

Im trying to make the bot join a voice channel but when im trying to use this command, the shard restart itself

const { joinVoiceChannel } = require('@discordjs/voice');
module.exports = {
    name: 'test',
    run: async (client, message, args) => {
        const voiceChannel = message.member.voice.channel;
        if (!voiceChannel) return message.reply('Join channel pls.');
        await joinVoiceChannel({
            channelId: voiceChannel.id,
            guildID: message.guild.id,
            selfDeaf: true,
            adapterCreator: message.guild.voiceAdapterCreator,
        });
    },
};
cobalt jolt

my bot doesn't joins my vc but still says that i'm connected

        const connection = await joinVoiceChannel({
            channelId: message.member.voice.channel,
            guildId: message.guild.id,
            adapterCreator: message.guild.voiceAdapterCreator,
        })
        console.log("connected");
        const player = await createAudioPlayer({
            behaviors: {
                noSubscriber: NoSubscriberBehavior.Pause,
            },
        });
        const resource = createAudioResource('./assets/pub-carglass.mp3');
        await player.play(resource);

        await connection.subscribe(player);
        console.log("playing pub-carglass.mp3")```
hoary delta

how can a bot join a stage Channel?

devout gull

Hello, with the basic example, how can I play the song in loop?

carmine timber
carmine timber
hoary delta
carmine timber
lunar narwhal

Is there any way to make player stream a local file like in v12 and not buffer it for like 2 seconds first?

lunar narwhal

I don't see anything there that could help me

willow thistle

hi how can ı get connections and connection.subscribe

getVoiceConnection function is not working

glacial turret

Those are the exact steps you need to take in order to create a connection and subscribe to an audio player.

willow thistle

mean ı must use create connection for subscribe ?

yes

elfin lynx

is there a event when player done playing resource ?

player.play(resource);
connection.subscribe(player);
subtle granite

Can someone explain how bot join a voice channel

subtle granite
subtle granite
subtle granite

AudioPlayerStatus.Idle

cobalt jolt
subtle granite

you need GUILD_VOICE_STATES intent

cobalt jolt

ohh okay thanks

it works now 👍

elfin lynx
subtle granite

how can i play audios on seperate voice channel

like user1 talking > play audio into user2 channel

willow thistle

@subtle granite must be different guild

I know you can't do it on the same server

subtle granite

yeah ik

cobalt jolt

how do you make a queue system? (ping me when you repond please)

jolly mason
Error: aborted
    at connResetException (node:internal/errors:691:14)
    at TLSSocket.socketCloseListener (node:_http_client:407:19)
    at TLSSocket.emit (node:events:406:35)
    at node:net:672:12
    at TCP.done (node:_tls_wrap:580:7)
subtle granite
sharp gull

You need to use node 16

subtle granite
north roost

weSmart

oblique totem

Haha ima assume this is a question yall get alot, but how do you join a voice channel?

icy maple

Use the joinVoiceChannel function from the voice package

frank night
icy maple

The guide in the pins goes more into detail (voice connections section)

oblique totem

Will check out

heady quest

someone know how to create a voice channel?
im confusing LMFAO

brisk finch

i cant install sodium

worldly sorrel

Try using libsodium-wrappers instead, it might work for you

frank night
fallow locust

Isn't oldMember only suppose to update when someone leaves a call? From what it looks like newMember and oldMember are the exact same thing.

glacial turret
frank night
glacial turret

What are you on...

frank night
glacial turret
frank night Windows

Is this in a container or something? I see it looking at a path of /home/container.

frank night
glacial turret

OK but Windows doesn't have file paths like /home/container.

frank night
glacial turret
frank night

I need to install build tools? Ah. I know how to do that

glacial turret

Yeah. node-gyp is the C++ addon compiler and it needs make and friends to do that of course (which yours says is missing).

carmine timber

@frank night Can you try installing discordjs/opus in a separate new folder by :

npm i init -y
npm i @discordjs/opus
glacial turret
brisk finch

how to let bot join a voice channel

brisk finch
const { joinVoiceChannel } = require('@discordjs/voice');

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

connection.on(VoiceConnectionStatus.Ready, () => {
    console.log('The connection has entered the Ready state - ready to play audio!');
});

then the bot will join the vc?

carmine timber

Yes but you need GUILD_VOICE_STATES intent also

brisk finch

Pepeok thanks

carmine timber
brisk finch
const { joinVoiceChannel, VoiceConnectionStatus, createAudioPlayer, NoSubscriberBehavior } = require('@discordjs/voice');
        const connection = joinVoiceChannel({
            channelId: message.member.voice.channel.id,
            guildId: message.channel.guild.id,
            adapterCreator: message.channel.guild.voiceAdapterCreator,
        });
        connection.on(VoiceConnectionStatus.Ready, () => {
            console.log('The connection has entered the Ready state - ready to play audio!');
        });
        const player = createAudioPlayer({
            behaviors: {
                noSubscriber: NoSubscriberBehavior.Pause,
            }
        });
        player.play(stream);
C:\Users\User\Documents\GitHub\lolol\node_modules\@discordjs\voice\dist\audio\AudioPlayer.js:221
        resource.playStream.once('error', onStreamError);
                            ^

TypeError: Cannot read property 'once' of undefined
    at AudioPlayer.play (C:\Users\User\Documents\GitHub\lolol\node_modules\@discordjs\voice\dist\audio\AudioPlayer.js:221:29)
    at Client.<anonymous> (C:\Users\User\Documents\GitHub\lolol\index.js:36:16)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
icy maple

You can’t pass a stream into player.play

brisk finch
icy maple

Isn’t stdout a writable stream?

brisk finch

yes

icy maple

Meaning it takes input

Like console.log("foo")

Bc even if you create the resource as described in the guide, it takes a ReadableStream

voice expects input to send to the vc

brisk finch

oh

vast magnet

How to detect if member isnt in a voice channel?

dusty needleBOT

Documentation suggestion for @vast magnet:
_ (event) Client#voiceStateUpdate
Emitted whenever a member changes voice state - e.g. joins/leaves a channel, mutes/unmutes.

vast magnet

why doesnt this play audio in the channel?
player.play(resource);

i have defined player and resource
resource code
const resource = createAudioResource('./cool.mp3');

it joins channel and doesnt play audio

icy maple

Did you subscribe the connection to the player?

carmine timber
vast magnet
carmine timber
vast magnet

no

carmine timber
vast magnet

thanks it works

icy maple

Would highly recommend reading through the guide

vast magnet

when i do /pause it doesnt pause the sound

carmine timber
vast magnet
carmine timber
rustic pelican

How can i check how many people are using specific vc?

carmine timber
dusty needleBOT

Documentation suggestion for @rustic pelican:
_ VoiceChannel#members
The members in this voice-based channel

vast magnet
carmine timber

Then show me console.log

rustic pelican
elfin lake

how wud i use message.member.voice.channelID with slash commands?

interaction.member.voice.channelID?

dusty needleBOT

Documentation suggestion for @elfin lake:
_ Interaction#member
If this interaction was sent in a guild, the member which sent it

elfin lake

o h k

hushed narwhal

Quick question; why is my bot deafened?

verbal moth

How to know when the bot joins a voice Channel ?

fervent estuary
hushed narwhal

I see. What if I wanted to make voice commands?

fervent estuary

set selfDeaf to false in the join config

hushed narwhal

Ah, got it. Thanks!

whole flare

How do I set a highWaterMark?

carmine timber
whole flare
carmine timber
fervent estuary

there no dispatcher anymore that would extend a stream

so thats y its not possible anymore

brisk roost

Has the voiceOld been updated?

fervent estuary

whats that?

brisk roost

(parameter) voiceOld: Discord.VoiceState

fervent estuary

that should still work like it did on v12

VoiceState didnt have that big of change as the rest of voice

cursive nimbus

why i cant use ${client.voice.connection.size} more ?

icy maple

Bc d.js doesn’t handle voice connections anymore

icy maple
subtle granite

I might be doing something wrong, but on an interaction the Voice Channel does not change for me, e.g. the state that I was in before application launch is the only one I can read.

console.log(interaction.member.voice.channel.id) // => null

// Joining Channel

console.log(interaction.member.displayName) // => null

// Restarting Application

console.log(interaction.member.displayName) // => 8239...

Curiously, other attributes do change, e.g. if I change the nickname, it does show

console.log(interaction.member.displayName) // => mäh

// changing nick to "Test"

console.log(interaction.member.displayName) // => Test

Do any of you guys know how I "refresh" this or something?

carmine timber
subtle granite

Ah yes, my bad, sorry. The changes in v13 are a bit unclear to me

carmine timber

No Problem

plucky basin

how can I check if my bot is outputting audio?

bleak heart

guys im having an issue download @discordjs/opus, can anyone help

bleak heart

1 sec

plucky basin

cuz that will tell u what the problem is

vast magnet
plucky basin
bleak heart
plucky basin

wait gimme a sec

bleak heart

npm i node gyp@latest?

plucky basin

i think i was lookin at somethin else

idk tbh

bleak heart

well thx for ur effort

visual wyvern

Hello, how define ressource if ressource is a Youtube video ?

plucky basin
bleak heart

ill try that

plucky basin

might help

bleak heart

didnt help :(

carmine timber

Then install discordjs/opus there and then tell me

plucky basin
bleak heart
plucky basin

im saying run the command npm update
idk but it could work or do what NIP said

carmine timber
vast magnet

but it is playing audio in the voice channel

carmine timber

@bleak heart worked ??

bleak heart

omg yes

plucky basin
bleak heart

its on another bot

carmine timber
bleak heart

im still getting the error on my current bot

carmine timber
vast magnet
carmine timber
vast magnet
vast magnet

should i use functions?

carmine timber
pure pewter

Error: Cannot find module 'C:\Users\myname\Desktop\Naxeys-Discord-radio\node_modules\@discordjs\voice\dist\index.js'. Please verify that the package.json has a valid "main" entry
any idea on how to fix this

please DM or @pure pewter me

glacial turret
pure pewter

seems to be the only solution ig

glacial turret

Doesn't seem like a particularly bad solution...quick and easy? Thinkeng

carmine timber
carmine timber
grizzled wadi

I'm having issues playing audio, I have an mp3 file at the path, and there is already a connection open, it's a top level variable in the file. I'm not getting any errors.

/**
 * 
 * @param {*} info 
 * @param {Discord.Interaction} interaction 
 */
async function playVideo(info, interaction) {
  if (!connection) {
    return interaction.editReply(
        "Sorry, you can't do that! \n`Error Code: 3 | BOT_NO_VC`"
      );
  } else {
    const videoPath = path.resolve("../rdt-rdr-bot/download/video.mp3")
    const video = voice.createAudioResource(videoPath)
    console.log(video)
    audioPlayer.play(video)
    sub = connection.subscribe(audioPlayer)
      interaction.deleteReply()
  }
}
subtle granite

Where's connection defined there?

grizzled wadi

It's defined higher up, before the function

at top level, so it exists at that point

let me put it in a bin rq

glacial turret

When you go to change e.g. the speed of some audio, is there any way to get the current timestamp of the stream?

Or maybe another way to ask that is, can I clone the stream somehow with additional/different arguments.

grizzled wadi

Now I'm not sure what's wrong, I did some logging and found that it buffers and plays like normal, but it switches instantly, with the resource never starting.

log

buffering false
playing false
idle undefined

code for log

audioPlayer.on("stateChange", (n, o) => {
  console.log(o.status, o.resource?.started)
})

relevant code

/**
 * 
 * @param {*} info 
 * @param {Discord.Interaction} interaction 
 */
async function playVideo(info, interaction) {
  if (!connection) {
    return interaction.editReply(
        "Sorry, you can't do that! \n`Error Code: 3 | BOT_NO_VC`"
      );
  } else {
    const videoPath = path.resolve("../rdt-rdr-bot/download/video.mp3")
    const video = voice.createAudioResource(videoPath)

    console.log(video.playbackDuration)

    audioPlayer.play(video)
    sub.unsubscribe()
    sub = connection.subscribe(audioPlayer)
    interaction.deleteReply()
  }
}
bold cairn

What could be causing this error?
Error: Did not enter state ready within 30000ms
It's very strange because it only showed this error after hundreds of times playing audio.
The code i'm using to avoid the error:

if (newState.channel?.type == 'GUILD_STAGE_VOICE') return;
if (newState.channel?.joinable && !newState.channel?.full) {
    playAudio(oldState, newState);
}
icy maple
bold cairn

yes, I have that intent.

Could it be a network issue? (I'm using a VPS so very unlikely)

icy maple

Does it happen every time you play audio, or just that one time?

bold cairn

Just that one time

icy maple

Hard to rly tell if your can’t reliably reproduce it

It could be network issue or smth in ur code slowing down the entire bot

bold cairn

Yep, I know. I asked in case there was any known bug or something

thanks anyway!

carmine timber
grizzled wadi
//video.js 

/**
 *
 * @param {string} url
 */
async function downloadVideo(url, interaction) {
  const fs = require("fs");
  const ytdl = require("ytdl-core");

  const vc = require("./vc.js");

  ytdl(url, { filter: "audioonly" }).pipe(
    fs.createWriteStream("./download/video.mp3")
  );

  const info = await ytdl.getInfo(url);

  vc.playVideo(info, interaction); //HERE
  return;
}

exports.downloadVideo = downloadVideo;

//controlPanel.js

async function handleSlectMenu(Discord, Client, interaction) {
    const v = require("./video.js")
    interaction.deferReply()
    console.log(interaction.values[0])
    await v.downloadVideo(interaction.values[0], interaction)   //HERE
}

//....

if (interaction.customId == "join") {
      vc.joinVC(Discord, Client, interaction)
  }

grizzled wadi

all interactions get forwarded to it

glacial turret

This is purely semantic but why call it playVideo if it strictly does not play video.

carmine timber
grizzled wadi

/root/bot/download/video.mp3

Which is the correct path

carmine timber
carmine timber
grizzled wadi

I edited the reply because I think the bot's name stupid, my mistake 😆

grizzled wadi
carmine timber
grizzled wadi

Still no audio, and the path didn't change

carmine timber
grizzled wadi

Yes

If I wanted to stream it, do pipe it into the audio player?

carmine timber
carmine timber
grizzled wadi

It said false

carmine timber

AudioResource is not playable by audioPlayer

grizzled wadi

Alright, I just tried playing video.mp3 in VLC and it works fine, is it that I'm doing it too fast and the video hasn't fully downloaded?

carmine timber
grizzled wadi

I changed it to

 ytdl(url, { filter: "audioonly" }).pipe(
    fs.createWriteStream("./download/video.mp3")
    .on("finish", async () => {
      const info = await ytdl.getInfo(url);

      vc.playVideo(info, interaction);
    })
  );

but it's never firing

subtle granite

I'm having an issue where the audio finishes within a second of it saying Enqued <track>. I am using the sample music bot example by the way.

Any common reasons to why it may be happening?

grizzled wadi

Woah!

@carmine timber It just started playing after 5 minutes

grizzled wadi

Very odd

quasi tundra

my code is getting stuck on the line where it creates the audio player
const player = Voice.createAudioPlayer({debug: true});

olive river

Why Is my channel.join function not working?

quasi tundra

i'm sure the people here would be glad to see some code

olive river

Just I do channel.join() but it shows TypeError: channel.join is not a function

@quasi tundra

quasi tundra
        //const player = Voice.createAudioPlayer({debug: true});
        
        // const resource = Voice.createAudioResource(MP3Path, {
        //     metadata: {
        //         title: "Bad Apple!! - nomico"
        //     }
        // });

it got stuck on both of these parts

my code hangs anytime i call a function from the Voice library

I can't import everything through 1 object
import {destructure here...} from "@discordjs/voice"

ok it works now

subtle granite
opaque geyser

djs voice example please

icy maple

Link is in the pins

opaque geyser

i need js, not ts

icy maple

Also use const { joinVoiceChannel, … } = require("…") in place of the import

carmine timber
icy maple

The guide in the pins is more helpful imo

opaque geyser

How to play ffmpeg file?

i have connection, how to play something there?

knotty dock

Hello. When I get the member's voice state (member.voice), It gives me the correct channel, But when I go to another channel and run the command again, It still shows me the previous channel. Until I restart the bot. How can I fix it?

icy maple
olive river

hello i am getting this error -

TypeError: Cannot read property 'once' of undefined
    at AudioPlayer.play (C:\Users\a\Desktop\v13\djsv13\node_modules\@discordjs\voice\dist\audio\AudioPlayer.js:221:29)
    at Object.module.exports.run (C:\Users\a\Desktop\v13\djsv13\commands\cmd2\play.js:130:12)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

My code -

carmine timber
olive river
carmine timber
fiery tree

yea

ytdl-core allows you to filter out the audio only

quasi tundra

and you pass that to createAudioResource?

quasi tundra
        const resource = createAudioResource(stream);```
does this download the audio all at once before playing or is it playing as it's being downloaded?
obsidian walrus

I'm basically trying to do the same thing and it wasn't working with downloading the youtube link so I tried with just a file on hand but it still won't play the audio

const ytdl = require('ytdl-core');
const path = require("path");
const filesystem = require("fs")

exports.run = async (bot,message,args) => {
    const connection = voice.joinVoiceChannel({
        channelId: message.member.voice.channel.id,
        guildId: message.channel.guild.id,
        adapterCreator: message.channel.guild.voiceAdapterCreator,
    });

    connection.on(voice.VoiceConnectionStatus.Ready, () => {
        console.log('The connection has entered the Ready state - ready to play audio!');
    });

    const player = voice.createAudioPlayer({
        behaviors: {
            noSubscriber: voice.NoSubscriberBehavior.Pause,
        }
    });
   // ytdl("https://www.youtube.com/watch?v=sGyBWNVNdP0", {filter: 'audioonly'}).pipe(filesystem.createWriteStream('./downloads/music.mp3'));
    const videoPath = path.resolve("./downloads/succ.mp3")
    const audio = voice.createAudioResource(videoPath)
    player.play(audio);
}
exports.help = {
   name: 'Play'
}```
quasi tundra

am i blind
the connection never subscribes to the player?

obsidian walrus

What's that then? literally just connection.Subscribe(player) ?

quasi tundra

.subscribe, but yes

obsidian walrus

cheers pal

quasi tundra

damn, the stream is firing an error, ECONNRESET and it's causing the bot to just hang even after i handle it

neon ibex

Sometimes there's an unfinished YouTube-dl process. Do you have any idea why?

obsidian walrus

yeah I might be having the same issue. The youtube stream plays now but it cuts out about 20 seconds in, no errors in the log.

quasi tundra

this 100% works with local files

        stream.on("error", stream.destroy);
        const resource = createAudioResource(stream);```
this is the only thing i changed, it hangs
ytdl is just the default export of ytdl-core

I've been able to get the entire song to play once.

obsidian walrus

could it possibly be a bitrate issue?

muted remnant

how can i manage volume?

obsidian walrus

theres some info options similar to the filter I used in the code block up above

dispatcher.setVolume((volum/100));``` from https://www.tabnine.com/code/javascript/functions/ytdl-core/ytdl
swift bear

Is there a documentation for the new voice library?
or I can only find stuff in the guide?

cobalt jolt

I get this error

    at ClientRequest.<anonymous> (C:\Users\Utilisateur\node_modules\miniget\dist\index.js:210:27)
    at Object.onceWrapper (node:events:514:26)
    at ClientRequest.emit (node:events:394:28)
    at HTTPParser.parserOnIncomingClient (node:_http_client:621:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
    at TLSSocket.socketOnData (node:_http_client:487:22)
    at TLSSocket.emit (node:events:394:28)
    at addChunk (node:internal/streams/readable:312:12)
    at readableAddChunk (node:internal/streams/readable:287:9)
    at TLSSocket.Readable.push (node:internal/streams/readable:226:10)
Emitted 'error' event on AudioPlayer instance at:
    at OggDemuxer.onStreamError (C:\Users\Utilisateur\Discord\Bots\keymey\node_modules\@discordjs\voice\dist\audio\AudioPlayer.js:213:22)
    at Object.onceWrapper (node:events:514:26)
    at OggDemuxer.emit (node:events:406:35)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)```

with this code ```js
async playSound(channel, guild, sound) {
const connection = await joinVoiceChannel({
channelId: channel.id,
guildId: guild.id,
adapterCreator: guild.voiceAdapterCreator,
})
//if (channel.type == "GUILD_STAGE") guild.me.voice.setSuppressed(true);
console.log("Joined #" + channel.name)
const player = await createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Stop,
},
});
const resource = await createAudioResource(sound);
await player.play(resource);

    await connection.subscribe(player);

}```

subtle granite
cobalt jolt

oh

muted remnant

how to configure volume?

obsidian walrus
obsidian walrus
muted remnant

Ok ;-;

oak pawn

What is AudioResource.volume?.setVolume()'s range? Is it 0.1 ~ 1?

frank night
carmine timber
carmine timber
carmine timber
frank night
muted remnant

\

cobalt jolt
obsidian walrus