#archive-voice

30636 messages · Page 6 of 31

warm marsh

may i ask last thing
what should be the options in ytdl(...)?

i did the same thing but i can't stil hear anything.

lapis trench

with djs13, stage channel are supported?

carmine timber
lapis trench
carmine timber
lapis trench

okay

txbut if I don't have the intents it detects it anyway?

carmine timber

indents are only meant for listening to events like messageCreate, messageDelete etc.

lapis trench

messageCreate its "message" on djs12?

carmine timber
lapis trench

uh, and i have a certified bot, and he dont have intents

carmine timber
lapis trench

12

carmine timber
lapis trench

because it does not require a lot of event

so my bot will become unusable?

carmine timber
carmine timber
lapis trench

i mean

carmine timber

?v13-intents

bronze swanBOT

The master branch of Discord.js requires you to choose suitable intents (as it uses a new version of Discord's API)
For information on using websocket intents: https://discordjs.guide/popular-topics/intents.html

Note that this is a v12 guide - in master intents are provided directly to the ClientOptions:

- const client = new Client({ ws: { intents: ['GUILDS', 'GUILD_MESSAGES'] } });
+ const client = new Client({ intents: ['GUILDS', 'GUILD_MESSAGES'] });```
lapis trench

okay

carmine timber
lapis trench

oh, okay lmao I was so scared

carmine timber

XD

lapis trench
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of null      ```

```js
    let channelid = message.member.voice.channel.id
    let channel = message.guild.channels.cache.get(channelid)
    await channel.join()```

i cant make this?

carmine timber
lapis trench

djs 13

carmine timber

To install new voice module type : npm i @discordjs/voice

lapis trench

nice tgx

obtuse cradle

What is a good substitute for ytdl-core, ytdl?

pseudo rampart
obtuse cradle

Thks

Should I create one player per guild playing?

final jay

if you want a radio style bot, with one stream for all guilds, no

obtuse cradle
subtle granite
client.on('message', async message => {
    const prefix = "!";
    if(message.author.bot || !message.guild || !message.content.startsWith(prefix)) return;
    const args = message.content.slice(prefix.length).trim().split(/ +/);
    const command = args.shift().toLowerCase()
    if(command == 'record') {
        if(!message.member.voice.channel) return;
        const stream = await message.member.voice.channel.join()
        console.log(stream)
    }
})

Error:

(node:7904) UnhandledPromiseRejectionWarning: TypeError: message.member.voice.channel.join is not a function
compact timber
const channel = message.member.voice.channel
joinVoiceChannel({
channel: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator
})```

its now in @discordjs/voice

subtle granite
compact timber
inland ginkgo

Hello, do you have a solution for this error? Error: Did not enter state ready within 30000ms

let voiceChannel = message.member.voice.channel;
let connection = joinVoiceChannel({ channelId: voiceChannel.id, guildId: voiceChannel.guildId, adapterCreator: voiceChannel.guild.voiceAdapterCreator });
try {
    entersState(connection, VoiceConnectionStatus.Ready, 30000);
} catch (err) {
    connection.destroy();
    console.log(err);
}

Okay I just replaced guildId by guild.id, my bad x)

obtuse cradle

Any tips in how to stop the Aborted Connection error?

Or causes of it

signal sigil

what is wrong?

@celest basalt,can you help me?

celest basalt

No

signal sigil
celest basalt

Whoever comes into this channel to help. Stop trying to ping

?r6

bronze swanBOT

6. Do not mention or DM individual members just for help. You may not get a reply quickly, if at all. Post your question in the public channels where more people can see it.

warm marsh

how do i disconnect the bot from a voice channel?

spare wave

have you check the intent?

drifting niche

so... about a month ago I started messing around with the new voice stuff to see if it was worth implementing it into one of my projects. I got it working for what I wanted - basically when a particular user joins a vc I wanted the bot to also join and play an audio file. it worked fine but I disabled it because it was annoying a few people.

I just tried to add it back so I can further tweak it and am finding it now to not be working. I know this is still in dev and I'm sure something was changed that affects my code but I'm wondering if someone might be able to just have a little look over it and give their two cents please

const { joinVoiceChannel, createAudioPlayer, NoSubscriberBehavior, createAudioResource, StreamType } = require('@discordjs/voice');

module.exports = class voiceStateUpdate extends baseEvent {
    constructor() {
        super('voiceStateUpdate');
    }
    async run(client, oldState, newState) {
        const nope = 1;
        if(newState.id === '139152491496472576' && !oldState.channel) {
            const connection = joinVoiceChannel({
                channelId: newState.channelID,
                guildId: newState.guild.id,
                adapterCreator: newState.guild.voiceAdapterCreator,
            });
            const player = createAudioPlayer({
                noSubscriber: NoSubscriberBehavior.Pause,
                selfDeaf: true,
            });
            const resource = createAudioResource('https://okie.eu/i/mikaj.mp3', {
                inputType: StreamType.Arbitrary,
            });
            player.play(resource);
            connection.subscribe(player);
            if(newState.id === '139152491496472576' && newState.selfMute === true && connection) {
                connection.destroy();
            }
        }
    }
}```

user joins the vc, and provided they weren't already in a vc on the server then the bot should join the same vc and play the audio file. the user can then just self mute once forcing the bot to disconnect again. however with that above code, the bot doesn't join nor does it emit any error to tell me why

but it did work about a month ago

drifting niche

nevermind. I see why now - part of this odd pattern of changing ID to Id everywhere

carmine timber
carmine timber
vocal jetty
carmine timber
vocal jetty

not me, the message is gone lol

carmine timber

LOL

worthy coyote

broadcasts are more valid in v13?

brisk urchin

how would I debug buffering issues? only thing I found was AudioPlayer debug event which just logs state changes

round harbor

Every time I try to execute```js
newMember.member.voice.kick()

`Error [VOICE_STATE_UNCACHED_MEMBER]: The member of this voice state is uncached.`
How to fix this or how to cache the user?
There were no such problems before..
round harbor
carmine timber
carmine timber
subtle granite

how can i get this function in V13?

connection.receiver.createStream()
vocal valley
long plank
let newConnection = joinVoiceChannel({ channelId: VC.id, guildId: VC.guild.id, adapterCreator: VC.guild.voiceAdapterCreator });
            entersState(newConnection, VoiceConnectionStatus.Ready, 60000).then(connection => {

UnhandledPromiseRejectionWarning: ReferenceError: joinVoiceChannel is not defined how come

edgy burrow

did you require it from discord.js/voice?

long plank

why do i need to do all this authenticating shit when trying to install /voice

or was it @discordjs/voice

edgy burrow

@discordjs/voice

long plank

Package subpath './voice' is not defined by "exports"

long plank

inve installed sodium @edgy burrow

still got the same error...

can createAudioResource handle URL's?

supple crane

Hi, tell me if the bot might want to Stage?

deep crag

How would I have my bot leave the voice channel after playing an mp3 file?

brisk urchin

it's just stuck on buffering Weirdge

brisk urchin

yeah it only happens when trying to play live radio streams after a youtube video has been played, very weird thinkw

it also appears that calling AudioPlayer#stop while its buffering doesn't actually ever stop it/changes state to idle weirdeg

nvm I had to do AudioPlayer#stop(true) OMEGAlul

subtle granite

how can i use:

new AudioReceiveStream()
kindred yarrow

Oh i posted my issue in the wrong channel i think

This is the discord.js@dev voice right?

edgy burrow

yes

well @discordjs/voice which is needed on v13 for voice

warm marsh

how do i prevent when doing a process, it stops suddenly?

spare wave

give more context maybe?

warm marsh

when the player is playing and doing some process (like yt-search api), the player suddenly stops and after a few seconds (after the process), the player will play back.
how do i prevent that?

spare wave

in my experience, it is because of the search package. I have the same issue before, forgot what package I used for searching youtube, and notice that the package dependency that make it eating up cpu/ram thus interrupting the song playback. I change to other search package, which is lighter the issue not occur anymore. Have a try, I can't guarantee, but that's that

obtuse cradle

Any tips in how to handle / prevent the Abort error?

spare wave
warm marsh

how can i skip a song?

obtuse cradle
warm marsh how can i skip a song?

I coded that everytime the player enters idle it searches for the next song, so in my implementation I use player.stop() to skip. If (!song) it just waits a time and disconnect

worthy coyote

broadcast has now unavailable on v13 ?

vocal valley

@worthy coyote everything is now a broadcast instead

You can make an audio player, and then play that across as many voice connections as you want

The audio player is essentially the broadcast here

worthy coyote

yes but my bot wan't play, i have follow all steps of doc

brisk urchin

what's the correct way to destroy the AudioPlayer? (so it cleans everything up)

dapper helm

hey with the @discord/voice

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

im getting an error with the adapterCreator
Type 'InternalDiscordGatewayAdapterCreator' is not assignable to type 'DiscordGatewayAdapterCreator'.

inland ginkgo

Hello, is it normal that when my bot plays music on a vc, I have this error: DeprecationWarning: Socket.prototype._handle is deprecated?

south totem
node:events:371
      throw er; // Unhandled 'error' event
      ^

AudioPlayerError: aborted
Emitted 'error' event on AudioPlayer instance at:
    at OggDemuxer.onStreamError

Keep Getting this error after a few minutes of playback :/
"@discordjs/voice": "^0.5.4", "sodium": "^3.0.2", "yt-search": "^2.9.0", "ytdl-core": "^4.8.3"
Any Fix Please?

solemn current
npm i @​discordjs/opus

error:

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/container/node_modules/@​discordjs/opus/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/container/node_modules/@​discordjs/opus/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/container/.npm/_logs/2021-07-18T18_34_21_561Z-debug.log
solemn current

connection.pause() is not a function?

fervent estuary

ig u meant to do audioPlayer.pause? not connection.pause

solemn current

oh

solemn current
fervent estuary

i personally use ytdl-core

solemn current
fervent estuary

ill see if i got a simple one

just a sec

welp i dont have a simple one unfortunately

but it should be quite straightforward

solemn current
fervent estuary

uhhh the one i got is really just a mess xd

just try to use it urself. If u get any problems i can do my best to assist

solemn current
fervent estuary

updating ytdl-core should fix that

forest topaz

are there any plans to put @djs/voice into the client like the old voice code
or is it gonna stay used via functions exported by the module

eg are we going to have VoiceChannel#join again or will it be @discordjs/voice#joinVoiceChannel for the forseeable future

fervent estuary

it will stay as a seperate library

solemn current
fervent estuary

ytdl returns a readable stream. Which as itself is a stream of buffers.

inland ginkgo

Is there a way to play a livestream from ytdl?

When I try this, the bot disconnects after 5 seconds without error

solemn current
inland ginkgo

With ytdl?

solemn current

@inland ginkgo r u there

inland ginkgo
solemn current yes show the code
let connection = joinVoiceChannel({ channelId: voiceChannel.id, guildId: voiceChannel.guild.id, adapterCreator: voiceChannel.guild.voiceAdapterCreator });
entersState(connection, VoiceConnectionStatus.Ready, 30000).then(() => {
    ytdl.getInfo(args[1]).then(video => {
        let song = { title: video.videoDetails.title, url: video.videoDetails.video_url, author: message.author.id };
        let stream = ytdl(song.url, { filter: 'audioonly' });
        let resource = createAudioResource(stream);
        player.play(resource);
        entersState(player, AudioPlayerStatus.Playing, 5000);
    })
})
inland ginkgo
solemn current
inland ginkgo

with a normal video it works without problems

just when i try with a stream, the bot stops after 5 seconds

I think it doesn't work with livestreams because there's no playbackDuration (livestreams do not have limits), so is there a way to resolve that?

solemn current
obtuse cradle

What are good packages to handle spotify playlist and links?

brittle veldt

not djs

final jay

lmao

final jay

works well with tracks, playlists, albums

and it's easy to use

inland ginkgo

So do you have a solution for playing a livestream on a voice channel?

north lion

@discordjs/voice contains everything for voice now right? including joining a voice channel?

brisk urchin

yes

north lion

cool thanks

obtuse cradle
long plank

Hey there, i have my bot joining however its not playing the audio and it is also not giving any errors

long plank
//Code for reference
const player = createAudioPlayer({
                behaviors: {
                    noSubscriber: NoSubscriberBehavior.Pause
                },
            });

let connection = joinVoiceChannel({ channelId: voiceChannel.id, guildId: voiceChannel.guild.id, adapterCreator: voiceChannel.guild.voiceAdapterCreator });
                entersState(connection, VoiceConnectionStatus.Ready, 30000).then(() => {
                    let resource = createAudioResource(songurl);
                    player.play(resource);
                    entersState(player, AudioPlayerStatus.Playing, 5000);

//as i said, song url is formed as https://mylink.com/song.mp3
west perch
inland ginkgo
brisk urchin

try logging player state changes

long plank

how so? @brisk urchin

void ingot

how do i play sound from youtube (i made the Video Finder)

void ingot

why that code doesn't playing the audio

void ingot

thats not playing the auido but when i do a mp3 link from another website it works but when i get from youtube is not works help pls

There's no any errors

i fixed don't use opus

long plank

how do i seek to a part of the current song?

void ingot

as ms

long plank

im not using ytdl

void ingot

what u use

long plank

im using my own links

void ingot

then idk

chrome sundial

hello i have a question about my memory leak situation i use very similar concept to https://github.com/discordjs/voice/tree/main/examples/music-bot for my q and etc. and i suspected when i destroy the voice connection then deleted the musicsub object i have 1 active handler more from the original value of active handler before the voice connection and this dont happen when the played resource ends then i destroy connection and delete the voice sub is this a library issue or a something me to handle as a user and how can i handle this?

long plank

how do i seek to a part of a song that is about to be broadcasted?? is there the same {seek: <seconds>} functionality like how there is in v12

subtle granite

?docs

bronze swanBOT

@subtle granite, what would you like to search for?

Type cancel to cancel the command.

subtle granite

voice

bronze swanBOT
long plank
brisk urchin
worthy coyote

can i have help please ?

Song is ready to play!
/root/PrivateBot/Coins/node_modules/@discordjs/voice/dist/util/Secretbox.js:27
    throw new Error(`Cannot play audio as no valid encryption package is installed.
    ^

Error: Cannot play audio as no valid encryption package is installed.
- Install sodium, libsodium-wrappers, or tweetnacl.

I have already install sodium

long plank

how can i define a start time for a song?

like if i want to start 5 seconds in?

carmine timber
carmine timber
long plank how can i define a start time for a song?

You can create an FFMPEG instance from prism-media module and then pass these arguments to that FFMPEG instance.

#archive-voice message

const prism_media = require('prism-media')
const { createAudioResource, StreamType }  = require('@discordjs/voice')
const FFMPEG_OPUS_ARGUMENTS = [
    '-analyzeduration',
    '0',
    '-loglevel',
    '0',
    '-acodec',
    'libopus',
    '-f',
    'opus',
    '-ar',
    '48000',
    '-ac',
    '2',
];

// Above code should be at top
const url = < your url>
const ffmpeg_instance = new prism_media.FFmpeg({
        args : ['-ss', '5000ms', '-accurate_seek' ,'-i', url, ...FFMPEG_OPUS_ARGUMENTS ]
    })
var source = createAudioResource(ffmpeg_instance, { inputType: StreamType.OggOpus , inlineVolume : true })

This will start song at 5 seconds.

long plank

nvm, i had my audio output on discord disabled

bold cairn

How can I check if a user joined a stage channel using voiceStateUpdate?

fervent estuary

If ur using 13-dev Check if newState channel is of type GUILD_STAGE_VOICE

bold cairn

found it :) newState.channel?.type == 'GUILD_STAGE_VOICE'

