#archive-voice

30636 messages · Page 3 of 31

carmine timber

tell me the version by npm list @discordjs/voice

fervent bloom

These are my dependancies from package.json file

fervent bloom
carmine timber
fervent bloom
fervent bloom
carmine timber
fervent bloom

Yes

It works

Thank you

carmine timber

😄

fervent bloom

No wait

I got another error when I play a song

🥲

carmine timber
fervent bloom
    at RequestHandler.execute (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async RequestHandler.push (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:13884) 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:13884) [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.
carmine timber
fervent bloom

But

That's the thing

It's not an empty message

carmine timber
fervent bloom
bot.distube.on("playSong", (queue, song) => {
  if (song.playlist) {
    return queue.textChannel.send(
      new MessageEmbed()
        .setAuthor("Started playing", "https://raw.githubusercontent.com/SudhanPlayz/Discord-MusicBot/master/assets/Music.gif")
        .setThumbnail(song.thumbnail)
        .setColor("BLUE")
        .addField("Playlist's name:", `[\`${song.playlist.name}\`](${song.playlist.url})`, true)
        .addField("Playlist duration:", `\`${song.playlist.formattedDuration}\``, true)
        .addField("Currently playing:", `[\`${song.name}\`](${song.url})`, true)
        .addField("Song duration:", `\`${song.duration} seconds (${song.formattedDuration})\``)
        .addField("Requested by", `<@${song.playlist.user.id}>`, true)
        .setFooter(`👁️Views: ${song.views} | 👍Likes: ${song.likes} | 👎Dislikes: ${song.dislikes} | ${status(queue)}`)
    )
  } else {
    return queue.textChannel.send(
      new MessageEmbed()
        .setAuthor("Started playing", "https://raw.githubusercontent.com/SudhanPlayz/Discord-MusicBot/master/assets/Music.gif")
        .setThumbnail(song.thumbnail)
        .setColor("BLUE")
        .addField("Name:", `[\`${song.name}\`](${song.url})`, true)
        .addField("Duration:", `\`${song.duration} seconds (${song.formattedDuration})\``)
        .addField("Requested by:", `<@${song.user.id}>`, true)
        .setFooter(`👁️Views: ${song.views} | 👍Likes: ${song.likes} | 👎Dislikes: ${song.dislikes} | ${status(queue)}`)
    )
  }
})```
carmine timber
fervent bloom

Oh

carmine timber

?v13-send

bronze swanBOT
carmine timber

See this

fervent bloom

Ahhhhhh

carmine timber
fervent bloom

Thanks!

carmine timber

😄

fervent bloom

Well, it still joins as a listener and not a speaker

And I got the same error again

smh

carmine timber
fervent bloom

If it's not speaker, how will it play music?

fervent bloom

Oki, I'll check that out

bot.distube.on("playSong", (queue, song) => {
  if (song.playlist) {
    return queue.textChannel.send({
      embed: new MessageEmbed()
        .setAuthor("Started playing", "https://raw.githubusercontent.com/SudhanPlayz/Discord-MusicBot/master/assets/Music.gif")
        .setThumbnail(song.thumbnail)
        .setColor("BLUE")
        .addField("Playlist's name:", `[\`${song.playlist.name}\`](${song.playlist.url})`, true)
        .addField("Playlist duration:", `\`${song.playlist.formattedDuration}\``, true)
        .addField("Currently playing:", `[\`${song.name}\`](${song.url})`, true)
        .addField("Song duration:", `\`${song.duration} seconds (${song.formattedDuration})\``)
        .addField("Requested by", `<@${song.playlist.user.id}>`, true)
        .setFooter(`👁️Views: ${song.views} | 👍Likes: ${song.likes} | 👎Dislikes: ${song.dislikes} | ${status(queue)}`)
    })
  } else {
    return queue.textChannel.send({
      embed: new MessageEmbed()
        .setAuthor("Started playing", "https://raw.githubusercontent.com/SudhanPlayz/Discord-MusicBot/master/assets/Music.gif")
        .setThumbnail(song.thumbnail)
        .setColor("BLUE")
        .addField("Name:", `[\`${song.name}\`](${song.url})`, true)
        .addField("Duration:", `\`${song.duration} seconds (${song.formattedDuration})\``)
        .addField("Requested by:", `<@${song.user.id}>`, true)
        .setFooter(`👁️Views: ${song.views} | 👍Likes: ${song.likes} | 👎Dislikes: ${song.dislikes} | ${status(queue)}`)
    })
  }
})```

This is my code now

It's giving same error?

carmine timber

?v13-send

bronze swanBOT
carmine timber

It is embeds not embed

and embeds is an array

fervent bloom

Ah fooking hell

(node:12056) UnhandledPromiseRejectionWarning: TypeError: this.options.embeds?.map is not a function
    at APIMessage.resolveData (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\discord.js\src\structures\APIMessage.js:194:36)
    at TextChannel.send (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:177:53)
    at DisTube.<anonymous> (C:\Users\HP\Documents\GitHub\Sharkymusic\index.js:63:30)
    at DisTube.emit (events.js:376:20)
    at DisTube.playVoiceChannel (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\distube\dist\DisTube.js:233:30)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async DisTube.play (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\distube\dist\DisTube.js:157:9)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:12056) 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:12056) [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.

What is this supposed to mean now 😭

I changed it to embeds insted of embed

carmine timber
fervent bloom

bot.distube.on("playSong", (queue, song) => {
  if (song.playlist) {
    return queue.textChannel.send({
      embeds: new MessageEmbed()
        .setAuthor("Started playing", "https://raw.githubusercontent.com/SudhanPlayz/Discord-MusicBot/master/assets/Music.gif")
        .setThumbnail(song.thumbnail)
        .setColor("BLUE")
        .addField("Playlist's name:", `[\`${song.playlist.name}\`](${song.playlist.url})`, true)
        .addField("Playlist duration:", `\`${song.playlist.formattedDuration}\``, true)
        .addField("Currently playing:", `[\`${song.name}\`](${song.url})`, true)
        .addField("Song duration:", `\`${song.duration} seconds (${song.formattedDuration})\``)
        .addField("Requested by", `<@${song.playlist.user.id}>`, true)
        .setFooter(`👁️Views: ${song.views} | 👍Likes: ${song.likes} | 👎Dislikes: ${song.dislikes} | ${status(queue)}`)
    })
  } else {
    return queue.textChannel.send({
      embeds: new MessageEmbed()
        .setAuthor("Started playing", "https://raw.githubusercontent.com/SudhanPlayz/Discord-MusicBot/master/assets/Music.gif")
        .setThumbnail(song.thumbnail)
        .setColor("BLUE")
        .addField("Name:", `[\`${song.name}\`](${song.url})`, true)
        .addField("Duration:", `\`${song.duration} seconds (${song.formattedDuration})\``)
        .addField("Requested by:", `<@${song.user.id}>`, true)
        .setFooter(`👁️Views: ${song.views} | 👍Likes: ${song.likes} | 👎Dislikes: ${song.dislikes} | ${status(queue)}`)
    })
  }
})```
carmine timber

WTF

minor bison

embeds takes an array

carmine timber

embeds takes array

See this @fervent bloom

?v13-send

bronze swanBOT
carmine timber

embeds: [embed, embed2]

fervent bloom

Ah

carmine timber

This one

carmine timber
fervent bloom

Yep

It does

Thank you

carmine timber

NP

lime parcel

how do you get the bot to join a stage channel?

fervent estuary

just like you would with regural voiceChannels

fervent bloom

message.member.voiceChannel.leave()
Cannot read property 'leave' of undefined

lime parcel
fervent estuary

that channel doesnt seem to exist

wise anchor
fervent bloom

Then it says

message.member.voice.channel.leave() is not a function

wise anchor

are you in a vc when you run that?

fervent bloom
wise anchor

can you do

console.log(message.member)

carmine timber
wise anchor

oh yeah, i forgot about that

fervent bloom
carmine timber

You need to do something like

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

var connection = getVoiceConnection(message.guild.id)
connection.destroy()

fervent bloom

Oh Jesus.

Okay.

They made this way too complicated

carmine timber

Not old one

fervent bloom

Yes I remembered

carmine timber

VoiceConnection and AudioPlayer have different events

fervent bloom

Dang

Okay makes sense

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

how do I put it here for the bot to come in as a speaker?
hallow pumice
    const connection = joinVoiceChannel({
        channelId: VoiceChannel.id,
        guildId: message.guild.id,
        adapterCreator: createDiscordJSAdapter(message.member.voice.channel.id),
        selfDeaf : false,
        selfMute : false
    });
    try {
        await entersState(connection, VoiceConnectionStatus.Ready, 30e3);
        return connection;
    } catch (error) {
        connection.destroy();
        throw error;
    }
}
``` message not defined
hallow pumice
grim fulcrum

