#archive-voice

30636 messages · Page 25 of 31

slender sparrow

you should read changelog for v13

hardy relic

Is there a way for me to check what's currently playing on an audio player?
Or do I have to keep track of that manually?

grizzled vessel
grizzled vessel
glad tiger

This is my code, how can I make my bot leave the channel after it's done speaking?

    const call = args.join(" ");
    if (!call)
      return message.reply(
        `Emergency Services was not contacted as you did not mention a reason for them to come.`
      );
    const stream = TTS.getVoiceStream(call);
    const audioResource = createAudioResource(stream, {
      inputType: StreamType.Arbitrary,
      inlineVolume: true,
    });
    if (
      !voiceConnection ||
      voiceConnection?.status === VoiceConnectionStatus.Disconnected
    ) {
      voiceConnection = joinVoiceChannel({
        channelId: "927568962139590677",
        guildId: message.guildId,
        adapterCreator: message.guild.voiceAdapterCreator,
      });
      voiceConnection = await entersState(
        voiceConnection,
        VoiceConnectionStatus.Connecting,
        5_000
      );
    }

    if (voiceConnection.status === VoiceConnectionStatus.Connected) {
      voiceConnection.subscribe(audioPlayer);
      audioPlayer.play(audioResource);
      message.reply(`Contacting Emergency Services\n> ${call}`)
    }
subtle granite

I don't want to record it, i want to hear what someone is saying and check if someone said: "play" or "stop" or "skip" and etc..

junior glen

Somebody experienced that it is not possible to play something after some time when ytdl was used?

const stream = ytdl(url, {filter: 'audioonly'});
resource = createAudioResource(stream, {inlineVolume: true, inputType: StreamType.OggOpus});
junior glen

looks like it has the same problem

junior glen

and youtube-dl does not have any explanation how to read as stream or it is not supported...

junior glen

Neither ytdl nor play-dl is working.

  • play something via ytdl or play-dl
  • after that play a file
  • player is stuck in buffering

Note: I'm re-using the AudioPlayer instance

idk if just discord.js is a huge mess...
if I provide the file via createStream instead of just the path, it is not stuck in buffering

brave blaze

Hey, does anyone know how to choose what client you want to connect?

brave blaze

?

wispy aurora

Is there a way of having silence and sometimes add a Sound into that so the bot starts with the playing and then starts Listening so am able to add a Sound from a mp3 file into that silence so the Sound gets played insted of trying so send Sound after i started listening

blissful hearth

`
const ytdl = require('ytdl-core');
const ytSearch = require('yt-search');

module.exports = {
name: 'play',
description: 'Joins and play a youtube video',
async execute(message, args) {
const voiceChannel = message.member.voice.channel;

    if (!voiceChannel) return message.channel.send('You need to join a voice channel to use this command dumbass.');
    const permissions = voiceChannel.permissionsFor(message.client.user);
    if(!permissions.has('CONNECT')) return message.channel.send(' You lack the required perms, peasant.');
    if(!permissions.has('SPEAK')) return message.channel.send(' You lack the required perms, peasant.');
    if (!args.length) return message.channel.send('You must add a link or a keyword, stupid.');

    const connection = await voiceChannel.join();

`
error says: voiceChannel.join(); is not a function

dusty needleBOT
grizzled vessel

Can anyone help?

quaint meteor

I made a music bot which works with play-dl it works but when adding another song to my queue the music stops for a short time and I dont know how to solve this. This is the code where I add a song to the queue:

var song;
if(!message.content.startsWith("https")){
    const {videos} = await yts(message.content);
    if (!videos.length) return message.reply("No songs were found!");
    song = {
        title: videos[0].title,
        stream: await (await playdl.stream(videos[0].url)).stream,
        url: videos[0].url
    };
}else if(playdl.yt_validate(message.content) === "video"){
    const vid = await playdl.video_info(message.content)
    song = {
                title: vid.video_details.title,
        stream: await playdl.stream_from_info(vid),
        url: message.content
    };    
}else{
    message.reply("URL isn't valid").then(msg => setTimeout(() => {msg.delete()},              10000));
    return;
}
setTimeout(() => {message.delete()}, 4000);
message.reply("Song was added! "+song.url).then(msg => setTimeout(() => {msg.delete()}, 10000));
if(musicqueue.length == 0){
    playmusic(song.stream);
}
musicqueue.push(song);
updateQueue(message);
frail blaze

Just a quick question, is it possible to get access to voice-channels webcam feeds?

sacred lintel
vagrant garnet
soft burrow
nimble island

Anyone know a package that counts time on the Voice Channel?

and displays the top voice?

rose helm

time on the VoiceChannel can easily be done by just storing Date.now() somewhere when you join the voice channel.
As for "displays the top voice"; You're kinda being ambiguous here

grizzled parrot

GuildMemberSpeaking
It still works ?

icy maple
grizzled parrot
icy maple

You would have to make use of the VoiceReceiver from the voice package

Tho, I would just remove it if it’s a useless feature

grizzled parrot

but i use v12

icy maple

Then it should still work with the same restrictions

dusty needleBOT

Documentation suggestion from @storm storm:
_ VoiceState
Represents the voice state for a Guild Member.

cerulean topaz
 WARN  Issues with peer dependencies found
.
└─┬ @discordjs/voice
  └─┬ prism-media
    └── ✕ unmet peer @discordjs/opus@^0.5.0: found 0.7.0

Shall I use @discordjs/opus@0.5.3 (auto downloaded as dependency) or 0.7.0 (from pnpm add) then?

pseudo forum

npm i @discordjs/opus@latest

cerulean topaz

yeah, so 0.7.0, just as I did

pseudo forum

0.7.0 yes

cerulean topaz

gotta deal with annoying WARN then, thanks

subtle granite

This is correct if am not wrong

const connection = voice.joinVoiceChannel({
guildId: interaction.guild.id,
channelId: interaction.guild.members.cache.get(interaction.user.id).voice.channel.id,
adapterCreator: interaction.guild.voiceAdapterCreator
})
const player = voice.createAudioPlayer()
const res = voice.createAudioResource(stations[num - 1].url)
player.play(res)
connection.subscribe(player)

but it doesnt play anything

subtle granite

can anyone reply?

rugged sky
subtle granite
rugged sky

Nope

You can use other libraries to get a readable stream from a url. Often ytdl-core or play-dl are used to get a stream of a youtube video from the url for example. I'm sure there's a package that works for you.

subtle granite

okay

open tulip

is there any problem with this code ? https://sourceb.in/BtyPqB84zt
because for example sometimes connect to wrong voice
or
im not mute but send me mute err
or
im connect to voice but told me that you are not in any voice

rugged sky
open tulip

oh
nope
XD

how can i check that bot is talking or no ?

i mean when someone play voice 1 and another one play voice 2 after that bot tell him that i am playing voice 1 and i cant play your voice rn

open tulip
rugged sky
rugged sky
open tulip
rugged sky
open tulip

ok got it

next leaf

Hello, when the bot stop playing the music when he is alone on the channel for a long time ?

quaint meteor

When I play music with play-dl and than play music via mp3 streams no sound comes up does anyone know whats the problem?

lofty basin

How can i check, when an audio / song finish?

mossy ether

Hi guys!
How could I increase performance?
I have a working music bot with queue system using play-dl. The problem is the audio is very laggy and it's crackling sometimes. Even if I type a new song to play and press enter the playing stops for about 1 sec.
My internet connection is good, 150/50 Mbps, so I don't think that would be an issue.

shut zenith

How do I check if my bot is in a voice channel?

mossy ether

EU Central

shut zenith

Like you check if a member is in a voicechannel with <member>.voice.channel what do I need to check if the bot is in a voice channel?

mossy ether

why? should I host it on a hosting service?

woeful dove
modest nebula

I have a bot that is trying to join 800ish voice channels on different servers and it is unable to establish connection on any of them. I have it in multiple shard but it sill cant seem to handle that. Is this just something beyond discord js capabilities?

mossy ether

What about free hosting services likes heroku glitch or repl.it? I saw some people telling that heroku is not the best...

woeful dove

well, i have a music bot that uses heroku, it works fine

i created my own queue system so that it optimize the computing power

mossy ether

My bot is only for one server

Okay, then I'll try out some hosting. I hope it'll be better

woeful dove
mossy ether

I don't have one

woeful dove

what i do is i use github, edit on my local machine, then push to github then my bot updates on heroku

mossy ether

that's quite handy.

median sleet

I am trying to detect if a specific user is speaking.... I am newer to coding but have been scouring the docs and cant understand how to use it appropriately I would assume I can use Voice.SpeakingMap somehow since it has a users property on it but cant seem to even get it working in my code. Anyone have any ideas on speakingmap?

mossy ether
quaint meteor
timid wharf

hey im still confused with this package (even after the examples) Thonkang

timid wharf

is the packages below required to be downloaded?
(if not what should i download here)

icy maple

Top is the recommended one (usually gives best performance, mainly for production)

lean storm

can this module play music?

timid wharf

(also how do i setup this package)
so lets say i have an mp3 file how do i join a vc and play that file 🤔

icy maple
icy maple
timid wharf

alright POGGERS

lean storm
tall tangle

how do I create an AudioResource with ytdl?

I am new to discord.js/voice

rugged sky
tall tangle

how do I change the volume of an existing track that playing?

if i used player.play(resource)

rugged sky
fading pollen

Is there any way to check if a song/audiofile has ended?

In V12 you had something like dispatcher.once('finish', ()) But how do you do this in V13?

fading pollen

omg thank you, I feel stupid 😂

still elm