bold cairn

Any major updates from v0.5.1 to 0.5.4? It stopped working when I updated and returns no errors

void ingot

how can i make an dispatcher e.x

dispatcher.on('finish', () = {
// code to get song from queue
})```
long plank

dispatchers don’t exist in v13 if i’m not wrong

fervent estuary

yes they dont

the closest to it would be the AudioPlayer/AudioResource

final jay
fervent estuary

no. U will have to respawn the process with the new arguments

void ingot
ripe nacelle

I have this:

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

But I get an error for the adapterCreator. It says:

TS2322: Type 'InternalDiscordGatewayAdapterCreator' is not assignable to type 'DiscordGatewayAdapterCreator'.

...

What am I doing wrong here?

void ingot
lyric drift

Hi, I've created an audio resourse in my client ready by launching a radio on the bot. But if I want to change the radio with a command, it doesn't change. I think I have to replace te audio resource somehow but I need some help. This is what I am using to play/modify the radios:

long plank

is therer anyway to speed up the seeking process? it takes a good 10-15 seconds for my music to start playing while seeking

spiral jetty

I have a PCM stream, what do I need to do to change it into an opus
(Or any bot readable) stream?
I'm trying

    args: [
        '-analyzeduration', '0',
        '-loglevel', '0',
        '-f', 's16le', 
        '-i', PCMStream, 
        '-acodec', 'libopus',
        '-f', 'opus',
        '-ar', '48000',
        '-ac', '2',
    ],
});```
But the bot stays silent every time I try to play encoder
long plank

@spiral jetty i did this:

let resource = createAudioResource(ffmpeg_instance, { inputType: StreamType.OggOpus , inlineVolume : true });

@spiral jetty one more thing, where did u get a list of arg's you can use for the encodeR?

spiral jetty
sonic torrent

is it possible to identify what the user said in a voice channel?

finite echo
knotty socket

How know if my bot is connected to a voiceChannel?

sonic torrent
finite echo
sonic torrent

ok

wooden latch

how do i install sodium?

i get this error when installing sodium

ripe nacelle
wooden latch

okay 👍

carmine timber
wooden latch i get this error when installing sodium

