#archive-voice

30636 messages · Page 21 of 31

viral plank

No

rugged sky

You need that.

viral plank

ok i'm sorry

rugged sky

No need to apologize, it's a easy mistake to fall into.

leaden totem

Hello! To use an audio bot in different servers i need to create an audioplayer for each one? If i start an audio in a server it goes in ALL where it's actived

subtle granite
subtle granite

it's normal when i kick my client in the voice channel, the player.on idle repeating itself?

marsh lark

can one define adaptorcreator? (i want the bot to join the voice channel without anyone having to send a message)

leaden totem
ionic peak
/home/runner/b1/index.js:28
        radio.channels.cache.get(log).send(reset)
                                           ^

ReferenceError: reset is not defined
    at StreamDispatcher.<anonymous> (/home/runner/b1/index.js:28:44)
    at StreamDispatcher.emit (events.js:326:22)
    at finishMaybe (_stream_writable.js:639:14)
    at _stream_writable.js:616:5
    at StreamDispatcher._final (/home/runner/b1/node_modules/discord.js/src/client/voice/dispatcher/StreamDispatcher.js:248:5)
    at callFinal (_stream_writable.js:609:10)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
exit status 1

Help Plz

full grove
full grove
torpid abyss
leaden totem
full grove
hidden summit

hi

leaden totem

but it doesn't work, the audio doesn't play

austere plinth

if i subscribe a voice connection to a player, will it automaticly destroy when song is ended or bot is removed from channel and what events are there?

subtle granite

Hi! When my bot plays music i get the following error sometimes

I read online that this error is cause by the discord js version

grim cove

i am doing a music bot, but v13 isnt working as v12...

const stream = ytdl(video.url, {filter: 'audioonly'});
            connection.play(stream, {seek: 0, volume: 1})
            .on('finish', () => {
                voiceChannel.leave();
            });
``` doesnt work anymore, `connection.play()` is not a function. is there any other function that works the same?
vapid jay

BRH!

grim cove
fervent estuary
grim cove

i have got it working

fervent estuary
subtle granite

and i need to downgrade my discord js version?

grim cove

ive read on github that the setting ytdl-core highWatermark to 32MiB fixes this issue... havent tested it yet tho

fervent estuary

that shouldnt have anything to do with it @subtle granite

grim cove

it was apparently an issue with node v16+ and ytdl

maiden plank

how can i check how much people are in a voice channel? When i log channel?.members the result in console is Collection(0) [Map] {} so that channel?.members.size is always 0

fervent estuary

do you have GUILD_VOICE_STATES intent?

maiden plank

yes

cosmic flame

any one knows something about implementa tions of genius api

fervent estuary

this is for djs voice support. Not genius api

mint pawn

how can i change volume of the player?

full grove
mint pawn
full grove
mint pawn

ok

dude i cant find audio resource options in djs voice docs

maiden plank

how can i check how much people are in a voice channel? When i log channel?.members the result in console is Collection(0) [Map] {} so that channel?.members.size is always 0. There are all intents in a client.

mint pawn

or 0-1?

full grove
mint pawn

okk

TypeError: Cannot read properties of undefined (reading 'setVolume')
full grove

can you show the code where you implement it

mint pawn

wait it works now idk how but ok

full grove

Okay great

mint pawn

thx

river oxide
mint pawn

can i seek audio to 0?

full grove
mint pawn

yeah bcs my audio start from 2 sec like that

full grove

You would have to write a function to do that yourself it is not build in

maiden plank

how can i check how much people are in a voice channel? When i log channel?.members the result in console is Collection(0) [Map] {} so that channel?.members.size is always 0. There are all intents in a client.

quiet jolt

Whenever I make my bot to join stage channel, it joins as an audience. How to make it join as a speaker? Please reply with a ping 🙏

Btw its a Music Bot and uses Erela.js. I have added the following code which didn't work:

        try {
            await player.guild.me.voice.setSuppressed(false);
        } catch (e) {
            return;
        }
    }```
rugged sky
maiden plank

@rugged sky yep

fervent estuary
quiet jolt
 if(player.voiceChannel.type === "GUILD_STAGE_VOICE" && server.me.voice.suppress) {
   try {
     await server.me.voice.setSuppressed(false);
 } catch(e) {
   server.me.voice.setRequestToSpeak(true);
}} ```

Why doesn't this work 🥲

fallen vector

hello, how can i use "finish" event in new voice?

tidal olive

Do i have to create a new audioPlayer for every guild i am connecting a voice to?

or is that a waste of resources?

full grove
tidal olive

thanks :)

rugged sky
digital bobcat

Hello! How do I get the AudioPlayer from VoiceConnection?

icy maple

<Connection>.state.subscription.player, assuming it’s subscribed

digital bobcat

Okay thanks!

How can I set the volume in AudioPlayer?

full grove
digital bobcat

Thank you!

Why I don't have that volume object in the resource object?

It says undefined

full grove
digital bobcat

okay

full grove
vernal tapir

Hello guys ! just a little question. Do you guys know how to detect if someone is speaking on a voice channel ? I used voiceStateUpdate event but it's only for mute/leaf detection. Thanks!

leaden totem

Hello! Sometimes the bot returns at RequestHandler.js and sometimes AudioPlayerError: aborted.
Sometimes when i start the audio/music, sometimes, polaying it, it stops and gives that error.

full grove
leaden totem
hybrid trout

Hello! The following code makes typescript very angry and I do not know how to fix it considering this is the very first few lines in the guides.
Type 'InternalDiscordGatewayAdapterCreator' is not assignable to type 'DiscordGatewayAdapterCreator' and a few other errors that come with the adapterCreator property.

hoary widget
prime elbow

Ok IDK why it's mad, so can someone explain why it's telling me this isnt a function when the docs say that it is a function

(the channel ID is hardcoded for testing)

icy maple
dusty needleBOT
icy maple

Would recommend reading the voice guide more thoroughly

formal rock

and then it crashes

rugged sky
formal rock

it just crashes and TypeError: Cannot read properties of undefined (reading '0')
at Object.execute (C:\Users\rauno\OneDrive\Töölaud\bot v2\commands\play.js:10:18)
at Client.<anonymous> (C:\Users\rauno\OneDrive\Töölaud\bot v2\index.js:39:35)
at Client.emit (node:events:390:28)
at MessageCreateAction.handle (C:\Users\rauno\OneDrive\Töölaud\bot v2\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\rauno\OneDrive\Töölaud\bot v2\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\rauno\OneDrive\Töölaud\bot v2\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\rauno\OneDrive\Töölaud\bot v2\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\rauno\OneDrive\Töölaud\bot v2\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\rauno\OneDrive\Töölaud\bot v2\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (node:events:390:28)

rugged sky
formal rock

oh

you mean node v 12 ??
Ops i have 17.0.1 version

rugged sky
formal rock

what does That v12 means

rugged sky

Version 12.

formal rock

for what

rugged sky

Of Discordjs, the library you are using.

formal rock

shall i upgrade it or what

rugged sky

I would recommend so, often good to be on the latest version of stuff. V13 does change a lot about playing audio, so you would have to do a bit more research.

formal rock

ok

digital bobcat

Why does the bot stops playing the resource after a few seconds although the audio stream is longer (10 seconds)? This happens only in short audio streams.

lone oxide

How would I detect when someone first joins a vc and who it is and then send a message in a channel tagging a role, and when the last person leaves the vc edit the message

obsidian quarry
vague remnant

Do connections and the player that is subscribed to a connection share the same stateChange event listener?

if (connection.listeners('stateChange').length < 1) {
  connection.on('stateChange', (oS, nS) => {
    if (nS.status == 'disconnected') {
      stop();
    }
  });
}

i have this bit of code to stop the player if the connection is terminated but the listener never registered, and im not registering any other listeners on the connection, but i do have listeners on the player

And if i dont do checks then i get maximum listener threshold warnings

leaden totem

Hello! How could i implement a stop function for a queue audio bot? I handle the "stop" with the audioplayer idle event, but i do not know how to stop it, for because, for a queue if there are songs it still play. Also if i put a flag variable it's in "play" status (for because it plays the songs at start"

vague remnant

If you want it to just stop playing but not remove anything you can just do player.pause()

and then player.unpause() to start again

cursive nimbus

hi, how can i fix this error ?

i installed @discordjs/opus v0.6.0

quasi chasm

how can i made a command to see in how many channels are connected my bot

frozen sierra

how to set volume in @discordjs/voice ?

valid marsh

<AudioResource>.volume.setVolume()

frozen sierra
digital bobcat
digital bobcat
odd ocean
error: stream: Error: aborted
node:events:371
      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:662:12
    at TCP.done (node:_tls_wrap:580:7)
Emitted 'error' event on AudioPlayer instance at:
    at OggDemuxer.onStreamError (/home/ubuntu/Desktop/cellbot/CELL-bot/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:213:22)
    at Object.onceWrapper (node:events:514:26)
    at OggDemuxer.emit (node:events:406:35)
    at emitErrorNT (node:internal/streams/destroy:193:8)
    at emitErrorCloseNT (node:internal/streams/destroy:158:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  resource: <ref *4> AudioResource {

any idea hat causes this error?

chrome ravine

any script where i can get currently connected member list to a certain voice channel

fervent estuary

voiceChannel.members is a collection of all the currently connected members

rugged sky
south lark

How do I wait for the current audio resource to finish playing before starting the next one?

icy maple
south lark

Well then what do I put in the player idle event?

icy maple

Play the next song, if any

south lark

How do I add songs to like a queue then?

Actually wait nvm I have an idea
I fixed it smiledog

odd ocean
urban carbon

How detect in what voice channel is the bot

cursive nimbus

i can't install @discordjs/opus, this is the logs, anyone help me pls 😦

subtle granite
cursive nimbus

The photo above is the logs

subtle granite
cursive nimbus

i have error like this guy

subtle granite

Hmm

cursive nimbus

its because i'm using node v17.0.1

the glibc of node doesn't matches with the glibc of @discordjs/opus

I reverted to node v16.8.0 and it worked fine

subtle granite

Lol.

mint pawn

when i play an audio it dont get completed till ends sometimes any fixes?

carmine timber

You can install discordjs opus in node 17 also.

cursive nimbus
carmine timber
cursive nimbus
carmine timber

👍

proper sundial
cursive nimbus
proper sundial
cursive nimbus

ye

digital bobcat

Hey. Why does the bot stop playing short audio streams before they actually finish? This happens when the audio stream is shorter than 20 seconds.

humble chasm

Hello I try to send a song on a vocal channel, but I receive an error:
connection.play is not a function
My code:

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

(...)

let songInfo = await ytdl.getInfo("https://www.youtube.com/watch?v=yUXJjIvhZz8");
let song = {
    title: songInfo.videoDetails.title,
    url: songInfo.videoDetails.video_url,
};

const dispatcher = connection
    .play(ytdl(song.url))
    .on("finish", () => {
        channel.send("fini")
    })
    .on("error", error => console.error(error));
dispatcher.setVolumeLogarithmic(1);

Can you help me please?
Thank you

And when I replace

.play(ytdl(song.url))

By

.playFile(ytdl(song.url))

I receive the same error

dusty needleBOT
icy maple

It’s not the job of the connection to play songs anymore, audio players handle that

humble chasm

Like this?

let songInfo = await ytdl.getInfo("https://www.youtube.com/watch?v=yUXJjIvhZz8");
let song = {
    title: songInfo.videoDetails.title,
    url: songInfo.videoDetails.video_url,
};

const player = createAudioPlayer();

const resource = createAudioResource(ytdl(song.url), {
    metadata: {
        title: 'A good song!',
    },
});

player.play(resource);
rugged sky
humble chasm

What?

rugged sky

The voice connection needs to be told to stream whatever your player is playing by subscribing it.

humble chasm

ah

It good I have added the subscribe but I have a new error:
Error: FFmpeg/avconv not found!

I try npm i ffmpeg-static....

Now I don't have error but I don't have the song...

And I don't have any idea to resolve the problem

My new code

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

let songInfo = await ytdl.getInfo("https://www.youtube.com/watch?v=yUXJjIvhZz8");
let song = {
    title: songInfo.videoDetails.title,
    url: songInfo.videoDetails.video_url,
};
const player = createAudioPlayer();
const resource = createAudioResource(ytdl(song.url), {
    metadata: {
        title: 'A good song!',
    },
});
player.play(resource);
connection.subscribe(player);

Have you an idea?

carmine timber
humble chasm

This?

const resource = createAudioResource(ytdl(song.url), {
    metadata: {
        title: 'A good song!',
        inputType: "???"
    },
});
humble chasm

and ```JS
const resource = createAudioResource(ytdl(song.url), {
inputType: StreamType.Arbitrary,
metadata: {
title: 'A good song!',
},
});