Hey so I am wondering about the memory usage of my bot (I think I have a leak somewhere, but I can't find it)
I have one of those usual yt music bots and run it via pm2.
If repeatedly tell my bot to play something and disconnect over and over again, after a while it uses near to 200mb of RAM which seems kinda out of order to me. (It uses around 60mb after startup)
This leak only appears to happen for the voice stuff, as my image command (the usual "enter tag", fetch images from api, post) works just fine and the memory usage returns to around 60mb.

Has someone got an idea maybe? (should I send the code I use for the playback?)

still elm

And this is the code I use for disconnecting:

export const disconnect = async function disconnect(guildId) {
    return cleanUp(guildId);
}

async function cleanUp(guildId) {
    const connection = getVoiceConnection(guildId);
    if (connection) {
        connection.subscribtion.unsubscribe(player);
        connection.subscribtion = null;
        connection.destroy();
    }
    if (queue) queue = null;
    if (player) {
        const ret = player.stop();
        player = null;
        return ret;
    }
    return false;
}
mossy ether
still elm
quick geyser
Encountered error on command "play" at path "G:\New folder (4)\namemc-namechecker\bot\commands\play.js" TypeError: Cannot read properties of undefined (reading 'once')
    at H.play (G:\New folder (4)\namemc-namechecker\node_modules\.pnpm\@discordjs+voice@0.7.5_7dc12e6632e2c96122987847b0dba7c5\node_modules\@discordjs\voice\dist\index.js:8:430)
``` why is this happening?
molten ridge

idk why I'm getting these error messages, when I have the packages installed

rose helm

The packages are installed, but the properties of opus you're reading don't exist

cloud vine

hello, im trying to kick my bot if no one is in channel for x seconds. Im using .leave but i get typeerror .leave is not a function. What should i use instead of leave?

icy maple

<connection>.destroy()

cloud vine

Like this?

client.on('voiceStateUpdate', (oldState, newState) => {

  if (oldState.channelID !==  oldState.guild.me.voice.channelID || newState.channel)
    return;

  if (!oldState.channel.members.size - 1) 
    setTimeout(() => { 
      if (!oldState.channel.members.size - 1) 
         oldState.channel.destroy(); // leave
     }, 5000); // 300000
});
icy maple

You need the voice connection

Also, that if statement is faulty due to operator precedence

Use getVoiceConnection(guildId) to get the current voice connection

cloud vine

Ok now i do like this and it doesnt crash but bot doesnt leave the channel after 5000 ms

client.on('voiceStateUpdate', (oldState, newState) => {

  if (oldState.channelID !==  oldState.guild.me.voice.channelID || newState.channel)
    return;

  if (!oldState.channel.members.size - 1) 
    setTimeout(() => { 
      if (!oldState.channel.members.size - 1) {
         //oldState.channel.destroy(); // leave
         var voiceConn = getVoiceConnection(oldState.guild.me.voice.channelID);
         if (voiceConn) {
           voiceConn.destroy();
         }
      }
     }, 5000); // 300000
});
tall tangle

what does it mean?

The expected type comes from property 'adapterCreator' which is declared here on type 'JoinVoiceChannelOptions & CreateVoiceConnectionOptions'

        let queue = client.queue.get(interaction.guild?.id!)
        
        let voice_channel = member.voice.channel;

        const connection = joinVoiceChannel({
            channelId: voice_channel!.id,
            guildId: interaction.guild!.id,
            adapterCreator: interaction.guild!.voiceAdapterCreator, 
        });
``` this is the code

nvm

humble vale

How can i receive voice?

tall tangle

is there a way to change the volume level of a playing resource?

real vapor

anyone know how to play from soundcloud or spotify?

drowsy dew
fluid garden

Hi, question, I have a music bot that supports both youtube and file URLs my problem is, after playing a youtube video no files will play only other youtube videos, any help is appreciated

(Ping reply please)

chilly zinc

I’m using one resource URL to play audio. Is there a way to improve the quality and functionality to be flawless? Like should I make a new resource every time when a user types a command for bot to join?

chrome sundial

i have noticed that my bot, which uses slightly modificated version of MusicSubscriptions in the examples/music-bot, doesnt clear these two handles everytime i use function stop() any ideas why its doing this note: it does properly dispose all handles when music is ended properly without stoping

still elm

Is there a way to preload videos for djs-voice and ytdl-core (I am calling the play stuff in a timeout function)?

fluid garden
whole flare Can you please provide a code

apologies for the late reply

    if(this.playing.has(guild.id))return;
    const musicData = await this.fetchMusicData(guild);
    if(!musicData) return;
    try {
      this.playing.add(guild.id);
      var player = music.createAudioPlayer();
      var connection = music.joinVoiceChannel({
          channelId: VC.id,
          guildId: VC.guild.id,
          adapterCreator: VC.guild.voiceAdapterCreator,
      })
        await music.entersState(connection, "ready", 30e3);
        if(!connection) return;
        connection.subscribe(player);
        var resource = music.createAudioResource(musicData.queue[0].URL); // <- string for files and whatever ytdl produces for yt
        player.play(resource);

        player.on(music.AudioPlayerStatus.Idle, async () => {
        if(!musicData.queue[1]) {
            musicData.queue.shift();
            this.playing.delete(guild.id);
            connection.destroy();
            return;
        } else {
            musicData.queue.shift();
            this.playing.delete(guild.id);
            await functions.playMusic(guild, VC, functions).catch(() => {null;});
        }
      })
    } catch(e) {
      console.log(e);
      this.playing.delete(guild.id);
    }```
icy maple

Would recommend using play-dl

fluid garden

alright thanks

fluid garden

before playing a video, no problems but after the queue won't play any mp3 files

icy maple

Then it’s prob smth wrong with the functions.playMusic function

fluid garden

also the code should be this.playMusic(), just haven't redone my old code yet

icy maple

ytdl only takes yt urls, not file paths

fluid garden

ik

my problem is after a youtube video completes, the format YTDL provides seems to ruin something and nothing except other youtube videos converted through ytdl will play

I am trying to see if anyone knows what it's messing up with their experience

icy maple

That seems far-fetched

Are you getting an error?

From the code you shown, it doesn’t seem like ur handling yt urls differently from file paths

I am assuming that music is just the voice package, not a special object with the same exports as the voice package. Especially since you have a separate functions variable

fluid garden
fluid garden
icy maple

It’s being added to the same queue

fluid garden

yes

icy maple

So the functions.playMusic function must be able to handle both types of urls

fluid garden

everything works until a youtube video plays and then the queue stops and won't play anymore .mp3s

icy maple

Where are you adding to queue actually?

fluid garden

for play-file I add the file attachment URL https://discord.com/attachment/whatever and for play-yt it is whatever YTDL's output is

ytdl puts out some sort of stream

icy maple

Where are you adding the song to queue?

fluid garden

I'll fetch an example

@icy maple

and for pushing .mp3s, we just push the Discord attachment URL

icy maple

That doesn’t rly answer my question

I’m asking where are you adding the song to queue? As in show the line(s) in the code that add the song to the queue

fluid garden
//in my exports
//...
queue: {};
//...

//in my add song files
//...
//after fetching the queue for the quild
queue.queue.push({name: "song", tags: [], URL: <the ytdl result or attachment URL>, source: `${interaction.member.user.tag}`})
//...
fair crag

really new to voice, forgive me if i am being blind,

when someone joins the voice channel, make a new channel is my intention, but when they leave the voice channel it makes another channel. is there a way to determine when someone joins / leaves?

client.on('voiceStateUpdate', async (oldState, newState) => {
    const primarychannel = newState.channelId;
        const newID = newState.id;
        const oldID = oldState.id;
        console.log(`old ${oldID}`);
        console.log(`new ${newID}`);
        newState.guild.channels.create(`temporary`, {
          type: 'GUILD_VOICE',
          position: 256,
    })
});

is there a property that can help me count the amount of users in the voicestate?

figured it out

nevermind

red spire

I'm trying to find out when a user is talking. I can do it very well in v12 with this code

connection.on('speaking', async (user, speaking) => {
          if (speaking.has('SPEAKING')) {

            console.log(`${user.username} Speaking !`);
          }
         })

but i tried in v13 it doesn't work, i tried to explore files such as index.d.ts in v12 and in v13 i noticed that the function didn't exist anymore, did v13 bring an alternative to access the audio of a user?

runic mantle

AbortError: The operation was aborted why does this happen?

languid magnet

How to avoid getting rate limited by Miniget!
Please help me.

languid magnet
tulip elbow
languid magnet
tulip elbow

ok

abstract acorn
chrome sundial
glass nexus

if I want my bot to join a voice channel when someone joins a voice channel using voiceStateUpdate (unless there's already a user in said channel) how to I check to make sure the bot isn't already in a channel? sorry if this is a dumb question

pulsar trout

kk

fluid garden

nvm

gritty gyro

is it possible for an existing bot to play music? because I just want to have my existing bot to join and play a specific playlist

I was able to have it automatically join but it doesn't play music

or have it play music I have downloaded on my pc

subtle granite

why isnt my bot playing attachments? it was working before when .join() was still a function```js
const stream=msg.attachments.first().proxyURL
const resource=createAudioResource(stream,{inlineVolume: true})
resource.volume.setVolume(text.substring(5, text.length))
player.play(resource)

subtle granite
 assignAudioConnection(msg.guild.id,voice.channelId,msg.guild.voiceAdapterCreator).then(connect => {
      const player=createAudioPlayer()
      connect.subscribe(player)
subtle granite

why

just show bruhhhhhh, how I know your everything defined

my codes 470 lines

subtle granite

code not code line bruhhhhh

msg is the guildmember message

const {joinVoiceChannel, getVoiceConnection, createAudioPlayer, createAudioResource}=require("@discordjs/voice")

its working for ytdl-core but not attachments

did you join the channel first?

subtle granite
subtle granite
red spire

How to get the event when a user speaks from AudioReceiveStream of receiver.subscribe(user.id) ?

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

  const receiver = connection.receiver;

  var capture = receiver.subscribe(message.author.id);

  capture.on('data', async (user) => 
  {
    await console.log(`${user} a fini de parler`);
  });

I have tried every type of event possible and never get one

gritty gyro

does someone know whats wrong with my code?

formal vale
chrome raptor

Hi, I'm trying to install @discordjs/opus but I always get that error:

npm ERR! code 126
npm ERR! path /home/musicbot/node_modules/@discordjs/opus
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! sh: 1: node-pre-gyp: Permission denied

npm ERR! A complete log of this run can be found in: /path/to/logfile.log

I'm using Ubuntu server 64 bit on my raspberry pi. Running npm install @discordjs/opus as root throws the same error.

Edit: I tried nodejs 16 and 17 but none of them works.

abstract acorn

what about other packages?


is it just me or voice channel connection API is broken again

quasi oar
gritty gyro

does anyone know whats wrong with this?

rose helm

Not djs voice related

but I will tell you that string.setDescription is not a function

fading pollen

Is it possible to do something after a song is playing for example 30 seconds?

fading pollen

Ah, i found a way!

patent breach

What is the best way to have the bot join a specific channel in every server it's in?

Like if the voice channel name is
24/7 radio
it will join and start playing from a specific channel

teal sleet

Is there an event dispatcher for when the bot gets DC'ed from a vc? or any sort of event dispatcher for vc events, I tried taking a look at the documentation but couldn't find anything about it as it seems to be unfinished?

icy maple

It’ll become destroyed after disconnected

I believe this was explained in the guide somewhere

Or nvm, it’ll start signaling a little after being disconnected

dusty needleBOT
patent breach
          if (this.shard.status !== Status.READY) return false;
                         ^

TypeError: Cannot read properties of undefined (reading 'status')
``` tried a bunch of different things any idea why this is happening
stiff junco

when i run my distube bot with
client.distube = new distube(client, { searchSongs: false, emitNewSongOnly: true})
it says distube is not a constructor, can someone help??

abstract acorn

My bot is experiencing Error: Unexpected server response: 525 and AbortError: The operation was aborted errors, do anyone also get the error when the bot is joining a voice channel?

vale cloak

it dosent say anything about supporting ras pi4 on the github for discordjs/opus and i get an error when i try to install it is there an alternative way to install?

subtle granite

It doesn't work, according to the guide it should join the channel and play the audio file

frank kelp
subtle granite

you should probably subscribe to the player before playing.
probably going to want to add the file extension to the resource path as well

frank kelp

connection.subscribe(player)

subtle granite
frank kelp

read my initial message again

subtle granite

it joins but it doesnt reproduce the file

@frank kelp

frank kelp

have you done this

probably going to want to add the file extension to the resource path as well

subtle granite

@frank kelp found the problem, intents xd

GUILD_VOICE_STATES

patent breach

Again any idea why I keep getting this

          if (this.shard.status !== Status.READY) return false;
                         ^

TypeError: Cannot read properties of undefined (reading 'status')```
subtle granite

is there any guide on receiving audio from users in voice channels? Or any examples of how to use Voice.VoiceReceiver?

frank kelp
subtle granite

I was reading over that example earlier, the problem is I couldn’t get prism to work no matter what I did so I’m looking for examples that don’t use it.

Ty anyway though

stiff junco
marble gust Show code

I worked it out, you had to require it with .default

const Distube = require("distube").default;
client.distube = new Distube(client, { searchSongs: false, emitNewSongOnly: true})```
thanks for asking though
patent breach
hallow jolt

pls help me out withthis error

young bough

But where is your error

hallow jolt
young bough

And what you provided isn't djs, neither is it voice

hallow jolt

pls anyone help me out with this

icy maple
dusty needleBOT
icy maple

Guide tells you what you need to provide

hallow jolt
icy maple

It tells you the proper way to call it

hallow jolt
icy maple

<Member>.voice.channelId or .channel to get the full VoiceChannel

hallow jolt
icy maple

<Member>.voice.channel gives a voice channel

hallow jolt
icy maple

No

hallow jolt
icy maple

I showed how to get a voice channel from a member so you can use it

icy maple
hallow jolt
icy maple

You have to provide an object into joinVoiceChannel

With the properties shown in the guide

hallow jolt
void storm

what did they change VoiceChannel#Join to?

cerulean matrix

how can I get the boit join in staged channel as speaker ?

final jay

if the bot has permission, it will become a speaker, otherwise, the bot will request to speak

cerulean matrix

thanks ❤️

final jay

maybe

you're looking to make the bot join a voice channel?

void storm
final jay

woah woah woah

void storm

lololol

final jay

I ain't help you coding your entire bot

void storm

i tried using one off a tutorial and now it wont work since its in v12

void storm
final jay

well

that is as simple as reading, "video is not defined"

void storm

ye but look const video = await videoFinder(args.join(' '));

white viper

how can I make the bot always stay same channel (when its disconnected it will rejoin or move to another channel rejoin old channel again) with voiceStateUpdate ?

void storm
final jay that is as simple as reading, "video is not defined"
        const connection = joinVoiceChannel({ channelId: message.member.voice.channel, guildId: message.guild.id, adapterCreator: message.guild.voiceAdapterCreator });
        const stream = ytdl(video.url, { filter: 'audioonly' });
        const player = createAudioPlayer();
        const resource = createAudioResource(stream);

        async function play() {
            await player.play(resource);
            connection.subscribe(player);
            
        }
        
        const videoFinder = async (query) => {
            const videoResult = await ytSearch(query);
            return (videoResult.videos.length > 1) ? videoResult.videos[0] : null;
        }

        const video = await videoFinder(args.join(' '));
    }
}```
final jay

videoFinder to ytSearch
some crazy stuff going on uh?

subtle granite

Ey how do if nobody join to channel this bot no search a id?

prime jewel

Hi again. Is there a way to get a player element, from a specific guild and voice channel? Like, in Djs 11-12 you could get the connection(and dispatcher) by joining channel, that you're in. But Djs 13 does not have a connection/dispatcher, only AudioPlayer. And how can I get it from a specific guild and vc, like I could do with connection object?

proper sundial
prime jewel
proper sundial
prime jewel

i know how to join vc, but question is - How to get a PLAYER object?

proper sundial

Oh i get2

prime jewel
prime jewel
proper sundial

wait let me think first

proper sundial
prime jewel
proper sundial

Wait

prime jewel

so we can subscribe player to connection

and if it is global - control it
but I want get the player that is associated with some vc/connection

and get it everywhere, when the other connections have different players, and I control for example, only player #32, when all other players continue playing their file

Before i did this for getting a player(dispatcher) object

           if (typeof message.member.voiceChannel !== 'undefined') {
      message.member.voiceChannel.join()
        .then(connection => { connection.dispatcher.pause();
          message.channel.send('Paused.')
 });

in djs 11, but now in djs 13 I can't do this, because there is no dispatcher! Only audioplayer.

prime jewel
proper sundial
proper sundial

If i late respon meant i didnt get it ^^

prime jewel
proper sundial

I didnt get :(

prime jewel

k

proud sonnet

Djs voice is what ya'll use for music bots?

acoustic mountain

ye

patent breach

Again any idea why I keep getting this

          if (this.shard.status !== Status.READY) return false;
                         ^

TypeError: Cannot read properties of undefined (reading 'status')```
prime obsidian
untold wharf

I need help

how to write connection.play() in discord.js 13 cuz it's not viewed as a function any longer

eager lake

You should read the pinned guide, voice has changed

untold wharf

ahhh lemme check

seems like this needs lot of read through which my weak point currently !! can any1 gimme a quick hint

untold wharf

I don't even know how to read that document

patent breach
prime obsidian
patent breach

Ah

It’s only when trying to do the radio stream

prime obsidian

@patent breach try to do a console log reading the shard variable before that stage.

subtle granite

how do i get an AudioPlayer's status without using the statusChange event?

atomic compass

Is there any way to change voice region to the country which they live to fix music bot lag

wide mirage

You're joking?

You don't care about this at all 😂

minor bison

voice has been moved to the d.js mono-repo

wide mirage

and what about the memory leaks?

Are they going to be fixed?

subtle granite

Good morning ! Right now I want to create a script that displays the number of :

  • selfDeaf users
  • selfMute users,
  • users with selfVideo
  • users who streaming
  • users serverDeaf
  • users serverMute

However, when I enter the voiceinfo command, I get the following error: TypeError: voiceChannel.members.selfDeaf is not a function

I managed to display the total number of people in voice in the server but no more...

Can you help me please ??
The bot is coded in discord.js v12.5.3 with node 14
Thank you

pallid nimbus

how do i play a mp3 file and not a yt video

final jay
bright moth
rose helm
rose helm

Theoretically, no code changes should be necessary

silver raven

Hi, For some reason I started getting this random error. I wanted to ask and see what the issue is in hopes I can solve it https://sourceb.in/79ECgTqply

patent breach

Hey @rose helm mind if I dm regarding a few questions on discord js voice

atomic compass

Is there any way to change voice region to the country which they live to fix music bot lag

rose helm

You can map voice nodes to regions and select nodes based off what you strip out

atomic compass
dusty needleBOT

Documentation suggestion for @atomic compass:
_ Client#voice
The voice manager of the client

rose helm

There are no docs for what I mentioned. That's all on you

atomic compass
atomic compass
bright moth

When i try to queue a stream if the bot is already playing a stream the previous stream just cuts out for a second or so. Is that like a thing that is supposed to happen or hardware issue (but i doubt that), or just my code is trash?

subtle granite
rose helm

in this case, members is not defined, You'll need to do

for (const [_, voiceChannel] of voiceChannels) {
  count += voiceChannel.members.size;
  voiceChannel.members.forEach(member => {
    if (somePropertyOnMember) countForThisProperty++; // not literally these variables obviously.
    if (someOtherPropertyOnMember) otherCount++;
  });
}
subtle granite

thumbsup thank you very much for your help oooh

rose helm

Like I mentioned though, this is basic JS knowledge, so I would highly recommend learning the language's paradigms and such before considering continuing much further and I'm not saying that to discourage you. You will be faced with much resistance if you continue without a comprehensive knowledge of JS

subtle granite

Thank you for your advice. I will learn more about the documentation oooh

bright moth

btw by stream i ment a song

rose helm

Could be a multitude of things such as the process locking for whatever reason. A Queue should just be pushing basic info to an Array and then fetching the data when actually needed instead of fetching it as it's requested as it can be removed by the user at any time.
In my case, I prefetch songs only if they're up next and always check if the songs are fetched or not and fetch if necessary on play

Depending on how many tracks you have queued, queueing more can exhaust system resources if you're fetching as they're being requested. Also quite wasteful on bandwidth and can get you banned from services

wide mirage

This module is depreacted

rose helm

I'm not joking. The solution to the memory leak is that simple

wide mirage

Nop. Opusscript has lots of bugs

else i will use it

rose helm

I'm using it in production and there are no issues. If you're having issues, it's on your end

wide mirage
rose helm

Volcano is a lavalink rewrite using Discord.js/voice

wide mirage

Yes, that's good when you have 10k servers

rose helm

What's your point

icy maple
wide mirage

Il forgot, sorry 😕 i'll try to see with opusscript

wide mirage

That's due to connection errors

bright moth

meguFace and i kinda don't know what to do about that

rose helm

That is not how to do it. If you absolutely must do it the way you're doing it, offload the work onto a worker_thread

subtle granite

So I followed your syntax like that but when I switch to voice command, there is only the variable count (total users in voice) that works. The other variables remain at 0 😅

icy maple
subtle granite

plz help

TypeError: Database is not a constructor

full error code = TypeError: Database is not a constructor at Object.<anonymous> (C:\Users\saksh\Desktop\Brandan Final\index.js:21:13) at Module._compile (node:internal/modules/cjs/loader:1097:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10) at Module.load (node:internal/modules/cjs/loader:975:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:17:47

plz help someone

subtle granite
icy maple Did you enable the guild voice states intent?

Async said " i can filter over all of the members of a voice channel and check all of the properties i want to accumulate and increment the values i desire , and it is
basic JS and not djs-voice related "
so I don't know if I should use the voicestate as you say or use the method he suggested to me... I guess there are several ways to do it but honestly it's a bit complicated for me XD

subtle granite
subtle granite

I've found some type problems between @discordjs/voice - DiscordGatewayAdapterCreator and discord.js - Guild.voiceAdapterCreator

// voiceChannel = Discord.VoiceChannel
joinVoiceChannel({
  channelId: voiceChannel.id,
  guildId: voiceChannel.guild.id,
  adapterCreator: voiceChannel.guild.voiceAdapterCreator, // Type Error
});

Seems like type dismatch between DiscordGatewayAdapterCreator and InternalDiscordGatewayAdapterCreator.
How to deal with this problem?

btw, currently works Guild.voiceAdapterCreator to any type. (but.. I think any type is not good with typescript)

joinVoiceChannel({
  channelId: voiceChannel.id,
  guildId: voiceChannel.guild.id,
  adapterCreator: voiceChannel.guild.voiceAdapterCreator as any,
});
tough axle

How to map voice nodes to regions

wide mirage

@rose helm opusscript didn't changed anything 👌

carmine timber
carmine timber
wide mirage

see

carmine timber

Or simply do npm ls @discordjs/opus

wide mirage

uh

carmine timber

Magic 😂😂

wide mirage

And then how can i remove the package? bc npm uninstall doesn't works

carmine timber
solar dew

Unhandled promise rejection: TypeError: channel.join is not a function

iam getting this error

const channel = await interaction.member.guild.channels.cache.get(voiceChannelId);
    if (!channel) return console.error("The channel does not exist!");
    const connection = await channel.join();


rose helm
solar dew

const receiver = connection.receiver.subscribe(559899420582477847, { });
const writer = receiver.pipe(fs.createWriteStream('./recording.pcm'),);

its not working at all

rose helm

Pretty sure subscribe doesn't accept an int as the first parameter. Check the docs to see what it does accept

rose helm

LaceShrug

IDs are supposed to be strings. Not ints

subtle granite
solar dew
rose helm

That's why I said read the docs

solar dew
 const receiver = connection.receiver.subscribe('559899420582477847', {
            mode: "pcm",
            end: "silence",
          });

        const writer = receiver.pipe(fs.createWriteStream('./recording.pcm'));

        writer.on('data', (chunk) => {
            console.log('hghhhghghj');
            writer.write(chunk)
        })

solar dew
solar dew
rose helm

Seems like it does accept an ID first

Since that's the case, I'm not sure how to help you. All I know is IDs are supposed to be strings

solar dew

@rose helm same issues

rose helm

HibikiShrug

solar dew

🥲 that mean i need to remove discord js and make my on

silver raven

Why do I keep getting this error?

  [
    { status: 'connecting', adapter: [Object], networking: [te] },
    { status: 'ready', adapter: [Object], networking: [te] }
  ]
} 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 wt(/Users/kavishgulati/Desktop/Github/brainbotdev/node_modules/@discordjs/voice/dist/index.js:9:680)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ABORT_ERR'
}
prime jewel

Hi everyone. How can I set volume for bot?

subtle granite
pseudo forum

why getVoiceConnections().size gives 0 and client.guilds.cache.filter((guild) => guild.me.voice.channel).size gives 1?

icy maple

Prob didn’t gracefully destroy the connection when you restarted the bot

Discord still thinks ur connected, until it realizes you aren’t

pseudo forum

but like yesterday I didn't reboot my bot since some days

keen flower

hey mates,
is there any way to record all voice from a channel. like subscribe the channel or somethin?

thanks for help 🙂

ripe jungle

whats wrong??

pure quest
ripe jungle

Error:

pure quest
ripe jungle
pure quest

I'd suggest following a guide, or watching a few videos to learn basic JS if you don't know how to resolve this error. FYI - you're missing that module 👍

carmine timber
carmine timber
ripe jungle
carmine timber
carmine timber
ripe jungle
carmine timber
ripe jungle how? idk rly man 😅 error:
const channel = ( message | interaction ).member.voice.channel

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

Just this only

carmine timber

👍

ripe jungle
carmine timber
ripe jungle
fiery pond

how to check someone disconnect bot from vc ?

dusty needleBOT

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

fiery pond
carmine timber
fiery pond
carmine timber
fiery pond
carmine timber Show me your intents
 intents: [
    Intents.FLAGS.GUILDS,
    Intents.FLAGS.GUILD_MEMBERS,
    // Intents.FLAGS.GUILD_BANS,
    Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
    //Intents.FLAGS.GUILD_INTEGRATIONS,
    //Intents.FLAGS.GUILD_WEBHOOKS,
    //Intents.FLAGS.GUILD_INVITES,
    Intents.FLAGS.GUILD_VOICE_STATES,
    //Intents.FLAGS.GUILD_PRESENCES,
    Intents.FLAGS.GUILD_MESSAGES,
    Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
    //Intents.FLAGS.GUILD_MESSAGE_TYPING,
    // Intents.FLAGS.DIRECT_MESSAGES,
    Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
    //Intents.FLAGS.DIRECT_MESSAGE_TYPING,
  ],```
carmine timber
  if (!ns.guild.me.voice.channel?.id) {
    client.updateembed(client, os.guild);
    joinVC(client, os.guild.id);
    console.log(`done`);
  }

@fiery pond Try this one

rose helm

might want to console log in the voice state update event unless that's all the code in the voice state update event.

You'll need to find where the code is returning before it reaches the code you're showing

violet thorn

Hello! Why does my bot show it's connected to a voice channel in a server even though it isn't
The voice state events are messed up

subtle granite
violet thorn

even though it isn't connected to these channels, it shows their ids

rose helm

That could possibly happen if you restart the bot while it's in a voice channel. GUILD_CREATE data includes a voice_states field which could include your client's. Bots can usually restart completely before Discord auto disconnects them from a voice channel if they don't reconnect before that window.

violet thorn
icy maple

Wdym by "manually" disconnecting the bot?

icy maple

Did you enable the guild voice states intent?

violet thorn
fleet ice

Guys

is there solve for that error?

carmine timber
fleet ice

okay i will try

onyx copper

Hey folks, I'm having an issue where after streaming audio with ytdl-core, streaming local files no longer works, even after creating completely fresh players and resources. I've seen similar issues earlier in this chat but couldn't pin down a solution

Queueing and playing of local files and youtube videos work independently just fine. But after playing with ytdl-core, local files are permanently borked until I restart

I've seen the recommendations for play-dl but I can't find any kind of setvolume() function in that library (which i kinda need)

subtle granite

You can set the volume with djs voice

onyx copper

right you are - I got confused as to what lib the createAudioResource function was from, thanks

quaint meteor

Does anyone know why my musicbot stops playing music after changing audioressource?

rugged sky

If you send your code perhaps I can find out.

quaint meteor

@rugged sky I play music with mp3 streams and with the play-dl libary. It works when switching from mp3 stream to play-dl, but not from play-dl to mp3 it just stops

async function playmusic(streamURL){
        var resource;
        if(typeof streamURL == 'string'){
            resource = createAudioResource(streamURL)
        }else{
            resource = createAudioResource(await (await playdl.stream(streamURL.url)).stream);
        }
        try{
            player.play(resource);
            bot.connection.subscribe(player);
        }catch(error){
            console.log(error);
        }
    }
rugged sky
quaint meteor
carmine timber
quaint meteor

What could be the problem when my bot stops playing music for a second while adding a song to the queue?

undone finch
icy maple
onyx carbon

My discord bot wont join a channele

loud breach

So i have this code:

import * as dc from "discord.js"

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

Im working with Typescript so i cant use the require statement what is my way to do it? Its saying: "Cannot find name 'joinVoiceChannel'

quaint meteor
onyx carbon

tmr

loud breach
quaint meteor
tender siren

I am trying to get a voice connection using discordjs/voice but it is always returning undefined even when the bot is in a voice chat and playing audio.

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

    async execute(interaction) {
       
        const connection = getVoiceConnection(interaction.guildId);
        console.log(connection) //undefined

        connection.destroy(); //errors
        return interaction.reply({ content: "Left Voice Chat!" });
    }
tender siren

I have even tried putting the guildID manually

its still undefined

rugged sky
placid ginkgo

What's going on here. I am following the information here:
https://discordjs.guide/voice/voice-connections.html#cheat-sheet

However, the following code:

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

Returns the following error:
TypeError: s is not a function

placid ginkgo

Further debugging shows that value for adapterCreator ends up being undefined 🤔

placid ginkgo

Seems to work fine if I upgrade to discord.js@13 - no mention that this is required in the docs. Maybe this can be included to save people such hassle in the future 😠
I would rather not upgrade to v13, though. Is there any other option?

icy maple

Use the regular voice if ur not using d.js v13

icy maple

v12 and lower is deprecated and no longer supported anyways

placid ginkgo

To be more specific, the built-in one has issues where the bot would randomly stop broadcasting arbitrary audio stream input after some time. The client voice connection would still show as connected and speaking, even though its not. Just a buggy mess in short. We're hoping discord.js/voice would fix these issues (a couple of github issues say it would)

placid ginkgo
dusty needleBOT

Version 13 has released! Please update at your earliest convenience, we will not indefinitely support v12.
• Update: npm rm discord.js npm i discord.js
Update guide (use CTRL + F to search for the old method or property)

placid ginkgo

Neat 👍

placid ginkgo

i.e. you can use the getVoiceConnection() method to find an existing connection in a server, but it doesnt let us know which channel it's in

violet thorn
runic mantle

Error: Cannot perform IP discovery - socket closed
what does this mean?

placid ginkgo
rose helm

The lib doesn't receive any packets other than voice state update and voice server update which isn't enough to actually provide any meaningful voice channel info other than guild_id and channel_id

Mapping the channels is up to the main Discord interface you use. Or up to you if you take a lower level approach

getting a connection from the lib requires a guild ID (and a clientID if 1 process manages multiple clients) which is more than sufficient for you to get the guild by ID in your cache and then filter over the voice_states to find the desired client's voice state data

carmine timber
thick junco

I'm trying to make a music bot, but it keeps running into this error:

node:events:368
      throw er; // Unhandled 'error' event
      ^

N [Error]: aborted
    at connResetException (node:internal/errors:691:14)
    at TLSSocket.socketCloseListener (node:_http_client:407:19)
    at TLSSocket.emit (node:events:402:35)
    at node:net:687:12
    at TCP.done (node:_tls_wrap:580:7)
Emitted 'error' event on H instance at:
    at OggDemuxer.t (/path/to/node_modules/@discordjs/voice/dist/index.js:8:288)

It happens around 45 seconds into the song playing, not at the start or end. How would i fix this?

hmm, playing another song doesn't seem to error. The song erroring is HENNSON - SAHARA

too much bass? ¯_(ツ)_/¯

quaint meteor
thick junco

it works with all other songs I've tried though lol

quaint meteor

Cause ytdl has some stream abort issues

arctic relic

.

sly rain
vagrant garnet
sly rain

im using @discordjs/voice, yt-search and ytdl-core

vagrant garnet

it's a common issue with ytdl iirc

sly rain
vagrant garnet

you can use play-dl

sly rain

it works like ytdl?

vagrant garnet

yea more or less

sly rain

ok thx

sly rain
neat escarp

So I have a music bot that used to be on discord v12 but I upgraded to v13. I have a finish function and I have no clue how to implement that into the new audioPlayer function. Does player.on('finish') still work? How do I know when a song is finished playing?

runic mantle
Multiple Resolves
reject Promise {
  [
    { status: 'connecting', adapter: [Object], networking: [te] },
    { status: 'ready', adapter: [Object], networking: [te] }
  ]
} AbortError: The operation was aborted
    at abortListener (node:events:842:14)
    at EventTarget.<anonymous> (node:events:878:47)
    at EventTarget.[nodejs.internal.kHybridDispatch] (node:internal/event_target:460:20)
    at EventTarget.dispatchEvent (node:internal/event_target:405:26)
    at abortSignal (node:internal/abort_controller:98:10)
    at AbortController.abort (node:internal/abort_controller:123:5)
    at wt (C:\Users\MrFluffycloud\Documents\Botto\node_modules\@discordjs\voice\dist\index.js:9:680)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ABORT_ERR'
}```

wat does this mean?

patent breach
      reject(new AbortError());
             ^

AbortError: The operation was aborted```

Any idea when I use voice

carmine timber
patent breach
jaunty peak

Hey, how what exactly adapterCreator does?

Also how i can play youtube video? it wont let me use ytdl..

rugged sky
jaunty peak
rugged sky
jaunty peak
rugged sky
jaunty peak
rugged sky
jaunty peak

tried subscribe but still getting an error

rugged sky

Pinned messages has a guide, it will explain how to do it now.

rocky oxide

any know why?
i'm trying to entersState()

patent breach

What is the best way to play the same audio in every server (main server auto connects on ready) the rest of the servers use a command to join it

rose helm

subscribe all connections to 1 player

wintry sapphire

Possible EventEmitter memory leak detected. 11 closing listeners added to [VoiceConnection]. Use emitter.setMaxListeners() to increase limit
As far as I read on the internet, there is a solution to not show the error message (client.setMaxListeners(30) or process.setMaxListeners(30)), but we need to find the exact solution of the error ourselves, what do you think causes this error?

jaunty peak

Hey, for some reason my bot wont play the sound, im not getting any error just "Abort Error" after few seconds..

my code:


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

            try {
                await entersState(connection, VoiceConnectionStatus.Ready, 30e3);

                return connection;
            } catch (error) {
                console.log(error)
                connection.destroy()
            }

            const resource = createAudioResource(vid, {
                inputType: StreamType.Arbitrary,
            })
            
            player.play(resource)

            //resource.volume.setVolume(vol / 5)

            return entersState(player, AudioPlayerStatus.Playing, 5e3)```
ionic eagle

How can I make a seek command in V13?

patent breach
rose helm

Correct

patent breach
rose helm

Yeah

each chunk of data the player receives, it pushes that to all of its subscribers to send the packet to their voice channel
After processing is done of course

carmine timber
old sparrow

Is there a way to get a player from a connection?

carmine timber
old sparrow

Thanks!

atomic compass

How do I define all voice region

karmic glade

How would i go about making a music bot?

merry parcel

I'm getting AbortError: The operation was aborted When i disconnect it manually

why?

subtle granite

help med pls

willow plank

does anyone know what this error means(more of why its happening), and if so how to fix it? Error happens when using joinVoiceChannel, code below

joinVoiceChannel({
  channelId: channelid,
  guildId: serverid,
  voiceAdapterCreator: voiceAdapterCreator,
}); //exact copy from code, variables are extracted from interaction

I have looked everywhere for a explanation on the error and cant get one.

rose helm

Myself and my users are currently running into an issue where the lib throws that it cannot probe a readable stream in object mode. Is there a fix for this?

rose helm

seems like just play-dl is emitting object mode streams, so I'm just avoiding the demuxing from play-dl since it provides voice compatible stream types

trail trout

Trying to convert old code to the new version. where did go VoiceConnection.dispatcher?

tight fjord
trail trout
carmine timber
rose helm

Already switched it to use the types the lib provides to avoid useless cpu time spent demuxing

subtle granite
subtle granite
subtle granite
bright moth

when the VoiceConnectionState gets destroyed i can't really enter another state after that. Anybody know what is the cause of that

willow plank
still bison

how can I make my bot join VC?

bright moth

thru the joinVoiceChannel function provided from discordjs/voice

subtle granite
willow plank
subtle granite

Hm maybe show the full code in a bin? Of the interaction and where you try to join

willow plank

I am not at home rn but I will when I get home(around 3pm cst)

I’ll ping you the when I do

still bison

where can i get createDiscordJSAdapter?

its from a package?

subtle granite

Refer to this @still bison

still bison

guild is my guild right?

bright moth

yes a guild object that u provide

still bison

oh ok

const guild = client.guilds.cache.get(guildID);

this works right?

subtle granite
subtle granite
still bison
if (interaction.commandName === "clem") {
    console.log(interaction.member.voice.channel);
    const channel = interaction.member?.voice.channel;
    if (channel) {
      try {
        const connection = await connectToChannel(channel,interaction.guild);

        connection.subscribe(player);
        await interaction.reply("Playing");
      } catch (e) {
        console.log(e);
      }
    } else {
      await interaction.reply("not in voice");
    }
    await interaction.reply({ content: "Clem!", empheral: true });
  }

i have this error

subtle granite

What is connectToChannel defined as?

still bison
async function connectToChannel(channel,guild) {
  const connection = joinVoiceChannel({
    channelId: channel.id,
    guildId: channel.guild.id,
    adapterCreator: guild.voiceAdapterCreator(channel),
  });
  try {
    await entersState(connection, VoiceConnectionStatus.Ready, 30e3);

    return connection;
  } catch (e) {
    connection.destroy();
    throw e;
  }
}
subtle granite

I think it is only <guild>.voiceAdapterCreator 🤔

still bison

same error

bright moth

when i disconnect it it can't go back in a ready state

slim sigil

AA question, how can we get the resource total duration of connection.state.subscription.player.resource?

slim sigil

And how can I seek in a track in discord.js 13?

subtle granite
slim sigil
abstract acorn

what about webm/opus streams?

willow plank
carmine timber
willow plank

the vars are defined above

thick junco

How do I play an audio file with the new joinVoiceChannel function? I can't do connection.play anymore

thick junco

yeah i figured it out in the guide, thanks regardless :D

tepid tulip

Hello everyone, i've got a problem i'm a beginner, and i can't manage to make it work :

    if (message.member.voice.channel) {
        const connection = joinVoiceChannel(
            {
                channelId: message.member.voice.channel,
                guildId: message.guild.id,
                adapterCreator: message.guild.voiceAdapterCreator
            }
        );
        if (message.content.startsWith("$play")) {
            let args = message.content.split(' ')
            let live = YoutubeStream(args[1])
            const player = createAudioPlayer();
            const resource = createAudioResource(live);

            async function play() {
                await player.play(resource);
                connection.subscribe(player);
            }
            
        }
    }

})```

Does anyone know where did i make an error ?

bright moth

When the VoiceConnection state gets destroyed, why can't it get in a ready state after that?

icy maple

Destroyed means it’s no longer usable

icy maple
bright moth
icy maple

You don’t?

If you destroy it, then you have to make a new connection

bright moth

aha ok ok ty

tepid tulip
icy maple
tepid tulip

Yes sir,

Error: FFmpeg/avconv not found!

icy maple

You need to install ffmpeg

dusty needleBOT

_ discordjs.guide results:
• Getting Started: Installation - Barebones

icy maple

Either ffmpeg from the official site (not an npm package), or ffmpeg-static from npm

tepid tulip

So we're talking about my let args = message.content.split('') here ?

bright sable

`client.on('message', message => {
if (message.content == '!report') {
message.author.send('Hello, if you would like to report please say their username and tag')
setTimeout(function() {
var reporteduser = message.lastMessage
console.log(reporteduser)
}, 10000);

}

});`

It keeps returning undefined

fervent estuary

not voice related

sudden cloud

has anyone else had discordjs's voice randomly go idle and stop playing after some time while playing audio? I've encountered it multiple times now, each time after some amount of minutes
not sure if because I'm using ffmpeg to create the resource with raw stream type

abstract acorn

AudioPlayer does not play mp3 files stored in Discord CDN if a stream was played before

any fix for ⬆️?

icy maple

Make a new resource

@abstract acorn

abstract acorn

my code always create new audio resource tho

icy maple
abstract acorn

no

solar dew

any documentation on discord js recording

abstract acorn

it just doesn't play anything, but everything else worked (even now playing message came through)

carmine timber
abstract acorn
// ... (this handles end of queue)
  } else {
    serverInfo.playing = true;
    if (serverInfo.leaveTimer != undefined) {
      try { // clear timer before playing track
        clearTimeout(serverInfo.leaveTimer);
        serverInfo.leaveTimer = null;
      } catch(err) {} // there's no leaveTimer
    }

    if (!serverInfo.player) createPlayer(client, message, song);
    serverInfo.resource = null;

    let resource;
    if (song.source === "youtube") resource = createAudioResource(ytdl(song.url, { filter:"audioonly", highWaterMark: 1 << 23, type: 'opus' }), {inlineVolume: true});
    else if (song.source === "discord") resource = createAudioResource(song.url, {inlineVolume: true});
    resource.volume.setVolume(serverInfo.volume);

    serverInfo.player.play(resource);
    serverInfo.resource = resource;

    embed.setColor(message.guild.me.displayHexColor);
    embed.setTitle("Now playing");
    embed.setDescription(songTitle(song));

    return message.channel.send({ embeds: [embed] }).then(msg => {
      serverInfo.npMessageID = msg.id;
    });
  }

song.source === "youtube" means the url is youtube video, where ytdl create streams
song.source === "discord" means the url of audio file from discord CDN

carmine timber
abstract acorn
function createPlayer(client, message, song) {
  const serverInfo = centralInfo.get(message.guild.id);
  const player = createAudioPlayer({
    behaviors: {
      noSubscriber: NoSubscriberBehavior.Pause,
    },
  });

  serverInfo.connection.subscribe(player);
  serverInfo.player = player;

  /* start of many handlers */
  /* not really needed here? */
  /* end of many handlers */
}```
carmine timber
abstract acorn

fyi i just checked the player object, it seems like status is stuck in "buffering" when this bug happens

carmine timber
abstract acorn

hmm i tried changing type to vp9 (as others feel like random numbers) and removing all options altogether, but the bug still persists

carmine timber
abstract acorn

why is ytdl-core somehow a mess now?
and I tried play-dl but nothing would play after needing to use it, even youtube link is somehow unplayable now

carmine timber
abstract acorn

i dont use discord-player package tho
just discordjs/voice

carmine timber
abstract acorn

and the changed code is this

if (song.source === "youtube") {
      const pain = await playdl.stream(song.url, { discordPlayerCompatibility: true });
      resource = createAudioResource(pain.stream, {inlineVolume: true});
    }```
carmine timber
abstract acorn

should we move to direct message?


Core Dependencies

  • @discordjs/voice: 0.7.4
  • prism-media: 1.3.2

Opus Libraries

  • @discordjs/opus: 0.5.3
  • opusscript: 0.0.8

Encryption Libraries

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

FFmpeg

  • version: 4.3.1
  • libopus: yes

wait i uninstalled @discordjs/opus already tho

first time running mp3 (playable)json [ { type: 'ffmpeg pcm', to: Ue { edges: [Array], type: 'raw' }, cost: 2, transformer: [Function: transformer], from: Ue { edges: [Array], type: 'arbitrary' } }, { type: 'volume transformer', to: Ue { edges: [Array], type: 'raw' }, cost: 0.5, transformer: [Function: transformer], from: Ue { edges: [Array], type: 'raw' } }, { type: 'opus encoder', to: Ue { edges: [Array], type: 'opus' }, cost: 1.5, transformer: [Function: transformer], from: Ue { edges: [Array], type: 'raw' } } ]
run yt (play-dl)json [ { type: 'ffmpeg pcm', to: Ue { edges: [Array], type: 'raw' }, cost: 2, transformer: [Function: transformer], from: Ue { edges: [Array], type: 'arbitrary' } }, { type: 'volume transformer', to: Ue { edges: [Array], type: 'raw' }, cost: 0.5, transformer: [Function: transformer], from: Ue { edges: [Array], type: 'raw' } }, { type: 'opus encoder', to: Ue { edges: [Array], type: 'opus' }, cost: 1.5, transformer: [Function: transformer], from: Ue { edges: [Array], type: 'raw' } } ]
second time running mp3 (unplayable)json [ { type: 'ffmpeg pcm', to: Ue { edges: [Array], type: 'raw' }, cost: 2, transformer: [Function: transformer], from: Ue { edges: [Array], type: 'arbitrary' } }, { type: 'volume transformer', to: Ue { edges: [Array], type: 'raw' }, cost: 0.5, transformer: [Function: transformer], from: Ue { edges: [Array], type: 'raw' } }, { type: 'opus encoder', to: Ue { edges: [Array], type: 'opus' }, cost: 1.5, transformer: [Function: transformer], from: Ue { edges: [Array], type: 'raw' } } ]

also this one, using ytdl-core instead of play-dl

[
  {
    type: 'ffmpeg pcm',
    to: Ue { edges: [Array], type: 'raw' },
    cost: 2,
    transformer: [Function: transformer],
    from: Ue { edges: [Array], type: 'arbitrary' }
  },
  {
    type: 'volume transformer',
    to: Ue { edges: [Array], type: 'raw' },
    cost: 0.5,
    transformer: [Function: transformer],
    from: Ue { edges: [Array], type: 'raw' }
  },
  {
    type: 'opus encoder',
    to: Ue { edges: [Array], type: 'opus' },
    cost: 1.5,
    transformer: [Function: transformer],
    from: Ue { edges: [Array], type: 'raw' }
  }
]```
atomic compass

How do I define voiceregion

serene echo

Hello! I know is a little against the rules of this server but can anyone tell me what should i put. So my bot has an music feature and when the music ends he automatic leaves the voice chat. The thing i want is to stay in. And when all the members leaves the voice channel then the bot can leave it too.

bright moth
blissful jewel

Does anyone know why @discordjs/voice is archived?

solar dew

is their any way i can add ogg slient file in the audio recorder

final raptor

My code seems correct, when i tell it to play outside the vc it gives me the error prompts as it should but if I join a vc and hit play it doesn't react at all. what do I do?

simple plank

Is there a way to get the current voice channel of a member that creates an interaction from the interaction event? I don't see the property in the member docs. (not sure if this belongs in #archive-interactions or #archive-voice )

rugged sky
simple plank

Thank you! ❤️

subtle granite

Are you able to make a music system from multiple files?

subtle granite

How can I cache all voice channel informations on each command run?

rapid rain

What would signify the bot in a voice channel? Would it be <Client>.user.voice.channel?

valid marsh

<Guild>.me.voice.channel

rugged sky
final raptor

I... don't think so?

or well since then its gotten different. now the code isn't showing any errors, but it won't play the 'play' command

subtle granite

How do I get my bot to join a VC? No need to unmute, or play anything, just join.

atomic compass

How do I define voiceregion

rose helm
rose helm
atomic compass How do I define voiceregion

voice regions are tricky because you can only access a voice channels region after you receive a VOICE_SERVER_UPDATE packet and strip out the region from the endpoint Discord sends you unless the channel has the rtc_region set already and available in the gateway/api.

bleak prawn

Was wondering if anyone knows how to seek using ytdl-core? (Discord v13 btw)
begin option apparently doesn't work

wintry sapphire
bleak prawn

sadly thats v12, thnx anyway tho

wintry sapphire

😦 yes v12

undone finch

this msg is being sent by the bot even if im in a voice channel

bleak prawn

does the bot have access to that channel?

¯_(ツ)_/¯

frank kelp
undone finch
frank kelp
undone finch

Connection.play() is not a function?

bleak prawn

oh ok good to know

rugged sky
lapis ingot

Hello, help me, please update the voice status.
But it only increases, it does not decrease

client.on('ready', () => {
  const server = client.guilds.cache.get('')
  const member_channel = client.channels.cache.get('')
  const voiceChannels = server.channels.cache.filter(c => c.type === 'voice');
        
        const alivevoice = client.channels.cache.get('')

        let alivecount = 0;
        for (const [id, voiceChannel] of voiceChannels) alivecount += voiceChannel.members.size;

        setInterval(() => {
        member_channel.setName('⦿ Total User: ' + server.memberCount)
        alivevoice.setName('⦿ Total Mic: ' + alivecount)
        }, 60000)
}) ```
wintry sapphire
lapis ingot Hello, help me, please update the voice status. But it only increases, it do...

I think it's because the system is looping but the data is always in the same place

        setInterval(() => {
        let alivecount = 0;
        for (const [id, voiceChannel] of voiceChannels) alivecount += voiceChannel.members.size;
        member_channel.setName('⦿ Total User: ' + server.memberCount)
        alivevoice.setName('⦿ Total Mic: ' + alivecount)
        }, 60000)

Note : I'm not sure about this maybe it will work

subtle granite

Hi, do you have a way to fix the issue of voice channels randomly disconnecting in the middle of playback, which can happen after 10 minutes like 6 hours of listening ?

inner horizon

Hey guys anyone know why when I disconnect the oldState returns channelId as null?

the oldState used to show the channel someone left on discord.js v 12

now it shows null

red rover

i've been following the discord.js voice recording guide, and the bot joins and tries to start listening. when i'm using prism.opus.OggLogicalBitstream i'm getting an error:

TypeError: failed to downcast any to number

i suspect it has to do with node-crc, because in the OggLogicalBitstream options if i setcrc to false, it makes a recording but it doesn't work

subtle granite

how can i know the status of the audio if it was playing or paused ....

subtle granite

🤝

subtle granite

how do i make a command from which my bot will join the voice channel

dusty needleBOT
wintry geyser

What is message?

stoic orbit
const ytdl = require('ytdl-core');
const {
    AudioPlayerStatus,
    StreamType,
    createAudioPlayer,
    createAudioResource,
    joinVoiceChannel,
} = require('@discordjs/voice');

const voice = require('@discordjs/voice');

module.exports = {
  category: 'Music',
  description: 'Plays music in an voice channel',
  slash: true,
  minArgs: 1,
  testOnly: true,
  expectedArgs: '<title>',
  callback: async ({ client, message, interaction, args }) => {
    const [ title ] = args;

    const connection = joinVoiceChannel({
    channelId: interaction.member.voice.channelId,
    guildId: interaction.guild.id,
     adapterCreator: interaction.guild.voiceAdapterCreator,
    });
        
    const stream = ytdl(`https://www.youtube.com/watch?v=dQw4w9WgXcQ`, { filter: 'audioonly' });
    const resource = createAudioResource(stream, { inputType: StreamType.Arbitrary });
    const player = createAudioPlayer();
    player.play(resource);
    connection.subscribe(player);
    interaction.reply(title)
 }
}

won't play anything

subtle granite
const { channel } = message.member.voice;
const botchannel = message.guild.me.voice.channel;
if (!channel) {return message.reply({embeds: [new MessageEmbed().setTitle('![no](https://cdn.discordapp.com/emojis/833101993668771842.webp?size=128 "no") You need to join a voice channel').setColor(es.wrongcolor).setFooter(client.getFooter(es))]});}

if(!channel.permissionsFor(message.guild.me).has("CONNECT")){return message.reply({embeds: [new MessageEmbed().setTitle(":x: I'm missing the Permission to join your Voice Channel").setColor(es.wrongcolor).setFooter(client.getFooter(es))]});}
if(!channel.permissionsFor(message.guild.me).has("SPEAK")){return message.reply({embeds: [new MessageEmbed().setTitle(":x: I'm missing the Permission to speak in your Voice Channel").setColor(es.wrongcolor).setFooter(client.getFooter(es))]});}
if(channel.userLimit != 0 && channel.full){return message.reply({embeds: [new MessageEmbed().setTitle(":x: Your Voice Channel is full!").setColor(es.wrongcolor).setFooter(client.getFooter(es))]});}

if (botchannel) {return message.reply({embeds: [new MessageEmbed().setTitle(`![no](https://cdn.discordapp.com/emojis/833101993668771842.webp?size=128 "no") I am already connected in: \`${botchannel.name}\``).setFooter(client.getFooter(es))]});}

const e = await message.react('🎙️').catch(e => console.log(String(e).grey))

let VoiceConnection = joinVoiceChannel({channelId: channel.id,guildId: channel.guild.id,adapterCreator: channel.guild.voiceAdapterCreator}); 
let file = path.join(__dirname + `/audio/${CmdName}.mp3`);
if(!file || !fs.existsSync(file)) file = path.join(__dirname + `/audio/${CmdName}.m4a`);
if(!file || !fs.existsSync(file)) file = path.join(__dirname + `/audio/${CmdName}.mov`);
if(!file || !fs.existsSync(file)){return message.reply({embeds: [new MessageEmbed().setTitle(":x: Could not find the AUDIO").setColor(es.wrongcolor).setFooter(client.getFooter(es))]});}

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

const player = createAudioPlayer();
VoiceConnection.subscribe(player);
player.play(resource);

player.on("idle", () => {
    try {player.stop();} catch (e) {console.log(String(e).grey)}
    try {VoiceConnection.destroy();} catch (e) {console.log(String(e).grey)}
    e.remove().catch(e => console.log(String(e).grey))
});

This is my script
It works just fine, but after 10-12hours of uptime, it won't play any audio... what should i do to fix that?

rotund obsidian
rotund obsidian
rancid heart

how do I convert old v12 voice code to v13

brisk shard
vivid glen

I've been trying to install the dependencies (sodium and opus) and cant get them to install

PS D:\code\spotify-bot> npm install sodium
npm ERR! code 1
npm ERR! path D:\code\spotify-bot\node_modules\sodium
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node install.js --install
npm ERR! MS Version: 2015
npm ERR! Install Mode
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@17.4.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.5 found at "C:\Users\joel_\AppData\Local\Programs\Python\Python39\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version was set from command line or npm config
npm ERR! gyp ERR! find VS - looking for Visual Studio version 2015
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS checking VS2017 (15.9.28307.1778) found at:
npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features"
npm ERR! gyp ERR! find VS - found VC++ toolset: v141
npm ERR! gyp ERR! find VS - found Windows SDK: 10.0.17763.0
npm ERR! gyp ERR! find VS - msvs_version does not match this version
npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS valid versions for msvs_version:
npm ERR! gyp ERR! find VS - "2017"
npm ERR! gyp ERR! find VS - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
npm ERR! gyp ERR! find VS

I've ran npm i windows-build-tools --vs2015 many times already and even when it installs successfully i get the same error message when installing the dependencies

anyone know a fix?

dusty needleBOT

• Run npm i windows-build-tools --production --vs2015 --add-python-to-PATH --global as admin.
• Restart your terminal or machine (if terminal is not sufficient).

icy maple

Wierd enough, the logs seems to indicate you also have 2017 installed, but ur npm config is currently set to use 2015 (or some version other than 2027)

vivid glen

i set that manually, should i use 2017? i read that sodium only works with build tools 2015 and below

anyways i get error msvs version is not defined if i do iirc

icy maple

When it tried to use the 2015

find VS VCINSTALLDIR not set, not running in VS Command Prompt

vivid glen

gonna try installing the 2015 build tools manually

icy maple

You could try using the VS Build Tools installer

vivid glen

i just installed it with that, it worked and the npm install command ran fine 👍

serene echo

How i can setup the banner of the video as embed. Like for example: .setImage("banner-here")

is there any code for that?

rapid elk

Did you find an alternative to this?

wary rain
client.on("interactionCreate", interaction => {
  if (interaction.commandName === "music") {
  const ytdl = require('ytdl-core');
const {
    AudioPlayerStatus,
    StreamType,
    createAudioPlayer,
    createAudioResource,
    joinVoiceChannel,
} = require('@discordjs/voice');

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

const stream = ytdl('https://youtu.be/3nQNiWdeH2Q', { filter: 'audioonly' });
const resource = createAudioResource(stream, { inputType: StreamType.Arbitrary });
const player = createAudioPlayer();

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

player.on(AudioPlayerStatus.Idle, () => connection.destroy());
interaction.reply({content: "successfully"})
  }
})```
slash command `music` not showing up
wary rain
rotund obsidian

Hi fam do you know why my bot can play radio flux url only if he start with ip+port ? ^^

lapis ingot

Hello, please help me how to define this update

client.on('ready', () => {
  const server = client.guilds.cache.get('')
  const member_channel = client.channels.cache.get('')
  const voiceChannels = server.channels.cache.filter(c => c.type === 'voice');
        
        const alivevoice = client.channels.cache.get('')

        let alivecount = 0;
        for (const [id, voiceChannel] of voiceChannels) alivecount += voiceChannel.members.size;

        setInterval(() => {
        member_channel.setName('⦿ Total User: ' + server.memberCount)
        alivevoice.setName('⦿ Total Mic: ' + alivecount)
        }, 60000)
})```
When it is turned on, it saves the status from the moment, if the status changes, it will not receive the new status
lilac rover

How to loop?

errant mirage

**What is code for join vc and play any audio from any file in v13

Like there was a code in v12

message.member.voice.channel.join().then((connection) => {
connection.play(path.join(__dirname + './../../structures/test404.mp3'))
})```**
rancid heart

wh y is my bot not playing music when I've created a resource, created a player, connected to the VC, subscribed to the player?

young wasp
rapid elk Did you find an alternative to this?

only solution i figured out was:

  • after creating a voice connection using joinVoiceChannel
  • access the connection's receiver's speaking map: speakingMap = connection.receiver?.speaking
  • add event listeners for 'start' and 'stop' to the speakingMap:
    speakingMap?.addListener("start", (userId: string) => {
    //register that userId started speaking
    })
subtle granite

how do i make my bot join the msg.member's vc

v13 btw

subtle granite
tepid tulip

If you're still having trouble, tell me i'll try to help

subtle granite

alr ty

errant mirage

**```js
joinVoiceChannel({ channelId: channel.id, guildId: channel.guild.id, adapterCreator: channel.guild.voiceAdapterCreator })

        const astra = createAudioPlayer({
            behaviors: {
                noSubscriber: NoSubscriberBehavior.Pause,
            },
        });
        const resource = createAudioResource('./../../structures/Resuming.mp3');
        astra.play(resource);

@tepid tulip

tepid tulip

I'm not sure that error comes from what you're showing me

subtle granite
tepid tulip If you're still having trouble, tell me i'll try to help
    if (cmd == prefix + "joinvc") {
        let channel = msg.guild.channels.cache.find(
            channel => channel.id === 926392547876671511
        )

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

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

        const connection = getVoiceConnection(msg.channel.guild.id);

        const subscription = connection.subscribe(player);

        if (subscription) {
            setTimeout(() => subscription.unsubscribe(), 5_000);
        }
    }

doesnt work im very stupid lmao

this is the top:

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

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

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

new to djs voice

tepid tulip

Let me check

subtle granite

alr

tepid tulip

Is that the only place you put the joinVoiceChannel ?

subtle granite
tepid tulip

Did you put a resource anywhere ?

subtle granite

ill add that too

tepid tulip

Without the resource, the bot won't play anything

subtle granite

alright nvm i got it working im just mentally special

tepid tulip
subtle granite

i forgor my own command name 💀

tepid tulip
gleaming harbor

why wont my player play

it works on another bot but not with a diffrent token

gleaming harbor
rancid heart

why is my bot not playing anything? I've joined the VC, created a player, subscribed, started playing but I can't hear anything

errant grail

took me forever to realize that to fix "ffmpeg not found" error is to just drag ffmpeg.exe into the folder 😐

tepid tulip

and your code

rancid heart

no error

tepid tulip

Show me your code if you're willing to 🙂

languid quail
rancid heart

I did, still no sound

rancid heart

I miss v12 where it was as simple as connection.play(file)

hearty shale

is there any way to download an earlier version of discordjs voice that doesnt require node.js 16.9? I can only install v16.7

prime jewel

Hi everyone. I am trying to make a music bot, but I have an issue. Bot randomly crashes with error that does not make any sense to me. The error itself:


node:events:368
      throw er; // Unhandled 'error' event
      ^

N [Error]: aborted
    at connResetException (node:internal/errors:691:14)
    at TLSSocket.socketCloseListener (node:_http_client:407:19)
    at TLSSocket.emit (node:events:402:35)
    at node:net:687:12
    at TCP.done (node:_tls_wrap:580:7)
Emitted 'error' event on H instance at:
    at OggDemuxer.t (/test/musicbot/node_modules/@discordjs/voice/dist/index.js:8:288)
    at Object.onceWrapper (node:events:510:26)
    at OggDemuxer.emit (node:events:402:35)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)

Bot runs off a VPS with Ubuntu 18.04 and Node.js 16.13.1. I am not a professional dev, but can assume, that according to error it have tried to make a HTTP request with default http lib, but got connection reset error(It might be important to add, that I live in Russia, and some websites that are blocked return provider's message saying that this site is blocked or just ERR_CONNECTION_RESET returns). How can I fix this issue?

And also, why it even happens?

rancid heart

my bot doesn't play sound, even though the code looks fine

rancid heart

hello?

rancid heart
                    const connection = joinVoiceChannel({
                                channelId: interaction.member.voice.channel.id,
                                guildId: interaction.guild.id,
                                adapterCreator: interaction.guild.voiceAdapterCreator,
                                selfMute: false,
                                selfDeaf: false
                              });
                        
                    const audioPlayer = createAudioPlayer();
                              connection.subscribe(audioPlayer);
                              audioPlayer.play(
                                createAudioResource(
                                  createReadStream(`/home/bot/luibot/data/music/${music}.ogg`)
                                ),
                                { inlineVolume: true }```
rancid heart

Hello?

icy maple

Oh, I see it

Did you enable the guild voice states intent in the client?

rancid heart

Oh, one moment

rancid heart

Thanks, that worked

hearty shale
var connection = await voiceChannel.join();
const voiceChannel = message.member.voice.channel;```
error:```js
TypeError: voiceChannel.join is not a function
    at execute (/home/runner/Marvin/index.js:92:43)
    at runMicrotasks (<anonymous>)```

nvm im thinking of discord.js v12
time to reread docs ig

im looking through the documentation and I can't find any info on the function joinVoiceChannel
I see joinVoiceChannel options
but not joinVoiceChannel

prime jewel
hearty shale im looking through the documentation and I can't find any info on the function j...

I use this to connect to vc:

//top of the file:
const {
    AudioPlayerStatus,
    StreamType,
    createAudioPlayer,
    createAudioResource,
    joinVoiceChannel,
} = require('@discordjs/voice');


// use this part of code in interaction event:
const connection = joinVoiceChannel({
    channelId: interaction.member.voice.channel.id,
    guildId: interaction.member.guild.id,
    adapterCreator:interaction.member.voice.guild.voiceAdapterCreator,
});
prime jewel
prime jewel

i use spotify-it

carmine timber
prime jewel

oh ok

so, i need to create issue on ytdl-core repo?

carmine timber
prime jewel

and youtube

prime jewel

play-dl is good, but I did not understood how to authorize

carmine timber
copper flare

Hey guys, im trying to make my bot join a channel but it keeps on giving me this error:
TypeError: Cannot read properties of null (reading 'id')

here's the code i used for the bot to join the vc:
const { joinVoiceChannel } = require('@discordjs/voice') if (message.content === '!voice') { joinVoiceChannel({ channelId: message.member.voice.channel.id, guildId: message.guild.id, adapterCreator: message.guild.voiceAdapterCreator }) }
Can someone please help me resolve this issue?

rugged sky
copper flare

No

rugged sky

You need that.

copper flare

Ayt bet lemme try that

It still gives me the same error

rugged sky

For some reason it thinks you're not in a voice channel. Can't figure out why from this, but perhaps that knowledge can help you figure it out.

copper flare

Ok thanks

rancid heart

how do I get the current vc connection?

unique karma
client.on("ready", async () => {
  // gharar dadn id voice va server
  let serverid = "394910662662553600";
  let voiceid = "821407901549330432";
  //join shodan bot dar voice
  if (!client.voice.connections.find(serverid)) {
    let channel =
      client.channels.cache.find(voiceid) ||
      (await client.channels.fetch(voiceid));
    if (!channel) return;

    const connection = await channel.join();
    //slef-deaf
    const setSelfDeaf = connection.voice.setSelfDeaf(true);
    // slef-mute
    const setSelfMeaf = connection.voice.setSelfMute(false);
  }
});

update on djs 13 (edited)

heavy sigil

is there anyway to play a .pls file?

or asx files?

narrow oracle
fickle quartz

hello like the message right before mine i m here because i dont know how to make my bot join a voice channel and all i try give me an error pls how does it work ?

zealous blade

Hey, client.voice.setChannel(937722527894089807) isnt functioning.

Errorcode:

             ^

TypeError: client.voice.setChannel is not a function
    at Object.cmd_sup [as sup] ```

Can somebody help? 😅
carmine timber
queen reef

I'm completely struggling to install @discordjs/opus despite having node at the absolute latest version you can install, and npm fully updated

errant grail
queen reef

I managed to find an alternative using normal opusscript for now, which has allowed me to utilize discord's voice feature anyway.

queen reef

I also think, according to recent bug reports, it's a compatibility issue with linux as a whole

odd pebble

what would be the v13 equivalents of the v11 setVolume(), setVolumeDecibels(), and setVolumeLogarithmic(), if any?

queen reef

I am using prism-media and attempting to play an audio with play-dl, though I am discovering that it will suddenly stop playing the resource as though it reached the end of its duration. I know other people have utilized ffmpeg and this for the purpose I am trying to use it for, yet don't have this issue. Is there anything I am missing?

newResource = function(Stream,seek){
                queue.ffmpeg = new prism.FFmpeg({
                    args: [
                        '-analyzeduration', '0',
                        '-loglevel', '0',
                        '-ar', '48000',
                        '-ac', '2',
                        '-ss', seek || 0
                    ]
                })

                Stream.pipe(queue.ffmpeg);
                queue.resource = djsVoice.createAudioResource(Stream,{
                    "bitrate":"auto",
                    "inlineVolume": true,
                    "inputType": Stream.type
                })

                queue.player.play(queue.resource);
            }```
carmine timber
queen reef

I'm going to attempt the settings of another individual that I found with the search function you talked to in October, to see if that fixes it

It does not appear that it has, and my ffmpeg settings are now looking quite ridiculous, haha.

newResource = function(Stream,seek){
                queue.ffmpeg = new prism.FFmpeg({
                    args: [
                        '-ss', seek/1000 || 0,
                        '-loglevel', '0', 
                        '-acodec', 'libopus', 
                        '-f', 'opus', 
                        '-ar', '48000', 
                        '-ac', '2',
                        '-reconnect', '1', 
                        '-reconnect_streamed', '1',
                        '-reconnect_at_eof', '1', 
                        '-reconnect_on_network_error', '1', 
                        '-reconnect_on_http_error', '1',
                        '-reconnect_delay_max', '30'
                    ]
                })

                Stream.pipe(queue.ffmpeg);
                queue.resource = djsVoice.createAudioResource(Stream,{
                    "bitrate":"auto",
                    "inlineVolume": true,
                    "inputType": djsVoice.StreamType.OggOpus
                })

                queue.player.play(queue.resource);
            }```
zealous blade
carmine timber
zealous blade

I dont want to execute it on command such as !move

I have saved the IDs of the people I want to move.
So can I do smth like member.INSERTIDHERE.voice.setChannel('blah id')

` message.member.voice.setChannel('937722527894089804')
^

ReferenceError: message is not defined`

And your code also gives an error

carmine timber

OR you can do with channel ID also.

client.channels.cache.get(voice_channel_id).members.... rest same as above

zealous blade
zealous blade
sturdy fulcrum

how to make bot join a voice channel and play an mp3 in v13?

gleaming harbor
    at Object.execute (C:\Users\User\Documents\EvoBot Reright v13\commands\play.js:143:49)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
C:\Users\User\Documents\EvoBot Reright v13\commands\play.js:149
      await channel.leave();
                    ^

TypeError: channel.leave is not a function
    at Object.execute (C:\Users\User\Documents\EvoBot Reright v13\commands\play.js:149:21)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
[nodemon] app crashed - waiting for file changes before starting...```

how do i get the voice channel a person is in

tepid tulip
gleaming harbor

can i get the channel not just id or will i need to fetch the channel

red rover

i've been following the discord.js voice recording guide, and the bot joins and tries to start listening. when i'm using prism.opus.OggLogicalBitstream i'm getting an error:

TypeError: failed to downcast any to number

i suspect it has to do with node-crc, because in the OggLogicalBitstream options if i setcrc to false, it makes a recording but it doesn't work

gleaming harbor

after a few hours my bot just stops playing radio

carmine timber
carmine timber

Maybe you forgot to do connection.subscribe(player)

tepid tulip

Does anyone know how to create a "queue" ? like to prepare the next music our bot will play

rotund wave

How do I turn on the bot's self deafening?

vernal skiff
adapterCreator: bot.guilds.cache.get('938447445539577928').voiceAdapterCreator

voiceAdapterCreator is undefined why

blissful wind

HOW DO I GET MY BOT'S TOTAL VOICE CONNECTIONS SIZE?

supple crane

How can I get the status of the bot's voice stream?

cunning charm

i've tried getting sodium to install via yarn but it keeps saying it can't build it and I require msvs 2015 although I have those build tools
i also have node-gyp installed globally

glossy spear

Is it possible to know why the bot disconnected from the voice channel?(disconnected by someone or error)

grim nova

i have a problem where when the bot joins the channel its deafened, i tried coding it so it will unmute but it just wont

grim nova

here is my code: ```js

module.exports.run = async (bot, message, args, guild) => {
const { getVoiceConnections, VoiceConnection, joinVoiceChannel, PlayerSubscription, createAudioPlayer } = require('@discordjs/voice');
const { createReadStream } = require('fs');
const player = createAudioPlayer();
const client_user = message.guild.members.fetch(message.client);
const Member = guild.members.cache.get(message.author.id);
const BotMember = guild.members.cache.get(bot.user.id);
const { join } = require('path');
const { createAudioResource, StreamType } = require('@discordjs/voice');
const connection = joinVoiceChannel({
channelId: Member.voice.channelId,
guildId: message.channel.guildId,
adapterCreator: guild.voiceAdapterCreator,
});
const resource = createAudioResource(createReadStream('./679.ogg'), {
inputType: StreamType.OggOpus,
});
connection.subscribe(player);
player.play(resource);
}

module.exports.help = {
name:"play"
}

tepid tulip

I'll check and tell you

zealous blade

I cant find it how to connect to a vc?

shell fern
zealous blade

How to use new Voice.AudioPlayer(options);

For example if I wanna play the audio of a youtube video

icy maple
dusty needleBOT
dreamy drum

sm

grizzled wadi

I'm trying to make my bot play local mp3 files, starting from a certain point, playing for a bit, and then stopping.

I can't find a method anywhere to tell it where to start

languid quail
prisma bear

i give up on this, i tried many ways on getting this to work..

const url = googleTTS.getAudioBase64('Hello World', {
    lang: 'en',
    slow: false,
    host: 'https://translate.google.com',
    timeout: 10000,
  });

    const resource = createAudioResource(url);
    player.play(resource);

it joins the channel.. i tried local mp3, it worked. but playing a tts is not working...

2nd code:

    const url = googleTTS.getAudioUrl('Hello World', {
  lang: 'en',
  slow: false,
  host: 'https://translate.google.com',
});

    const resource = createAudioResource(url);
    player.play(resource);

3rd code:

    const { url } = await request
        .get(`http://tts.cyzon.us/tts?text=${speakmsg}`);
const resource = createAudioResource(url);
    player.play(resource);

none works

all are giving the above error [ Image ]

coarse summit
prisma bear

doesnt fix the problem

tried it, anyways i will try to figure out something

coarse summit
prisma bear

i alrdy tried installing those

even did npm install @discordjs/voice libsodium-wrappers

also had a doubt.

in v12 we had events like

      const dispatcher = connection.play(url);
      dispatcher.once("finish", () => voiceChannel.leave());

is there one to use in v13?

player.on('error', error => {
    console.error(error);
});

like rn its this, is there one for finish? instead of error?

coarse summit

Here's a little snippet of my music code, it completely works

The packages possibly needed are: ytdl-core, tweetnacl, ffmpeg-static, @discordjs/voice

prisma bear

ic

thanks!

prisma bear

@coarse summit

so i used this once the play was over

        audioPlayer.once(AudioPlayerStatus.Idle, () => voiceConnection.destroy() );

or

        audioPlayer.once(AudioPlayerStatus.Idle, () => voiceConnection.disconnect() );

but when i use the command again, all other stuffs work but the bot deosn't join back

nvm got it

sterile sable

Hello. Any tips on preventing my bot from randomly crashing and restarting because of this error when playing audio? I'm using @discordjs/voice v0.8.0 and node v16.13.2 hosted as a background worker on https://render.com/. I'm using ytdl-core v4.10.1 to stream audio from Youtube.

jolly idol

how do i play a direct audio link?

round cloak

Hey, I am building a discord bot to transcribe voice chats.
Is it possible, and a good idea, to decouple voice streaming and command handling in two different servers?
Like build one server to handle all the user commands and events, and one just to record voice input (and merge the multi-part audio streams and store them in our db)?

Are there any other better ways implemented that I can look at?

carmine timber
round cloak
carmine timber
subtle granite

how would i go about playing a certain mhtz pitch in a vc

regal fulcrum
sterile sable

@carmine timber @regal fulcrum Got it. Thank you!

regal fulcrum

Anytime! Its why we are here!

subtle granite

no but like how to i play the audio even if i save a recording

carmine timber
regal fulcrum

Unless youre making a public bot that will get more than 100 servers

carmine timber
regal fulcrum

which issues?

carmine timber
regal fulcrum

theres one issue and thats super easy to fix

carmine timber
regal fulcrum

ive been running my music bot for 6 months without any issues with aborted

carmine timber
regal fulcrum
carmine timber
regal fulcrum

Lavalink + erela.js is the only other option ive been able to find

and their docs get blocked for being fishy links on my end lol

carmine timber
regal fulcrum
carmine timber

LOL

regal fulcrum
carmine timber
regal fulcrum

many issues, now i cant be 100% sure which ones i had but songs just flat out not playing, random skips etc

carmine timber

Looking at play-dl downloads, I think it is pretty successful.

regal fulcrum

curious: what does play-dl use

carmine timber
regal fulcrum

is it taking the songs straight from spotify?

carmine timber
regal fulcrum

even with yt cracking down on music bots?

carmine timber

It also supports soundcloud for those users