You can't install sodium on windows as sodium supports msVersion upto 2015 and most of current users have higher msVersion like 2017, 2019 etc..

Moreover, windows-build-tools are also on msVersion 2017.

So ignore installing sodium, go for libsodium-wrappers.

spare wave

In the pin guide, it show you how to

Or just go for libsodium-wrapper

vocal valley

The voice library can automatically encode PCM streams to opus for you

void ingot

How can I make an event when the song ends

warm marsh

<AudioPlayer>.on(AudioPlayerStatus.Idle, fn) or 'idle' event.

long plank
warm marsh

how do i change the playbackDration? like seeking

void ingot
subtle granite

i want to make Music bot do i can make it with this new voice ?

void ingot

who had make the first music package for v13

fervent estuary
fervent estuary
warm marsh
void ingot that worked thanks but is that per guild?

maybe if you subscribe the connections from other guilds in the same audioPlayer, it will emit the same event because it has the same player.
you can get the audioPlayer from a connection by <VoiceConnection>._state.subscription.player.

void ingot
fervent estuary

can u link it to me here?

void ingot
fervent estuary

can u give a link to that package?

void ingot

who made it was my question

bcs i want to make it

fervent estuary

im not exactly sure which package youre talking about

so could u please link it so i can take a look?

void ingot
void ingot
warm marsh maybe if you subscribe the connections from other guilds in the same audioPlayer...

not work

(node:9052) UnhandledPromiseRejectionWarning: TypeError: connection._state.subscription.player is not a function
    at playSong (C:\Users\Startklar\Desktop\Main\Discord Bot\JS v13\Dianos\functions\player.js:50:33)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:9052) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9052) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with 
a non-zero exit code.
fervent estuary
fervent estuary
void ingot

oh s***

warm marsh
void ingot
warm marsh

<audioPlayer.on('idle', fn)
you already have the audioPlayer in your code. you can just do player.on('idle', fn)

void ingot

what do i make wrong

(node:16392) UnhandledPromiseRejectionWarning: C:\Users\Startklar\Desktop\Main\Discord Bot\JS v13\Dianos\commands\music\queue.js:21
          let data = await find(value);
                     ^^^^^

SyntaxError: await is only valid in async function
    at wrapSafe (internal/modules/cjs/loader.js:979:16)
    at Module._compile (internal/modules/cjs/loader.js:1027:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at C:\Users\Startklar\Desktop\Main\Discord Bot\JS v13\Dianos\handler\index.js:10:22
    at Array.map (<anonymous>)
    at module.exports (C:\Users\Startklar\Desktop\Main\Discord Bot\JS v13\Dianos\handler\index.js:9:18)
rustic temple

That's basic JS. You need to make your function async (the one in the loop where you're using await)

sonic torrent
long plank

which lib? @sonic torrent

sonic torrent
subtle granite

where can i find music bot example with v13 but js not typescript

distant osprey
subtle granite
fervent estuary

U can convert it to js

Just remove all the typecasting etc

bold furnace

does anyone here made a audio cliping bot? I mean bot that records the audio in the voice channel and on some command makes an clip; cca 2 mins long record

dim ether

Help me please, How i can play mp3 file in voice channel.

dim ether
carmine timber
dim ether

Change this line to interaction.guild.voiceAdapterCreator

You can't pass undefined to adapterCreator (by using ? in guild)

spare wave

Update djs to latest commit, or just ignore the typing chech

"discord.js": "^13.0.0-dev.07017a9.1626869177", Thi commit should remove the error

spare wave

No, still have it error, just ignore it for now

Time to poke @vocal valley

carmine timber
spare wave No, still have it error, just ignore it for now

There is a simple fix for this thing.
Just go to node_modules -> discord.js -> typings -> index.d.ts

Then add this line at top import { DiscordGatewayAdapterCreator } from '@discordjs/voice';

Then around Line 568 public readonly voiceAdapterCreator: InternalDiscordGatewayAdapterCreator;

Change this to public readonly voiceAdapterCreator: DiscordGatewayAdapterCreator;

This DiscordGatewayAdapterCreator has been marked for internal assessment and will be applied soon.

spare wave

There already fix for it I see, just visited github, well either install it from github or wait for npm release

carmine timber
vocal valley

I think your typescript maybe?

using setTimeout with 2 parameters like this is perfectly fine

carmine timber
vocal valley

🤷‍♂️

carmine timber
vocal valley 🤷‍♂️

Resolve needs an argument to be passed. So setTimeout is asking for that argument for resolve only.

So it might be for all not specifically for me.

Should I make a pr for this OR you will do it yourself ??

spare wave

I think got 1 person make a PR few hours ago when I go to the github repo

same issue

What node version you on @carmine timber ? Since I'm on v16.4.2 with jsconfig.json, no TS dependancy. TS doesn't bug me any error about it

carmine timber
spare wave

Let me fork it and see

carmine timber

👍

vocal valley

@carmine timber thanks for PR, will review tonight, hopefully merge, then make a release

spare wave

v16.2.0 no error, thinkLul

dim ether

how to leave bot in voice channel ?

carmine timber
carmine timber
spare wave

earlier wrong directory, didn't npm install on the right folder, yup saw that error. done import util from 'util'; const wait = util.promisify(setTimeout) and it gone

dim ether

@carmine timber help me please. how to get listener count in voice channel ?

carmine timber
carmine timber
dim ether

Then do interaction.member.voice.channel and rest above ^^

carmine timber
dim ether

If your bot is also connected to same voice channel, then do something like this :

var connected_users = 0
<VoiceChannel>.members.each((m) => {
    if(m.id === client.user?.id) return
    else connected_users++
})
console.log(`Members connected = ${connected_users}`)
warm field

is there is any lavalink client who support discord.js v13?

fervent estuary

new voice should have little effect on everyone using lavalink

just make sure your discord.js v13 client is up to date

warm field

hmm

currently my lavalink just load track but can't play track

fervent estuary

doesnt really sound like a discord.js related issue. Lavalink handles all the sending of audio etc by itsself

uneven igloo

hey so i was trying to make a lavalink music bot but it doesnt connect to lavalink node neither gives any error

steel crescent

This has nothing to do with us

uneven igloo

ok

topaz quail
    at Object.run (/home/container/commands/Music/stop.js:25:22)
    at module.exports (/home/container/events/guild/messageCreate.js:262:15)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)```code: https://pastebin.com/ACDUZXbp

and bot was connected to a channel

stone meadow
bronze estuary
const x = interaction.member.voice.channelId;
        const y = interaction.guild.channels.cache.get(x);
        if (y.joinable) {
            y.join();
        }

y.join() is not a function
Why doesn't this work anymore? Is there a new way to join voice channels in v13?

rustic temple

You need to use the new library. Check pinned messages

livid apex

Hello there, I'm trying to port my bot to the new DJS Voice, and I believe I stumbled across a little issue: It seems VoiceConnection.channel has been removed. Is there a new way to get the currently connected channel?

empty torrent

Is the pr merged by which i can track active voice connections on all guilds? Previously client.voice.connections.size

obtuse cradle

What could be the causes of the Connection Aborted error?

obtuse cradle
livid apex
dusty needleBOT
obtuse cradle

Wrong one

dusty needleBOT

Documentation suggestion for @livid apex:
djsatdev VoiceState#channel
The channel that the member is connected to

livid apex

Alright I'm dumb, sorry for the bother. Thank you 🙂

By the way, if you don't mind me asking, should I use createAudioPlayer()'s return as the old dispatcher? idk, like storing it in a map or sth?
Sorry, this update got me really confused

solemn current

how to set a description on a stage?

narrow jetty

How can I join a voice channel on @discordjs/voice

carmine timber
rose helm

Does voice internally add any listeners to players

warm marsh

what's the event when a user disconnects the voice channel

rose helm

Not new voice related. The discord.js event is voiceStateUpdate whenever the newState channel ID is not equal to the previous state channel ID or is null.

carmine timber
rose helm

The voice lib doesn't facilitate a connection to the bot gateway. On user disconnect should not get passed to the library unless it's the current user. (even then, the session invalidates and the lib handles that)
VOICE_STATE_UPDATE can transition between one channel ID to another. A user can move voice channels. The gateway doesn't send null and then the new channel ID. The channel_id is only null if the user is not in any voice channels anymore. The term "disconnect" is ambiguous, but my interpretation was that the user could move voice channels (which facilitates a disconnect from the previous voice channel and then connect to the new one)

old state channel ID is not always null for the same reason I already outlined.
I'd recommend doing more research on the raw gateway :)

carmine timber
empty torrent
carmine timber
empty torrent

Let me try. Thank you

carmine timber

@vocal valley Seen my PR ??

carmine timber
ruby garnet
vocal valley
vocal valley
sonic sky

I dont understand this very well, can I get any examples?

carmine timber
sonic sky

OMEGAlul I see

I hope hydrabolt sees this-

narrow jetty

I can't get voice connection when I restart bot but the bot is still in the voice channel. How can I fix it?

I use:
getVoiceConnection(guild.id).destroy()
carmine timber
narrow jetty

Thanks and how can I play audio on a channel

carmine timber
narrow jetty Thanks and how can I play audio on a channel

You need to do this in 3 steps :

  1. CreateAudioResource :- prepares audio that is going to play ( either local files or any stream (ytdl-core-discord or youtube-dl) ) [https://deploy-preview-595--discordjs-guide.netlify.app/voice/audio-resources.html#creation]

  2. CreateAudioPlayer :- Player that is going to play that created resource [https://deploy-preview-595--discordjs-guide.netlify.app/voice/audio-player.html#creation]

  3. Attaching Audio Player :- Then attaching this audio player to created voice connection. [https://deploy-preview-595--discordjs-guide.netlify.app/voice/voice-connections.html#playing-audio] with subscribe function.

narrow jetty

Thank you

rose helm

You should be storing queues in a form of persistent storage so that you can have enough data to restore them and resume where you left off

sonic sky
glacial quail

hey, I would like to know how to fix this problem and if there is an error can you tell me ^^'

code:js module.exports = { name: 'join', description: 'Cette commande permet de rejoindre un salon vocale', // EXECUTEUR async execute(client, message, args) { const connection = await message.member.voice.channel.join(); connection.join() }, }; error:```diff

  • message.member.voice.channel.join is not a function