npm i libsodium-wrappers

native lance

Is it possible to know which channel the bot is currently in from the connection? I use

  let connection = getVoiceConnection(newState.guild.id)
vocal valley

@native lance connection.joinConfig.channelId

vocal valley

Np

raven dust
module.exports = function spawnAudioResource(nextInQueue) {
    return new Promise((resolve, reject) => {
        console.log(nextInQueue.videoUrl)
        const process = raw(
            nextInQueue.videoUrl,
            {
                o: '-',
                q: '',
                f: 'bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio',
                r: '100K',
            },
            { stdio: ['ignore', 'pipe', 'ignore'] },
        );


        if (!process.stdout) {
            reject(new Error('No stdout'));
            return;
        }
        const stream = process.stdout;
        
        const onError = (error) => {
            console.log("error" , error)
            if (!process.killed) process.kill();

            stream.resume();
            reject(error);
        };
        console.log("process will spawn?")
        process
            .once('spawn', () => {
                console.log("ping")
                demuxProbe(stream)
                    .then((probe) => resolve(createAudioResource(probe.stream, { inputType: probe.type })))
                    .catch(onError);
            })
            .catch(onError);
    });
}

So following the example I got this code to work in my linux server but doesn't work in my windows 10 machine. process.once doesn't get called nor does the onError. In console last message i see is "process will spawn?" and it's stuck there. any ideas?

and also

const { raw  } = require('youtube-dl-exec')

Might be an issue with youtube-dl-exec but can't get my head around solving it, might as well try my chances here

spare wave

all the extra dependency installed? Like python, etc2

raven dust

seems like it, when i run the command in terminal i get a stream there also if i console.log the stream variable i get a socket object

spare wave

try change the option q:true? But that should work though

raven dust

when q set to 'true' I'm getting bunch of the stream bytes into my vscode terminal, even though not consol.logging anything in the file

spare wave

well, yeah. q parameter is supposed to mean quiet, which mean don't print unnecessary stream to console. So far, it only work on ubuntu with option q:true.

youtube-dl quirks passing the quiet args, not really sure what I can recommend you, since hydrabolt used q:true before changing it to now q:''

The music play though?

raven dust