humble chasm
humble chasm

at the line 122

in commands/startchallenge.js

frozen sierra

how to check if client has GUILD_VOICE_STATES intent

plain parrot
TypeError: Cannot read properties of undefined (reading 'setVolume')
    at /home/runner/Astroz-Support/index.js:36:29```
mint pawn

is there any voice event handler?

mint pawn
reef latch

why is my boy not playing audio?

earnest cliff

hi all i have start to code my bot with typescript
know i need some help with the permission settings by my auto channel (temp channel) code
my temp channel runs know with permissions that i incloud in the code:

await newChannel.overwritePermissions([
    {
        id: member.id,
        allow: ['MANAGE_CHANNELS'],
    },
    {
        id: guild.id,
        allow: ['VIEW_CHANNEL'],
    },
]);
console.log(`created new temp voice channel for ${effectiveName}: ${newChannel.id}`);
return newChannel;

}

but i want that the bot synchron with the master channel by the permissions

crisp falcon

does anyone have a minute or two i have question? it's about getting a bot to join a vc which i've been having trouble with.

reef latch

my music bot shows as its speaking but its not playing anything

leaden totem

Hello! I've perms problems. I've a voice bot that should take perms only from a text channel. In the other channels i've thaat the bot could ONLY see the channel (sync with category where there are the voice channles too), but it cannot read message. Why if i put the command "-play" for example it reads the command (so join the channel), but obviusly crash for missing permission.

quick lantern

Hi, it happens to me that sometimes the bot crashes when it is playing something, it tells me AudioPlayerError: aborted and much more, the log is here: https://pastebin.com/UFjbEHgx
why does that happen? and how can i solve it?

i use

audioPlayer.play(createAudioResource(await ytdl(this.link)))
quick lantern
carmine timber
carmine timber
mint pawn

how can we get a channel from a voice connection??

true timber

How memory heavy is a music bot? What can I expect?

carmine timber
carmine timber
mint pawn

are there any docs to it?

bcs i didnt find joinconfig in djs voice

mint pawn

i mean doc for join config isnt there

mint pawn
carmine timber
mint pawn

oh

mint pawn

basically what i wanna do is in the play command to check for if something is playing or not

carmine timber
mint pawn

cant figure out

carmine timber
mint pawn how can we get it?

Just make sure you have attached a audio player with connection and then get player by

const player = connection.state.subscription.player
mint pawn

ooo

thank you so much!

carmine timber
mint pawn ooo

Then you can check player status by

if(player.state.status === "playing")

Or use AudioPlayerState instead of playing

mint pawn

yeah

thx

carmine timber

👍

verbal moth

Hey 👋 I made a music bot with a loop system but sometimes it stops playing because of an Http 403 forbidden error. How can i fix it ?

verbal moth

Play-dl

carmine timber
verbal moth

Ok

leaden totem
carmine timber
leaden totem
carmine timber
leaden totem

yes but in that way i the sync from category

i need all the text channels to be synced with category

subtle granite

hm

rugged sky
carmine timber
leaden totem

Thanks for all tips :)

crisp falcon
carmine timber
mint pawn

the event player.on idle status is called even when we suscribe the player?

glossy yew

Is there a way to record a user's audio while they are in a vc ?

edgy burrow

Yes

glossy yew
edgy burrow

I can't tell you much more than yes it's possible and refer you to the example, sorry.
I just really don't know how

glossy yew

oh ok np then, anyways ty tho

neon cape

Hi, is there a way I can create multiple players ?
example:

const palyer1 = createAudioPlayer();
const palyer2 = createAudioPlayer();
full grove

Yes you can

neon cape

I just found out, that wasn't the issue...
can you let 2 or more different clients join seperate channels in the same guild from one script?
sth like this:

const client1 = new Client({ intents: 32767 });
const client2 = new Client({ intents: 32767 });

const connection1 = joinVoiceChannel({ channelId: channel1.id, guildId: guild.id, adapterCreator: guild.voiceAdapterCreator })

const connection2 = joinVoiceChannel({ channelId: channel2.id, guildId: guild.id, adapterCreator: guild.voiceAdapterCreator })

It was possible in v12

frozen sierra

how to get time passed in playing songs ?

neon cape

how can you set the volume of a player

full grove

Okay here we go again

full grove
subtle granite

https://www.toptal.com/developers/hastebin/pevekanuwe.coffeescript

I can't install @discordjs/opus & @discordjs/voice

Debian: 8
latest npm & nodejs
all required packages installed

interesting is, that i can install it on another vps with same specs, just with debian 9 or higher

After copying the node_modules using scp, it all worked fine for me...

muted pebble

Does anyone have an example of a voice recording bot? Mine kinda works but when I try to open the saved recording VLC can't read it.

rugged sky

Haven't seen anyone with a fix yet, I'd recommend switching to play-dl.

carmine timber
whole flare

I'm not entirely sure but I thought the problem was that ytdl sometimes isn't able to get the YouTube download link which would return a 403 error and will make the stream unreadable for the AudioPlayer

whole flare
icy maple

403 error is a known issue

leaden totem

How do i set that the bot, after a time of not use, leaves the channel alone?

rose saffron

Hey is there a tutorial for receiving audio with djs/voice?

rose saffron
whole flare
whole flare
rose saffron

oof

I would just be able to use intellisense if my vs code would work like its supposed to

lofty warren

my bot isn't joining the call, but it answers the interaction and no error is logged in console. what's happening?

lofty warren
rugged sky Show code
const { joinVoiceChannel, createAudioPlayer, createAudioResource, NoSubscriberBehavior } = require('@discordjs/voice');
module.exports = {
    name: 'play',
    execute(interaction) {
        const connection = joinVoiceChannel({
            channelId: interaction.channelId,
            guildId: interaction.guildId,
            adapterCreator: interaction.guild.voiceAdapterCreator
        });
        const player = createAudioPlayer({
            behaviors: {
            noSubscriber: NoSubscriberBehavior.Pause,
            }
        });
        const resource = createAudioResource('./audio.mp3')
        player.play(resource);
        connection.subscribe(player);
        interaction.reply('playing :thumbsup:');
    }
}```
rugged sky
rugged sky

Nevermind, I'm not thinking straight, just change interaction.channelId to interaction.member.voice.channel.id. You're currently trying to connect to a text channel as if it were a voice channel.

lofty warren

thanks

rugged sky

np

maiden plank

Hi, guys! Why <VoiceState>.channel.members is always Collection(0) [Map] {}? I have all necessary intents, and <VoiceState>.channel is defined.

maiden plank

@rugged sky ```client.on('voiceStateUpdate', async (newVoice: VoiceState, oldVoice: VoiceState) => {
const member = await newVoice.guild.members.fetch(newVoice.id);

...//code, which creates a channel

await member.guild.members.fetch();
console.log(newVoice.channel?.members);

if (
oldVoice.channel?.parentId === getConfig().channels.voice.createRoomCategory &&
oldVoice!.channel!.id !== getConfig().channels.voice.createRoom &&
oldVoice!.channel!.members.size == 0
) {
oldVoice!.channel!.delete().catch(() => {});
}
});

rugged sky

I'm not sure if this is the cause of your issue, but I think voiceStateUpdate parameters are the other way around (i.e. (oldstate, newstate)).

maiden plank

@rugged sky if rename parameters it doesn`t work too

rugged sky
maiden plank

@rugged sky i resolved this problem: GuildMemberManager in client was 0 :D

sacred sluice
npm ERR! code 1
npm ERR! path D:\Desktop_main\voice\node_modules\@discordjs\opus
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-pre-gyp install --fallback-to-build

I am gettting this error when i am trying to install @discordjs/opus . How can I solve this error

coral frigate

has nothing related to discordjs

search up npm ERR! code 1

icy maple

Or bin the entire error

sacred sluice
carmine timber

Install them and you are good to go

sacred sluice
carmine timber You are missing build essential tools

when I am trying npm i -g windows-build-tools

npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated windows-build-tools@5.2.2: Node.js now includes build tools for Windows. You probably no longer need this tool. See https://github.com/felixrieseberg/windows-build-tools for details.
npm ERR! code 1
npm ERR! path C:\Users\vedan\AppData\Roaming\npm\node_modules\windows-build-tools
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node ./dist/index.js
Downloading python-2.7.15.amd64.msi
npm ERR! [>                                            ] 0.0% (0 B/s)
npm ERR! Downloaded python-2.7.15.amd64.msi. Saved to C:\Users\vedan\.windows-build-tools\python-2.7.15.amd64.msi.
Downloading vs_BuildTools.exe
npm ERR! [>                                            ] 0.0% (0 B/s)
npm ERR! Downloaded vs_BuildTools.exe. Saved to C:\Users\vedan\.windows-build-tools\vs_BuildTools.exe.
npm ERR!
npm ERR! Starting installation...
npm ERR! Please restart this script from an administrative PowerShell!
npm ERR! The build tools cannot be installed without administrative rights.
npm ERR! To fix, right-click on PowerShell and run "as Administrator".

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\vedan\AppData\Local\npm-cache\_logs\2021-10-28T08_56_30_564Z-debug.log```
icy maple

You need to run the terminal as admin

sacred sluice
icy maple

It still says the same thing on the bottom?

Please restart this script from an administrative PowerShell!

sacred sluice

ok

sacred sluice
icy maple

It still says that when running as admin?

sacred sluice

ya

icy maple
sacred sluice
carmine timber
sacred sluice
tulip dust

I try to get the bot to join and play a stream in a stage channel sometimes it works sometimes it dont.
The error comes back as

    at VoiceState.setSuppressed (C:\Dans Stuff\Beats Radio\DiscordBot\node_modules\discord.js\src\structures\VoiceState.js:248:59)
    at Client.<anonymous> (C:\Dans Stuff\Beats Radio\DiscordBot\index.js:56:41)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  [Symbol(code)]: 'VOICE_NOT_STAGE_CHANNEL'
}``` yet it is a stage channel
        const stageChannel = await client.channels.fetch('903216515967500288')
        if(!stageChannel) return;
        if(!stageChannel.stageInstance) {
            await stageChannel.createStageInstance({
                topic: "Playing you the latest beats from around the world.",
                privacyLevel: "PUBLIC"
            });
        }
            connection = joinVoiceChannel({
                channelId: stageChannel.id,
                guildId: stageChannel.guild.id,
                adapterCreator: stageChannel.guild.voiceAdapterCreator,
            });
            
            let resource = createAudioResource(('STREAM URL'), { inlineVolume: true });
            resource.volume.setVolume(0.7);
            
            const player = createAudioPlayer();
    
            connection.subscribe(player);
            player.play(resource)
    
            stageChannel.guild.me.voice.setSuppressed(false);
            if(stageChannel.guild.me.voice.channel?.type === 'GUILD_STAGE_VOICE') {
                stageChannel.guild.me.voice.setDeaf(true);
            }```this is the code
rustic oak

Hi, does anyone know how I could add filters like bass boost?
I'm using play-dl and discord.js/voice.

subtle granite

how to use youtube-dl in discordjs/voice?

rugged sky
subtle granite
rugged sky

I don't know how to use that package, you should ask in their support discord if they have one.

subtle granite

unfortunately no, they have no discord. And no matter how much I inquire, I can't find how to retrieve the music stream, even with ffmpeg I can't retrieve the stream.

subtle granite
rugged sky
subtle granite

yes

of youtube-dl?

rugged sky
subtle granite of youtube-dl?

Yeah, because I just looked at it and the second header explains how to get a youtube resource stream that you can input into your createAudioResource() function.

subtle granite
rugged sky

Can I see your code?

subtle granite
rugged sky

Show the surrounding code as well, and can you give a description of what is happening, what isn't happening, and what you're expecting?

rugged sky

If you're using youtube-dl-exec you should be using their method of calling the package like they describe on their npm page.

subtle granite

yes but this return a json object. And this don't contains the stream

rugged sky

They say it's the same as the youtubedl method in youtube-dl. If that's not the case I can't help you. Either way I'd recommend using play-dl instead.

subtle granite
rugged sky

Never seen that error before, but they have a support server if I'm not mistaken. And if not, you can ask NIP, he made it.

subtle granite

no response from them after several days

rugged sky

Then probably no one knows the answer, which kinda sucks but it happens. Means, you'll have to be the one to figure it out and bring the solution to them.

subtle granite

ok thx 🙂

spiral ibex
next sable

define channel

my bad i didnt know it wouldnt work

since i dont use the library

coarse wharf

if I put the playing song code from the discord.js guide into a play command (in a command handler) how do I interact with it in another command?

Like, I have a /play command, I want to have a /pause command and other commands of the sort

lofty warren

my bot joins the voice channnel, but it doesn't plays the song and doesn't logs any error in the console
code:

module.exports = {
    name: 'play',
    execute(interaction) {
        const connection = joinVoiceChannel({
            channelId: interaction.member.voice.channelId,
            guildId: interaction.guildId,
            adapterCreator: interaction.guild.voiceAdapterCreator
        });
        const player = createAudioPlayer({
            behaviors: {
                noSubscriber: NoSubscriberBehavior.Pause
            }
        });
        const resource = createAudioResource('./audio.mp3');
        player.play(resource);
        connection.subscribe(player);
        interaction.reply('playing :thumbsup:');
    }
}```
cosmic prawn

What's this AudioPlayerError: Status code: 403

Forbidden ik, but how it occurred

Please ping me on reply

carmine timber
cosmic prawn

Stream

carmine timber
carmine timber
frozen sierra

AudioResource.playbackDuration , what is returns ?

the time it has been played ? substracting paused time ?

wide mirage

Why discord.js/voice is getting all my ram ?

this issue has been already reported but no one care of this

With lavalink I have only 2gb used

so the issue is from this package

carmine timber
wide mirage

Is there an alternative to inLineVolume ?

cosmic prawn
carmine timber
cosmic prawn

Sad

carmine timber
cosmic prawn

Any alt, or fix

carmine timber
cosmic prawn

Okey

wide mirage

because my bot was using 18gb ram

leaden vapor

18gb ram wtf

cosmic prawn
cosmic prawn
wide mirage

I have 32gb on my server but...

cosmic prawn

blobsweats

cosmic prawn

My bot don't even need 1 gb ram

wide mirage
wide mirage
cosmic prawn

1 connection on 1 time, sometimes 2

wide mirage

yes me it's with 500 connections

cosmic prawn

And it plays music 5+ hours,

cosmic prawn

R u a verified bot dev

wary remnant

No, you can check badges yourself

cosmic prawn

Wooh , his bot has 2k+ servers

How he didn't got badge,

wary remnant

You can't get the badge anymore

cosmic prawn

Sad

wary remnant

Yeah, a lot of people would like that badge :D, the problem is people made bot and invited to 75 servers just to get the badge. Its "early verified bot developer" now, but let's keep off topic somewhere else

cosmic prawn

@wide mirage btw same hobby, I also like listening music while coding

cosmic prawn

:D

carmine timber
wide mirage

Hmm I will wait 👌

brazen pecan

How do I make my bot, automatically move to the speaking section of a stage channel?

dusty needleBOT

Documentation suggestion for @brazen pecan:
_ VoiceState#setSuppressed()
Suppress/unsuppress the user. Only applicable for stage channels.

subtle granite
brazen pecan

Is there a way to remove the Live now message at the top of the channels?
When using Stage channels

vapid kite

in v12 creating a broadcast was like this
client.voice.createBroadcast()
how is it now

wary remnant
sacred sluice
 const channel = message.member.voice.channel;

     if(!channel) return message.reply(`join voice channel`);

    const{
        createAudioPlayer,
        getVoiceConnection,
        joinVoiceChannel,
        NoSubscriberBehavior,
        createAudioResource
    } = require('@discordjs/voice');
    
    const connection = joinVoiceChannel({
        channelId: channel.id,
        guildId: message.guild.id,
        adapterCreator: message.guild.voiceAdapterCreator,
        getVoiceConnection: getVoiceConnection(message.guild.id)
    })

    const player = createAudioPlayer() 
    const song = createAudioResource('demosong.mp3')

    player.play(song)

    connection.subscribe(player);
     }

my bot is connecting but why it is not playing song?

rugged sky
sacred sluice
rugged sky

Great

stuck spindle

I am sorry I know how to use Voice in djs v12 but I am totally lost in djs v13 is there any way to use normal dispatcher on djs v13 ?

tired wind

Where is the docs for voice lib?

tired wind

Thanks!