mental patio
glacial quail

okay thx

vocal valley

@carmine timber i still cant reproduce any of the errors raised in your pull request

what version of typescript are you using

nimble spindle

can anyone please help me know how to make the bot join the voice channel. I tried this but it didn't work out:

const { joinVoiceChannel } = require("@discordjs/voice");
       const vc = joinVoiceChannel({
          channelId: message.member.voice.channelId,
          guildId: message.guild.id,
          selfDeaf: true
        })
        console.log(vc)
        await message.react(embedsetting.emojis.success)
        .catch((err) => {});
latent oasis

how discord.js v13 new voice looks like ?

sonic sky
vocal valley

does npm run build in the music-bot folder work for you

vocal valley

there's an open PR for it

sonic sky

yya finally hydrabolt respond to me

sonic sky
nimble spindle
spare wave
solemn current

when will be able to record audio

nimble spindle
spare wave

YW

solemn current

@vocal valley how would you use the voice-reciver im on that dev branch

carmine timber
carmine timber
carmine timber
spare wave

Strange enough on my repo which have the same function, ts doesnt bug me about it, though it is js file with jsconfig.json to typecheck my js files

carmine timber

I am talking with hydrabolt, I know how to solve this error. I have created a PR for this only. I need no suggestions.

bitter sky
const process = require("youtube-dl-exec").raw("youtubeurl", {
    o: "-",
    q: "",
    f: "bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio",
    r: "100K"
}, {
    stdio: ["ignore", "pipe", "ignore"]
});

if(!process.stdout) return;
const stream = process.stdout;
process.once("spawn", () => {
    demuxProbe(stream).then(probe => {
        this.resource = createAudioResource(probe.stream, { inputType: probe.type });
        this.play(); // internal funcs
    }).catch(e => {
        if(!process.killed) process.kill();
        stream.resume();
    });
}); 

Essentially the example code incorporated into my own audio controller

When I go to play the audioResource, I get the silence frames and nothing else. Either that or its playing nothing at all.

I've been scratching my head for hours and I've tried everything I could think of. I just need a nudge in the right direction.

carmine timber
bitter sky

Of course. This is just an example of what I have.

carmine timber
bitter sky

Yep, I've got the socket connection, no errors, looks good

I've also already checked the output of demuxProbe() and then also the output of createAudioResource()

They both look alright to me

carmine timber

This looks good to me.

bitter sky

<audioPlayer>.play(<audioResource>);
Nothing special

To clarify - this worked fine with ytdl, except that every so often it would abort the stream for no reason

So I've moved to youtube-dl-exec and followed an example available in the @discordjs/voice repo

vocal valley

@bitter sky could you try replacing youtube-dl-exec with just regular youtube-dl with ChildProcess.spawn

bitter sky

Sure, just a moment

It's telling me I don't have sodium installed, although I do. I'm going to reinstall it and try again

I installed youtube-dl through python3-pip and spawn it with the same arguments, and I get the same result, but much quicker.

It joins then leaves the channel straight away.

I've had a look at probe.stream and it has a length of 0 @vocal valley

The process.stdout itself also has a length of 0

I'm pretty sure I'm spawning it properly

vocal valley

@bitter sky anything in stderr

?

bitter sky

stderr <Socket> length: 0

vocal valley

will message u later about it

my guess for now is to see if you can get ChildProcess.spawn to work outside of any voice code, e.g. can you spawn the process and then pipe stdout to a valid audio file?

bitter sky

If I run the youtube-dl command from my cli I can see the stream just fine. I'll try piping it to a file

Thanks for the help :)
I'll see what I can do

stone meadow

how to seek a song in v13

long plank
stone meadow how to seek a song in v13
const ffmpeg_instance = new prism_media.FFmpeg({
                        args : ['-ss', '5000ms', '-accurate_seek' ,'-i', songurl, ...FFMPEG_OPUS_ARGUMENTS ]
                    })

                    let resource = createAudioResource(ffmpeg_instance, { inputType: StreamType.OggOpus , inlineVolume : true });

thatll seek 5 seconds into the stream

_ _

_ _

Following https://github.com/discordjs/voice/blob/main/examples/radio-bot/index.js

I see that there is:

function attachRecorder() {
    player.play(
        createAudioResource(
            new prism.FFmpeg({
                args: [
                    '-analyzeduration',
                    '0',
                    '-loglevel',
                    '0',
                    '-f',
                    'pulse',
                    '-i',
                    'pulse' === 'dshow' ? `audio=audio_hw_device_id` : 'audio_hw_device_id',
                    '-acodec',
                    'libopus',
                    '-f',
                    'opus',
                    '-ar',
                    '48000',
                    '-ac',
                    '2',
                ],
            }),
            {
                inputType: StreamType.OggOpus,
            },
        ),
    );
    console.log('Attached recorder - ready to go!');
}

how do i define what song to play? with the above code snippet

carmine timber

@vocal valley Now merge the PR.

carmine timber
long plank

so "'pulse' === 'dshow' ? audio=audio_hw_device_id : 'audio_hw_device_id'," should be my URL?

carmine timber
carmine timber
long plank

could i do more than one song if i filter through songurl for where the url of the media is meant to be?

or would i have to make multiple players?

subtle granite
TypeError: adapterCreator is not a function
dim ether

I have problem, my bot streaming music but after about 3 hours the streaming stopped.

dim ether

what is 5_000

carmine timber
carmine timber
carmine timber
carmine timber
dim ether

i want to streaming 24/7

long plank

i want more than one option for radio but i want it to sync across all

subtle granite
carmine timber
carmine timber
long plank
long plank

fuckkk ok ok

barren ferry

const Discord = require("discord.js");
const fs = require('fs');

// eslint-disable-next-line no-undef
client.on('message', async message => {
// Join the same voice channel of the author of the message
if (message.member.voice.channel) {
const connection = await message.member.voice.channel.join();
}
});

// Create a dispatcher
connection.play('');

dispatcher.on('start', () => {
console.log('audio.mp3 is now playing!');
});

dispatcher.on('finish', () => {
console.log('audio.mp3 has finished playing!');
});

// Always remember to handle errors appropriately!
dispatcher.on('error', console.error);

dispatcher.pause();
dispatcher.resume();
// Set the volume to 25%
dispatcher.setVolume(0.25);
voiceChannel.leave();

any error?

@bronze swanhelp

bronze swanBOT
carmine timber
obtuse cradle

What could be the causes of the Error: aborted, the connection between the AudioPlayer and the resource or an Ytdl error from downloading the video?

It happens randomly and it puts the player on Idle with in my case passes to the next music

fervent estuary

Thats an ytdl error

eager perch
        var channel = message.channel
        var resource = voiceclient.createAudioResource(ytdl('https://www.youtube.com/watch?v=26Ln8V6og-c', { filter : 'audioonly' } ))
        var player = voiceclient.createAudioPlayer()
        player.play(resource)
        voiceclient.joinVoiceChannel({
            channelId: channel.id,
            guildId: channel.guild.id,
            adapterCreator: channel.guild.voiceAdapterCreator,
        }).subscribe()

TypeError: Cannot read property 'subscribe' of undefined

What would cause this?

I know joinVoiceChannel would be undefined but I dont see how

obtuse cradle
carmine timber
eager perch

alrigfht thx

eager perch

Error [VOICE_NOT_STAGE_CHANNEL]: You are only allowed to do this in stage channels.

This is definetley a stage channel

bitter sky

Haven't tested it yet but maybe it'll help. I'm using node 16 too

obtuse cradle
eager perch

nope I put the wrong ID variable name

carmine timber
carmine timber

Creating streams with ytdl-core has many issues.