in ubuntu server it plays, in windows it doesn't. execution just hangs there, doesn't want to progress to process.once('spawn', ...

but yeah must be some shennanigans with the module and windows. I shall ask the author or youtube-dl-exec devs

thanks for your time

spare wave

np

carmine timber

Is Tweetnacl bug not fixed in latest release of @discordjs/voice ??

carmine timber

Slow-mode in both voice channels _GG_Fat_cry

subtle granite

how can bot join stage?

carmine timber
solemn grail

is it recommended to use command handlers in discord.js/voice?

carmine timber

@steel crescent This bug

steel crescent

That’s not a bug

If you don’t install one of the three libs you get an error

That’s on the user

carmine timber
carmine timber
steel crescent

That person didn’t have it installed

Not sure what you are on about

carmine timber
steel crescent

It doesn’t matter, the one you linked is not the bug you talk about lol

He didn’t have any of those libs installed

carmine timber
steel crescent

You don’t need to prove your point.

No sodium, no libsodium-wrappers, no tweetnacl

Case closed

carmine timber
steel crescent

Yes

Dependencies are alphabetically sorted

carmine timber
steel crescent

tweetnacl comes before ws

And it’s not there

carmine timber
steel crescent

It doesn’t

Nope 👎

Stop with the misleading and wrong messages

indigo skiff

It doesn't

eager lake

Keep in mind, this lib is for v13 and onwards.
It was in v12, but not in v13 anymore.

carmine timber
misty saddle

ok

carmine timber

My bad Sorry

Crawl

subtle granite

wait new discord.js@dev can't send embed?

icy maple

It can, it just changed

subtle granite

i wanna join stage

icy maple

?v13-send

bronze swanBOT
subtle granite

ok

icy maple

You’ll need the use the new voice lib or smth

subtle granite

ok it works but i have to change 126 commands files for embed cry

icy maple

Can’t just use the global find and replace ?

fervent bloom

guild.me.voice.setSuppressed(false);

fervent estuary

ur client as a member of that guild

dusty needleBOT

djs Guild#me
The client user as a GuildMember of this guild

fervent bloom

Ah

How do I check if a channel is a stage?

fervent estuary

u can just do if (channel instanceof Discord.StageChannel)

fervent bloom

Ah thanks

const Discord = require('discord.js')

module.exports.run = async (bot, message, args) => {
    if (!message.member.voice.channel) return message.channel.send(`What? Excuse me? Do you really expect me to execute a MUSIC command without you being in a voice channel? Like how you gonna use them if you can't hear them bruh? Big brain much?`);

    const music = args.join(" ");
    if (message.member.voice.channel instanceof Discord.StageChannel) {
        console.log('true')
        message.guild.me.voice.setRequestToSpeak(true);}
    bot.distube.play(message, music)
}

module.exports.config = {
    name: "play",
    aliases: ['p', 'P', 'PLAY']
}```
Bot is online!
[DisTube] Updated youtube-dl to 2021.06.06!
true
(node:10956) UnhandledPromiseRejectionWarning: Error [VOICE_NOT_STAGE_CHANNEL]: You are only allowed to do this in stage channels.
    at VoiceState.setRequestToSpeak (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\discord.js\src\structures\VoiceState.js:177:42)
    at Object.module.exports.run (C:\Users\HP\Documents\GitHub\Sharkymusic\commands\play.js:9:32)
    at Client.<anonymous> (C:\Users\HP\Documents\GitHub\Sharkymusic\index.js:41:17)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)```

But I am in a stage channel

Anyone?

vocal valley

@fervent bloom if you log message.member.voice.channel.type, what do you get

fervent bloom

Lemme check. wait

It says stage

Bot is online!
[DisTube] Updated youtube-dl to 2021.06.06!
stage
(node:13280) UnhandledPromiseRejectionWarning: Error [VOICE_NOT_STAGE_CHANNEL]: You are only allowed to do this in stage channels.
    at VoiceState.setRequestToSpeak (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\discord.js\src\structures\VoiceState.js:177:42)
    at Object.module.exports.run (C:\Users\HP\Documents\GitHub\Sharkymusic\commands\play.js:9:32)
    at Client.<anonymous> (C:\Users\HP\Documents\GitHub\Sharkymusic\index.js:42:17)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:13280) 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:13280) [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.```
vocal valley

Thonk

fervent bloom

Why is discord like this

vocal valley

can you do this:

go to node_modules/discord.js/src/structures/VoiceState.js, and make this change:

  async setRequestToSpeak(request) {
    const channel = this.channel;
+   console.log("real type", channel.type);
    if (channel?.type !== 'stage') throw new Error('VOICE_NOT_STAGE_CHANNEL');
frosty dawn

AudioPlayerError: Status code: 403 My bot plays music but it stops after some hour or so and this error happens can anyone tell me why?

vocal valley

a network error

you just have to handle these and mvoe on

fervent bloom
frosty dawn

ahh! i see i thought of that but asked anyway if something is wrong in my code

vocal valley

ahh no worries, yeah sometimes it is just network error

are you using ytdl-core/discord-ytdl-core/ytdl-core-discord?

frosty dawn

yes the 3rd one

should i shift to youtube-dl?

fervent bloom
Bot is online!
[DisTube] Updated youtube-dl to 2021.06.06!
stage
(node:5828) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'type' of null
    at VoiceState.setRequestToSpeak (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\discord.js\src\structures\VoiceState.js:177:38)
    at Object.module.exports.run (C:\Users\HP\Documents\GitHub\Sharkymusic\commands\play.js:9:39)
    at Client.<anonymous> (C:\Users\HP\Documents\GitHub\Sharkymusic\index.js:42:17)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)```
vocal valley

ok, can you make this change:

  async setRequestToSpeak(request) {
    const channel = this.channel;
+   console.log("this", this);
    if (channel?.type !== 'stage') throw new Error('VOICE_NOT_STAGE_CHANNEL');
vocal valley
frosty dawn

K thanks

vocal valley

np

fervent bloom
vocal valley

ohh wait lol

first you have to get the bot to join the voice channel before you request to speak

fervent bloom

OH jesus

vocal valley

ok phew

fervent bloom

Sorry, I'm really new to coding

vocal valley

it's no problem

everyone makes oversights like that lol

fervent bloom

I've barely learnt anything tbh XD, but yea, idk how to fix this. Do I async and await?

vocal valley

well with this new voice library, it'd be something like this:

const connection = joinVoiceChannel({ ... });
await entersState(connection, VoiceConnectionStatus.Connecting);
// now you can request to speak

idk what the distube package looks like internally, but if it gives you access to the voice connection, that works ^

alternatively, if it gives you an indicator that the connection is ready to play, that would also work

carmine timber

Hydrabolt add something in New Voice API so that if none of encryption is present, then it will tell that he has some missing dependencies

vocal valley

👍

good idea

fervent bloom
vocal valley
carmine timber
fervent bloom
fervent bloom
vocal valley

then:

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

Oh nvm

fervent bloom

ngl, this has become very complicated 😭

vocal valley

we're working on a wrapper for @discordjs/voice that is a ready-to-go music bot with queue essentially 👀

carmine timber

WoW

fervent bloom

Ohhhh, niceee, that'll definitely be really helpful

vocal valley

👍

i agree the new /voice library is definitely more technical and low-level than d.js v12 voice

fervent bloom

This brings me back to a year ago when I started coding discord.js, where I didn't know shit 😭. Time for the hustle now

vocal valley

so no worries if you don't feel comfortable using it just yet

carmine timber

I saw an example code in your music bot

That will cover only one guild

if I am not wrong

vocal valley

with the wrapper you dont have to concern yourself directly with the player at all

you can just tell it which channel you want to join, give it the URL of a song/video to play, and manage a queue

fervent bloom

It says joinVoiceChannel is not defined 🤡

vocal valley

you'll need to import it from @discordjs/voice

fervent bloom

Oh right, I forgot about that

vocal valley

just some examples in typescript/javascript on how to use /voice

carmine timber
vocal valley

not sure exactly about that feature just yet,

but you can also use /voice's players in multiple connections yeah

carmine timber

Oh

vocal valley

if you wanted you could make a radio bot that has a single player and play it across multiple voice connections, in fact this is what the radio-bot example does

carmine timber
vocal valley

yep

the music bot example is one queue per guild, and that cannot be shared across guilds

whereas radio bot is a single player for all guilds

carmine timber

yes

carmine timber
vocal valley

yep

vocal valley

well a connection is 1:1 with a guild anyway

so in a music bot, you'd typically have one player for each guild/voiceconnection

bold kernel

ya, just making sure

vocal valley

you could make it fancier and give your music bot a global radio player for ALL voice connections if you wanted

bold kernel

(sorry discord js devs, but i dont love so much docomentation)

vocal valley

i've not coded that 😅 that's up to developer

but there are two examples that do each thing

the radio bot does one player for all guilds, and the music bot does one player for each guild

you could combine what each does

bold kernel

oh, ok

fervent bloom

It says entersState is not defined 🥲

vocal valley

did you import it

fervent bloom

I did

nvm, I spelt it wrong while importing, kill me

const Discord = require('discord.js')
const { VoiceConnectionStatus, entersState, joinVoiceChannel } = require('@discordjs/voice')

module.exports.run = async (bot, message, args) => {
    if (!message.member.voice.channel) return message.channel.send(`What? Excuse me? Do you really expect me to execute a MUSIC command without you being in a voice channel? Like how you gonna use them if you can't hear them bruh? Big brain much?`);

    const music = args.join(" ");
    bot.distube.play(message, music)
    const connection = joinVoiceChannel({
        channelId: message.channel.id,
        guildId: message.member.guild.id,
        adapterCreator: message.member.guild.voiceAdapterCreator,});
    await entersState(connection, VoiceConnectionStatus.Connecting);
    if (message.member.voice.channel instanceof Discord.StageChannel) {
        message.member.guild.me.voice.setRequestToSpeak(true);}
}

module.exports.config = {
    name: "play",
    aliases: ['p', 'P', 'PLAY']
}```
C:\Users\HP\Documents\GitHub\Sharkymusic>node .
Bot is online!
[DisTube] Updated youtube-dl to 2021.06.06!
(node:9936) UnhandledPromiseRejectionWarning: Error: Did not enter state connecting within undefinedms
    at Timeout.<anonymous> (C:\Users\HP\Documents\GitHub\Sharkymusic\node_modules\@discordjs\voice\dist\util\entersState.js:17:49)
    at listOnTimeout (internal/timers.js:555:17)
    at processTimers (internal/timers.js:498:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:9936) 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: 2)
(node:9936) [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.
vocal valley

oops, for entersState, there should be a 3rd param

fervent bloom

OH

vocal valley

the 3rd param is how long in milliseconds you should wait for that state to be entered

if its for vc i'd say maybe 15_000 is a good value? you could up it if on a bad network

fervent bloom

I don't have a bad network but I do have a terrible PC 😭

AAAAAA OMGGG THANK YOU I MIGHT CRY IT WORKS

Wait how do I use the disconnect command now?

connection.disconnect() ?

vocal valley

🎉

fervent bloom

But, it's a different file

vocal valley

lol atm i am currently adding a disconnect method

for now you will have to do joinVoiceChannel({ channelId: null, ... }); to disconnect

where ... is the same stuff as if you were actually joining

fervent bloom

Bruh

I can't do that cuz it's already in a voicechannel

It waits to connect, but it's already connected...

carmine timber
vocal valley

yep but that destroys it entirely

if you don't want to reuse it that works

vocal valley

for most purposes .destroy() is fine tho

carmine timber
fervent bloom

But for that I'll have to define connection

carmine timber
vocal valley

if it's already connected, entersState won't wait

fervent bloom

It did

I have 2 different files. I defined connection in the play.js file and now disconnect.js file I'll have to define it

carmine timber
fervent bloom

Testing, PC a lil slow, sorry

carmine timber

ok

fervent bloom

Yes, it works, thank you so much

carmine timber

😄

carmine timber
rustic temple

To prevent spamming I guess thinKappa

carmine timber

Who spams here ??

rustic temple

Idk

fervent estuary

its just to keep the channel in order. It would be a mayhem in #archive-djs-v12-deprecated if there would be no slowmode. Same thing here

carmine timber
fervent estuary

i can suggest that to the admins

carmine timber

Just suggest them 🙂

spare wave

I dont mind that much about it, at least it lessen the spam, I've seen ppl with typing each word every line

steel crescent

^this, its only a problem for people who shotgun messages by typing a lot of message instead of 1 concise message

subtle granite
 files: request.options.files ?? [],
                                    ^

SyntaxError: Unexpected token '?'

New dev version gives error

steel crescent

update to node 14

subtle granite

ok

carmine timber

Show me full error

carmine timber

What is on line 20 in index.js ??

subtle granite

how can i send buttons with v13? because old way was removed 😓

ping reply me if you can help

fervent estuary

not voice related

subtle granite

it is i am working on music bot

if not then sorry for off-topic

fervent estuary

that... doesnt make it really related to voice

this channel is for @discordjs/voice

fervent estuary

just remember in the future xd. Its all good

carmine timber

Change that line to message.member.voice.channel.id

spare snow

Is it possible to add a new AudioPlayerStatus "errored" to the API? Listening to Idle status and errors ~~may ~~ is causing both of them being triggered on error.

carmine timber

Now show me line 20 again

spare snow
carmine timber
carmine timber
spare snow
spare snow
carmine timber

Oh sorry I didn't read second part,
No it will trigger both events as bot player status is changing to idle and errors are emitted so both will trigger

spare snow

welp, I'm not familiar with ts sadly

fervent estuary

in that case ig u could open an issue

carmine timber

are u connected in vc while running this command ??

Can you console log message.member ??

native lance

I am making a bot that when a user enters a channel it play a short clip. However the bot starts playing the clip before the user is actually connected to the channel and listening. Is there a way to make the bot wait until that user has fully connected?

carmine timber

Then your message is not an instance of discord.Message Class, So check your code properly

carmine timber
native lance

A good workaround for now. Ty

mental adder

To update the volume, I need to update on audio resource?

Like <AudioResource>.volume.setVolume ?

carmine timber
mental adder

Ty

carmine timber

Change this line

const channel = message.member?.voice.channel

TO

const channel = message.member.voice.channel

And then use this example only

Oh

chilly zinc

Thanks NIP!

carmine timber

😄

heady jetty

anyone has a open saurce discord bot that works in stages?

carmine timber
heady jetty

I have a bot that works fine in vc but when I try to join him to stages he leaves

carmine timber
heady jetty

yeah second later

carmine timber
heady jetty
carmine timber

This part mainly tells the bot that after join command is executed, Wait me to verify that I am totally connected to VC in 30 seconds. IF some errors come or bot fails to join in 30 seconds, It will throw error and disconnect from that VC

heady jetty

btw Thank you

carmine timber

Same to you

carmine timber
carmine timber
heady jetty

12.5.3, I am using lava and erella to play

carmine timber

So ask their respective developers

heady jetty

oh ok do you know other way to get music from youtube?

carmine timber
heady jetty

do you know an open saurce project of it so i can learn it?

carmine timber

@heady jetty Use this as reference for new voice API

heady jetty

ok Thank you very much

carmine timber

👍

spare snow
steel crescent

Yeah and it was quite badly hardcoded with 15sec

So if it takes longer you couldnt do anything about it lol

Now you can

carmine timber

Yes New API is very flexible

spare snow
carmine timber
stark drum

Has anyone thought about writing a Lavalink-like yet or not?

vocal valley

yep 👀

spare snow

Crawl said something about VoiceLink 👀

stark drum

Oh nice zajW

vocal valley
tropic ocean

nice

frosty dawn

OwO new features are nice and helpful

carmine timber

@steel crescent See test(Secretbox): fix tweetnacl test Latest release only

carmine timber
fervent bloom

.addField(`**Number of songs in queue: ${queue.length} | Total Duration of queue: ${queue.duration}**`)

What is wrong in this? I am getting error field value must be non-empty string

vocal valley
carmine timber
fervent bloom

Ah thank you

rustic temple

I don't think embeds are interactions btw 😂

carmine timber

LOL

subtle granite

i just downloaded ffmpeg from https://www.ffmpeg.org/download.html and i pressed, Download source code and it downloaded a zip file do i have to do anything or can i get coding ?

worthy compass

npm i ffmpeg-static

subtle granite

Hey, why does my bot stop playing music after some time randomly? Alone

ripe orchid

https://imgur.com/WegrBWc I'm getting this error trying to run a bot on master that doesn't use anything voice related, I tried installing the package anyway but its still erroring

vocal valley

You need to enable skipLibCheck in the tsconfig file

ripe orchid
vocal valley

You could fix it by installing @discordjs/voice as a Dev dep

But besides that there is no other way to fix it than enabling skipLibCheck

subtle granite

True

carmine timber

Show me playSong function.

main crow

I'm I right woth the following assumption?

A bot can obly5be active on 1 audio channel per server?

If I want to relay some audio between multiples channel z I would need more than 1 bot/token?

carmine timber
fervent bloom
const { getVoiceConnection } = require('@discordjs/voice');
const { MessageEmbed } = require('discord.js');

module.exports.run = async (bot, message, args, queue) => {
    if (!message.member.voice.channel) return message.channel.send({ content: `What? Excuse me? Do you really expect me to execute a MUSIC command without you being in a voice channel? Like how you gonna use them if you can't hear them bruh? Big brain much?` });

    if (queue === undefined) {
        const connection = getVoiceConnection(message.guild.id)
        connection.leave()
        message.channel.send({
            embeds: [new MessageEmbed()
                .setDescription("Thanks for tuning in!")
                .setColor("RED")
            ]
        })
        message.react("✅")
    } else {
        bot.distube.stop(message)
        message.react("✅")
        const connection = getVoiceConnection(message.guild.id)
        connection.leave()
        message.channel.send({
            embeds: [new MessageEmbed()
                .setDescription("Thanks for tuning in!")
                .setColor("RED")
            ]
        })
    }
};
module.exports.config = {
    name: "disconnect",
    aliases: ['dc', 'DC', 'DISCONNECT']
}``` I don't want to use connection.destroy() So I tried using disconnect and leave but neither work.
carmine timber
fervent bloom
carmine timber
fervent bloom

Oki

do I just do npm i @discordjs/voice

carmine timber
fervent bloom

Oki

carmine timber
fervent bloom

Lol okay XD

hearty whale

Hey, guys! Is voice receiver available rn?

carmine timber
hearty whale

How does MEE6 use it?

carmine timber
hearty whale
vocal valley

@hearty whale should be available by Monday 😁

subtle granite

Hey, why does my bot stop playing music after some time randomly? Alone

vocal valley

@subtle granite are you using the new voice library?

carmine timber
hearty whale

Can someone give me a information about new voice?

vocal valley

See pinned messages

hearty whale
carmine timber
carmine timber

You are also not using player

vocal valley

it's a separate package, not the same as voice in discord.js v12

subtle granite

How to install and where ???

carmine timber
subtle granite

its complicated

steel crescent

ye

very sad

mental patio

sometimes i have a issue is that the music haven't reached the end but the bot stop playing & emit idle state. idk what to do to make it play the whole song proper

mental patio

welp where can i put my long code

carmine timber
mental patio
if (message.content === '!play') {
  const channel = message.member.voice.channel;
  if (!channel) return message.reply('You must be in the voice channel.');
  client.players.set(channel.guild.id, createAudioPlayer());

  const player = client.players.get(channel.guild.id);
  const info = await ytdl.getInfo('https://www.youtube.com/watch?v=x8VYWazR5mE');
  const url = filter(info.formats)[0].url;
  const resource = createAudioResource(url, { inputType: StreamType.Opus, });
  console.log(url);

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

  player.play(resource);
  connection.subscribe(player);
  await message.reply('Playing now!');

  player.once(AudioPlayerStatus.Idle, () => {
    message.channel.send('finished playing!');
  });
}

i played this song and met the problem. i did have this problem before with other songs but it become okay and idk y. then it's here again

carmine timber
mental patio

i referenced the "hello world djs/voice ver" above and the filter function is also referenced somewhere this channel.

carmine timber
mental patio

yeah sure

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

@mental patio can you try with the music bot example instead?

if the music bot example runs well for you then I'd recommend using youtube-dl

steel crescent

Just ban any mention of ytdl-core

vocal valley

Tbh

Maybe we should add a tag for it

carmine timber
mental patio yeah sure ```js function filter(format) { var results = [] format.forEach((e...

You need to add some lines before creating a source

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

const stream = new prism_media.FFmpeg({
        args : ['-reconnect', '1', '-reconnect_streamed', '1', '-reconnect_delay_max', '5','-i', url, ...FFMPEG_OPUS_ARGUMENTS ]
    })

var source = createAudioResource(stream, { inputType: StreamType.OggOpus , inlineVolume : true })

Try this

carmine timber
steel crescent

Because it’s trash

carmine timber
steel crescent

Yeah completely

vocal valley

For discord bots it's not good

Anyway for this specific case,

carmine timber
vocal valley

yes that is fine

But I'm still not sure why you would rather use FFmpeg over YouTube-dl here

youtube-dl gives better performance and you don't have to worry about reconnect arguments

I would prefer if we pushed people to use youtube-dl over ffmpeg for this reason

it's simpler and faster

carmine timber

For music-bot, resources matter a lot

vocal valley

🤔

It uses less

youtube-dl in our music bot example only streams the audio file

Ffmpeg has to both stream it and transcode it

mental patio

wait whats the prism_media
do i have to require or import anything to use it

carmine timber
mental patio

and its state now change to idle instantly
did i use the wrong package? since i guess it's prism-media

carmine timber
mental patio
mental patio

yeah it now emit the idle instantly. did do anything wrong with the code?

const player = client.players.get(channel.guild.id);
const url = filter(info.formats)[0].url;
const FFMPEG_OPUS_ARGUMENTS = ['-analyzeduration','0','-loglevel','0','acodec','libopus','-f','opus','-ar','48000','-ac','2'];
const stream = new prism.FFmpeg({
    args : ['-reconnect', '1', '-reconnect_streamed', '1', '-reconnect_delay_max', '5','-i', url, ...FFMPEG_OPUS_ARGUMENTS ]
});

const resource = createAudioResource(stream, { inputType: StreamType.OggOpus , inlineVolume : true });
console.log(url);

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

player.play(resource);
connection.subscribe(player);
await message.reply('Playing now!');

this is the part i changed

vocal valley

@lime gale I'll take a look at your PR in a bit, honestly I'm not against just using as any here but I'm trying to find a nicer way

seems like something the typescript compiler should be happy with to me so I'm a bit confused why it's not

steel crescent

Any bad

lime gale
vocal valley

crawl grace us with your typescript knowledge on that PR 😩

steel crescent

When discord gives me voice gw without needing the main gw

vocal valley

so never?

PepeHands

carmine timber
mental patio

beginning of my code

const ytdl = require('ytdl-core-discord');
const { joinVoiceChannel, createAudioResource, createAudioPlayer, StreamType, AudioPlayerStatus } = require('@discordjs/voice');
const { Client, Intents, MessageEmbed } = require('discord.js');
const prism = require('prism-media');
carmine timber
mental patio

no errors

carmine timber
mental patio

yeah the url is logged proper

carmine timber

I want to see it

mental patio

yeah i have
can i dm u?

carmine timber
mental patio

k

carmine timber

@vocal valley What will happen if we have wrong adapterCreator ?? Do it emits errors ?

I know that if we have nothing, then it will emit errors, but what about wrong function ??

vocal valley

if the function is incorrect, it depends on how incorrect the function is

E.g. if it is very incorrect, bot may not connect at all

If partially incorrect, bot could get disconnected incorrectly

carmine timber

Is there anything wrong ??

Full Code :

if (message.content === '!play') {
  const channel = message.member.voice.channel;
  if (!channel) return message.reply('You must be in the voice channel.');
  client.players.set(channel.guild.id, createAudioPlayer());

  const player = client.players.get(channel.guild.id);
  const info = await ytdl.getInfo('https://www.youtube.com/watch?v=x8VYWazR5mE');
  const url = filter(info.formats)[0].url;
  const FFMPEG_OPUS_ARGUMENTS = ['-analyzeduration','0','-loglevel','0','acodec','libopus','-f','opus','-ar','48000','-ac','2'];
  const stream = new prism.FFmpeg({
      args : ['-reconnect', '1', '-reconnect_streamed', '1', '-reconnect_delay_max', '5','-i', url, ...FFMPEG_OPUS_ARGUMENTS ]
  });

  var resource = createAudioResource(stream, { inputType: StreamType.OggOpus , inlineVolume : true })
  console.log(url);

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

  player.play(resource);
  connection.subscribe(player);
  await message.reply('Playing now!');

  player.once(AudioPlayerStatus.Idle, () => {
    message.channel.send('finished playing!');
  });
}

@vocal valley In this, bot connects and tries to play a song but is unable to do so and no errors in console either

As per my predictions, joining command has some fault, everything works as it is supposed to be

vocal valley

First I would appreciate if @mental patio would try to see if the music bot example works first

spare wave

Been using the example from the repo, nothing error related so far, well except for the intraction failed on onfinish since past 15min from interaction.defer()

vocal valley

Ah yeah

spare wave

I have not update to the latest 0.5 version with disconnect?

I shared my repo before too, which basically just a converted example of the typescript to javascript

vocal valley
carmine timber

You don't need to pipe Pass through

Leave that part and try again

ffmpeg version ??

change args and then try again :

const args = ['-reconnect', '1', '-reconnect_streamed', '1', '-reconnect_delay_max', '5','-i', url, ...FFMPEG_OPUS_ARGUMENTS ]
spare wave

What I did before when it join and then no voice is change the stream type. StreamType.Opus, other type doesn't seem to be voicing out, and horrible on raw

carmine timber

is your url audio endpoint ??

Show me code after these lines

Whole playing code

When did you created the audio player, as far as I can see you are just playing music at start of bot ??

Without creating a audio player _GG_clap1

chilly zinc

Shhhh;(

carmine timber

Worked ??

valid bobcat

Is there any context to the error TypeError: secretbox.methods.close is not a function? Figured out that it gets generated from the AudioPlayer.play method. Is there any general guides for me to follow with this issue?

I'd assume the resource isn't valid, as that might be the case. How does one create an audio resource from disk?

steel crescent

npm i libsodium-wrappers

valid bobcat

Ty, thought all peer deps were installed. my bad

subtle granite

hey i am making a music bot ....so any body can give me public lavalink
pls

carmine timber
carmine timber

I agree with your points

vocal valley

👍

ty for putting together a comparison

carmine timber

👍

carmine timber

Which ??
You got your problem fixed right ??
Show me code now

Code ??

yes sure

smoky ravine

Hi there, I am trying to make a new channel and lock it to specific roles and get the ID of the channel

this is my code so far

message.guild.channels.create(name + "'s group", {
    type: 'voice'
})
    .then((channel) => {
                    channel.setParent(categoryID)
channel.setUserLimit(5)
    //nelow does not work                
var channelId = ""                channel.guild.channels.cache.get(channelId)
console.log(channelId)
})```

Anyone know how to do this?
steel crescent

what has that to do with voice?

smoky ravine

its a voice channel?

steel crescent

that doesn't really matter

sending and receiving audio

not voice "channels"

smoky ravine

oohhh

my bad

native lance

Does the audio player automatically get destroyed when it goes to idle or do I have to do it myself?

carmine timber
wise anchor

how can i play a playlist

carmine timber
wise anchor

okay thx

wise anchor
carmine timber
wise anchor

okay thx

mental adder

Sorry if I can't ask this here, but is the voicelink in the discord.js github an example?

mental adder
carmine timber
frank void

I'm trying to learn about new voice library with the basic example

but when i'm trying to run tsc i got this error RangeError: Maximum call stack size exceeded

any help?

carmine timber
frank void
carmine timber
frank void
carmine timber

Ok, then I don't know about your error

high kite
const connection = joinVoiceChannel({
        channelId: channel.id,
        guildId: channel.guild.id,
        selfDeaf: false,
        selfMute: true,
        adapterCreator: channel.guild.voiceAdapterCreator,
    });

While the bot is selfMute, why can it play sounds in my server?

subtle granite

It can not

// => TypeError: adapterCreator is not a function

  const connection = joinVoiceChannel({
    channelId: channel.id,
    guildId: channel.guild.id,
    adapterCreator: channel.guild.voiceAdapterCreator,
    selfDeaf: true,
  });
``` It works on my development environment but not on my server?
spare wave

what version? update to latest version 0.5.0

subtle granite
fervent bloom
const Discord = require('discord.js')
const { VoiceConnectionStatus, entersState, joinVoiceChannel } = require('@discordjs/voice')

module.exports.run = async (bot, message, args) => {
    if (!message.member.voice.channel) return message.channel.send({ content: `What? Excuse me? Do you really expect me to execute a MUSIC command without you being in a voice channel? Like how you gonna use them if you can't hear them bruh? Big brain much?` });

    const music = args.join(" ");
    bot.distube.play(message, music)
    if (VoiceConnectionStatus.Ready) {
        if (message.member.voice.channel instanceof Discord.StageChannel) {
            message.member.guild.me.voice.setSuppressed(false);
        }
    } else {
        const connection = joinVoiceChannel({
            channelId: message.channel.id,
            guildId: message.member.guild.id,
            adapterCreator: message.member.guild.voiceAdapterCreator,
        })
        await entersState(connection, VoiceConnectionStatus.Connecting, 15000);
    }
}

module.exports.config = {
    name: "play",
    aliases: ['p', 'P', 'PLAY']
}```VoiceConnectionStatus.Ready doesn't work for me. it doesn't join channel but it says ready
spare wave

try run npm ls @discordjs/voice and see what version

subtle granite

The problem is it works on my local machine with windows. But when I run my bot on linux I get this error: TypeError: adapterCreator is not a function

fiery blade

not working on different machines sounds like different versions

subtle granite
    at new VoiceConnection (/home/my-project/node_modules/@discordjs/voice/dist/VoiceConnection.js:74:25)
    at Object.createVoiceConnection (/home/my-project/node_modules/@discordjs/voice/dist/VoiceConnection.js:475:29)
    at joinVoiceChannel (/home/my-project/node_modules/@discordjs/voice/dist/joinVoiceChannel.js:17:30
subtle granite
fiery blade

of that yeah, if not different versions then I don't know

subtle granite

The package.json is exactly the same

ffmpeg and all dependencies installed

fervent bloom
subtle granite
v14.17.1
➜  ~ npm -v
6.14.13```

Am I using wrong versions?

fervent bloom

On both machines

subtle granite

Now it works, the bot joins the voice channel but does only play silence

fervent bloom
subtle granite

No, it works on my windows machine

spare wave

on the linux, have you installed all the necessary dependant? FFMpeg, ptyhon 2.7

subtle granite
spare wave

python?

and what lib you using youtube-dl?

subtle granite

Python 2.7.16

I dont use any lib. I play a stream url via ffmpeg -i

const attachRecorder = () => {
  player.play(
    createAudioResource(
      new prism.FFmpeg({
        args: [
          '-analyzeduration',
          '0',
          '-loglevel',
          '0',
          '-reconnect',
          '1',
          '-reconnect_streamed',
          '1',
          '-reconnect_on_network_error',
          '1',
          '-reconnect_on_http_error',
          '4xx,5xx',
          '-reconnect_delay_max',
          '30',
          '-i',
          streamURL,
          '-acodec',
          'libopus',
          '-f',
          'opus',
          '-ar',
          '48000',
          '-ac',
          '2',
          '-af',
          'bass=g=4',
        ],
      }),
      { inputType: StreamType.OggOpus },
    ),
  );
}; 
``` Which works fine on windows
carmine timber
spare wave

ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2), this is my ffmpeg version on my ubuntu, try update the ffmpeg maybe? Or change the StreamType

carmine timber
spare wave

solved, but no sound

subtle granite

yes

I will try to update my ffmpeg now if there is a newer version

carmine timber
subtle granite

The bot joins, but does only play silence

carmine timber
subtle granite

Which args are wrong then? Because it works on my windows machine

carmine timber

@subtle granite

const FFMPEG_OPUS_ARGUMENTS = [
    '-analyzeduration',
    '0',
    '-loglevel',
    '0',
    '-acodec',
    'libopus',
    '-f',
    'opus',
    '-ar',
    '48000',
    '-ac',
    '2',
];
player.play(
    createAudioResource(new prism_media.FFmpeg({
        args : ['-reconnect', '1', '-reconnect_streamed', '1', '-reconnect_delay_max', '5','-i', url, ...FFMPEG_OPUS_ARGUMENTS ]
    }), { inputType: StreamType.OggOpus }))

Try doing this

subtle granite

give me a sec I will try this

rain flare

how to make a music bot, as i have never ever made music bots, any idea or video tutorial i would preffer docs

bronze swanBOT
rain flare
spare wave

The example repo seem using the old v12

carmine timber
subtle granite
carmine timber
carmine timber
subtle granite

How do I use getVoiceConnection ? It always returns null

carmine timber
subtle granite
carmine timber
subtle granite

I use the same as in the radio bot example and the try to use getVoiceConnection(guildId) but it returns null even when it is connected

@carmine timber

carmine timber
indigo scaffold

How can I make the bot join my voice channel when I make a command?

carmine timber
indigo scaffold

It's not for a music bot, I do voice recognition... But I managed to make it join the vc, now the bot just doesn't understand the guildMemberSpeaking event...

carmine timber
indigo scaffold

Okay nice

empty torrent
subtle granite
carmine timber
subtle granite

Because it was in the docs marked as export, I thought it can be used

carmine timber
subtle granite

Its not there but in the documentation page it is as a method

And why can it be imported from the module then?

carmine timber
subtle granite
subtle granite
carmine timber

Don't tell me that it is a method and I used it

I want to see the code

carmine timber
subtle granite
carmine timber
carmine timber
vocal valley

I would say that it's a bit of both?

We can alter voice to not play to vc's that are self muted

But at the same time discord really shouldn't allow us to do so

carmine timber

Yes

steel crescent

I don’t think we should stop playback when we self mute

Because it would act like a pause then, you might not want to pause

And just not sending packets but continuing the playback seems like a major hack

subtle granite

Do I have to store it somewhere?

empty torrent

?music

bronze swanBOT
subtle granite

@empty torrent that got nothing to do with my question and nothing to do with the new voice module

empty torrent

I did not mention you

empty torrent

How can i install the dev branch of discord js which includes adapterCreator function?

I’m getting TypeError: adapterCreator is not a function

I have tried 13.0.0-dev.02693bc02f45980d8165820a103220f0027b96b7 and reran npm i but didn’t seem to help

Using ubuntu

spare wave

npm i @discordjs/voice@latest, also get some decent understanding of js first. Saw you asking on Programming Hangout server as well

empty torrent

Thank you. I’m trying

solemn current

How to join a vc? message.member.voice.channel.join() no longer works..

can someone help?

marsh sentinel

It does...

hazy copper

did something break with an update?

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

this doesn't work anymore, i get the error message TypeError: adapterCreator is not a function

this is on version 0.5.0

(update) using the github version of discordjs works fine, guess its just a bug with the one on npm then

carmine timber
hazy copper

i did that, didn't work, what did work was installing the github version of discordjs

and @latest installs the same exact version, 0.5.0

can you read what i said? the problem was in discord.js itself, not the voice module

👍

carmine timber

PES_ThumbsUp

mental patio

is the djs version 13 since i think voiceAdapterCreator is added in v13

hazy copper
mental patio

you mean the npm i discord.js@dev didnt download the beta v13 now
i can sure few days ago this is okay but idk what happens now too

hazy copper

yeah i had an earlier one, i updated it today and it broke

so now im using the github one until the npm one gets updated

mental patio

i dont think this is a voice lib question anymore perhaps you can ask #djs-help-v14
or did you uninstall and install again?

hazy copper

there are no more issues, i fixed it 👍

subtle granite
main crow

Do you know if it's easy to mix multiple audio sources? we're looking to use a nodejs app4that would relay some live audio communications trought DiscordJS.

I know it's not a core feature of DJS but does anyone know some library that could help with this topic?

carmine timber
subtle granite
steel crescent

you always know which shard a guild is on

subtle granite

Does this new Voice Module automatically check for permissions to speak?

steel crescent

Nop

subtle granite
karmic rose

does the new voice update only affect playing sounds in voice channels? like will voiceStateUpdate work as it did before as well as moving users between voice channels?

(currently i'm running an accountability bot in v12 that tracks user minutes in a few specific voice channels)

subtle granite

thonk I keep getting ```js
Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close

whenever I use `<AudioPlayer>.stop()`

also, it started happening from today (never happened before)

silver sleet

CoolThonk

steel crescent

V13 doesn’t have voice module anymore

Read the pins

loud breach

I tried to connect to a voice channel by doing

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

and i get the error adapterCreator is not a function
This only happened after i updated the voice api from when i installed it yesterday. Any idea as to why?

steel crescent

You need to update to the latest dev version

Uninstall discord.js@dev and reinstall it

loud breach

ok

serene dawn

Can you use @discordjs/voice in djs v12?

icy maple

No

Well, prob could

serene dawn

Wym prob?

icy maple

It hasn’t been tested and isn’t an intended feature

serene dawn

Hmm alr

icy maple

In theory, it would work since the package is independent

serene dawn

Alr

vocal valley

It should work @serene dawn, the basic example we have works with v12

to get /voice to work with v12, you just need to use the adapter file included in the basic example

serene dawn
vocal valley

Yep

The basic example there

serene dawn

Alr ty, i see it

vocal valley

^ that's just the compiled version of the typescript file

serene dawn

Oh i c, im just blind

vocal valley

np

knotty frost
module.exports = {
    name: 'play',
    description: 'play',
    async execute(message, args) {
        message.member.voice.channel.join()
        const connection =await message.member.voice.channel.join();
        connection.play('commands\Delax - Drop You Like.mp3');
        
        
    },
};

doesn't output any sound

vocal valley

@knotty frost please read the channel topic and pins before blindly posting code here and saying it doesn't work

spare wave

expanded the Track class from the original example to Soundcloud as well now, though I not very sure the youtube-dl options need adjustment or not

how big is the inlineVolume impact on performance? Against 2 vcore vps

vocal valley
vocal valley
spare wave

I have no method or any idea how to benchmark either. process.cpuUsage? or something like that?

vocal valley

cpuUsage will definitely be higher but im not sure by what quantity, so measuring that could be useful

but another thing to measure would be how smooth the playback is.

this is pretty easy to do qualitatively, but at some point in the future im planning on doing a quantitative measurement on this

and also considering some improvements that have big performance improvements for streams that have inline volume enabled

spare wave

sound like a plan

loud breach

Is there a way to see when an audio source has finished playing?

echo crypt
const channel = msg.member.voice.channel;
 const connection = await channel.join();

TypeError: channel.join is not a function

loud breach
echo crypt

thanks

@loud breach how can i play ?

TypeError: connection.play is not a function

loud breach

You need a audio player

I recommend you read that

echo crypt

ok thanks

loud breach
spare wave

Check the AudioPlayerStatus , If the Idle state is entered from a non-Idle state, it means that an audio resource has finished playing.

loud breach

Well i do that

But sometimes it triggers even tho the video hasn't finished playing

Thats why im asking. Like is there a .on('finish') function?

junior glen

Is there a way to adjust the quality?
At the moment the audio sounds like the old voice-implementation, which is a bit different than the file itself.
For example the discord-leave sound. It's completely different if it is played in a voice channel through the bot.
AudioResource is set via

resource = createAudioResource(fs.createReadStream(filePath), {inputType: StreamType.OggOpus});
chrome sundial

is there a way to disconnect client from a channel without using voiceConnection because i want to disconnect my bots user from a channel but the bot is crashed so there is no voiceConnection available

shell crag
chrome sundial

oh let me try didnt know that method

subtle granite

How can I get a voice connection with sharding by only having the guildId?

echo bone
const DiscordVoice = require('@discordjs/voice');

DiscordVoice.joinVoiceChannel({ adapterCreator: Interaction.guild.voiceAdapterCreator, channelId: MemberVoiceChannel.id, guilId: Interaction.guildID, selfDeaf: false, selfMute: false });

The client just dont joins the voice channel; The ids are right but it does nothing.... Can someone help me?

Never mind, forgot the d at guild...

hallow pumice
    if (!message.guild) return;
    if (!client.application.owner) await client.application.fetch();

    if (message.content.toLowerCase() === '!deploy' && message.author.id === client.application.owner.id) {```

TypeError: Cannot read property 'application' of undefined
chrome sundial

First this isnt related with new voice library second message event doesnt give you client so the client var will be undefined and you cant acsess all the properties of a client object

ps: i think you tried to copy music-bot example which is somewhat related but as i mentioned you dont need to use client paramater on this event listener because i am assuming by looking at how you listen to events you already have a client variable so by removing client paramater it should fix your issue

rustic temple

You actually forgot a ? before .owner

hallow pumice
vocal valley

And also maybe send the audio files

steel crescent

Isn’t that expected?

Voice channels don’t have a high enough Bitrate

vocal valley

well the bitrate thing is more of a client side thing

bots don't have to respect the bitrate of the channel

well they should respect it, but there is nothing stopping bots from picking any bitrate they want

surreal gust

is it necessary to use discordjs@voice in v13 djs?

steel crescent

Yes

surreal gust

😭

im questioning if i shall re write my bot to v13

junior glen

how it is played in voice chat

vocal valley

@junior glen out of interest, are you playing it as an ogg/opus file? or as an arbitrary input

junior glen
vocal valley

hmm interesting, i'll take a look later today

my guess is that the Ogg file has a volume adjustment that is not being respected

junior glen

also tried a mp3 file

vocal valley

could you try an mp3 file with inlineVolume: true?

junior glen

same result
do you need the result/recording?

fair berry

any guide or docs for new djs voice?

vocal valley
spring jackal

Is the music example what it's gonna be or is it gonna get updated?

vocal valley

music example is basically complete

fair berry

thanks

chrome sundial
neat wing

There isn't any error in console. Bot is joining to vc but it isn't playing any song. Ytdl or ytsr isn't returning undefined or null, they are returning the data that they suppose to return.

What is the problem?

// msg = message class
// client = client class
// args is coming from command handler which parses every arguement.
// ytsr is a function coming from ytsr module for yt video search
// ytdl is a function comfing from discord-ytdl-core module for downloading videos from yt

        let requestedSong = args.join(' ');

        if (!requestedSong) return msg.reply('Invalid song specified!');

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

        const subscription = connection.subscribe(player);

        const searchResult = (await ytsr(requestedSong, { pages: 1, limit: 1 })).items[0] || null;
        if (!searchResult) return msg.reply('Song not found on youtube.');

        subscription.player.play({ audioPlayer: subscription.player, playStream: await ytdl(searchResult.url, { filter: 'audioonly'}) });
plain canopy

My music commands for my bot just died out due to new updates and hence i'm looking for a new solution to playing music with my bot that is not to hard.. any suggestions?

neat wing
echo bone

How can I set the volume of the <AudioPlayer>?

misty saddle

How can I let my bot join to any voice channel in new voice lib ?

frosty dawn
      throw er; // Unhandled 'error' event
      ^

AudioPlayerError: aborted
    at connResetException (node:internal/errors:683:14)
    at TLSSocket.socketCloseListener (node:_http_client:407:19)
    at TLSSocket.emit (node:events:406:35)
    at node:net:661:12
    at TCP.done (node:_tls_wrap:580:7)
Emitted 'error' event on AudioPlayer instance at:
    at WebmDemuxer.onStreamError (/workspace/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:213:22)
    at Object.onceWrapper (node:events:514:26)
    at WebmDemuxer.emit (node:events:406:35)
    at emitErrorNT (node:internal/streams/destroy:193:8)
    at emitErrorCloseNT (node:internal/streams/destroy:158:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {```

why this crash!

spare wave

^using ytdl-core?

frosty dawn

no ytdl discord core

spare wave

well, it is from the dependacy of ytdl-core, ytdl-discord-core still use ytdl

frosty dawn

ya i know so its a ytdl error?

spare wave

yes

frosty dawn

is youtube-dl stable?

spare wave

I'm using youtube-dl, the example uses youtube-dl, so far no issue

thorn bough

Hey I'm making a radio bot, and I don't understand this package, like I wanna play a livestream from youtube and distribute to every channel bot joins, but I'm confused how to do it, in v12 I could do it by creating a broadcast, and I need to do this because I wanna add stage channel support too

misty saddle

entersState(target: VoiceConnection, status: VoiceConnectionStatus, maxTime: number) here what maxtime means ?
Like for connecting or staying on the voice channel ?

spare wave

^ like delay before the connection to voice channel is stable

vocal valley
misty saddle
thorn bough
vocal valley

there are 3 examples in the repo, the radio-bot is probably helpful

since that is one audio stream across many voice connections

misty saddle
vocal valley

15 or 20 seconds is good i think

spare wave

btw hydrabolt,suggestion to make the description of maxState in milisecond(s)

vocal valley

noted, ty

misty saddle
spare wave

yes

misty saddle

riley_cool

thorn bough

Wait how would that thing will play there is no options for passing any stream link

or any url

subtle granite
vocal valley

or the basic example

thorn bough

ok

subtle granite

do i need to download the thing he does or can i just code it ?

spare wave
subtle granite

ok thx

echo bone

Can I change the Volume of a Song while playing? And if yes, how can i do it?

I didn't found something in the examples...

vocal valley
keen plaza

It looks like CreateAudioResourceOptions does not appear on the docs real_eyes

misty saddle

How to make bot speaker when he joins the stage channel ?

keen plaza

(That's something for #djs-help-v14 btw, as this channel is for @discordjs/voice))

misty saddle
celest zealot

events.js:292
throw er; // Unhandled 'error' event
^

AudioPlayerError: Video unavailable

deft wedge

hey, I wanted to know does this require node v14 like djs v13?

surreal gust

Yes

subtle granite

Need a Person who can design the UI for my application DM me

surreal gust
subtle granite

ok

echo bone
steep sedge

ok

south lark

Sorry it took me so long to get back to you, I had to tweak lots of things to see if I am still able to replicate. The issue appears to only happen when receiving audio from someone on the Chrome browser.
This is the error I get:

Segmentation fault (core dumped)
exit status 139

And it completely crashes the bot. Doesn't just crash the command. It crashes the whole bot.

austere sphinx

is there documentation coming for @discordjs/voice? I have a bot that plays a livestream from youtube in all voice channels its connected to, but I'm having a lot of trouble making it compatible with v13 in javascript.

keen plaza
austere sphinx

this is too confusing but i also want to upgrade to v13 so ig i'll kill the music bot

vocal valley
south lark
vocal valley

could you try @discordjs/opus

I am fairly certain this is fixed in the new voice library

south lark

Actually, I think I'm using @discordjs/opus

vocal valley

but voice receive is still a little unpleasant to use in the new voice library, I made a PR to improve it but it's still WIP

oh interesting 👀

south lark

Yeah I lied, I'm not using opusscript. I'm using discordjs/opus

vocal valley

👍

I'm assuming maybe some faulty receiving code is passing bad Opus packets to the discordjsopus library

causing a segfault

south lark

This is a little bit of my code if it helps.

  // this creates a 16-bit signed PCM, stereo 48KHz stream
        const audioStream = voice_Connection.receiver.createStream(user, { mode: 'pcm' })
        audioStream.on('error', (e) => {
          console.log('audioStream: ' + e)
        });
        let buffer = [];
        audioStream.on('data', (data) => {
          buffer.push(data)
        })
        audioStream.on('end', async () => {
          buffer = Buffer.concat(buffer)
          const duration = buffer.length / 48000 / 4;
          console.log("duration: " + duration)

          if (duration < 1.0 || duration > 19) { // 20 seconds max dur
            console.log("TOO SHORT / TOO LONG; SKPPING")
            return;
          }

          try {
            let new_buffer = await convert_audio(buffer)
            let out = await transcribe(new_buffer);
            if (out != null)
              process_commands_query(out, mapKey, user);
          } catch (e) {
            console.log('tmpraw rename: ' + e)
          }
vocal valley

and then you can actually use voice receive in the new library without hating it lol

south lark

Alright lol

vocal valley

Actually, could you try this out

That might fix your issue

south lark

I'll try that and let you know like

south lark

Okay wait wtf

vocal valley

👀

rustic temple

Thonk

south lark
vocal valley 👀

First it got this:

21:28:23: FATAL ERROR: Error::ThrowAsJavaScriptException napi_throw
21:28:23:  1: 0xa89e60 node::Abort() [node /home/dzlandis/Discord-Scriptly-Free/index.js]
21:28:23:  2: 0x9ade29 node::FatalError(char const*, char const*) [node /home/dzlandis/Discord-Scriptly-Free/index.js]
21:28:23:  3: 0x9ade32  [node /home/dzlandis/Discord-Scriptly-Free/index.js]
21:28:23:  4: 0xa55b3b napi_fatal_error [node /home/dzlandis/Discord-Scriptly-Free/index.js]
21:28:23:  5: 0x7fa2a867cc8e  [/home/dzlandis/Discord-Scriptly-Free/node_modules/@discordjs/opus/prebuild/node-v88-napi-v3-linux-x64-glibc-2.31/opus.node]
21:28:23:  6: 0x7fa2a867d3ec Napi::Error::ThrowAsJavaScriptException() const [/home/dzlandis/Discord-Scriptly-Free/node_modules/@discordjs/opus/prebuild/node-v88-napi-v3-linux-x64-glibc-2.31/opus.node]
21:28:23:  7: 0x7fa2a8689d68 OpusEncoder::Decode(Napi::CallbackInfo const&) [/home/dzlandis/Discord-Scriptly-Free/node_modules/@discordjs/opus/prebuild/node-v88-napi-v3-linux-x64-glibc-2.31/opus.node]
21:28:23:  8: 0x7fa2a86802da Napi::InstanceWrap<OpusEncoder>::InstanceMethodCallbackWrapper(napi_env__*, napi_callback_info__*) [/home/dzlandis/Discord-Scriptly-Free/node_modules/@discordjs/opus/prebuild/node-v88-napi-v3-linux-x64-glibc-2.31/opus.node]
21:28:23:  9: 0xa390bf  [node /home/dzlandis/Discord-Scriptly-Free/index.js]
21:28:23: 10: 0xce224b  [node /home/dzlandis/Discord-Scriptly-Free/index.js]
21:28:23: 11: 0xce37fc  [node /home/dzlandis/Discord-Scriptly-Free/index.js]
21:28:23: 12: 0xce3e76 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node /home/dzlandis/Discord-Scriptly-Free/index.js]
21:28:23: 13: 0x15046d9  [node /home/dzlandis/Discord-Scriptly-Free/index.js]

But then it restarted and now it's working perfectly and transcribing the user on Chrome quack

vocal valley

meguFace

yea I have no clue

That's uhhh odd

south lark

I mean, I guess it is working now? So thanks??!!?!?

vocal valley

Maybe it hadn't got the change the first time around

np hahaha, thanks to the person who made the fix in the first place

south lark

Well yeah, thanks again lmao

vocal valley

Np 👍

subtle granite

yo i need help

south lark
vocal valley Np 👍

So like, if I do an update to discordjs or something, will it erase that change though?

subtle granite

what are the packages that need to be installed before coding a discord music bot ?

south lark
vocal valley

@subtle granite this is not relevant to the new voice channel

subtle granite

ah ok but if get an error in the code can i come here ?

vocal valley

if you get errors you should still use that channel, this channel is for people using @discordjs/voice which is a new library

subtle granite

OHHH ok thanks

vocal valley

Np

celest zealot

errored: Error: connect ETIMEDOUT

how can i fix that

drifting niche

I've never messed with typescript - I'm a little confused on how I would use the examples for new voice in a JS project...

woeful shuttle

does the new voice lib have typings included?

fervent estuary

its coded in ts so yes

woeful shuttle
mild viper

f

drifting niche

I'm trying to be a good noodle and use new voice considering I'm using v13 but I hit a stumbling block pretty early on - Error: Cannot find module 'Z:\dory\node_modules\@discordjs\voice\dist\index.js'. Please verify that the package.json has a valid "main" entry

getting that whenever I try to start the bot. check node_modules and as I expected, the dist directory doesn't even exist. I have the dependencies I need (tweetnacl, ffmpeg-static and discordjs/opus - I just want to play a single audio file)

drifting niche

am I missing something obvious?

balmy canopy

how did you install it

drifting niche

ermmm I installed via npm i discordjs/voice

balmy canopy
drifting niche

read my follow up

balmy canopy

yeah i saw it, but it probably didnt update properly
can you try fully uninstalling it and then reinstalling it

drifting niche

mhmmm, 2 secs

drifting niche
fiery blade

@woeful shuttle turn on skipLibCheck in tsconfig

empty torrent

How can i check voice connections size?

frosty dawn

Are there any js implementation of YouTube-dl instead of ts?

steel crescent

Converting the TS to JS code is simpler than you think

Having a JS example would just duplicate the code

frosty dawn

I did but it doesn't play and doesn't throw any error

steel crescent

That has nothing to do with TS or JS then lol

Also kinda hard to debug if it does “nothing”

frosty dawn

I know but just to be sure

steel crescent

You gotta do some digging

Check the docs for debug events n stuff

See if they emit something

frosty dawn

Ok thanks

misty saddle

how to subscribe a specfic live stream in youtube for every player ?

like I tested radio bot example , but doesn't help

echo bone

How can i get the stream time with this new package? The old was <Dispatcher>.streamTime but this does no longer exist in the new package or I dont found it..

celest zealot

what is Error: write EPIPE?

misty saddle
misty saddle

TypeError: adapterCreator is not a function is coming when i try to join to a channel
Error

    at new VoiceConnection (/home/container/node_modules/@discordjs/voice/dist/VoiceConnection.js:74:25)
    at Object.createVoiceConnection (/home/container/node_modules/@discordjs/voice/dist/VoiceConnection.js:475:29)
    at joinVoiceChannel (/home/container/node_modules/@discordjs/voice/dist/joinVoiceChannel.js:17:30)
    at Join_Voice (/home/container/events/Music_Player_events/Voice_Main_events/Music_Manager.js:65:34)
    at Auto_Join_Voice_Music_Player (/home/container/events/Music_Player_events/Music_Player_Voice_events/Auto_Voice_Connection.js:10:110)
    at Voice_Checker (/home/container/index.js:376:34)
    at Client.<anonymous> (/home/container/index.js:368:2)
    at Client.emit (events.js:388:22)
    at WebSocketManager.triggerClientReady (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:377:17)
    at WebSocketManager.checkShardsReady (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:361:10)```
spare wave

Update discord.js

neat wing

is ytdl-core or other sub modules of ytdl-core compatible with this library

steel crescent

Yeah but not encouraged because of the problems when it comes to streaming audio with them

neat wing
steel crescent

Like we use in our examples

youtube-dl

neat wing

but i think we can't change the encoding of the video in that module right?

steel crescent

Sure can

It can download the version you want

Just like the others

neat wing

oh, thats cool thanks!

empty torrent

How do i get the voice connections size?

mellow falcon

how can my bot play music in a stage channel?

celest zealot

read the pins

empty torrent
echo bone
bright moth

that was removed from d.js in v13 you use the joinVoiceChannel method that is provided from the @discord.js/voice module

@onyx bough ^ there is also examples how to use the new voice library in the pins

echo bone

I get an error while using the audio player:
Error:

AudioPlayerError: Status code: 404
    at ClientRequest.<anonymous> (/home/disgroup/DisBot/node_modules/miniget/dist/index.js:210:27)
    at Object.onceWrapper (events.js:483:26)
    at ClientRequest.emit (events.js:376:20)
    at HTTPParser.parserOnIncomingClient (_http_client.js:647:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
    at TLSSocket.socketOnData (_http_client.js:515:22)
    at TLSSocket.emit (events.js:376:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:223:10)
Emitted 'error' event on AudioPlayer instance at:
    at Encoder.onStreamError (/home/disgroup/DisBot/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:213:22)
    at Object.onceWrapper (events.js:483:26)
    at Encoder.emit (events.js:388:22)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

What does this mean? Help

steel crescent

not an error from us

thats from ytdl-core

echo bone

Okay...thank you

celest zealot
steel crescent

youtube-dl

celest zealot

thx bro

echo bone

Now I get another error:

TypeError: adapterCreator is not a function

How can I handle this?