mint pawn
TypeError: stream.on is not a function
    at destroyer (node:internal/streams/pipeline:41:10)
    at Function.pipeline (node:internal/streams/pipeline:209:21)
    at new AudioResource (C:\Users\HP\Desktop\ARYAN\dc-bot\node_modules\@discordjs\voice\dist\audio\AudioResource.js:29:57)
    at createAudioResource (C:\Users\HP\Desktop\ARYAN\dc-bot\node_modules\@discordjs\voice\dist\audio\AudioResource.js:159:12)
    at Music.playFirstTime (C:\Users\HP\Desktop\ARYAN\dc-bot\helpers\Music.js:162:24)
    at Object.execute (C:\Users\HP\Desktop\ARYAN\dc-bot\commands\slash-commands\play.js:62:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.execute (C:\Users\HP\Desktop\ARYAN\dc-bot\events\interactionCreate.js:27:17)```
why its showing like that there is no stream.on in ther code there dk what is creating it
wooden solstice

Which music package is good for spotify streams in a voice channel?

slender sparrow

you cant stream from spotify

wooden solstice

then how to play spotify in a voice channel?

slender sparrow

you cant

wooden solstice

ok

fervent estuary

you can use spotify song metadata to search it up and stream from another source

lucid sail

how to destroy the player?

open wraith

Guys, is there a way to access the AudioResource from the AudioPlayer object ?

serene silo

When creating a listening stream like this

    end: {
      behavior: EndBehaviorType.Manual,
    },
  });```
How do I manually end it? I tried doing ```connection.destroy()``` but that throws an error saying 'Premature close'
I tried looking into the voice api code but couldn't find anything
Appreciate the help, thanks 🙂
molten owl

I have the last version of opus and ffmpeg and ffmpeg-static

rugged sky
oak folio

is it possible to see which users in the same voice channel have muted my bot?

teal nymph

I got this error after updating to v0.7.0

downgrading to 0.6.0 worked

@steel crescent

open wraith
low needle

Hello. How to play songs in v13?

rugged sky
paper dawn

updated my bot to discordjs v14 a few days ago, and trying to port my voice playback code over, but hitting a bit problem: createAudioResource dumps this lovely error:

Require stack:
- _bot_\node_modules@discordjs\opus\lib\index.js
<snip>
Error: Cannot find module 'node-opus'
Require stack:
- _bot_\node_modules\prism-media\src\util\loader.js
<snip>
Error: Cannot find module 'opusscript'
Require stack:
- _bot_\node_modules\prism-media\src\util\loader.js
<snip>
at Object.loader [as require] (_bot_\node_modules\prism-media\src\util\loader.js:12:9)
at loadOpus (_bot_\node_modules\prism-media\src\opus\Opus.js:17:17)
at new OpusStream (_bot_\node_modules\prism-media\src\opus\Opus.js:46:10)
at new Encoder (_bot_\node_modules\prism-media\src\opus\Opus.js:149:5)
at Object.transformer (_bot_\node_modules@discordjs\voice\dist\audio\TransformerGraph.js:120:24)
at _bot_\node_modules@discordjs\voice\dist\audio\AudioResource.js:156:60
at Array.map (<anonymous>)
at createAudioResource (_bot_\node_modules@discordjs\voice\dist\audio\AudioResource.js:156:41)
at playFile (_bot_\build\misc\music core.js:230:61)
at refreshQueue (_bot_\build\misc\music core.js:218:23)```

no idea what cause this, and it worked just fine before the update, so any ideas?

low needle

Okay, i have a new question. How do i make my bot to leave from voice channel?

I didn`t found any information about that

rugged sky
paper dawn
low needle
paper dawn

I ask because the documentation says to install one, not all, so it doesn't seem like that's the right option

rugged sky

You should only need one.

You can try debugging dependencies.

paper dawn

yeah, everything looked correct there as well too

teal nymph
steel crescent

the same?

that can't be, I changed how I import it, the error should at least look different Thonkang

teal nymph

the generated index.mjs looks the same

it looks like the same error

steel crescent

ugh

I hate modules OMEGALUL

its fine if you downgrade to a version that works btw

no real "new" things got released

its all just for documentation purposes that I bumped it to 0.7.x

ill try to get this sorted out in the meantime

teal nymph

no problem, thank you

I checked index.mjs and found that

steel crescent

yeah just saw it too

teal nymph

but you changed that in your code so 🤔

steel crescent

I guess esbuild does some automatic optimizations for that

since we aren't using tsc

teal nymph

yes, maybe there is a flag to disable a specific optimization, idk

steel crescent

is it enough to import the voice module to get this error? @teal nymph

or do I need to call something specific

teal nymph

let me check

yes it is enough

steel crescent

aight

so if I manage to do this

import { VoiceConnection } from './dist/index.mjs';
console.log(VoiceConnection);

and get this

❯ node .\test.mjs
[class Z extends EventEmitter]

we should be fine right?

replacing the import with @discordjs/voice on your end obv

teal nymph

yes

steel crescent

perfect

ill publish a fix then

teal nymph

thx 😄

steel crescent

should be published as 0.7.2

teal nymph

libsodium-wrappers is installed

but now there is no more esm error

@discordjs/opus is also installed

steel crescent

🤔

can you try installing tweetnacl instead

teal nymph

still not found

steel crescent

that is interesting

is it feasible for you to try cjs instead of mjs?

just to see if it shows up there at all

teal nymph

yes

with cjs

steel crescent

ugh

expected as much

will investigate further

thanks for letting me know

teal nymph

no problem

for example const pkg = require(attemptedPath); (assuming attemptedPath is absolute)

const pkg = await import('file://' + attemptedPath)
quick lantern

why this error occurs?

i have this loop

this.on('startQueue', queue => {
    this.voiceConnection.subscribe(this.audioPlayer)
    this.audioPlayer.play(this.queue.first().resource)
    this.channel?.send(`Reproduciendo ${this.queue.first()}`).catch(()=>{})
})

this.audioPlayer.on('idle', async () => {
    this.history.add(this.queue.first())
    if(this.loop.mode == 0) this.queue.shift()
    else if(this.loop.mode == 1) this.queue.add(await this.queue.shift().restore())
    if(this.queue.size > 0) this.emit('startQueue', this.queue)
    else {
        console.log('disconnect')
        this.voiceConnection.disconnect()
        this.voiceConnection = null
    }
})

it works but stops at an hour or less approximately

teal nymph

@quick lantern are you using ytdl-core ?

quick lantern

yes

this.queue.first().resource is

createAudioResource(this.type == 'file' ? this.link : await ytdld(this.link, { highWaterMark: 1<<25, filter: 'audioonly' }))
teal nymph

your error is a known issue of ytdl-core

I'd recommend switching to play-dl

quick lantern

I will keep it in mind tnx

mint pawn

Is there any state change when we pause the player manually

fiery pond

reject Promise {
[
{
status: 'connecting',
adapter: [Object],
networking: [Networking]
},
{ status: 'ready', adapter: [Object], networking: [Networking] }
]
} AbortError: The operation was aborted
at abortListener (node:events:838:14)
at EventTarget.<anonymous> (node:events:874:47)
at EventTarget.[nodejs.internal.kHybridDispatch] (node:internal/event_target:562:20)
at EventTarget.dispatchEvent (node:internal/event_target:504:26)
at abortSignal (node:internal/abort_controller:97:10)
at AbortController.abort (node:internal/abort_controller:122:5)
at Object.entersState (D:\Programing\coding\My Code\v13 - Copy\node_modules@discordjs\voice\dist\util\entersState.js:20:56)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: 'ABORT_ERR'
how to fix

dark prairie
fiery pond

no i am using discord-player

carmine timber

Remove entersState from your code.

mint pawn

I cant find the get voice connection in the new docs at official page?had some things changed?

fiery pond
carmine timber
fiery pond
carmine timber
serene silo

Hi! Could someone tell me how to manually end an AudioReceiveStream https://discord.js.org/#/docs/voice/stable/class/AudioReceiveStream
I initialise it like this

    end: {
      behavior: EndBehaviorType.Manual,
    },
  });```
And then I try to output it in a file which works fine if my EndBehaviourType is silence or something but when I set it to manual and I destroy the opus stream it throws an error saying premature close, I tried looking at the docs but don't see a manual way to close it without throwing an error
Appreciate the help
grave pike

hi can someone explain to me what adapterCreator in joinVoiceChannel do and what should i type in it to work?

rugged sky
grave pike

oh ok thx

orchid thunder

hello there i use v13 how can i make bo join authors channel?

 message.guild.members.cache.get(user.id).voiceChannel.join();

TypeError: Cannot read properties of undefined (reading 'join')

rugged sky

To make it join the channel of the author of a message just get it with const channel = message.member.voice.channel.

serene meadow

NODE EVENT: Unhandled rejection: TypeError: voiceChannel.join is not a function

quiet phoenix
teal nymph

this is a known issue of v0.7.x when using the esm build

quiet phoenix

ty

rose helm

@carmine timber I hate to ping, but was there ever a resolution to memory leaking with inlineVolume?

bold jolt
carmine timber
rose helm

Blegh. Okay. I look forward to it

I did try to update Voice and prism to not use that duplex stream lib, but gave up and was tempted to just pipe everything through ffmpeg, but that's not ideal

carmine timber

Yep not ideal at all.

molten merlin

TypeError: channel.join is not a function having error help

alr thanks

oak folio

is there a way to seek music with the current discordjs

icy maple

Not atm

teal wyvernBOT
icy maple
teal wolf

How do I get decibals of a user

slim sigil

A question, is it possible to make my bot connect to multiple vcs? (and make it play different musics for each vc)

summer crow
slim sigil

oh

summer crow
summer crow
teal wolf I cant live stream it?

You can but you need to develop a system, because discord will stop sending audio packets if user stops speaking so yeah you need to resubscribe to the user

teal wolf

You mean djs not discord

whole vector
const { joinVoiceChannel } = require("@discordjs/voice");

client.on("ready", () => {

const channel = client.channels.cache.get("903660399268876349");
const guild = client.guilds.cache.get("881543330763259974");

joinVoiceChannel({ channelId: "903660399268876349", guildId: "881543330763259974", adapterCreator: guild.voiceAdapterCreator});

})

How to connect bot to voice? this code didn't work

help

rugged sky
whole vector ```js const { joinVoiceChannel } = require("@discordjs/voice"); client.on("read...

Are you sure you have the right IDs? It is often better in my experience to just get the guild ID from the guild as an object with guild.id and if you have the channel you want to connect to as an object you can get that ID in the same way. That way you're always sure the IDs are right.

In this case I am referring to the objects if you didn't get them by requesting them from the IDs manually in the first place of course.

subtle granite

or i just do ... client.channels.cache.get

rugged sky
wide mirage

This error occurs everytime

teal nymph

@whole vector you can get the guild from the channel

for the channel id you can use channel.id, and for the guild id channel.guild.id

rugged sky
whole vector

no error

teal nymph

console.log channel

whole vector

I did it, put it in the ready.js event and it worked

rugged sky
wide mirage
teal nymph
whole vector
teal nymph

I was talking about console.log

but okay

whole vector
grave pike

hi someone can help with this: Cannot play a resource that has already ended.

rugged sky
grave pike

Thx man

knotty widget

Is it possible to get the bot's voice ping?

sudden hawk

guys how can I get the voice channel id? I am making a lavalink music bot and to make the player I need the voice channel id

harsh oriole

how to set deafen to bot auto?
let server = client.guilds.cache.get(bot.server)
if(server) {
if(server.guild.me.voice){
server.guild.me.voice.setSelfDeaf(true)
}
}

subtle granite

could somuane help me?

full grove
subtle granite

i will share my code and then the error

this is my ready.js

const Discord = require("discord.js");
const { joinVoiceChannel, createAudioPlayer, createAudioResource, } = require("@discordjs/voice");
const fetch = require("node-fetch");
const client = new Discord.Client({  
    intents: [
    Discord.Intents.FLAGS.GUILDS,
    Discord.Intents.FLAGS.GUILD_MESSAGES,
    Discord.Intents.FLAGS.GUILD_MEMBERS,
    Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
    Discord.Intents.FLAGS.GUILD_WEBHOOKS,
    Discord.Intents.FLAGS.GUILD_VOICE_STATES,
    Discord.Intents.FLAGS.GUILD_INVITES,
    Discord.Intents.FLAGS.GUILD_BANS,
    Discord.Intents.FLAGS.GUILD_PRESENCES,
  ],
    ws: {properties: { $browser: "Discord IOS" }}
});

module.exports = async () => {
    console.log('EriksRoadhouseBluesBot is nu online!');
    console.log('Radio is begonnen en werkt perfect!');
    const connect = joinVoiceChannel({
      channelId: "904522891679379506",
      guildId: "901086504154169374",
      adapterCreator: client.guild.voiceAdapterCreator,
      });
    const audioPlayer = createAudioPlayer();
    const res = fetch("https://joeyjunge.radioca.st/stream.mp3");
    if (!res.ok) console.log("Der is een was een probleem tijdens het fetching!");
    const stream = res.body;
    const resource = createAudioResource(stream);
    connection.subscribe(audioPlayer.play(resource));
  }

now the error i get

PS C:\Users\semeg\Desktop\EriksRoadhouseBot> node .
EriksRoadhouseBluesBot is nu online!
Radio is begonnen en werkt perfect!
C:\Users\semeg\Desktop\EriksRoadhouseBot\events\client\ready.js:25
      adapterCreator: client.guild.voiceAdapterCreator,
                                   ^

TypeError: Cannot read properties of undefined (reading 'voiceAdapterCreator')
    at module.exports (C:\Users\semeg\Desktop\EriksRoadhouseBot\events\client\ready.js:25:36)
    at Client.emit (node:events:390:28)
    at WebSocketManager.triggerClientReady (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:383:17)
    at WebSocketManager.checkShardsReady (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:366:10)
    at WebSocketShard.<anonymous> (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:188:14)
    at WebSocketShard.emit (node:events:390:28)
    at WebSocketShard.checkReady (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:474:12)
    at WebSocketShard.onPacket (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:446:16)
    at WebSocketShard.onMessage (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10)
    at WebSocket.onMessage (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\ws\lib\event-target.js:199:18)

Node.js v17.0.1
subtle granite
full grove
subtle granite could you help me with this?

The problem is that your voiceAdapterCreator is for guild meaning you need get the specific guild and then get the voiceadaptercreator of that guild: client.guilds.cache.get('901086504154169374').voiceAdapterCreator

That should work

subtle granite

il try

subtle granite
PS C:\Users\semeg\Desktop\EriksRoadhouseBot> node .
EriksRoadhouseBluesBot is nu online!
Radio is begonnen en werkt perfect!
C:\Users\semeg\Desktop\EriksRoadhouseBot\events\client\ready.js:25
      adapterCreator: client.guilds.cache.get('901086504154169374').voiceAdapterCreator,
                                                                   ^

TypeError: Cannot read properties of undefined (reading 'voiceAdapterCreator')
    at module.exports (C:\Users\semeg\Desktop\EriksRoadhouseBot\events\client\ready.js:25:68)
    at Client.emit (node:events:390:28)
    at WebSocketManager.triggerClientReady (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:383:17)
    at WebSocketManager.checkShardsReady (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:366:10)
    at WebSocketShard.<anonymous> (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:188:14)
    at WebSocketShard.emit (node:events:390:28)
    at WebSocketShard.checkReady (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:474:12)
    at WebSocketShard.onPacket (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:446:16)
    at WebSocketShard.onMessage (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10)
    at WebSocket.onMessage (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\ws\lib\event-target.js:199:18)

Node.js v17.0.1
full grove
subtle granite

sure

it says

Collection(0) [Map] {}
full grove

Okay did you add the bot to a server?

subtle granite

Yes i did

but this is the error right? ```js
TypeError: Cannot read properties of undefined (reading 'voiceAdapterCreator')

full grove

Yes it is and that is because it cant find the server because the client doesn't have any servers which it should if the bot is added to a server

subtle granite

strange bc it is in a server

full grove

Do you have a client.login call?

where you use the bot token

subtle granite

yes

const Discord = require("discord.js");
require('dotenv').config();
const client = new Discord.Client({  
    intents: [
    Discord.Intents.FLAGS.GUILDS,
    Discord.Intents.FLAGS.GUILD_MESSAGES,
    Discord.Intents.FLAGS.GUILD_MEMBERS,
    Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
    Discord.Intents.FLAGS.GUILD_WEBHOOKS,
    Discord.Intents.FLAGS.GUILD_VOICE_STATES,
    Discord.Intents.FLAGS.GUILD_INVITES,
    Discord.Intents.FLAGS.GUILD_BANS,
    Discord.Intents.FLAGS.GUILD_PRESENCES,
  ],
    ws: {properties: { $browser: "Discord IOS" }}
});

const { DiscordTogether } = require('discord-together');
client.discordTogether = new DiscordTogether(client);

client.on('guildMemberAdd', async member => {
    let welcomeRole = member.guild.roles.cache.find(role => role.name === 'luisteraar🎶');
    member.roles.add(welcomeRole);
    const welcomechannel = client.channels.cache.get('903332220612255794');
    welcomechannel.send(`:wave: Hey ${member}, Welkom in ${member.guild.name}!`);
});

client.commands = new Discord.Collection();
client.events = new Discord.Collection();

['command_handler', 'event_handler'].forEach(handler =>{
    require(`./handlers/${handler}`)(client, Discord);
})

client.login(process.env.DISCORD_TOKEN);

this is the main.js

full grove

and is the radio code run on the client.once('ready', {function that runs on startup}) of the client because if it is run before hand the client has no data

subtle granite
full grove

Yeah the function gets called but that might be before the client is connected and ready and then it will still do the console.log but not the functions which need the client.

subtle granite

how do i fix that?

full grove

by running it once the client is ready with client.once('ready', {function that runs on startup})

subtle granite

now it says this ```js
PS C:\Users\semeg\Desktop\EriksRoadhouseBot> node .
EriksRoadhouseBluesBot is nu online!
EriksRoadhouseBluesBot is nu online!
Radio is begonnen en werkt perfect!
Der is een was een probleem tijdens het fetching!
node:internal/errors:464
ErrorCaptureStackTrace(err);
^

TypeError [ERR_INVALID_ARG_TYPE]: The "body" argument must be of type function or an instance of Blob, ReadableStream, WritableStream, Stream, Iterable, AsyncIterable, or Promise or { readable, writable } pair. Received undefined
at new NodeError (node:internal/errors:371:5)
at duplexify (node:internal/streams/duplexify:199:9)
at Function.Duplex.from (node:internal/streams/duplex:143:10)
at pipelineImpl (node:internal/streams/pipeline:245:22)
at pipeline (node:internal/streams/pipeline:169:10)
at new j (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules@discordjs\voice\dist\index.js:8:15591)
at je (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules@discordjs\voice\dist\index.js:8:17218)
at Client.<anonymous> (C:\Users\semeg\Desktop\EriksRoadhouseBot\main.js:49:22)
at Object.onceWrapper (node:events:510:26)
at Client.emit (node:events:402:35) {
code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v17.0.1

full grove

Yeah with fetch I don't really have any experience but it might be worth a try just putting the link directly into the audio resource because it can handle quite a decent amount of types

subtle granite

okay

subtle granite
full grove

const resource = createAudioResource("https://joeyjunge.radioca.st/stream.mp3");

subtle granite
full grove ```const resource = createAudioResource("https://joeyjunge.radioca.st/stream.mp3...

like this? ```js
client.once('ready', async () => {
console.log('EriksRoadhouseBluesBot is nu online!');
console.log('Radio is begonnen en werkt perfect!');
const connect = joinVoiceChannel({
channelId: "904522891679379506",
guildId: "901086504154169374",
adapterCreator: client.guilds.cache.get('901086504154169374').voiceAdapterCreator,
});
const audioPlayer = createAudioPlayer();
const resource = createAudioResource("https://joeyjunge.radioca.st/stream.mp3");
connection.subscribe(audioPlayer.play(resource));
});

full grove

Yes try that

subtle granite

okay

I get this error

full grove

Well first of all you are subscribing to 'connection' while the connection you created is called 'connect'

subtle granite

i changed that and i got the same error

subtle granite
full grove

Can you try first subscribing the player to the connection and then separately do player.play(resource)

because player.play returns a void which you cant subscribe

subtle granite

ohw okay i will try

subtle granite

i only have one question how do i change te volume bc its really loud xd

full grove

player.play(resource, {seek:0, volume: 1} where volume is mapped between 0 and 1

full grove
subtle granite

still thx hahhaa

subtle granite
full grove
subtle granite

thx

again 😋

ionic mulch

help


MinigetError: Status code: 403
    at ClientRequest.<anonymous> (/home/runner/Neox-Music-Bot/node_modules/miniget/dist/index.js:196:27)
    at Object.onceWrapper (events.js:421:26)
    at ClientRequest.emit (events.js:314:20)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:601:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:122:17)
    at TLSSocket.socketOnData (_http_client.js:474:22)
    at TLSSocket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at TLSSocket.Readable.push (_stream_readable.js:213:10)
Emitted 'error' event on PassThrough instance at:
    at errorOrDestroy (internal/streams/destroy.js:108:12)
    at PassThrough.onerror (_stream_readable.js:754:7)
    at PassThrough.emit (events.js:314:20)
    at PassThrough.emit (events.js:314:20)
    at ClientRequest.<anonymous> (/home/runner/Neox-Music-Bot/node_modules/miniget/dist/index.js:201:28)
    at Object.onceWrapper (events.js:421:26)
    [... lines matching original stack trace ...]
    at TLSSocket.socketOnData (_http_client.js:474:22) {
  statusCode: 403
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! evobot@0.9.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the evobot@0.9.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-10-31T02_03_09_404Z-debug.log
exit status 1```
subtle granite

what's this
Emitted 'error' event on AudioPlayer instance at: at OggDemuxer.onStreamError

vernal tapir

Hello guys ! just a little question. Do you guys know how to detect if someone is speaking on a voice channel ? I used voiceStateUpdate event but it's only for mute/leaf detection. Thanks!

oak folio

is there a way to set default volume for bot or the music it plays

subtle granite

is playing song from youtube in discord legal (with ytdl)?

soft talon

any one Sad_Boi

fervent estuary
subtle granite
fervent estuary

same thing

heres it mentioned in the youtube tos

south lark

Djs voice is capable of listening to multiple users continuously, correct?

signal tulip

anyone know why this is happening

chilly vortex

How would I attempt to merge AudioResources for playing, seen as you can't subscribe to 2 Players, and there is no function to Play without stopping/overriding the other sound playing, however I don't need it to be the merging tactic if there is a better or easier & cleaner way.
I've looked into using Prism-Media for playing and modifying an Opus Stream, however I feel that would be a little too overcomplicated.
My main goal is to be able to play multiple sounds all overlapping each other allowing for stacking of multiple sounds.
If anyone knows a way that I'd be able to do this which would be simple-ish and easy, please let me know, any help is appreciated.

shut olive

hey, i'm using the **demuxProbe **function, but I'm receiving this error: "Cannot probe a readable stream in object mode". My stream is created by ytdlCore. Anyone knows how to fix that?

subtle granite
 Error: Cannot find module '/home/ubuntu/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-linux-x64-glibc-2.31/opus.node```
stiff junco

Is there a way to sense if a user is speaking in a voice channel? i.e. a bool value that returns true if a person is speaking in a voice channel and false if not

whole flare

The last commitment was on July 6 so I don't think so

slate eagle

hey umm so i downloaded discordjs/voice and i tried doing this thing which they shoed in the documentation but my bot still doesnt join the vc. any help woule be appreciated

eternal laurel
slate eagle

ok

it logs this out but it doesnt join the vc. am i doing this function correctly?

nvm i got it

i had to give the id of the voice channel. but now the bot itself is deafened

whole flare

This is only joining the voice channel btw, not playing something

slate eagle

oh

im using this voice_connection inside a switch case where im using cases for commands like case 'play' case 'dc'. so assume that i created this connection in the case 'play'. then is there a way to disconnect the bot from the case 'dc'? i tried and i run into scoping errors.

lilac eagle

Hi! Is there anyone to "view" a stream through discordjs?

subtle granite

me

lilac eagle

Looking to capture video streams

limber elk

Hey, idk if this is related to the voice section,

but i want to make some kind of script that detects when a user joins a specific voicechannel name and then the bot should need to make a new voicechannel and move the user to that channel and name the channel. also when they leave it needs to get removed

wary remnant
lilac eagle

(Bump) anyway for a bot to watch a screencast?

fervent estuary

no

lilac eagle

😞

Thanks for your reply!

shut olive

hey, i'm using the **demuxProbe **function, but I'm receiving this error: "Cannot probe a readable stream in object mode". My stream is created by ytdlCore. Anyone knows how to fix that?

tidal lantern

Heyy, how can I check if a user is in a voice channel via an interaction? Do I need a special intent?

bold jolt

Does anyone here know how to use youtube-dl-exec? Any help would be much appreciated, I'm struggling quite a bit with it.
I looked at the pinned music bot example but for some reason I can't get it to work.

function createResource(url: any): Promise<AudioResource<any>> {
  return new Promise((resolve, reject) => {
    const process: any = youtubedl.raw(
      url,
      {
        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: any = process.stdout;
    const onError = (error: any) => {
      if (!process.killed) process.kill();
      stream.resume();
      reject(error);
    };
    process
      .once("spawn", () => {
        demuxProbe(stream) // https://discordjs.github.io/voice/modules.html#demuxprobe
          .then((probe: { stream: any; type: any }) =>
            resolve(
              createAudioResource(probe.stream, {
                // @ts-ignore: Unreachable code error
                metadata: this,
                inputType: probe.type,
              })
            )
          )
          .catch(onError);
      })
      .catch(onError);
  });
}```
hoary kernel

someone has idea?

eager wyvern

why is member after message? arent you trying to get the channelID of the message? @hoary kernel

hoary kernel

yep i try

eager wyvern

so shouldnt it be message.channelId

member represents the author of message, channelId isnt a property of GuildMembers

if ur trying to the text channel, it should go from message.channelId, but if ur getting the VOICE channel i think it would need to be message.member.voice.channelId

hoary kernel

im going for voice channel

eager wyvern

try the second option

hoary kernel

y try and this happen

eager wyvern
rugged sky
hoary kernel

all code

rugged sky
hoary kernel

an other folderwith name config.js

rugged sky
hoary kernel

ok but wait me i need find that

rugged sky
hoary kernel

yea im trying dif codes

but not one works

eager wyvern

are u just copy pasting from examples?

hoary kernel

no copy just a guidingme

eager wyvern

i dont really no code but it seems like it doesnt know how to find the voice channel ID of the requesting user

hoary kernel

yea i dunno how to find that

rugged sky

In the last error you sent it couldn't find the member that sent the message, possibly because you're referring to it wrong. I suspect in general it has to do with the definitions of your voiceChannel and guild variables, but can't say for sure until I see them.

hoary kernel

I can't find my definitions folder maybe I delete it and that's what's causing the error

eager wyvern

definitions folder? are you splitting all ur code into different files and folders

hoary kernel

yea i made a folder with all definition

or it doesnt works?

rugged sky
hoary kernel

i made it

rugged sky

But in general you should try to just keep them in the file scope, in DJS you can do that for the most part.

hoary kernel

@rugged sky i was guiding me in a guide for v13 im using v16, this affects in anything?

rugged sky
hoary kernel

oh

i was using a guide for node 13

frozen sierra

Is there any examples for seek command ? I want to change the position.

chilly vortex
subtle granite

The bot just suddenly stop with this error

this's the third time!

full grove
stiff junco

my bot is joining the channel but is not playing audio
I've even tried debugging with console.log but it says it already has the video.

what do i do?

stiff junco
full grove

ytdl

whole flare
bold jolt
whole flare

What you can do is instead of using the ytdl() function to create a playable stream, use the downloadFromInfo function. This also will return a playable stream but if I'm right you'll be able to catch the error with the error event listener. I'm not entirely sure but I thought this would work. Here is an example: ```js
const ytdl = require('ytdl-core');

(async () => {
var info = null;
try {
info = await ytdl.getInfo(https://www.youtube.com/watch?v=dQw4w9WgXcQ);
} catch (error) {
console.log(error);
}
const stream = ytdl.downloadFromInfo(info, {
quality: 'highestaudio',
filter: 'audioonly',
watermark: 1048576 * 32
});
})();

final jay

how do I know if the bot actually disconnected or was just moved to another voice channel?

whole flare
final jay

:/
but I wanted to see it in this event

rugged sky
final jay

but how am I going to connect this two?

rugged sky
final jay

in this event, "disconnected", I clear the queue and player in case the bot is disconnected

rugged sky
final jay

and there is literally no other way of checking?

rugged sky
final jay

okay, voiceStateUpdate is not detecting when I switch voice channels

just when I actually join/leave

nvm, I am stupid

neon cape

how can my bot disconnect people from voice channels?

rugged sky
neon cape

Thank you very much

jolly mason

how to make a bot leave a voice channel if i don't have the connection/audioresource/etc variables of its connection

rugged sky
pale jackal

I'm probably doing something wrong, but writing a stream from voiceConnection.receiver to a file and later trying to read it with a readStream and decode with prism.opus.Decoder produces an error, while passing the stream directly through the decoder works just fine. Is there something i'm missing?

Here's the error:

 1: 0xb21900 node::Abort() [node]
 2: 0xa361fc node::FatalError(char const*, char const*) [node]
 3: 0xa36205  [node]
 4: 0xaea96b napi_fatal_error [node]
 5: 0x7fbcbc09dc8e  [/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-linux-x64-glibc-2.31/opus.node]
 6: 0x7fbcbc09e3ec Napi::Error::ThrowAsJavaScriptException() const [/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-linux-x64-glibc-2.31/opus.node]
 7: 0x7fbcbc0aad68 OpusEncoder::Decode(Napi::CallbackInfo const&) [/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-linux-x64-glibc-2.31/opus.node]
 8: 0x7fbcbc0a12da Napi::InstanceWrap<OpusEncoder>::InstanceMethodCallbackWrapper(napi_env__*, napi_callback_info__*) [/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-linux-x64-glibc-2.31/opus.node]
 9: 0xacb54d  [node]
10: 0xd6c26e  [node]
11: 0xd6d68f v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
12: 0x160f579  [node]
[1]    30432 abort      node test.js```
short nimbus

how do you make a bot join a stage channel as a speaker in v13

spring ice

i got voiceChannel.join is not a function :-? can u guys tell me why?

valid marsh

It changed in v13.

See pins for a guide.

spring ice

ty

worldly obsidian

I was trying to run the example music bot but i can't get it to run, some one can help me?

worldly obsidian
valid marsh

In this channel

worldly obsidian

thank you

blissful vector

How would I get my bot to join & record a voice channel

subtle granite

Help me with this error?
```return await interaction.reply(Command currently in work and progress. Please use \s!help` for now!`)
^

TypeError: interaction.reply is not a function```

viral root
module.exports = (oldState, newState, client) => {
    if (newState.channelID === '905893574015615117') {
        if (client.channels.get('905893574015615117').members.size > 1) return client.channels.get('905893574015615117').members.forEach((member) => {member.send(`<${member.id}> There are more than one person in the queue.`)});
    } else if (!newState.channelID === '905893574015615117') return;
}```
voiceStateUpdate.js

2 people in vc yet its not doing anything

rugged sky
viral root
teal marten

why does a bot, after joining a voice channel on one server, immediately play what is already playing on another

subtle granite

Watermark?

earnest axle

Hey can anyone tell how to define client voiceChannel

@viral root

final jay

hey uh,
are we getting the old seek option for the new discordjs/voice?

vernal jasper

hey guys, how do i make my bot work on multiple vc's at once?

subtle granite
vernal jasper

in multiple guilds

teal marten

TypeError [ERR_INVALID_ARG_TYPE]: The "body" argument must be of type function or an instance of Blob, ReadableStream, WritableStream, Stream, Iterable, AsyncIterable, or Promise or { readable, writable } pair. Received null

const stream = interaction.options.getString('stream');
const resource = createAudioResource(stream, {
    inputType: StreamType.Arbitrary,
});
player.play(resource);
lucid sail
async setFilter(message, filter) {
    let queue = this.getQueue(message)
    queue.queue[0].status.filters.push(filter)


    let Encoder = await this.AllFilters(queue);
    
    let res = ytdl(queue.queue[0]?.next[0].song.Link, {
      opusEncoded: false,
      filter: "audioonly",
      quality: "highestaudio",
      encoderArgs: Encoder,
      highWaterMark: 1 << 25,
      seek: this.streamTime(message)
  })

    let reso = createAudioResource(res, {
      inlineVolume: true 
    })

    queue.player.play(reso, {
      
    })    
 queue.connection.subscribe(queue.player)
      
    this.emit("trackFilterAdded", message, filter)
  }```
filters are not working
round peak

anyone have a good example link for youtube with discord js?

civic furnace
viral root
astral bolt

hey, if i want to play a song after short time the song will aborted and it send this ERROR: errored: Error: aborted

formal lodge

How to install FFmpeg

dusty needleBOT

• NPM: npm install ffmpeg-static
• Install: Download | chocolatey | homebrew | your distributions package manager
• Tutorial: YouTube
• ffmpeg-binaries is deprecated, uninstall it with npm rm ffmpeg-binaries

teal marten

TypeError [ERR_INVALID_ARG_TYPE]: The "body" argument must be of type function or an instance of Blob, ReadableStream, WritableStream, Stream, Iterable, AsyncIterable, or Promise or { readable, writable } pair. Received null

const stream = interaction.options.getString('stream');
const resource = createAudioResource(stream, {
    inputType: StreamType.Arbitrary,
});
player.play(resource);
dusty needleBOT

To help you we need more information:
• What are you trying to do?
• What is your code?
• What errors and debug logs do you have?

small roost
client.on("interactionCreate",
async interaction=>{
    if(!interaction.isCommand()) return
    if(interaction.commandName==="vc" && interaction.inGuild()){
        if(!interaction.member.voice.channel) return interaction.reply({content:"JOIN A VC first"})
        interaction.reply("Joining VC...")
        let connection = joinVoiceChannel({
            guildid:interaction.guild.id,
            channelId:interaction.member.voice.channel.id,
            adapterCreator:interaction.guild.voiceAdapterCreator
        })
        let player = createAudioPlayer();
        let resource = createAudioResource('https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3', {
            inputType:Voice.StreamType.arbitary
        })
        player.play(resource)
        await entersState(player, Voice.AudioPlayerStatus.Playing, 10e3)
        try{
            await entersState(connection, Voice.VoiceConnectionStatus.Ready, 10e3)
            interaction.editReply({content:"Joined VC"})
            connection.subscribe(player)    
        }catch(e){
            connection.destroy()
            interaction.editReply({content:e.message});
    console.error(e)
        console.log("Failed to connect to VC")
        }
    }
})

Always aborts and logs "failed to connect to VC" to console and does not show up in my VC

Core dependencies report from Voice.generateDependencyReport():

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

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

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

FFmpeg
- version: 4.4-static https://johnvansickle.com/ffmpeg/ 
- libopus: yes
--------------------------------------------------
icy maple
small roost
keen sail

node-opus is deprecated?

ripe orchid

yes

whole flare
wide mirage

What about the memory leak problem ?

you said that it will be fixed soon. It's not normal that your module uses 10gb ram after 1h

dry spruce

When discordjs/voice will fix that ram usage problem

spring ice

this.currPlayingResource = await nextTrack.createAudioResource(); this.audioPlayer.play(this.currPlayingResource);
guys how can i play again my currPlayingResource after it's ended?

little geyser

does .play use ffmpeg

brisk jasper

Cannot play audio as no valid encryption package is installed.
What packages do i need for discord.js/voice to play?

random zodiac

How do I get the current speaking users in a voice channel?

valid marsh
random zodiac
dire fossil

hello, Is there a seek option in the v13 as in the v12 ?

final jay
ocean garnet

Hey there, I am struggling with getting my bot to play a song. I think I did everything the way it said in the official guide and I just can't figure out how to get it to work. The Bot successfully connects to the voice channel and I don't get any error messages. Some advice would be much appreciated!

const { createAudioPlayer, NoSubscriberBehavior, createAudioResource, getVoiceConnection } = require('@discordjs/voice');
const { config } = require("../config.json");

module.exports = {
    data: new SlashCommandBuilder()
        .setName('play')
        .setDescription('Play song'),
    async execute(interaction) {
        const connection = getVoiceConnection("419444179404455937");

        const player = createAudioPlayer({
            behaviors: {
                noSubscriber: NoSubscriberBehavior.Pause,
            },
        });
        const resource = createAudioResource('../music/test.mp3');
        player.play(resource);
        player.on('error', error => {
            console.error(`Error: ${error.message} with resource ${error.resource.metadata.title}`);
            player.play(getNextResource());
        });

        connection.subscribe(player);
    },
};```
versed apex

how do I get audioplayers the voiceconnection is subscribed to?

icy maple
lapis kraken

My bot is not playing an audio file. It successfully connects to the vc and does not throw any errors. This is the typescript code i am using```
const connection = voice.joinVoiceChannel({
channelId: args[0],
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
});
const player = voice.createAudioPlayer();
const resource = voice.createAudioResource('test.mp3');
player.play(resource);
connection.subscribe(player);

neon cape

how can my bot become speaker in a stage channel?

dusty needleBOT

Documentation suggestion for @neon cape:
_ VoiceState#setSuppressed()
Suppress/unsuppress the user. Only applicable for stage channels.

digital bobcat

Why does the bot stops playing the resource after a few seconds although the resource stream is longer (10 seconds)? This happens only in short audio streams.

rose helm

If you probe the stream, you should pass the probe.stream to the AudioResource because probing the stream could read it to the end.

worldly obsidian

i have a smillar issue, the player raises an error after starts playing the stream, the stream is like 2 minutes but the player only plays like 20 seconds

worldly obsidian
    at connResetException (node:internal/errors:691:14)
    at TLSSocket.socketCloseListener (node:_http_client:407:19)
    at TLSSocket.emit (node:events:402:35)
    at TLSSocket.emit (node:domain:475:12)
    at node:net:687:12
    at TCP.done (node:_tls_wrap:580:7) {
  resource: j {
    playStream: OggDemuxer {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 5,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      _remainder: null,
      _head: null,
      _bitstream: null,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: [Function: bound onwrite]
    },
    edges: [ [Object], [Object] ],
    metadata: null,
    volume: undefined,
    encoder: undefined,
    audioPlayer: H {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _state: [Object],
      subscribers: [Array],
      behaviors: [Object],
      debug: [Function (anonymous)],
      [Symbol(kCapture)]: false
    },
    playbackDuration: 125760,
    started: true,
    silencePaddingFrames: 5,
    silenceRemaining: 5
  }
}```

So im constantly getting this error at exacly 125760 ms (~2:05 minutes) i dont think its a problem with the stream im getting from ytdl, anyone was seen this before?

carmine timber
worldly obsidian

thanks

final jay

why is it asking for all this packages?

I already have libsodium-wrappers installed!

digital bobcat

You must install one of these packages: @discordjs/opus (I recommend this), opusscript or node-opus

final jay
digital bobcat
final jay
digital bobcat

Okay

spring ice

guys can u give me the link of package FFmpeg to play youtube music 😄

teal marten

TypeError [ERR_INVALID_ARG_TYPE]: The "body" argument must be of type function or an instance of Blob, ReadableStream, WritableStream, Stream, Iterable, AsyncIterable, or Promise or { readable, writable } pair. Received null

const stream = interaction.options.getString('stream');
const resource = createAudioResource(stream, {
    inputType: StreamType.Arbitrary,
});
player.play(resource);
midnight heath

How to check if the bot is playing something to avoid new play

subtle granite

How can I make a speaker when the bot enters the stage channel ? ;-;

valid marsh

npm install @discordjs/voice libsodium-wrappers

Yes

worldly obsidian
reef perch

Hi, how can I use Stage Channels in Discord.js v12?

reef perch
twilit lion
azure bough

How would I detect when a user joins a specific voice channel? (since this bot is exclusive to one channel, the Join To Create VC won't change)

final jay

how do I create a seek command?

high whale
client.on('voiceStateUpdate', (oldMember, newMember) => {
    let newUserChannel = newMember.voiceChannel
    let oldUserChannel = oldMember.voiceChannel

    newMember.send("welcome to vc")
})``` no error. it doesn't send anything either. I want it to send a message to a user when thye join a vc
round peak

When i go from playing a youtube clip to playing a local file my player goes from idle to buffering but then never to playing and will abort out after a few seconds. I am not sure how to trace it or debug it. any help appreciated

icy maple
fiery pond

How to Update this code to djs v13

  const voicechannel = message.member.voice.channel;
    if (!voicechannel) return message.channel.send("Please join a voice channel first!");

    const connection = await message.member.voice.channel.join();
    const receiver = connection.receiver.createStream(message.member, {
        mode: "pcm",
        end: "silence"
    });

    const writer = receiver.pipe(fs.createWriteStream(`./recorded-${message.author.id}.pcm`));
    writer.on("finish", () => {
        message.member.voice.channel.leave();
        message.channel.send("Finished writing audio");
    });```
dusty needleBOT
icy maple

Well, leaving is <Connection>.destroy()

midnight heath

anybody have idea

    const connection = await connectToChannel(msg?.member?.voice?.channel as VoiceChannel);
        // serverInfo!.connection = connection;

        if (serverInfo?.audioPlayer?.state.status === AudioPlayerStatus.Playing) {
            return msg.channel.send(
                trans('soundboard.join.speaking', sLng, {
                    author: Util.escapeMarkdown(msg.author.tag)
                })
            );
        }

        let res = await streamTTS(tts_language, content);
        const player = createAudioPlayer();
        serverInfo!.audioPlayer = player;
        const resource = createAudioResource(res.data);
        resource?.volume?.setVolume(2);
        player.play(resource);
        connection.subscribe(player);
teal marten

how to get metadata from a stream?

dusty needleBOT
zenith zealot

Are music bots still something doable?

subtle granite

I think so?

It may not be allowed however you can still make some. Probably in future versions of discordjs they will remove the function to play music in a vc?

round peak
fiery pond

how to send mp3 files in discord.js in channel

whole flare
dusty needleBOT
final jay

whops, sorry

subtle granite

any vc pros willing to help in dms? its a kinda big bug and i dont wanna do it here cuz 1. it will take a lot of time and we will lose our msgs and 2. dms is better for this

whole flare
subtle granite
whole flare

Yes

high whale
final jay

Is @discordjs/voice abandoned?

or maybe @discordjs/opus?

fervent estuary

neither is abandoned

random zodiac

how would i convert this: let audioStream = connection.receiver.createStream(user, { mode: 'pcm' }) to Discord js v13?

lost fiber

is it possible to play audio from a url into vc?
(url thats not from youtube

rich yacht

You have to find a way to get the stream and pipe it to the player

narrow grotto

I want to play a mp3 livestream but it dont work

let sender = interaction.options.getString("Sender");
        const voice = require("@discordjs/voice");
        const connection = voice.joinVoiceChannel({
            channelId: 872006664348401709,
            guildId: interaction.guild.id,
            adapterCreator: interaction.guild.voiceAdapterCreator
        });
        const audioplayer = voice.createAudioPlayer();
        connection.subscribe(audioplayer);
        audioplayer.play(sender)

Any Idea?

teal wolf

Noww does anybody know how to get live bute data from voice

strong oracle

Hello i got this code:

      var VC = msg.member.voice.channel;
            if (!VC)
                return msg.reply("MESSAGE IF NOT IN A VOICE CHANNEL")
        VC.join()
            .then(connection => {
                const dispatcher = connection.play('giorno.mp3', { volume: 1 });

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

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

            })
            .catch(console.error);

But it dont play music just connects to channel

fervent estuary

V12 voice is not supported

strong oracle

oh thx so much i was wondering why

humble chasm

Hello,
Can I still play music in a vocal channel?

honest shuttle
narrow grotto
honest shuttle

something similar

Haven't looked into it, i stream only from yt

narrow grotto

I dont find any alternatives

narrow grotto
icy maple
digital bobcat

How to make a voice receiver that is in PCM format?

foggy hatch

is AudioPlayerStauts#Playing the same as the old "start" event?

ancient valley

@compact tide was helping me with this so dont say i stole his code, but I'm really confused with the VC API as it was changed. what do i need to change to make my join VC command work again? thanks!

            case "joinvc":
                const s = e.member.voice.channel;
                s ? s.join().then(() => {
                    msgReply(e, generateBotMessageEmbed("Connected", `I'm now in \`${s.name}\`, happy?\nFor me to leave, just use -leaveVC, I will automatically disconnect in 10 minutes if I'm left alone.`, 7935)),
                        client.user.setPresence({
                            activity: {
                                name: `to ${s.name}, because ${e.member.displayName} forced me to`,
                                type: "LISTENING"
                            },
                            status: "IDLE"
                        })
                }
                ).catch(t => {
                    console.log(t),
                        msgReply(e, generateBotMessageEmbed("Error", `Could not connect to \`${s.name}\` for some reason.`, 13369344))
                }
                ) : msgReply(e, generateBotMessageEmbed("Error", "You're not in a voice channel!", 13369344));
                break;
            case "leavevc":
                const o = Platform.mainGuildF.members.cache.get(client.user.id).voice.channel;
                o ? (o.leave(),
                    client.user.setPresence(Platform.lastStatus),
                    msgReply(e, generateBotMessageEmbed("Disconnected", `I was ejected from the VC, AKA \`${o.name}\` I guess.\n*PROTIP: To make me rejoin a VC, Just use -joinVC*`, 7935))) : msgReply(e, generateBotMessageEmbed("Error", "I'm not in a voice channel...", 13369344));
                break;
teal wolf

Does anybody know how to get live data from voice

earnest mountain

Hi guys!
I want to be able to reuse discorvoice audioResource's. The only way I can think of to do this is to duplicate the stream and then create two seperate AudioResources every time. This ofcourse requires double the memory and likely some extra computation aswell. Is there any other way that makes this possible? I am trying to do this to be able to 'cache' certain resources for instant playback as they require a good 1.5s to obtain.

umbral junco

Can someone give me an example or how to actually code the bot of playing an audio clip

quartz crescent

hi, is there any way a bot can connect to a stage type voice channel?

stiff junco

how do I make a volume command?? basically I want to alter the volume using a listener..

dense turtle

home/ubuntu/Manbo/node_modules/@discordjs/voice/dist/index.js:1
import path from "path";
^^^^^^

SyntaxError: Cannot use import statement outside a module
uhh it worked at right befor today, i dont have any idea why this is happening

can i get some help w this?

dire ledge

Hey,
I'm trying to play an mp3 file over voice chat, I've built my bot similar to the 'dynamically executing commands' example.

Then I built a command, which joins VC and should play an audio file, right now its just a rickroll mp3.
But when I try to join I get this error in the 'entersState' method:

DiscordAPIError: Unknown interaction
    at RequestHandler.execute (C:\GitProjects\LTTStoreDotCom\node_modules\discord.js\src\rest\RequestHandler.js:349:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\GitProjects\LTTStoreDotCom\node_modules\discord.js\src\rest\RequestHandler.js:50:14
)
    at async CommandInteraction.deferReply (C:\GitProjects\LTTStoreDotCom\node_modules\discord.js\src\structures\interfa
ces\InteractionResponses.js:57:5) {
  method: 'post',
  path: '/interactions/908285328564060210/aW50ZXJhY3Rpb246OTA4Mjg1MzI4NTY0MDYwMjEwOkxKc0FGcFZ3QlRlNG15MkRhc0llY0NkRVZvMm
5lWHVaR0drdmxkbTZvdVhyZ3JCRFhRM0ZzOHlQTGJmbWJpZURSVlFpb3lXcnlDSDlBNHIzQzNYQ2xZREN3OG93S0tFajJRaTJ1dzhCSWNqVDNZanFJM3hrQT
FWaXZ6dWcwb3o0/callback',
  code: 10062,
  httpStatus: 404,
  requestData: { json: { type: 5, data: [Object] }, files: [] }
} unhandledRejection
AbortError: The operation was aborted
    at abortListener (node:events:838:14)
    at EventTarget.<anonymous> (node:events:874:47)
    at EventTarget.[nodejs.internal.kHybridDispatch] (node:internal/event_target:559:20)
    at EventTarget.dispatchEvent (node:internal/event_target:504:26)
    at abortSignal (node:internal/abort_controller:97:10)
    at AbortController.abort (node:internal/abort_controller:122:5)
    at Timeout.<anonymous> (C:\GitProjects\LTTStoreDotCom\node_modules\@discordjs\voice\dist\index.js:9:420)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7) {
  code: 'ABORT_ERR'
}

This is the code I'm using:

const { SlashCommandBuilder } = require('@discordjs/builders')
const { createReadStream } = require('fs')
const { join } = require('path')
const { joinVoiceChannel, createAudioResource, createAudioPlayer, NoSubscriberBehavior , demuxProbe, entersState,
    VoiceConnectionStatus
} = require('@discordjs/voice')

module.exports = {
    data: new SlashCommandBuilder()
        .setName('ltt')
        .setDescription('Plays a random ltt advert in voice chat.'),
    async connectoToChannel(channel) {
        const connection = joinVoiceChannel({
            channelId: channel.id,
            guildId: channel.guild.id,
            adapterCreator: channel.guild.voiceAdapterCreator,
        });
        try {
            await entersState(connection, VoiceConnectionStatus.Ready, 5_000); // <-- Error gets thrown here
            return connection;
        } catch (error) {
            connection.destroy();
            throw error;
        }
    },
    async probeAndCreateResource(readbaleStream) {
        const {stream, type} = await demuxProbe(readbaleStream)
        return createAudioResource(stream, {inputType: type})
    },
    async execute(interaction) {

        console.log('Playing Advert')
        interaction.deferReply({ ephemeral: true })
        const member = interaction.member;
        const channel = member.voice.channel
        if (!channel || !channel.joinable) {
            return interaction.reply({
                content: `You must be connected to a voice channel in order to use this command`,
                ephemeral: true
            })
        }

        const connection = await this.connectoToChannel(channel)
        connection.on('stateChange', ((oldState, newState) => {
            console.log(`Connection transitioned from ${oldState.status} to ${newState.status}`)
        }))

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

        player.on('stateChange', ((oldState, newState) => {
            console.log(`Connection transitioned from ${oldState.status} to ${newState.status}`)
        }))

        player.on('error', error => {
            console.error('Error:', error.message, 'with track', error.resource.metadata.title)
        });

        const filePath = join(__dirname, 'media/rick.mp3')
        console.log(filePath)
        const readStream = createReadStream(filePath)
        const resource = await this.probeAndCreateResource(readStream)
        console.log(resource)
        player.play(resource)
        connection.subscribe(player)
        return interaction.reply({content: 'LTT STORE DOT COM!', ephemeral: true})
    },
};
teal marten

/app/node_modules/@discordjs/voice/dist/index.js:1
import path from "path";
^^^^^^
SyntaxError: Cannot use import statement outside a module

pine oar

i got the same error ^^

coral mural
torn marlin
coral mural

doing npm install @discordjs/voice@0.7.2 should be a workaround for now until they revert/fix it

bleak karma
/src/user/app/node_modules/@discordjs/voice/dist/index.js:1
import path from "path";
^^^^^^

SyntaxError: Cannot use import statement outside a module
open tulip

What is this error for ??

bleak karma
robust cove

same

vagrant mirage
robust cove

Downgrading the package works. Do npm i @discordjs/voice@0.7.2

vagrant mirage

In your package.json do "type": "module"

glad charm
wary remnant

Make it leave the channel if music is not playing

foggy hatch

Is inline volume so bad?

main ferry

how do i get my bot to join a channel?

dull flame

how I can downgrade the @discordjs/voice version to 0.7.2?

dreamy drum
main ferry
dreamy drum
main ferry
dreamy drum
const Voice = require('@discordjs/voice');
const voiceChannel = message.member.voice;
let player = Voice.joinVoiceChannel({
                channelId: voiceChannel.channel.id,
                guildId: voiceChannel.channel.guild.id,
                adapterCreator: voiceChannel.channel.guild.voiceAdapterCreator,
                selfDeaf: true,
            });

            try {
                await Voice.entersState(
                    player,
                    Voice.VoiceConnectionStatus.Ready,
                    20000
                );
            } catch(e) {
                console.log(e)
                const embed = new Discord.MessageEmbed()
                    .setDescription(
                        `**Failed to join voice channel within 20 seconds, please try again later!**`
                    );
                message.channel.send({ embeds: [embed] });
                return;
            }
``` an example if you confused
reef perch

im getting this error guys

dull flame
client.once('ready', async () => {
    console.log('A revenit botu ca boxiour din pumni');
    const connect = joinVoiceChannel({
        channelId: "783047893065924611",
        guildId: "395576333310230558",
        adapterCreator: client.guilds.cache.get('783047892243447809').voiceAdapterCreator,
        selfDeaf: true,
      });
    const audioPlayer = createAudioPlayer();
    const resource = createAudioResource("https://youtube.com/Hlbbn2pduqE?list=RDHlbbn2pduqE");
    connect.subscribe(audioPlayer);
    audioPlayer.play(resource);
  });

I use this code, but the bot doesn't connect to the channel, why?

dreamy drum
dreamy drum
dull flame

ty

reef perch
dreamy drum
teal nymph
dull flame still doesn't connect

replace client.guilds.cache.get('783047892243447809') by client.guilds.cache.get('395576333310230558') because 395576333310230558 is your guild id

you can remove selfDeaf which defaults to true

fleet glen

I have problem with finding all users connected to a voice channel. Sometimes it works sometimes it doesnt.
I personally never have problems, but when users run the command it sometimes doesnt work What do you guys think im missing?

teal nymph

can you show more?

fleet glen
teal nymph

and replace newSize.length by newSize

fleet glen
teal nymph

your var is "newSize"

fleet glen

yeah sorry the naming was wrong :)

teal nymph

I was thinking it was a size >.<

fleet glen

fixed naming

teal nymph
fleet glen
teal nymph

I am not sure about that, but is there any error ?

fleet glen

but the big difference is im not there in the chat

teal nymph

voiceUsers is empty when the error occurs ?

fleet glen

Yep

teal nymph

did you check voice.members also?

fleet glen

will check that as a double check

teal nymph

try

const voiceChannel = await interaction.guild.channels.cache.get(process.env.voiceId)
await interaction.guild.members.fetch()
const voiceUsers = voiceChannel.members
console.log(`There are ${voiceUsers.size} users in the voice channel.`)
for (const [, voiceUser] of voiceUsers) {
  await voiceUser.voice.disconnect()
}

@fleet glen

fleet glen
teal nymph

no pb

teal nymph
fleet glen
teal nymph
voiceUsers.forEach(async voiceUser => {
  await voiceUser.voice.disconnect()
})

I think forEach will run asynchronously so it could be safer to use for because it will wait until all users are disconnected

teal mountain

Does anyone have an example of how to get an "in" and "out" audio stream from a discord voice channel? I was checking out the examples from https://github.com/discordjs/voice/blob/main/examples and was trying to figure out what I actually need to create in order for this to work. Coming from good ol' discord.js master back when v12 was a dream, v13 is a little confusing for me so I maybe missing something. Any help is appreciated.

uncut oriole

what's my error?

dull flame

where I can find some documentation about yt-search?

umbral blade
dull flame

yep

rugged sky
neat wing

Hi, I'm having a problem with audio player automatically pausing itself.
I did several tests related with this issue but none of them worked for me:

  • Tried logging subscribe count every time state changes and saw that subscriber was not changing
  • Tried playing a song after subscribing to a voice channel

Versions:

  • @discordjs/voice: 0.7.5
  • discord.js: 13.1.0
  • @discordjs/opus: 0.5.3

Code:

      const resource = await createAudioResource(
        "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3",
        {
          inputType: StreamType.Arbitrary,
        }
      );

      player.play(resource);

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

      connection.subscribe(player);

To be clear data variable inherits Message class and contains extra information related with bot.

coral mica

How do I resume dispatcher?
dispatcher.resume() doesn't work

fervent estuary

v12 voice is not supported anymore

whole flare

What is line and when does the event gets emitted?

dry spruce

When inlineVolume memory leak fix?

latent forge

Why is opus not working at all for me? I try to install and it just says it’s failed and I’m not too sure why

Wait nevermind

real reef

hello i have a problem with the player

when i try to play a song, the player goes on playing state and then on autopaused state without playing the music

winged plover

So, am I crazy or is the voice module completely busted up when joining a VC using joinVoiceChannel - there is nothing wrong with my code from what I can tell, but I keep getting the most bizzare error of s is not a function

Moved from the general help channels^

I've been sitting here for an hour trying to figure this out and I don't think it's my code. I could share it if need be

rugged sky
winged plover

Aight, gimme 1 sec