obtuse cradle

I will give it a shot sometime, I already know how to use the Ytdl-core so I coded in that way

spare wave

Nothing much differ actually

carmine timber
spare wave

I mean the method ytdl(url, args) same as youtube-dl(url,arg)

carmine timber

But youtube-dl requires much more coding initially than ytdl-core.

bitter sky

Including using the python binary for youtube-dl

carmine timber
bitter sky

I still have to download the YouTube audio

spare wave

What exactly could be the issue though?

bitter sky

With the connection aborting?

Who knows, maybe YouTube does some kind of check now that ytdl doesn't handle, or the node runtime, or the package itself

spare wave

Aborting? So far, I dont have it issue, play fine for 4hrs+

carmine timber
bitter sky

So how do we get the audio stream from a url

We can't play what we haven't got haha

carmine timber
bitter sky

I'm out and about right now and am behind on an important freelance project anyway, so I can't do too much in the short term. If you could DM me any resources though I'll check them out. I appreciate it

carmine timber
bitter sky

I can have a quick look in a few hours but I've really got to make some progress on something else first

carmine timber

Ok, Let me send you

bitter sky

Thanks. It's not really a life or death issue anyway. Music streaming is a novelty

carmine timber

I know XD Hahah

obtuse cradle
bitter sky With the connection aborting?

It's Node 16 with something with Ytdl-core, after setting the js Ytdl(link, { filter: 'audioonly', quality: 'highestaudio', highWaterMark: 1048576 * 32 });
highWaterMark: 1048576 * 32 = which is (32 Mib) the issues stopped, it is running for 30 mins without any aborts if U don't want to use youtube-dl

bitter sky
carmine timber

@vocal valley May you consider my PR.

vocal valley

Just had a quick look, looks like a nice solution to be honest! I'll just try to think of some alternatives before settling on this

Thanks for the PRs

carmine timber

😄

knotty socket

Hi guys. I used the voice example Basic and music-bot and it does "work" for me. But sometimes player get Autopaused state and the only way around is a "needed" restart of the app to playing anything. I use this:

            o: '-',
            q: '',
            f: 'bestaudio[ext=webm+acodec=opus+asr=44000]/bestaudio',
            r: '64K',
        }, { stdio: ['ignore', 'pipe', 'ignore'], maxBuffer :  3e9 });
if (!process.stdio) {
            console.log('No readable stream');
            return;
}
const stream = process.stdout;
const onError = (error: Error) => {
            if (!process.killed) process.kill();
            stream.resume();
            console.log(error);
        };
    
const resource = createAudioResource(stream, {
            inputType: StreamType.Arbitrary,
        });
    
this.player.play(resource);
this._PlayerEvents(this.player);

Output:

[DEBUG] PlayerState:    playing -> idle
[DEBUG] PlayerState:    buffering -> playing
[DEBUG] PlayerState:    playing -> idle
[DEBUG] PlayerState:    buffering -> playing
[DEBUG] PlayerState:    playing -> idle
[DEBUG] PlayerState:    buffering -> playing
... (up to work fine song by song)
[DEBUG] PlayerState:    playing -> autopaused
[ERROR] Player <Autopaused> for +3 seconds```

Any idea? 

Node v16.5.0
discord.js: 13.0.0-dev.02693bc02f45980d8165820a103220f0027b96b7
discordjs/voice: 0.5.3
carmine timber
knotty socket
carmine timber
bitter sky
carmine timber
bitter sky

I used ytdl-core-discord, not sure if there's any difference, but my process manager hasn't flagged it for using too much memory

carmine timber
bitter sky

Ah, I can probably close the socket programmatically, plus I don't allow songs longer than 7 minutes or something

Thanks for your concern though

carmine timber
carmine timber
bitter sky

I'll keep an eye on it, thanks

carmine timber

Ok 👍

bitter sky

I had a look at your PR. Looks awesome

carmine timber

Thanks.

@vocal valley Do I need to worry about codecov/patch and codecov/patch failing (while running checks) ??

empty torrent

@carmine timber, i figured that memory leak happens with youtube-dl-exec. After playing music for 2-3 hours simultaneously, the bot automatically restarts and logs that the memory usage was overlimit.

I’m using ytdl-core and seem to play songs in repeat for like 13 hours now.

empty torrent
carmine timber
fervent estuary

the memory leaks are most likely with your own code or djs v12

i havent noticed any memory leaks in ytdl-core

carmine timber
empty torrent
fervent estuary

so the memory leak is caused by your own code not handling the stream correctly.

carmine timber
fervent estuary

so you should close the ytdl-core stream

carmine timber
fervent estuary

tbh

in my own code i have 4 + the audio resource streams running simultaneously. And so i dont get memory leaks i have to close all of those

carmine timber
fervent estuary

ytdl-core readme explicitly tells you to call stream.destroy() if u wish to abort the download

carmine timber
fervent estuary

if the same error didnt occur with ytdl-core with the same code it would look like there is a memory leak in youtube-dl-exec

dim ether

One bot can join only one voice channel right ?

fervent estuary

in a server yes

dim ether

thx

spare wave

For past 2 days, RAM usage are the same even with how many hours I played song using youtube-exec-dl

spare wave

I think he copied paste my code before, which on track.js, some of the code make the buffersize going higher and higher. and than I realized about it and changed. That the bad idea if copy pasting others without knowing thing

carmine timber
spare wave

youtube-dl arguments

carmine timber

Oh okay

spare wave

After the code changes, this is the value even after I played song 3hrs+, using ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB

carmine timber
spare wave

nope.

I can do some endurance test to see it, play song on repeated mode for 8hrs+ like it 🤔 Maybe I see something interesting

subtle granite

what are the changes of this new voice system?

carmine timber
subtle granite

I know this isn't documented here, that's why I'm looking for help lol

fervent estuary

you can simply say everything

carmine timber
subtle granite

wrong channel sorryl

spare wave
ripe nacelle

What type of AudioResource does this return?

return createAudioResource(createReadStream(audioFile), {
    inputType: StreamType.OggOpus
  });
carmine timber
spare wave

I think the other reason might be I'm using the event method instead of the collection method. Collector method add listener everytime, while interactionCreate only use 1 listener for the music button/selection

bold cairn

Is it possible to turn the adapter.ts to .js using ES6 exports?

fervent estuary

ye

bold cairn
fervent estuary

can you show the js code you got from that?

bold cairn

I'm importing it like this

import { createDiscordJSAdapter } from './adapter.js';

and using it in:

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

thonk

does it work if you use require() instead of import?

bold cairn
fervent estuary

ic

if u replace exports.createDiscordJSAdapter = createDiscordJSAdapter; with export createDiscordJSAdapter; in the adapter file work?

bold cairn
fervent estuary

ofc its a function so that wont work

on line 50 add export in front of the function declaration

bold cairn

same error

fervent estuary

how are u exporting anything out from your js files?

bold cairn

export { function_name }

fervent estuary

give that a shot in the adapter file

bold cairn

I just found out I'm using a different version of the adapter. If I use the one from pastebin, and leave it as it is, I get

Object.defineProperty(exports, "__esModule", { value: true });
                      ^
ReferenceError: exports is not defined```
If I replace the last line with `export createDiscordJSAdapter;` I get 

export createDiscordJSAdapter;
^^^^^^
SyntaxError: Unexpected token 'export'

bold cairn
fervent estuary

did u leave some of the other exports?

fervent estuary

it might be just easier if u manually removed all ts stuff from the file

bold cairn

yep, I forgot to delete the export from line 50. Now it's

Object.defineProperty(exports, "__esModule", { value: true });
                      ^
ReferenceError: exports is not defined
fervent estuary

thats just the problem of using compiled ts without actually having a ts project setup

bold cairn

Oh 😓

fervent estuary

so id recommend that u just remove all the typescript stuff from the adapter file and use it like that

empty torrent

Can i play live stream’s with the new voice? Seems to stop automatically after 10s

bold cairn
fervent estuary

👌

bold cairn

Why is new-voice written in ts? It is part of discord.JS so that's why I was wondering

fervent estuary

ig ts was just preferrable for it

compact timber
nimble spindle

Cannot perform IP discovery - socket closed i am getting this error but the bot joins the vc. is there anything to worry?

wise anchor

How do i record audio from a voice channel

(if possible)

fervent estuary

its possible. Not 100% sure of the state of support for it. Anyways there are no examples yet

wise anchor

Alright

bold furnace

Hi, I'm having an issue.
I just remade my v12 bot to v13, it works great but it sometimes when I want to play something it just fast joins and leaves and throws and error Error: Did not enter state ready within 20000ms
Do you have any suggestions to do? If you want the code I can provide it, but it is so long...

obtuse cradle
Error: getaddrinfo ENOTFOUND brazil5203.discord.media
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26)
    at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17)
Emitted 'error' event on VoiceConnection instance at:
    at VoiceConnection.onNetworkingError (c:\Users\jpedr\Desktop\Visual Code\Node.js\Botter V2\node_modules\@discordjs\voice\dist\VoiceConnection.js:266:14)
    at Networking.emit (node:events:394:28)
    at Networking.onChildError (c:\Users\jpedr\Desktop\Visual Code\Node.js\Botter V2\node_modules\@discordjs\voice\dist\networking\Networking.js:147:14)
    at VoiceWebSocket.emit (node:events:394:28)
    at WebSocket.VoiceWebSocket.ws.onerror (c:\Users\jpedr\Desktop\Visual Code\Node.js\Botter V2\node_modules\@discordjs\voice\dist\networking\VoiceWebSocket.js:28:39)
    at WebSocket.onError (c:\Users\jpedr\Desktop\Visual Code\Node.js\Botter V2\node_modules\ws\lib\event-target.js:140:16)
    at WebSocket.emit (node:events:394:28)
    at ClientRequest.<anonymous> (c:\Users\jpedr\Desktop\Visual Code\Node.js\Botter V2\node_modules\ws\lib\websocket.js:688:15)
    at ClientRequest.emit (node:events:394:28)
    at TLSSocket.socketErrorListener (node:_http_client:447:9) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'brazil5203.discord.media'
}

Adding a connection.on('error', (err) => { function... }) should stop it? If yes, how should I handle the error?

deep crag

For some reason there is a 5 second delay to play a file when my bot joins the voice channel. Does anyone know what could be the culprit? It was originally a one second delay.

Now the delay is massive, and occasionally the bot won't play any sound.
My code has remained the same. Maybe I'm getting rate limited?

eager perch

Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close

Im using youtube-dl

any reason? every thing work perfectley with ytdl

spare wave
  1. What does the youtube-dl arguments look like? Have you monitor the RAM usage when with both ytdl and youtube-dl?
eager perch

both were low usage < 100MB

spare wave

can you show the youtube-dl argument then? Might able to help, might not

eager perch

alright

url, "-f", "best[ext=mp4]"

does it have to do with "best[ext=mp4]"?

spare wave

I'm guessing you using child process and not the youtube-dl-exec package? you need to activate the quiet mode iirc

eager perch

wait a sec, im using a 3rd party wrapper

eager perch

thank you 🙏

I was using a wrapper called youtube-dl-wrap

spare wave

for the -f param try this bestaudio[ext=webm+acodec=opus+asr=44100]/best since discord use web opus or w/ever the name

eager perch

alright thank you!

eager perch

then it says the same error message

spare wave

url, "-f", "bestaudio[ext=webm+acodec=opus+asr=44100]/best", "-q", "", "-o","-" If I follow the wrapper format. The error is because youtube-dl crashes

eager perch

it still spikes like that, and crashes

it looks like the wrapper uses child process

so its a youtube-dl problem?

spare wave

my RAM usage so far, 48min song

eager perch
spare wave

yea.

This is snippet of mine, it uses the same principle of child process too

eager perch
carmine timber
eager perch

ok thanks!

carmine timber
eager perch

yea got it working!

carmine timber

😄

eager perch

thanks! Still have no clue what was wrong i just switch my wrapper to youtube-dl-exec and it started working

spare wave

Congrat and do mind checking RAM usage time to time

carmine timber

@vocal valley Found any alternatives ??

vocal valley

To what 👀

carmine timber
vocal valley

Have not had chance to look at it yet, working during the week

carmine timber

Ok

vocal valley

Will only be able to have a proper look next week unfortunately

carmine timber

No problem 👍

ripe nacelle

I have a resource that plays for a certain amount of time but usually not finishes. Then I play another resource via my audio player, do I need to get rid of my old resource that isn't played fully?

carmine timber
empty torrent

I updated discordjs to latest dev yesterday. Maybe after then, i can’t play music in multiple server’s at the same time. If i play on one server, the song starts without any issue. But if i try to play song in another server at the same time, the bot doesn’t join the vc and only queues the song. Any idea why this is happening?

empty torrent

I own it, but the music system i took from someone else’s player.

ripe nacelle

your problem sounds like that the system doesn't use multiple audio players

empty torrent
ripe nacelle

and you were on v13 that time?

empty torrent

Nothing major has changed after then. And, i updated v13 version yesterday.

empty torrent
ripe nacelle

huh, sadly I think I cannot help you then shrug

empty torrent

Hm, does the latest v13 changes interaction.guildID to interaction.guildId?

vocal valley

yep

all ID are now Id

empty torrent

Could that be the culprit?

vocal valley

probably, i think this has happened to a few people 😅

empty torrent

Hmm. Just to be clear, i’m on this version discord.js@13.0.0-dev.4886ae2.1627171445. Is it the latest dev version?

spare wave
empty torrent

I’m learning js and i usually do that by looking into other’s code’s then finding out what the code does. I know i still know a little about js, but i’m trying to learn.

empty torrent

Does the new voice can play livestreams properly?

spare wave

using youtube-dl or lavalink

empty torrent

Can’t i do it with ytdl-core? The problem is, livestreams play for 10-15s and then stops automatically.

azure iron

VSCode can't read the types from tiny-typed-emitter. Can I fix this somehow or do I have to wait for a @discordjs/voice update

carmine timber
azure iron

0.5.5

carmine timber
azure iron

Thank you, it worked. But it's weird: i just started VSCode a little while ago

spare wave

Go to their discord server? I saw the api, should be able to? But i never tried, it not lib related at this point

deep crag
carmine timber Code please.

Apparently it was my slow internet connection that was causing the delay. The bot was indeed playing the audio, my connection was just so bad it was delayed.

empty torrent
bold furnace

Hi, I'm having an issue.
I just remade my v12 bot to v13, it works great but if I want to play something it just fast joins and leaves and throws and error Error: Did not enter state ready within 20000ms
It make that every "first" play, cuz the second works great
Do you have any suggestions to do? If you want the code I can provide it, but it is so long...

spare wave

might be related to your issue

bold cairn

what could be throwing this error?

 Error: Did not enter state ready within 30000ms
     at Timeout.<anonymous> (/home/ubuntu/bot-discord-js-v13/node_modules/@discordjs/voice/dist/util/entersState.js:17:49)
     at listOnTimeout (internal/timers.js:557:17)
     at processTimers (internal/timers.js:500:7)

is the bot trying to connect to a voice channel it doesn't have permission to talk in?

subtle granite

How do i see if a member is in a voice channel...? message.member.voice.channel keeps returning that im not in one.
Do i need to install the voice library?

bold furnace
subtle granite
const voice_channel = message.member.voice.channel;```
```js
const connection = joinVoiceChannel({
  channelId: voice_channel.id,
  guildId: voice_channel.guild.id,
  adapterCreator: voice_channel.guild.voiceAdapterCreator,
});
connection.on(VoiceConnectionStatus.Ready, async () => {
  // not firing 
}```
Why is that event not firing...?
bold furnace
bold furnace
subtle granite
Error: Did not enter state ready within 30000ms
    at Timeout.<anonymous> (/home/container/node_modules/@discordjs/voice/dist/util/entersState.js:17:49)```
Why? I'm running it on a server and the bot responds, but its not entering the ready state..?
carmine timber
icy maple

Or didn’t enable the GUILD_VOICE_STATES intent

@subtle granite

autumn pebble

hey

can i get some examples of how voice works

rose helm

The examples you can find in the git for voice are quite comprehensive

autumn pebble
rose helm

If you're using Discord.js v13 dev, it comes with its own adapters built in. If using some other lib or <= v12, yes

autumn pebble

ok so i m using the dev built that means i dont need one

carmine timber
autumn pebble
rose helm

There are no other modular voice libs and baking voice support into the library increases lib size even if the user doesn't want voice support

autumn pebble
rose helm

They do

autumn pebble
rose helm

scroll down to the optional deps

autumn pebble

nice, ty discord.js

also one more thing, i cant get the property voice of GuildMember

rose helm

GuildMember.voice still exists in master

Make sure you're actually trying to access a GuildMember

autumn pebble
import Discord from 'discord.js'
import Voice from '@discordjs/voice'

export default {
    run: async (interaction: Discord.CommandInteraction) => {
        if (interaction.inGuild()) {
            Voice.joinVoiceChannel({
                channelId: '859635708020523022',
                guildId: '859635708020523018',
                adapterCreator: interaction.guild.voiceAdapterCreator
            })
        }
    }
}```
autumn pebble
carmine timber
autumn pebble
carmine timber
autumn pebble
carmine timber

Ok

autumn pebble
autumn pebble
carmine timber You need 3 lines of code : 1. Create a AudioResource first [https://deploy-prev...
import Discord from 'discord.js'
import Voice from '@discordjs/voice'

export default {
    run: async (interaction: Discord.CommandInteraction) => {
        let connection = Voice.joinVoiceChannel({
            channelId: interaction.guild.members.cache.get(interaction.member.user.id).voice.channel.id,
            guildId: interaction.guildId,
            adapterCreator: interaction.guild.voiceAdapterCreator
        })

        let resource = Voice.createAudioResource('C:\Users\hp\musiz\js\routes\bot_sounds_airhorn_airhorn_default.ogg')

        let player = Voice.createAudioPlayer()
        player.play(resource)

        connection.subscribe(player)
    }
}```

this code is not working, does not give error too

carmine timber
autumn pebble

oh

spare wave

interaction.guild.members.cache.get(interaction.member.user.id).voice.channel.id you can access member directly from interaction become interaction.member.voice.channel.id

autumn pebble
spare wave

lol? That is how I do, and working. Though, what is really not working again?

autumn pebble

its doing everything except for playing audio

import Discord from 'discord.js'
import Voice from '@discordjs/voice'

export default {
    run: async (interaction: Discord.CommandInteraction) => {
        let connection = Voice.joinVoiceChannel({
            channelId: interaction.guild.members.cache.get(interaction.member.user.id).voice.channel.id,
            guildId: interaction.guildId,
            adapterCreator: interaction.guild.voiceAdapterCreator
        })

        let resource = Voice.createAudioResource('C:\\Users\\hp\\musiz\\js\\routes\\bot_sounds_airhorn_airhorn_default.ogg')

        let player = Voice.createAudioPlayer()
        player.play(resource)

        connection.subscribe(player)

        interaction.reply({
            content: 'hi'
        })
    }
}```

here is my code till now, which works till interaction.reply except it does not play the file

carmine timber
autumn pebble
empty torrent

Hi @spare wave,
Sorry to bother but i’m stuck somewhere and createAudioResource function says no stdout. I know it’s not good to ask for code but can you please send the createAudioResource function of the Track.js file?

carmine timber
autumn pebble yesh

Can you create a separate file and add this code there and run and show me console.log:

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

console.log(generateDependencyReport());
autumn pebble
Core Dependencies
- @discordjs/voice: 0.5.5
- prism-media: 1.3.1

Opus Libraries
- @discordjs/opus: 0.4.0
- opusscript: 0.0.8

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

FFmpeg
- version: 4.3.2-2021-02-27-essentials_build-www.gyan.dev
- libopus: yes
--------------------------------------------------
spare wave

try update your discordjs/opus

carmine timber

Yes

spare wave

"@discordjs/opus": "^0.5.3", latest now is 0.5.3

carmine timber

That's what I was going to say XD

autumn pebble

still not working

spare wave

@empty torrent on here js if (!process.stdout) { reject(new Error('No readable stream')); return; } change the process.stdout to process.stdio

empty torrent
spare wave

yes. try and see

empty torrent
spare wave

What track you playing?

    createAudioResource() {
        return new Promise((resolve, reject) => {
            const process = ytdl.raw(this.url, {
                o: '-',
                q: '',
                f: 'bestaudio[ext=webm+acodec=opus+asr=44100]/best',
                r: '200K',
                userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0',
                geoBypass: '',
            }, { stdio:['ignore', 'pipe', 'ignore'], maxBuffer: 3e6 });
            if (!process.stdout) {
                reject(new Error('No readable stream'));
                return;
            }
            const stream = process.stdout;
            const onError = (error) => {
                if (!process.killed) {process.kill();}
                stream.resume();
                reject(error);
            };
            process
                .on('spawn', () => {
                    audio.demuxProbe(stream)
                        .then((probe) => resolve(audio.createAudioResource(probe.stream, { metadata: this, inputType: probe.type })))
                        .catch(onError);
                });
        });
    }``` this basically mine, if that still not working, I have no idea
carmine timber
spare wave

for science weSmart

carmine timber

🤣

spare wave

can remove it, it jsut some silly stuff I meddle around

autumn pebble
carmine timber Do this once again
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.5.5
- prism-media: 1.3.1

Opus Libraries
- @discordjs/opus: 0.5.3
- opusscript: 0.0.8

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

FFmpeg
- version: 4.3.2-2021-02-27-essentials_build-www.gyan.dev
- libopus: yes
--------------------------------------------------```
empty torrent
empty torrent
spare wave

you can try. I have no idea because I don't play live audio, and not planning to

carmine timber
empty torrent
vocal jetty
empty torrent

Oh, okay. I’m on it. Thank you

spare wave
autumn pebble

what is wrong with my djs voice

analog frost
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.5.5
- prism-media: 1.3.1

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

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

FFmpeg
- not found
--------------------------------------------------

Error: FFmpeg/avconv not found!
how to fix it?
npm install ?

carmine timber
analog frost
carmine timber
analog frost

thanks, it's work!

witch one is the best?

spare wave

best is sodium, but hard to install. so go for libsodium if you struggle installing sodium

carmine timber
solemn current

When will recording come out? and how can i install / use the dev branch version rn.

carmine timber
solemn current
carmine timber
solemn current dev **voice branch**

There is nothing like dev voice branch.

Voice module is a optional right now but it will be merged once v13 is released.

So you need to download voice module separately

nimble spindle

i am trying to join my bot to a stage channel but it joins in the audience section. can I directly move it to the speaker section?

analog frost
nimble spindle
subtle granite
ripe nacelle

When my bot joins a voice channel, it shows itself as muted. Any way to hide this?

visual temple
ripe nacelle

It shows the headphone symbol. It sends the audio but I would like to not have the headphones symbol.

subtle granite

By default the bot self deafens, it's not muted. It's fine

visual temple
ripe nacelle

yes, but I don't like the symbol there, looks odd

visual temple

It's common among bots

if you are making a usual bot it should be fine, otherwise, just undeafen

ripe nacelle

How do I undeaf it? I mean, I don't need to, but I'd like to.

oh, found it c:

thorn bough

Hey I created a radio bot, which has a single audio resource per shard/cluster and every server subscribes to the same resource but still the bot is using so much ram and cpu. ```
CPU: 6Vcore
RAM: 16GB

if you need any additional details let me know

carmine timber
thorn bough
thorn bough

And I have 34 shards and 6 clusters

carmine timber
thorn bough

So what would be the best way to do it?

carmine timber

So in this way, you use less resources

thorn bough

Isn't my player handler class doing thet?

carmine timber
thorn bough

So I remove the audio player from player handler class but where should I move it to Ready Event?

carmine timber
thorn bough

Hmm

Alright thanks. I'll look into it

muted pebble

Having trouble installing the package, I keep getting this error \node_modules\@discordjs\voice\dist\index.js'. Please verify that the package.json has a valid "main" entry Followed the guide that's pinned.

carmine timber
muted pebble

Yep, that worked. Thanks!

empty torrent

How can i get the playback time?

autumn pebble

hey, can i directly play music from yt, spotify and soundcloud using their urls or do i need to install packages

thorn bough

You can't play from Spotify,

autumn pebble
thorn bough

Nope

You need a Downloader for playing from youtube

carmine timber
carmine timber
thorn bough

Ytdl downloads the audio then it's get streamed to discord? Or you can create pipeline or something and stream to discord

carmine timber
thorn bough Ytdl downloads the audio then it's get streamed to discord? Or you can create pi...

YTDL do 2 things :

  1. Uses some mechanism (That I know, but you need to explore yourself) to extract a audio endpoint url which looks something like this [https://www.shorturl.at/bvGP4 ( A shortened URL but long url is the one which we extract audio endpoint url)]

  2. Then it uses this url to create a Readable NodeJS Stream (https://nodejs.org/api/stream.html) and just gives us output.

Now voice module also creates stream from a url or file path and then pass that to audio player for playing that audio. [ Voice Module can also accept Readable NodeJS Streams also ]

In this whole process, nothing is actually downloaded. It is just an example of NodeJS Stream functionality. You need to understand how nodeJS Streams actually work to understand this whole process

autumn pebble
carmine timber
autumn pebble
carmine timber
autumn pebble

4.3.5

carmine timber

This will convert your ts file to js file and then run that js file with node command

autumn pebble

cant i just run the ts file

carmine timber
autumn pebble
errant notch

typing are only used for developing, in the JS file there will be not types, because Javascript doesn't understand them and they are not needed

errant notch
unique phoenix

how do you make a bot join a voice channel and deafen

fervent estuary

In the joinConfig set selfDeaf to true

steel crescent

defaults to true anyway lol

unique phoenix
fervent estuary

Might wanna share some code with the error

carmine timber
unique phoenix

then my error Is I get this

TypeError: voiceChannel.join is not a function
    at Object.executeSlash (C:\Users\wow\Desktop\BrettFX Bot\commands\play.js:372:58)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

and this is on line 371 to line 378

if(interaction.member.permissions.has("MANAGE_MESSAGES")) {
  queueConstruct.connection = await voiceChannel.join();
  queueConstruct.connection.voice.setSelfDeaf(true);
  play(queueConstruct.songs[0], interaction, voiceChannel);
}
carmine timber
carmine timber
unique phoenix

what is that gonna do

green raft
carmine timber
green raft

true

bold furnace

is there any option to set audio bitrate? like in createAudioResource, demuxProbe, createAudioPlayer or can I somehow set it on audioplayer?

subtle granite

Is there a way i could pause and resume the player?

empty torrent
subtle granite

👍

subtle granite
bold furnace
empty torrent
subtle granite and how would i check if the song is already paused and such? Intellisense is a ...

I’m not sure if there is any function for that. But you can surely create an isPaused variable and assign boolean to it after pausing the player. And check for it always with a condition. Sorry for the bad English. Here is an example check -

//Following the example music bot
//In subscription.js after this.queue
this.isPaused = false;

//in your pause command (assuming ‘subscription’ is your get variable for each guilds playlist
if(subscription.isPaused) {
         interaction.reply('The player is already paused');
} else {
         subscription.isPaused = true;
         interaction.reply('Player paused successfully!')
}```

Same for the unpause/resume command. Sorry for the bad English
empty torrent
subtle granite
empty torrent
subtle granite

Thank you pizzaCat , so generous

bold furnace
empty torrent

Is there anything important i should do to play music in stage channel?
Currently the bot joins as an audience only.

bold furnace

music:67:27 createAudioResource

"@discordjs/voice": "^0.5.5"

spare wave

Like the error mentioned, you need to install this

bold furnace

I have it installed

spare wave

npm ls @discordjs/opus? If it exist , no idea. why it still not detecting

bold furnace

Ill try reinstall all deps

spare wave

Might be clash with the discord-mentions dep

bold furnace

I uninstalled it and it somehow works

spare wave

sharkHi

carmine timber
subtle granite

djsGame thanks!

carmine timber
carmine timber
subtle granite

wdym

yeah, that's all I need.

carmine timber
subtle granite

No I meant like having to create an explicitly assigned variable if the player is paused then set it to a condition and such. That works perfectly

carmine timber

Okay 👍

carmine timber
keen flume

can someone show me a just quick example on how to join/leave voice channels with the new system? my old method obviously doesnt work anymore, so i would like to see how its performed now

dry ember

how to check if a member is in a voice channel or not?

carmine timber
muted remnant

why does it doing this?

i am trying basic script

fervent estuary

What is the error?

cold geode
TypeError: adapterCreator is not a function
    at new VoiceConnection (F:\Rami\node_modules\@discordjs\voice\dist\VoiceConnection.js:74:25)
    at Object.createVoiceConnection (F:\Rami\node_modules\@discordjs\voice\dist\VoiceConnection.js:480:29)
    at Object.joinVoiceChannel (F:\Rami\node_modules\@discordjs\voice\dist\joinVoiceChannel.js:18:30)
    at F:\Rami\node_modules\discord-player-music\src\Player.js:532:30
    at new Promise (<anonymous>)
    at MusicPlayer.joinVoiceChannel (F:\Rami\node_modules\discord-player-music\src\Player.js:525:16)
    at Object.run (F:\Rami\cmds\slash\join.js:31:23)
    at run (F:\Rami\events\interactionCreate.js:20:17)
    at Rami.emit (events.js:315:20)
    at InteractionCreateAction.handle (F:\Rami\node_modules\discord.js\src\client\actions\InteractionCreate.js:51:12)

Add this in <Voice>.joinVoiceChannel() adapterCreator: channel.guild.voiceAdapterCreator?

carmine timber
carmine timber
cold geode
dgram.js:897
    throw new ERR_SOCKET_DGRAM_NOT_RUNNING();
    ^

Error [ERR_SOCKET_DGRAM_NOT_RUNNING]: Not running
    at healthCheck (dgram.js:897:11)
    at Socket.send (dgram.js:622:3)
    at VoiceUDPSocket.send (/root/voice/node_modules/@discordjs/voice/dist/networking/VoiceUDPSocket.js:90:28)
    at VoiceUDPSocket.keepAlive (/root/voice/node_modules/@discordjs/voice/dist/networking/VoiceUDPSocket.js:74:14)
    at Immediate._onImmediate (/root/voice/node_modules/@discordjs/voice/dist/networking/VoiceUDPSocket.js:42:33)
    at processImmediate (internal/timers.js:461:21) {
  code: 'ERR_SOCKET_DGRAM_NOT_RUNNING'
}```
How I can fix this error?
carmine timber
cold geode

Strange, but I don't want to play anything. Enters and immediately exits the voice channel.

let res = DiscordVoice.createAudioResource(song.url);
this.player.play(res);
dry ember

Do i need both djs opus and djs voice for a bot to join and do some stuff in vc?
Or i only need voice?

carmine timber
carmine timber
cold geode

I need to play a song, but the bot doesn't want to do it.

@carmine timber
Information update: the bot enters the voice channel, writes that the song is playing, but nothing is playing.

carmine timber
odd oyster

Ytdl-core?

carmine timber

Yes

cold geode
play(guild, song) {
        return new Promise(async (resolve, reject) => {
            const serverQueue = await this.queue.get(guild.id);
            try {
                let stream = await this.utils.createStream(guild);
                let res = DiscordVoice.createAudioResource(song.url)
                this.player.play(res)
                let connection = DiscordVoice.getVoiceConnection(guild.id);
                connection.subscribe(this.player)
                
                    this.player.on("error", error => {
                        return this.emit('playerError', { textChannel: song.textChannel, requested: song.requestedBy, method: 'play', error: error });
                    });
                //dispatcher.setVolumeLogarithmic(serverQueue.volume / 5);
                this.emit('playingSong', this.queue.get(guild.id));
            }catch(error){
                return this.emit('playerError', { textChannel: song.textChannel, requested: song.requestedBy, method: 'play', error: error });
            }
        })
    }

P.S. Don't throw stones, the code is not ready =)

carmine timber
cold geode

I already threw.

carmine timber
cold geode

let res = DiscordVoice.createAudioResource(ytdl(song.url))?

carmine timber
cold geode

The music starts playing, but most likely the filter system will not work.

carmine timber
cold geode

!filter 3D

carmine timber
cold geode
autumn pebble

how can i play spotify songs with discord.js voice

solemn current
slender sparrow

get spotify meta data, search on youtube

carmine timber
subtle granite
let connection = await joinVoiceChannel({
      channelId: member.voice.channel.id,
      guildId: member.guild.id,
      adapterCreator: member.guild.voiceAdapterCreator,
      selfDeaf: true
});

let stream = await ytdl(`https://www.youtube.com/watch?v=${video.id}`);
connection
    .subscribe(createAudioResource(stream))

Error:

TypeError: player.subscribe is not a function

help please

mental patio

also u r using connection to subscribe an audio resource, should be instead using a player to play

subtle granite
  let player = createAudioPlayer();
  player.play(createAudioResource(stream));

  connection
    .subscribe(player)

working, thx

How can I detect when the music stops + how change volume?

in djs v12 connection.play(stream).on("finish")

mental patio
autumn pebble

hey i m having trouble in getting my bot to play songs from yt urls

can someone help, i have the intents too

const Discord = require('discord.js')
const Voice = require('@discordjs/voice')
const ytdl = require('ytdl-core')
const Yt = require('youtube-sr')

module.exports = {
    name: 'play',
    execute: async (interaction = new Discord.CommandInteraction()) => {
        if (!interaction.member.voice.channel) return interaction.reply('Join vc')

        let channel = interaction.guild.channels.cache.get(interaction.member.voice.channel.id)
        if (!channel.permissionsFor(interaction.applicationId).toArray().includes('CONNECT' && 'SPEAK')) return interaction.reply('Hello')

        else try {
            let connection = Voice.joinVoiceChannel({
                channelId: interaction.member.voice.channel.id,
                guildId: interaction.guildId,
                adapterCreator: interaction.guild.voiceAdapterCreator
            })

            let video = (await Yt.YouTube.search('rickroll'))[0]
            let resource = Voice.createAudioResource(ytdl(video.url))
            let player = Voice.createAudioPlayer()
            player.play(resource)

            connection.subscribe(player)
        } catch(e) {
            console.log(e)
        }
    }
}``` here is my code
autumn pebble

nvm i fixed it

anyways how do i set the volume of the player

uneven igloo

HELLO GUYZ

I NEED HELP SO BAD MY BOT NOT WORKING WHEN I INSETALL @DISCORDJS/VOICE IT SHOW THIS ERROR TypeError: adapterCreator is not a functio

subtle granite

check out pins -> guide -> voice connections

cold geode

How can I get the voice connection if the bot connected to the voice channel? [discord.js v12]
P.S. I know it's not there, sorry.

spare wave

The typing error for adapterCreator back again, @discordjs/voice v0.5.5, "discord.js": "^13.0.0-dev.t1627732975.331a9d3",

carmine timber
spare wave

my fix // @ts-expect-error weSmart

spare wave

Turn out some of the command resolver broken too. welp, revert back to old commit

bold cairn

Error: Did not enter state ready within 30000ms
This happens when it tries to connect to a channel it doesn't have permission to join. How would I handle this?

fervent estuary

Check if ur bot has permissions to join

¯_(ツ)_/¯

bold cairn

something along the lines of newState.channel.joinable()

fervent estuary

Yeh