#archive-voice

30636 messages · Page 12 of 31

rugged notch

i don’t think will working

carmine timber
rugged notch

how can i use it ?

warped sigil

I was hoping I could get a quick bit of help. I'm new to discord.js and I wanted to make a simple music bot.

const { Client, Intents } = require("discord.js");
const botclient = new Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });
const { joinVoiceChannel } = require("@discordjs/voice");

const token = `lolnicetry`;

let PREFIX = "-";

botclient.on('ready', () => {
    console.log("Bot enabled.");
})

botclient.login(token);

botclient.on('messageCreate', message => {
    let args = message.content.substring(PREFIX.length).split(' ');

    switch (args[0]) {
        case 'play':

            let vc = message.member.voice.channel;

            console.log(message.member)
            console.log(vc);

            if (!vc) {
                message.channel.send("You must be in a channel to play music!");
                return;
            }

            if (!args[1]) {
                message.channel.send("You need to provide a link.");
                return;
            }

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

            break;
    }
})

When I execute the command in a voice channel, the bot doesn't connect. Any advice?

rugged notch

@warped sigil


const botclient = new Client({ intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_VOICE_STATES"]});
warped sigil

Got it!

rugged notch

yeah sorry, i edit it

warped sigil

Still wont connect unfortunately.

rugged notch

and. u must download ytdl-core & @discordjs@voice

warped sigil

I know I eventually will need ytdl-core but I just want it to connect.

It seems it wont

rugged notch
warped sigil It seems it wont
            joinVoiceChannel({
                channelId: message.member.voice.id,
                guildId: message.channel.guild.id,
                adapterCreator: message.channel.guild.voiceAdapterCreator
            }).subscribe();```


try this
fast gull

So, do I only need to install FFmpeg and discordjs/voice to make my code for voice from v12 work again?

empty torrent
warped sigil
rugged notch

I will try something, just some mins

fast gull
rugged notch
const createAudioResource = require('@discordjs/voice');

const player = createAudioPlayer();

@Mr.Treeman#6969 put this codes.

fast gull
// Listen for voice state updates
client.on("voiceStateUpdate", (oldState, newState) => {
    // Call the channel left handler from the voice controller
    voiceController.voiceUpdateHandler(oldState, newState, client);
});

// In another file and within some conditionals
oldState.channel.delete()
rugged notch

and download ffmpeg

.subscribe(player);

empty torrent
warped sigil
fast gull
empty torrent
fast gull

Temp channels.

When a user joins it "activates" the channel, then once activated, once all members leave the channel, it auto-deletes.

It worked fine in V12, I'm not sure what is preventing it from deleting now. I'm not getting any errors or anything

empty torrent

I’m not sure about it but did you enable GUILD_VOICE_STATES intent?

fast gull

Ooooooohhhhh, thanks.

Yea, that fixed it, thanks a lot Muhitrhn!

empty torrent

Anytime

queen reef

Using play-dl as my downloading import, is it possible to start the audio at a certain timestamp with a video?

I saw some docs use seek in a dictionary in the .play command as a second argument, but in the docs provided by hydrabolt, there is no second argument in .play. I tried it anyway but obviously nothing changed, so...

solar quiver

play-dl is a third party pacage that we don't support; if this question is specific to it we can't answer it here

you can reach out to the maintainer in dms or find its support server

queen reef

I'm specifically asking if there is a method in which to play the audio resource at a different timestamp. I saw playbackDuration was not read-only and thought that was the solution but no haha. If I can't do it through djs-voice, I'll see if I can find a way to do it with play-dl, but would prefer to do it with the audio being played.

My apologies for not clarifying.

fervent estuary

using ffmpeg would work using the seek option

warped sigil

@empty torrent Really quick, when playing an audio like this I only get about 3 seconds before the audio stops, is that anything quick to fix?

const resource = createAudioResource('C:/Users/Clayt/Downloads/firstsong.mp3');
            player.play(resource);
            connection.subscribe(player)
empty torrent

Do you have ffmpeg installed? Try installing ffmpeg

queen reef

Thanks, I'll try it out. I already have volume working, I just wasn't sure how to proceed, first time working with ffmpeg and djs voice, a bit overwhelming haha.

warped sigil
granite scaffold

Where do I find the ‘EndBehaviorType’s for receiving voice?

On ios so i can’t codeblock properly

empty torrent
warped sigil

Maybe I just need a restart

empty torrent

You can try that.

queen reef

Apologies for a lot of questions. Regarding ffmpeg, I'm struggling to figure out how I would use it with a stream or audioResource, considering it is typically used for video with some options for audio, and documentation seems light or hard to understand for djs-voice atm.

Do I need to fully save the audio to my computer for ffmpeg to modify it, or am I capable of doing that through djs-voice's provided options like with .inlineVolume and .volume? I assume the former because I couldn't find additional options provided in creating audioResources, including .inlineVolume and .volume on hydrabolt's documentation, I had to find it on https://discordjs.guide, and you wouldn't suggest me use ffmpeg otherwise. It's still good to check however ^^.

fervent estuary

you can create a new ffmpeg transcoder with prism-media

and then pipe ur input stream into that

and pass the transcoder into createAudioResource

queen reef

I'll take a look, thank you again once more. I should also learn streams more completely, to ensure I won't be confused in the future.

rugged notch
rugged notch

AudioPlayerError ?

fervent estuary

thats just how it shows up. The error was actually emitted from ytdl-core

queen reef

That I believe is an error that happens a lot using ytdl-core, I had less issues when I learned and switched to play-dl myself, if that helps.

fervent estuary

its interesting as i barely ever run into that issue when using ytdl-core

queen reef

Strange, I kept running into it and it would cause issues when playing audio for me, crashing at random times. I suppose I could have set something up wrong, that could very well be the case.

fervent estuary

the options you pass in could have an effect

queen reef

👍

rugged notch

Is she working like ytdl ?

like

ytdl("link")
queen reef
rugged notch
queen reef
carmine timber
queen reef
carmine timber

Oh big relief

queen reef

^^ Thanks for checking up on that though!

carmine timber

👍

carmine timber
queen reef
carmine timber

👍, I will test it

wicked rover

can someone please show me an example of how to create a new connection

bleak heart

hi, umm im having trouble downloading discordjs/opus

dull flame
    const subscription = connection.subscribe(player);
    player.play(resource);```
This is how I subscribe the connection, I think this is wrong. How can I subscribe correctly?
ebon trout

how can i get the volume down only having the player?

icy maple

Only works if the player is in the middle of playing smth

dull flame

The bot it's connecting

but not playing

ebon trout
icy maple

It’s assuming inlineVolume is enabled and the player is actually playing smth (not idle/destroyed)

Volume is per-resource, doesn’t persist between songs

icy maple
dull flame

nope

icy maple

Should use the entersState method to make sure the connection actually enters the ready state

dull flame

Ok, ty

wise anchor

what's this

icy maple
icy maple
wise anchor
icy maple

Prob lost internet or computer went to sleep

wise anchor

it errors then it logs the AudioResource i believe

icy maple

Ur brackets are off I think

You did ytdl(…).videos[0]. …

wise anchor

nope, found the issue

icy maple

Oh, you got some weird nesting there

wise anchor

the issue was that i didn't specify some options in the second parameter of ytdl-core

icy maple

I’ve never used that fork. The regular ytdl-core always worked fine for me

wise anchor

okay, thanks anyways

ebon trout

There is a player and a song playing

icy maple

You didn’t enable inlineVolume for the resource

ebon trout

how can i do that

like that?

icy maple

Yea

ebon trout

Ok thank you

wicked rover

PLZ SOMEONE HELP ME ! I've tried the discord.js guide on how to create a connection, and look through dozens of other websites but every time i try it like this it gives me an error that says "AdapterCreator is not a function" no matter what i declare Adapter function with.

carmine timber
carmine timber
wicked rover
carmine timber
wicked rover
carmine timber
wicked rover

i tried other inputs for adapterCreator too

carmine timber
wicked rover
carmine timber
wicked rover

done

bleak heart

@carmine timber im having trouble downloading @discordjs/opus

carmine timber
bleak heart

ok

carmine timber
wicked rover

now it says client_missing_intents

bleak heart
carmine timber
wicked rover

even after adding intents it gives me this

i tried giving it Intents.ALL and GUILD_VOICE_STATES but it just returns this

carmine timber
wicked rover

it's in the same file where i write my code

carmine timber

Now change according to this

See the + one

carmine timber
wicked rover

it fixed that previous error xD, but now i get this

wait 1 sec

i think this is because it misses alot of intents to execute other code, let me just add some more intents

carmine timber
wicked rover

how do i get that ?

carmine timber
wicked rover
carmine timber node version Update your node.

YOU F*CKING LEGEND !! I posted this question like a dozen times the past days and searched for answers for ever and u finally helped me !! IT WORKS TYYYY, though now my previous code that worked but that was probably outdated doesn't work no more, but thx !

subtle granite

🙃

dull flame
const ffmpeg = require("ffmpeg");
const opusscript = require("opusscript");
const fs = require('fs');
const request = require('request');
const { join } = require('path');
const { createReadStream } = require('fs');
const { joinVoiceChannel, createAudioResource, createAudioPlayer, StreamType, VoiceConnectionStatus, AudioPlayerStatus, entersState } = require('@discordjs/voice');
exports.run = (client, message, args) => {
  const player = createAudioPlayer();
  const member = message.member;
  if (member.voice.channel) {
    const channel = member.voice.channel;
    const connection = joinVoiceChannel({
      channelId: channel.id,
      guildId: channel.guild.id,
      adapterCreator: channel.guild.voiceAdapterCreator,
    });
    let resource = createAudioResource(join(__dirname, 'muzica.mp3'));
    const subscription = connection.subscribe(player);
    player.play(resource);
    message.reply('Connected! Playing..');
  } else {
    message.reply('Nu esti pe canal bedboi');
  }
};```

The connection doesn't enter the ready state, and the player, enters the playing state, and then AutoPaused.
The connection doesn't enter any status.
spare panther

how to play audio in discord.js v13

covert obsidian
dull flame

[Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_BANS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS]

covert obsidian

there's your problem, one sec

you'll want to add Intents.FLAGS.GUILD_VOICE_STATES

dull flame

done, ty so much

covert obsidian

🙇

spare panther

hmm why

covert obsidian
spare panther

oh thanks

misty saddle
Socket.<anonymous>(/home/container/node_modules/@discordjs/voice/dist/networking/VoiceUDPSocket.js:120:52)
Object.onceWrapper (node:events:475:28)
Socket.emit (node:events:381:22)
socketCloseNT (node:dgram:754:8)
processTicksAndRejections (node:internal/process/task_queues:80:21)
UnhandledRejection Error at - Error: Cannot perform IP discovery - socket closed```
Why is it happening and how to Solve ??
naive zenith

Why am I hearing no audio? The bot is joining the channel and it logs in console that the player started

dull flame

can I export a player from a play.js file, to leave.js file and control it?

split sun

do we have an event for audioPlayer for when it stop playing audio?

carmine timber
carmine timber
carmine timber
carmine timber
carmine timber
misty saddle

means there is no permanent solution ?>

carmine timber
misty saddle
misty saddle
naive zenith
carmine timber
naive zenith
carmine timber

GUILD_VOICE_STATES intent ??

naive zenith

yeah

carmine timber

Ok good

carmine timber
misty saddle
carmine timber
zinc wadi

Hi, i'm getting the following error and I don't know why...

TypeError: Cannot read property 'set' of undefined
    at /Users/MIGI28/vscode-git/opus-bot/node_modules/discord.js/src/structures/Guild.js:1290:34
    at new VoiceConnection (/Users/MIGI28/vscode-git/opus-bot/node_modules/@discordjs/voice/dist/VoiceConnection.js:76:25)
    at Object.createVoiceConnection (/Users/MIGI28/vscode-git/opus-bot/node_modules/@discordjs/voice/dist/VoiceConnection.js:515:29)
    at Object.joinVoiceChannel (/Users/MIGI28/vscode-git/opus-bot/node_modules/@discordjs/voice/dist/joinVoiceChannel.js:18:30)
    at Object.module.exports.run (/Users/MIGI28/vscode-git/opus-bot/commands/play.js:58:43)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

play.js:58 is

var connection = client.voice.joinVoiceChannel({
channelId: voiceChannel.id,
guildId: message.guildId,
adapterCreator: message.guild.voiceAdapterCreator,
});

Does someone have an idea of what happens?

quasi coral

@zinc wadi you're not supposed to have client.voice.joinVoiceChannel, it's just joinVoiceChannel

var connection = joinVoiceChannel({
  channelId: voiceChannel.id,
  guildId: message.guildId,
  adapterCreator: message.guild.voiceAdapterCreator,
});
zinc wadi
fervent estuary

are u using any partials?

zinc wadi
fervent estuary

can u show me ur client options?

zinc wadi
const client = new Discord.Client({ intents: [
    Discord.Intents.FLAGS.GUILDS,
    Discord.Intents.FLAGS.GUILD_MEMBERS,
    Discord.Intents.FLAGS.GUILD_MESSAGES,
    Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
    Discord.Intents.FLAGS.DIRECT_MESSAGES,
    Discord.Intents.FLAGS.GUILD_PRESENCES,
    Discord.Intents.FLAGS.GUILD_VOICE_STATES
] 
});
fervent estuary

hmm

looks like an issue within the voiceAdapter

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

the error comes from this.client.voice.adapters.set(this.id, methods);

this is Guild.js:1290

fervent estuary

which version of discord.js are u on?

zinc wadi

13.1.0

and 0.6.0 for @discordjs/voice

fervent estuary

ok i see ur issue

you overwrote client.voice by setting that as require('@discordjs/voice')

zinc wadi

true, that's it

thank you

sonic sky

Why tf is this giving me "ffmpeg/avconv" not found whne I clearly hav it

fervent estuary

how did u install it?

sonic sky

npm install ffmpeg

fervent estuary

thats not the correct thing

dusty needleBOT

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

sonic sky

FeelsBadMan oh

I see, lemme try that

Oo, thanks now it works, but it's not giving error and it's failing the interaction

sonic sky

It smth wrong with how I play it

Probably cuz its in a forEach loop, and the player gets overloaded becusse i try to play more than 1 resources at it at the same time

How will I make it wait untill the 1st resource finishes and then make it move on to the 2nd?

Can use like a sleep function or smth? Even for that I need to know the accurate duration of the audio file.

vernal walrus

on the old voice system there was a 'finish' event that was fired when the current track ends.

is it removed now? if so what should i use instead?

rose helm

Readable.once("end", () => ...)

vernal walrus
rose helm

ReadableStream

whatever you pipe into the lib

vernal walrus

I'm using createAudioResource

that returns an AudioResource

and putting it as parameter into player.play method

rose helm

Okay... but the audio you send into the library should be a ReadableStream

vernal walrus

I still don't understand, my current code is

vernal walrus
rose helm

looks like resource.playStream is a Readable

Alternatively, don't pass a string into create audio resource. It's more consistent to just pass in a ReadableStream for everything

subtle granite
finite echo

Does it need vs 2017 to run?

The recorder

vernal walrus
rose helm
naive zenith

This is an example code and I'm confused what this part of the script is for. Why is it multiplying the amount of rejoin attempts by 5 seconds? Why is it 5 rejoin attempts?

dull flame

how can I disconnect the bot if AudioPlayerStatus.idle?

        player.disconnect();
      })```
This isn't working
rose helm

it's Idle not idle

subtle granite

hi there, im relativelly new to djs.13 and after hours of trying to update voice i´ve failed. My bot joins, queqe works, bot is signaling that is speaking (the green circle) but it is totally silent. is there a known bug or something not written in docs ? I have downloaded the examples and also non of them works. I´am currently on windows 10 with node.js 16.8.0

amber epoch
amber epoch
green raft

If I receive a Buffer from a website that is audio in an unknown format, how can I "convert" or somehow make them into real opus packets?

mp3 file***

amber epoch
green raft

Actually nvm I think I can just pipe it into a stream

open ginkgo

im trying to set up a command that just makes my bot join whichever voice channel the user that prompts it is in, but im having trouble reading the guide and i don't know how to set it up exactly:

module.exports = {
    name: 'join',
    description: 'join',
    async execute(message, args){
        const Discord = require('discord.js');
        const { joinVoiceChannel } = require('@discordjs/voice');
        const channel = message.member.voice.channel;
        if (channel) {
            try {
                const connection = joinVoiceChannel({
                    channelId: channel.id,
                    guildId: channel.guild.id,
                    adapterCreator: channel.guild.voiceAdapterCreator,
                });
            } catch (error) {
                console.error(error);
            }
        } else {
            message.reply('join a voice channel');
        }
      
    }
}

this gives me the error TypeError: adapterCreator is not a function, why is this happening?

subtle granite
amber epoch
amber epoch
subtle granite
amber epoch
steady hatch

why doesnt this work?

const {joinVoiceChannel, DiscordGateawayAdapterCreator} = require("@discordjs/voice")

 joinVoiceChannel({
        channelId: memberIsInVoiceChannel.id,
        guildId: message.channel.guild.id,
        adapterCreator: DiscordGateawayAdapterCreator,
    });

problem: adapterCreator is not a function

wild zephyr

You made a typo

bright moth

I'm once again getting stuck with the voice module... it started throwing https://sourceb.in/nqHePvWA4f this out when trying to play songs

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

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

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

FFmpeg
- version: 4.4-essentials_build-www.gyan.dev
- libopus: yes
--------------------------------------------------
``` and here are the deps
queen reef

How do I destroy an AudioResource?

Oh actually, can I just unsubscribe and it would destroy itself, or would that lead to a memory leak?

analog notch
queen reef

Oh I can just AudioPlayer.stop()!

carmine timber
bright moth

but but that is now how it's supposed to work...

carmine timber
bright moth

but i deleted the file

i uninstalled d.js opus globally it was not in the modules folder anymore and reinstalled it

forced install on 0.6.0 opus and that resolved my problem

carmine timber

👍

carmine timber
carmine timber
drifting flame

This is a late response. However, I don't think Youtube Together would make music bots obsolete, cause Youtube together doesn't work on non desktop clients, in stage channels, or when another activity is being run at this point in time.

open ginkgo
subtle granite

Hello can i by @discord.js/voice get events about connecting disconnecting members

dusty needleBOT

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

frail valley
 client.on("voiceStateUpdate", async (oldState, newState) => {

Why this isnt working

carmine timber
frail valley
fervent estuary
sonic sky

How will I know the 1st resource ended

fervent estuary

you can listen when audioPlayer state changes from playing to idle

carmine timber
fervent estuary
sonic sky

Thonku, ima tri

fervent estuary

u can also listen for resouce.playStream end event

that should work too

sonic sky

Ohhh

steady hatch

how to leave a voice channel

fervent estuary

voiceConnection.destroy()

steady hatch
steady hatch
fervent estuary

did u get an error or what?

steady hatch

class constructor VoiceConnection cannot be invoked without "new"

if i do that, add new, then it wouldnt leave the channel

fervent estuary

can you show the code where youre trying to leave the channel and got this error?

steady hatch

sure just give me a minute or two

fervent estuary
steady hatch
fervent estuary

ah yeah got it

mb

where did u add the new

steady hatch

i already tried doing it with new and it didnt work

fervent estuary

yes but where did u add that?

steady hatch

before voiceConnection()

fervent estuary

here?

either way thats not how ur supposed to get the voiceConnection

require getVoiceConnection call that and then call destroy on the connection that returns (provided that ur client is in a vc)

bitter echo

connection.receiver.createStream is not a function any help?

sonic sky

Is AudioPlayer.status a string?

steady hatch

console log it

amber epoch

when i do player.unpause() then i get the error The reply to this interaction has already been sent or deferred

so how would i do

player.on(AudioPlayerStatus.Playing, () => {
         interaction.reply(`🎶 Now playing\n**${link}**`);
});

without getting that error?

worldly plume

so you want to reply to an interaction twice? Once with the original response, and then later when the player starts playing?

sonic sky
amber epoch
worldly plume

maybe something like this?

player.on('stateChange', (oldState, newState) => {
    if (oldState.status == "idle" && newState.status == "playing") {
        interaction.reply(`🎶 Now playing\n**${link}**`);
    }
});

so it only fires when it goes from idle to playing, not from paused

I realized I did it backwards lol, fixed

sonic sky
storm nova

is there like a place in a guide or just anywhere to help me get started on voice in v13
(I know nothing about voice)

subtle granite

Last link in pins

finite echo

Nvm

glass stirrup

Music Bot question: I'm using YT for music resources but as well all know some videos give a 410 error. I'm able to detect and print the 410 error, however the bot still joins the VC then leaves and prints the error.

            player.on('error', error => {
            botchannel.send(`Audio Player error ${error.message} due to ${video.title}`)
            console.log(`Error ${error.message}`) 
            });```

is there a better way to detect the error and have the bot do nothing?
neon ibex

Even if all song is finished, somtimes ffmpeg process is not finished. Is there any solution?

glass stirrup

AudioPlayerStatus.Idle ?

late eagle

Hey, guys. How u doin'? What can I do to make my bot join a voice channel with discordjs v13?

rose helm
neon ibex
rose helm
neon ibex

thanks

subtle granite

how can i link a youtube stream audio to a voice channel... since vc.join() is not there any more
coudl someone please let me know

empty torrent
fossil delta

hello
my bot takes so long to play audio
i will send the logs which indicate every step

you can see there it takes about 10 miliseconds to create the audio resources but takes about 5 seconds to play the resource

my code is basically like this:

const connection = joinVoiceChannel();
const player = await createAudioPlayer();
const subscription = await connection.subscribe(player);
async function play() {
  const resource = await createAudioResource(); // takes about 10ms
  player.play(resource); // takes about 5 seconds to start playing the resource
}
play(); // this is an async function since it plays multiple audios

this is what require('@discordjs/voice').generateDependencyReport() returns:

icy maple

Those aren’t async methods tho

Ur awaiting things that don’t return Promises

You have to use entersState to check if the connection actually enters the ready state

@fossil delta

fossil delta

sorry, my bad for not clarifying that

velvet jewel

how do i know if the bot is speaking in a voice channel-

rose helm
fossil delta

its not the resource's fault, this worked flawlessly with v12

carmine timber
velvet jewel someone-

You can check if bot is in a voice channel by :

(message | interaction).guild.me.voice?.channel

But I don't know how to check if it is speaking

@vocal valley
Have you got time to test play-dl ??

I am waiting for your review.

vocal valley

This weekend I am busy, however I should be free for a few weeks after this weekend

storm nova

ive never done voice at all and now my friends are forcing me to make a v13 music bot help

carmine timber

Oh okay 👍

vocal valley

will look at finishing up /voice reviews etc. and looking into play-dl next week

carmine timber

👍

storm nova
subtle granite
storm nova

the guides confusing

subtle granite
storm nova

i know basic JS

subtle granite

Well then it shouldn't be confusing

storm nova

eh i'll just pay more attention while im reading everything

subtle granite

can someone PLEASE help me?

const { MessageEmbed } = require('discord.js');

module.exports = {
    name: 'call',
    UserPerms: ["ADMINISTRATOR"],
    /** 
     * @param {Client} client 
     * @param {Message} message 
     * @param {String[]} args 
     */
    run: async (client, message, args) => {
        var voiceChannel = message.member.voice.channel;
        const joinEmbed = new MessageEmbed()
            .setColor('RED')
            .setTitle('!call - Error')
            .addField(`They didn't pick up...`, `You weren't in a voice channel.`)
        if (!voiceChannel) return message.channel.send({embeds: [joinEmbed]}); 
        voiceChannel.join().then(connection => {
            const dispatcher = connection.play('./call-center-open.mp3')
            const callEmbed = new MessageEmbed()
            .setColor('#15EC96')
            .setTitle('!call')
            .addFields(
                { name: 'Calling', value: 'UrGud Call Center'},
                { name: 'Channel', value: 'Waiting Room'},
                { name: 'Message ID', value: `\`${message.id}\``},
                { name: 'Username', value: `\`${mention.user.username}#${mention.user.discriminator}\``},
            )
            message.reply({embeds: [callEmbed]})
            dispatcher.on("end", end => {
                voiceChannel.leave();
            });
        }).catch(err => console.log(err))
    }
}```

here's the error
    voiceChannel.join().then(connection => {
                 ^

TypeError: voiceChannel.join is not a function
at Object.run (C:\Users-\Desktop\Bot\commands\Service\call.js:19:22)
at Client.<anonymous> (C:\Users-\Desktop\Bot\events\MessageCreate.js:22:23)
at Client.emit (node:events:394:28)
at MessageCreateAction.handle (C:\Users-\Desktop\Bot\node_modules\discord.js\src\client\actions\MessageCreate.js:23:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users-\Desktop\Bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users-\Desktop\Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:345:31)
at WebSocketShard.onPacket (C:\Users-\Desktop\Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:443:22)
at WebSocketShard.onMessage (C:\Users-\Desktop\Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10)
at WebSocket.onMessage (C:\Users-\Desktop\Bot\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (node:events:394:28)

storm nova

so i set up my connection variable and i'm just trying to make the bot join. is there like a function or anything i need for that?

icy maple

joinVoiceChannel

The guide linked above covers that

storm nova

i use joinVoiceChannel for my connection variable

icy maple

Then you got the connection correctly

storm nova

yeah

icy maple

I would use entersState to wait until it becomes ready or it disconnected

storm nova

is that for joining?

icy maple

Yea

storm nova

so is it like connection.entersState() or how does it work

icy maple

It’s an exported function from the lib

dusty needleBOT
storm nova

i dont, understand

icy maple

When you call joinVoiceChannel, it’ll start trying to connect to the vc (Signalling)

Since the method isn’t async, it will immediately return the connection

If it becomes disconnected next, then the bot is missing perms or the guild voice states intent

Otherwise, it’ll detect that it’s connected to the vc and becomes ready

storm nova

so I have my connect variable, i just need to call joinVoiceChannel and it'll join?

icy maple

It’ll try to join

storm nova

how do I call joinVoiceChannel

dusty needleBOT
jaunty nova

Hi, is there a way to set player volume rn?

pine rose

how i fix?

jaunty nova

ah ok I have to do that now

craggy tide

voiceChannel.join() doesn't exist

jaunty nova

also getting "cannot read property 'once' of undefined" errors

trying to get this working with ytdl

craggy tide
craggy tide

I'm sure it does

jaunty nova

it's just the music part I haven't got working yet, but thanks

craggy tide

Regardless, if you want to use voice, you'll need to update your node version

jaunty nova

yeah I did

craggy tide

and install discord voice

jaunty nova

yeah ofc

or I wouldn't be getting errors from the npm package

also I found the issue, I was stupid enough to play a non-resource 🤷

thanks

craggy tide

the voiceChannel.join() isn't a function though, wouldn't be getting that from a npm package.

jaunty nova
craggy tide

oh gotcha. My bad.

craggy tide
pine rose um

You're going to have to rewrite your music bot logic from scratch and pull what works out of the old code.

It's not a copy and paste situation from the docs

pine rose

oh

craggy tide
pine rose oh

@pine rose ```
function getVoice(message) {
//verify user is in voice channel
const voiceChannel = message.member.voice.channel;
if (!voiceChannel.isVoice()) {
return message.channel.send(
"You need to be in a voice channel to play music"
);
}
//check for existing connection in guild
const existingConnection = getVoiceConnection(voiceChannel.guild.id);
const connection = existingConnection !== undefined ? existingConnection : joinVoiceChannel({
channelId: voiceChannel.id,
guildId: voiceChannel.guild.id,
adapterCreator: voiceChannel.guild.voiceAdapterCreator,
});

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

return connection;

}

This will return the connection
pine rose

all of that

craggy tide

Then you just need create a player and subscribe the player to the connection

pine rose
jaunty nova
craggy tide

It's not globally scoped @pine rose

jaunty nova

YTDL is being a prick tho

pine rose
craggy tide
craggy tide
jaunty nova

I'll look around for a bit first lmao

craggy tide

Only issue i ran into it was i had to update the npm package

pine rose

whats a subscription?

do i also need audio player?

craggy tide

@pine rose Allows you to use an audio player for different voice connections. i.e. Lounge Channel and Gaming Channel can listen to the same audio source.

jaunty nova

tbh I'm just puzzled, what stream format does ytdl return?

craggy tide

@jaunty nova I can't recall. Are you running into an encryption error or are you getting no audio in voice channel ?

jaunty nova
pine rose
jaunty nova

since the example in the guide uses file names 🤷

craggy tide
pine rose the docs doesnt show how to play music

It does. It's a bit general, but all the information you need is there.

@jaunty nova this is what I'm using to load song data when it's ready to be played

function loadSong({ url, title }) {
    const resource = createAudioResource(ytdl(url), {
        metadata: {
            title: title,
            url: url
        },
    })
    return resource;
}

@jaunty nova then, player.play(resource);

craggy tide

This is how you pull the url and title
const songInfo = await ytdl.getInfo(url);

jaunty nova

I use simple-youtube-api to get those

since I search for songs first, and it's a monoserver bot so no big concerns about ratelimits

craggy tide

Gotcha. Regardless, the loadSong should return what you ned to play on demand. You dont want to build the resources ahead of time.

jaunty nova

yeah, the createAudioResource function seems like it'll work fine like that

thanks a lot :)

craggy tide

Np. Just a heads up, you can't reload those audio sources. ex) going to a previous song wont work since the stream is dead. You'll have to reload the audio

jaunty nova

figured that out when I tried to implement looping

craggy tide
jaunty nova

will note for the future

currently figuring out why my bot says it isn't in a stage channel when it is, probably because of async tho

unborn forge

How can I prevent my bot from losing connection when no one is in the channel?

craggy tide
jaunty nova

turns out it wasn't

async

solemn portal

Anyone able to help me solve a problem where my bot disconnects from VC after about 3-4 mins ( seems to be on every song change )

dire glen

how to make bot auto disconnect from vc after inactivity and send message that i left vc due to inactivity

vagrant garnet

<AudioPlayer>#on(AudioPlayerStatus.Idle, () => {
<VoiceConnection>#destroy();
/* your code */
})

you can use setTimeout to add a delay

vagrant garnet

put it in /* your code */, depending on the channel etc.

dire glen

sorry didnt undetood

subtle granite
  destroy(guildID) {
    const dispatcher = this.get(guildID);
    dispatcher?.connection?.destroy();
    return this.delete(guildID);
  }```
fervent estuary

the error is quite self explanatory

ur trying to destroy a voiceConnection that has already been destroyed

subtle granite

Hmm what I do wrong then

fervent estuary

literally exactly what i just said

outer kraken

for some reason my bot can join the voice channel but is just playing silence, does anyone know why? (queuem is a map btw) https://pastebin.com/9zBZb167

willow crown

whenever a certain person joins this vc, i made it where my bot joins and plays a sound, and it works, but it also joins and plays whenever the person mutes or unmutes, how would i fix this?

craggy tide

@outer kraken

        .then((probe) => playing = createAudioResource(probe.stream, {inputType: probe.type }));
    sQueue.player.play(playing)

    sQueue.player.play(resource);```
I don't see where you defined resource in your snippet
outer kraken

ignore sQueue.player.play(resource);, its been removed in the code but is on pastebin

craggy tide

@outer kraken Try this
demuxProbe(stream) .then((probe) => { const playing = createAudioResource(probe.stream, {inputType: probe.type })); sQueue.player.play(playing) }

willow crown
craggy tide

@outer kraken What happens when you do

       player.on(AudioPlayerStatus.Playing, () => {
            console.log('The audio player has started playing!');
        });
outer kraken

interesting, doesn't every say anything

craggy tide

did you put that near where you create the players?

outer kraken

nevermind

i put sQueue.player.on instead and it puts it in console

craggy tide

try this for your resource

    const resource = createAudioResource(ytdl(url), {
        metadata: {
            title: title,
            url: url
        },
    })
outer kraken

does it need the metadata?

craggy tide

No

outer kraken

can i just have it as const resource = createAudioResource(ytdl(url)) then?

craggy tide

should work

outer kraken
craggy tide

Hm. Try logging the audio resource

outer kraken

what do you mean by that?

willow crown

how do i make it where a bot detects only when someone joins not if they muted or not

craggy tide
outer kraken

and other half of it

craggy tide

show me the vp function again

outer kraken
  const sQueue = queuem.get(guild.id);
  if (!song) {
        interaction.followUp("something happened")
        return;
    }
    console.log(song)
    const stream = ytdl(song,{
            o: '-',
            q: '',
            f: 'bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio',
            r: '100K',
        }
    )
    const resource = createAudioResource(ytdl(song))
    console.log(resource);
    sQueue.player.on(AudioPlayerStatus.Playing, () => {
            console.log('The audio player has started playing!');
        });
    sQueue.player.play(resource);
    sQueue.player.on('stateChange', (oldState, newState) => {
            if (newState.status === AudioPlayerStatus.Idle && oldState.status !== AudioPlayerStatus.Idle) {
                sQueue.songs.shift();
            vP(guild, sQueue.songs[0])
            }
    })
}
craggy tide

async function vP(guild, song) {
    const sQueue = queuem.get(guild.id);
    console.log('QUEUE:',sQueue, '\n', song);
    const resource = createAudioResource(ytdl(song))
    sQueue.player.on(AudioPlayerStatus.Playing, () => {
        console.log('The audio player has started playing!');
    });
    sQueue.player.play(resource);
}

try running just this

then send me the console

outer kraken
slow pier
outer kraken
craggy tide

@outer kraken Can you log this connection._state.subscription

also add this to your connection just to be sure

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

Did you make sure to bind it to where you put make the connection ?

outer kraken

i put it here

craggy tide

Try this for your connection

          const existingConnection = getVoiceConnection(voiceChannel.guild.id);
            queue.connection = existingConnection !== undefined ? existingConnection : joinVoiceChannel({
                channelId: voiceChannel.id,
                guildId: voiceChannel.guild.id,
                adapterCreator: voiceChannel.guild.voiceAdapterCreator,
            });

slow pier
craggy tide

@outer kraken How's that lookin?

outer kraken
craggy tide

you still don't have any logs on the connection ?

outer kraken

lmao i should probably fix this first

craggy tide

That might be an issue lol

outer kraken

hasn't changed anything

craggy tide

No logs on connection ?

outer kraken

oh yeah there is this, but that was there already

craggy tide

Yeah i meant that the connection was in the ready state

outer kraken

nah

craggy tide

send me ur play function again just to be sure i'm looking at the same thing

outer kraken
        console.log(song)
    var queue = queuem.get(interaction.guild.id);
    if (!queue) {
            if ( interaction.member.voice.channel) {
                queuem.set(interaction.guild.id,{songs:[],connection:null,player:null});

                var queue = queuem.get(interaction.guild.id);

                const channel = interaction.member.voice.channel;
                const existingConnection = getVoiceConnection(channel.guild.id);
        queue.connection = existingConnection !== undefined ? existingConnection : joinVoiceChannel({
                channelId: channel.id,
                guildId: channel.guild.id,
                adapterCreator: channel.guild.voiceAdapterCreator,
            });
                queue.connection.on(VoiceConnectionStatus.Ready, () => {
                    console.log('The connection has entered the Ready state - ready to play audio!');
                });
                queue.songs = [song]
                queue.player = createAudioPlayer()
                queue.connection.subscribe(queue.player)
                try {
            vP(interaction.guild,queue.songs[0]);
          } catch (err) {
            console.log(err)
            interaction.followUp("an error occured, try again");
          }
            } else {
                await interaction.followUp('join a voice channel');
                return;
            }
        } else {
            queue.songs.push(song);
        }

};```
craggy tide

You're not getting any other errors in your console ?

outer kraken

nope, just a message saying the audio player has started, no message about the connection being ready

craggy tide

did you import VoiceConnectionStatus

outer kraken

its under { VoiceConnectionStatus, other stuff} = require("discordjs/voice")

craggy tide

gotcha, and you have GUILD_VOICE_STATES in your client?

outer kraken

where abouts?

craggy tide
glass stirrup

is there a simple way to troubleshoot "Invalid webhook token" errors? the bot plays music just fine but sometimes 5 - 20 mins into a 1hr song it errors with that^

outer kraken

i have this

craggy tide

try the line i pasted

outer kraken
craggy tide

Great to hear! and np

outer kraken

i forget intents were a thing, gotta love discord api changes

willow crown

how do i check if someone is speaking

final sage

how to make a bot join a voice channel?

gleaming harbor

how can i set the volume of bot in VC

subtle granite

How can i play mp3 file form url?

glass stirrup

still having invalid webhook token issues, especially on song end. any docs or resources i can take a look at to research?

subtle granite

its from file

glass stirrup

From file has an example on the cheat sheet posted above

craggy tide
craggy tide

something like that

subtle granite

okay

fossil delta
rancid blaze

The bot joins the channel but doesn't switch into Ready mode. I cannot figure out why.

// Create Audio Player
                const player = createAudioPlayer();

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

                connection.on('error', err => { console.log(err); })

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

                // Play song
                let audioResource = createAudioResource('./song.mp3');
                player.play(audioResource);
                
                // Subscribe to my channel
                connection.subscribe(player);

Created following the upgrade guide on the documentation

rose helm
subtle granite

createReadStream is through the fs. If you want a stream from the internet, use the built in http lib. If it's an icecast/shoutcast server and you get an http parse error, use the icy npm module which mimics the built in http lib

rancid blaze

Dabs in sad boi

narrow hollow

how to selfDeaf in discord js v13

fervent estuary

pass selfDeaf as true in the options when connecting to a channel

also its enabled by default

next barn

@rancid blaze please do not use slurs

short latch

hello, i am trying to make a bot join a voice channel and play an mp3 file. It successfully joins the channel, but then nothing happens. no audio is played. js DiscordVoice.joinVoiceChannel({ channelId: message.member.voice.channel.id, guildId: message.guild.id, adapterCreator: message.guild.voiceAdapterCreator }) const player = DiscordVoice.createAudioPlayer() const resource = DiscordVoice.createAudioResource('../../hello.mp3') player.play(resource)

fossil delta

connection.subscribe(player);

fossil delta
short latch

i just added that and it still doesnt work

fossil delta
fossil delta
fossil delta
short latch

ready occured, but playing didnt

fossil delta

what the hell is even that?

what is bot.queue.get()

check if the queue exists? thats not a djs voice issue?

fossil delta

thats still not a djs voice error, its an error in your code

short latch
fossil delta

then what are you doing here? XD

debug your code correctly and you will find the error

short latch

the on ready event works

fossil delta
short latch

im just trying to play this

fossil delta

XD

check if the resource is not null

short latch

logs this

fossil delta

hmm

can you run require('@discordjs/voice').generateDependencyReport()?

short latch

just paste it in the code and run it?

done that

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

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

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

FFmpeg
- version: N-101991-gc8fb68ec52-glq
- libopus: yes
--------------------------------------------------```

@fossil delta am I missing one i need

fossil delta

what is that ffmpeg version??

short latch

custom compiled version

fossil delta

oh i see

short latch

adds fixes for gifs so that they work better in discord

short latch

@fossil delta if i print the state every time it updates, it does this

shut axle

This error occurs while playing music

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

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

This is the code:

const Voice = require('@discordjs/voice');
const ytdl = require('ytdl-core')
const ytSearch = require('yt-search')
const { generateDependencyReport } = require('@discordjs/voice');

console.log(generateDependencyReport());

const cmdArray = [
    "play", "leave"
]
client.on("messageCreate", async (msg) => {
    x = msg.content.split(" ")
    if (msg.author.bot || msg.content.split(" ")[0] != prefix) return
    if (!cmdArray.includes(x[1])) return

    const { channel } = msg.member.voice;
    if (!channel) return msg.reply("You need to join a voice channel")
    const VoiceConnection = Voice.joinVoiceChannel({
        channelId: channel.id,
        guildId: channel.guild.id,
        adapterCreator: channel.guild.voiceAdapterCreator,
    });
    if (x[1] == "play") {
        if (x.length > 2) {
          try{
            const player = Voice.createAudioPlayer();
            VoiceConnection.subscribe(player)
            const videoFinder = async (query) => {
                const videoResult = await ytSearch(query)
                return (videoResult.videos.length > 1) ? videoResult.videos[0] : null
            }
            args = x.splice(2, x.length);
            console.log(args)
            const video = await videoFinder(args.join(' '))
            if (video) {
                const stream = ytdl(video.url, { filter: 'audioonly' })
                const resource = Voice.createAudioResource(stream);
                player.play(resource);
                await msg.reply(`Now Playing: ${video.title}`)
            }
            else {
                msg.reply("No video Results found")
            }
          }
          catch(e){
            console.log(e)
          }
        }
        else {
            msg.reply("Please send a song request as the second argument.")
        }
    }
    else if (x[1] == "leave") {
        VoiceConnection.destroy();
    }
})
empty torrent
shut axle

ok thanks

dire glen

@bronze swan

oak folio

Can someone explain what this piece of code does?

warped sigil

I'm currently trying to implement ytdl-core, getting the audio stream playing a song from url.

let stream = ytdl(song.url, {
       filter: "audioonly"
   });

   console.log(stream);

   song_queue.audio_player.play(stream, { seek: 0, volume: 0.5 })
       .on('finish', () => {
           song_queue.songs.shift();
           video_player(guild, song_queue.songs[0]);
       });
   song_queue.text_channel.send(`🎶 Now playing **${song.title}**`)

I'm currently getting this error, anyone know why?

E:\Discord Bots\Funky\node_modules\@discordjs\voice\dist\audio\AudioPlayer.js:221
        resource.playStream.once('error', onStreamError);
                            ^

TypeError: Cannot read property 'once' of undefined
    at AudioPlayer.play (E:\Discord Bots\Funky\node_modules\@discordjs\voice\dist\audio\AudioPlayer.js:221:29)
    at video_player (E:\Discord Bots\Funky\music.js:107:29)
    at musicPlay (E:\Discord Bots\Funky\music.js:74:17)
    at Client.<anonymous> (E:\Discord Bots\Funky\index.js:98:13)
    at Client.emit (node:events:394:28)
    at MessageCreateAction.handle (E:\Discord Bots\Funky\node_modules\discord.js\src\client\actions\MessageCreate.js:23:14)
    at Object.module.exports [as MESSAGE_CREATE] (E:\Discord Bots\Funky\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (E:\Discord Bots\Funky\node_modules\discord.js\src\client\websocket\WebSocketManager.js:345:31)
    at WebSocketShard.onPacket (E:\Discord Bots\Funky\node_modules\discord.js\src\client\websocket\WebSocketShard.js:443:22)
    at WebSocketShard.onMessage (E:\Discord Bots\Funky\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10)

The stream itself appears to be an object, as it returns information when I log it to the console.

austere osprey

I am getting the error Aborted everytime

glass stirrup

Any tips on catching Miniget errors? Currently I’m able to catch them via audioplayer.on error. But that’s after the bot attempts to play the YouTube search…

Usual errors are 410’s

carmine timber
carmine timber
carmine timber
carmine timber
carmine timber
fossil delta can someone please help me with this?

It depends upon what type of resource you are playing.

For example, If I play a unknow type of stream, then voice module will change it to ogg using ffmpeg and then pass this to OGG demuxer and then it will play.

Your pipeline is taking time, nothing else

It is recommended to pass inputType while creating a opus, webm-opus, ogg streams since they will be requiring a demuxer and will take less time to play.

For more info : https://discordjs.guide/voice/audio-resources.html#playing-opus-streams

empty torrent
austere osprey

@empty torrent au

empty torrent

I stopped using ytdl-core, in your case discord-player because of this error.

open ginkgo
const ytdl = require('ytdl-core');
const {
    AudioPlayerStatus,
    StreamType,
    createAudioPlayer,
    createAudioResource,
    joinVoiceChannel,
} = require('@discordjs/voice');
const { SlashCommandBuilder } = require('@discordjs/builders');

const Discord = require('discord.js');
const connection = joinVoiceChannel({
    channelId: voiceChannel.id,
    guildId: guild.id,
    adapterCreator: guild.voiceAdapterCreator,
});

trying out joining a voice chat with the code in the guide, but it gives me this error

D:\rustl\Documents\plazmicbot\commands\play.js:13
        channelId: voiceChannel.id,
                   ^

ReferenceError: voiceChannel is not defined

it doesn't say anywhere in the guide how to define it

nvm i didn't include the const { clientId, guildId, token } = require('./config.json'); if that's causing it

empty torrent
open ginkgo

thanks, but im getting this error now whenever i try to play a youtube link:

Error: Cannot play a resource that has already ended.
    at AudioPlayer.play (D:\rustl\Documents\plazmicbot\node_modules\@discordjs\voice\dist\audio\AudioPlayer.js:194:19)
    at Object.execute (D:\rustl\Documents\plazmicbot\commands\play.js:30:16)
    at Client.<anonymous> (D:\rustl\Documents\plazmicbot\index.js:153:17)
    at Client.emit (node:events:394:28)
    at InteractionCreateAction.handle (D:\rustl\Documents\plazmicbot\node_modules\discord.js\src\client\actions\InteractionCreate.js:66:12)
    at Object.module.exports [as INTERACTION_CREATE] (D:\rustl\Documents\plazmicbot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (D:\rustl\Documents\plazmicbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:345:31)
    at WebSocketShard.onPacket (D:\rustl\Documents\plazmicbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:443:22)
    at WebSocketShard.onMessage (D:\rustl\Documents\plazmicbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10)
    at WebSocket.onMessage (D:\rustl\Documents\plazmicbot\node_modules\ws\lib\event-target.js:132:16)

ill send the rest of the code in the next message

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

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

const stream = ytdl('youtube link', { filter: 'audioonly' });
const resource = createAudioResource(stream, { inputType: StreamType.Arbitrary });
const player = createAudioPlayer();

module.exports = {
    data: new SlashCommandBuilder()
        .setName('play')
        .setDescription('stupid music'),
    async execute(interaction) {
        voiceChannel = interaction.member.voice.channel;
        guild = interaction.member.guild;
        const connection = joinVoiceChannel({
            channelId: voiceChannel.id,
            guildId: guild.id,
            adapterCreator: guild.voiceAdapterCreator,
        });
        
        player.play(resource);
        connection.subscribe(player);

        player.once(AudioPlayerStatus.Idle, () => connection.destroy());
    },
  };

this is pretty much just copied from the guide so i don't know what i could've done wrong here

empty torrent
carmine timber
open ginkgo
carmine timber
empty torrent
shut axle
fervent estuary

Thats and ytdl-core error

It just gets forwarded from the resource over to the audioPlayer and then comes out as an audioPlayerError

shut axle

ok thanks

zenith raven

Hey I am pretty new to discord.js can anyone help out with what are some good audio library for discordjs

And I have been exploring erela.js can anyone tell me if I can play mp3 files with it or not

spare snow

Sometimes I get this error just after subscribing to an audio player and it crashes the process

    throw new ERR_SOCKET_DGRAM_NOT_RUNNING();

Error [ERR_SOCKET_DGRAM_NOT_RUNNING]: Not running```
originating from https://github.com/discordjs/voice/blob/f1869a9af5a44ec9a4f52c2dd282352b1521427d/src/networking/VoiceUDPSocket.ts#L152
Does anyone know why it's happening?
arctic orbit

Hello, how do I install the sodium package?

I get this error when installing

spare snow
arctic orbit

Okay but how?

spare snow

sudo apt install libtool if you're on ubuntu, otherwise google is your friend

arctic orbit

Okay thanks :) (im on ubuntu lol)

carmine timber
arctic orbit

Bruh after installing libtool I have the same error

carmine timber
arctic orbit

Okay

Ty :)

spare snow
spare snow

show us the new error

spare snow
arctic orbit
spare snow
arctic orbit

ah yes, you're missing autoconf too sudo apt install autoconf

carmine timber
arctic orbit

Okay

It works thanks!

spare snow
acoustic ingot

how would i get my bot to join voice channel id on ready? for my music bot

client.on("ready", () => {
    const channel = client.channels.cache.get("ChannelID");
    if (!channel) return console.error("The channel does not exist!");
    channel.join().then(connection => {
        // Yay, it worked!
        console.log("Successfully connected.");
    }).catch(e => {

        // Oh no, it errored! Let's log it to console :slight_smile:
        console.error(e);
    });
});

This seems to work but the bot joins the voice channel but cannot play music

fervent estuary
covert jackal

Hey, im trying to use player.on(AudioPlayerStatus.Idle, () => {
but audioplayerstatus is undefined, from where do i need to define it

fervent estuary

you need to require/import it from discordjs/voice

covert jackal

ok

pure basalt

how is this connection.dispatcher.streamTime now?

nvm it's player.state.playbackDuration

so how can you seek a stream now?

and also change the volume?

fervent estuary
pure basalt

yup already found about the volume

fervent estuary

for seeking

you can create ur own ffmpeg transcoder

and then spawn it with the seek argument

pure basalt

how can I do that

south ice
const { SlashCommandBuilder } = require('@discordjs/builders');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('play')
        .setDescription('Play mp3 file'),
    async execute(interaction) {
        channel = interaction.member.voice.channel;
        const connection = joinVoiceChannel({
            channelId: channel.id,
            guildId: channel.guild.id,
            adapterCreator: channel.guild.voiceAdapterCreator,
        });

        const player = createAudioPlayer();
        const resource = createAudioResource('../test.mp3');
        player.play(resource);
        connection.subscribe(player);

        await interaction.reply(`Bot is in the house!`);
    },
};``` Bot does join the channel but it doenst play any sound, pls help 😄
sudden folio

you need to subscribe the player

south ice

still doesnt work...

sonic sky

OMEGAlul how did you do it

south ice

i edited it

sudden folio

any error in the console?

south ice

nope

sonic sky
south ice

still doenst work

final sage
let vc = interaction.member.voice.channel;
        
        if(!vc){
            return interaction.reply({ content: "Please join a voice chat first", ephemeral: true });
        }else{
            const connection = joinVoiceChannel({
                        channelId: vc.id,
                        guildId: vc.guild.id,
                        adapterCreator: vc.guild.voiceAdapterCreator,
                    });
 
            
                }``` it says please join a voice chat even if I am already in a vocal chat
chrome junco
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require('@discordjs/voice');


module.exports = {
    data: new SlashCommandBuilder()
        .setName('test')
        .setDescription('This is a command for testing'),
    async execute(interaction) {
        await interaction.reply('Loading Data');
        const channel = interaction.member.voice.channel;
        const connection = joinVoiceChannel({
            channelId: channel.id,
            guildId: channel.guild.id,
            adapterCreator: channel.guild.voiceAdapterCreator,
        });

        const player = createAudioPlayer({});
        const resource = createAudioResource('../music/song.mp3');


        const subscription = connection.subscribe(player);
        subscription.play(resource);

    },
};

``` i have no errors but after my bot joins the voice channel it does not play music

oh i do get error i get this: ```Error: FFmpeg/avconv not found!
at Function.getInfo (D:\Programing\Discordbots\Danzr\node_modules\prism-media\src\core\FFmpeg.js:143:11)
at Function.create (D:\Programing\Discordbots\Danzr\node_modules\prism-media\src\core\FFmpeg.js:156:38)
at new FFmpeg (D:\Programing\Discordbots\Danzr\node_modules\prism-media\src\core\FFmpeg.js:45:27)
at Object.transformer (D:\Programing\Discordbots\Danzr\node_modules@discordjs\voice\dist\audio\TransformerGraph.js:144:29)
at D:\Programing\Discordbots\Danzr\node_modules@discordjs\voice\dist\audio\AudioResource.js:156:60
at Array.map (<anonymous>)
at createAudioResource (D:\Programing\Discordbots\Danzr\node_modules@discordjs\voice\dist\audio\AudioResource.js:156:41)
at Object.execute (D:\Programing\Discordbots\Danzr\commands\test.js:19:20)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Client.<anonymous> (D:\Programing\Discordbots\Danzr\index.js:27:3)
D:\Programing\Discordbots\Danzr\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:89
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
^

Error [INTERACTION_ALREADY_REPLIED]: The reply to this interaction has already been sent or deferred.
at CommandInteraction.reply (D:\Programing\Discordbots\Danzr\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:89:46)
at Client.<anonymous> (D:\Programing\Discordbots\Danzr\index.js:31:22)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
[Symbol(code)]: 'INTERACTION_ALREADY_REPLIED'
}

dusty needleBOT

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

chrome junco

thanks that worked, but now i dont get errors but it still does not work

i added this player.on(AudioPlayerStatus.Playing, () => { console.log('The audio player has started playing!'); });
now it prints in console that the audioplayer is playing but the bot itself does not produce any sound

fossil delta
chrome junco

hello, i am trying to make a command so my bot can play music but i get no errors but there is no sound comming out of the bot, this is the code: ```const { SlashCommandBuilder } = require('@discordjs/builders');
const { joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayerStatus } = require('@discordjs/voice');

module.exports = {
data: new SlashCommandBuilder()
.setName('test')
.setDescription('This is a command for testing'),
async execute(interaction) {
await interaction.reply('Loading Data');
const channel = interaction.member.voice.channel;
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});

    const player = createAudioPlayer({});
    const resource = createAudioResource('D:/Programing/Discordbots/Danzr/music/song.mp3');


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


    player.on(AudioPlayerStatus.Playing, () => {
        console.log('The audio player has started playing!');
    });

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

},

};

arctic orbit

Hello, does <AudioPlayer>.end() exist?

subtle granite
arctic orbit

In the past, we had <StreamDispatcher>.end()

fading palm

Hey guys, are there streamoptions available for this new discord audio player? Before we could specify a seek time and a volume, like this:

var streamOptions = {
    seek: 0,
    volume: 1
};

This new v13 audio player is not even documented. Seems inferior to the v12 version

arctic orbit

Documentation just for you

But the end method wasnt on the old documentation

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

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

how to change the end receiver? like end the record with a command or just say stop?

fading palm
vocal valley
ebon veldt

can anyone explain why the music-bot example is using import? im kinda confused

vocal valley

I can't remember the issue they posted it on exactly

fading palm
vocal valley
spare snow
fading palm
subtle granite

@fading palm

fading palm
vocal valley
jaunty trail
arctic orbit

Does joinVoiceConnection return a Promise ?

Because I get this error: TypeError: connection.suscribe is not a function

icy maple

Show code

Oh wait, you misspelled subscribe

suscribe, lol

arctic orbit
unborn void

F

lime bough

i need help with a small thing, do u guys know how to do the command !join for a music bot?

icy maple

Use the joinVoiceChannel function from the voice package

limber plinth

Hi, I'm trying to make my bot connect to a voice channel. I read the new guide (https://discordjs.guide/voice/voice-connections.html) and created this code:

const Discord = require("discord.js");
const client = new Discord.Client();
const { joinVoiceChannel } = require("@discordjs/voice");

client.on("message", message => {
    if(message.content === "!join") {
        var connection = joinVoiceChannel({
            channelId: message.member.voice.channel.id,
            guildId: message.guild.id,
            adapterCreator: message.channel.guild.voiceAdapterCreator
        })
    }
})

client.login(<MY_TOKEN>);

It ends with this error:

/node_modules/@discordjs/voice/dist/VoiceConnection.js:76
        const adapter = adapterCreator({
                        ^

TypeError: adapterCreator is not a function
    at new VoiceConnection (/node_modules/@discordjs/voice/dist/VoiceConnection.js:76:25)
    at Object.createVoiceConnection (/node_modules/@discordjs/voice/dist/VoiceConnection.js:515:29)
    at joinVoiceChannel (/node_modules/@discordjs/voice/dist/joinVoiceChannel.js:18:30)
    at Client.<anonymous> (/index.js:7:9)
    at Client.emit (events.js:314:20)
    at Client.EventEmitter.emit (domain.js:483:12)
    at MessageCreateAction.handle (/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)

What am I doing wrong?

dusty needleBOT
lime bough

i need help with a small thing, do u guys know how to do the command !join for a music bot?

lime bough
icy maple

The one owned by discordjs

@discordjs/voice

arctic orbit
lime bough
lime bough

im kind of new thats why im a bit slow

icy maple
limber plinth
icy maple

Can you try logging the <Guild>.voiceAdapterCreator

pure basalt

where can I find the docs for the voice library?

limber plinth
rustic temple
pure basalt

thanks

arctic orbit
rustic temple

Oh mb, sorry I misunderstood

jaunty nova

Hi, what do miniget error 410 gone errors thrown by players mean in this package?

limber plinth
fervent estuary
jaunty nova

is that just when ytdl-core's source errors out (e.g. 403)?

fervent estuary

yes

fervent estuary

it just shows up as an audioPlayerError due to the reason @discordjs/voice is built

jaunty nova

alright thanks a lot

also any better alternatives than ytdl-core you can recommend for djsvoice?

fervent estuary

youtube-dl possibly

jaunty nova

the non-depreciated package right? (the one in the guide example)

if so I'll go look at it and see what I can do

fervent estuary

the one the examples use

jaunty nova

ah ok good

pure basalt

hey Matte, you said this before when I asked about seeking:
for seeking you can create ur own ffmpeg transcoder and then spawn it with the seek argument
but how can I do this?

fervent estuary
arctic orbit

Is it possible to destroy an AudioPlayer ?

fervent estuary

audioPlayer#stop()

pure basalt
fervent estuary

ytdl returns a readable stream so in that case you would pipe stream to that and pass the result to createAudioResouce()

pure basalt

something like ytldStream.pipe(stream) right?

fervent estuary

yes

pure basalt

ok thank you

arctic orbit
fervent estuary

well thats the best solution for "destroying" the player that i can think of

arctic orbit

Okay

chrome junco
arctic orbit

@chrome junco idk if that can help you but you don't have to specify a channel when you <AudioPlayer>.play()

chrome junco

i know but it didn' t work when i did not specify the channel so i tested it also with specifieng it no difference

arctic orbit

Hm

Sorry but for me everything is fine with your code

chrome junco

yea that is what i was thinking too but it still does not seem to be working. and other people have the same problem or am i the only one?

outer kraken

hmm, this seems to happen sometimes during a song

crisp furnace

Hey, i upgraded to discord JS v13 and i ve got a problem.

I am trying to figure out how to make the following code work in the new version:

const { Client, Intents, MessageEmbed } = require('discord.js');
global.client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

client.on("voiceStateUpdate", function(oldMember, newMember) {
    console.log(`a user changes voice state`);
});

client.login(token);

I know that i need the discordJS/voice thing but idk how to use it xD

eager perch

What is this error? AudioPlayerError: write EPIPE

nevermind I didnt have ffmpeg-static installed

queen reef

Is there a way to get a voice connection's subscription? I'm trying to make a check for if the bot is moved to allow it to resubscribe to a vc which I presume is necessary.

If not I can definitely do a workaround

neon ibex

Which youtube module is best for discord bot to play the music?

void wadi

has anyone made this work with ytdl-core without the need of saving the file first?

icy maple

It works fine for me

I don’t do anything special. Just createAudioResource(ytdl(…)) then play it on the Player

void wadi

eew okay thank you, I was trying to add some meta data at the same time and wasn't working

now it works with only including the ytdl function

icy maple

It doesn’t work when you include meta data?

void wadi

no

short latch

how would i force a bot to leave all voice channels when it starts running (if it ended while in a voice channel and didnt leave)

icy maple

You can’t

You have to destroy the connections before the bot shuts down

void wadi
neon ibex

Hello, what is the advantage of using demuxProbe in discordjs/voice?

subtle granite

what does socket hang up mean?

glass stirrup

using play-dl for music now.. liking it alot better. whats the best way to catch "Error: While getting info from url
Sign in to confirm your age"

carmine timber
glass stirrup

thanks, typical overthinking at it's best

was trying to deconstruct the error from the Extractor util -.-

carmine timber

XD

carmine timber
carmine timber
carmine timber
carmine timber
carmine timber

👍

short gust

What's the typical approach for playing Spotify playlists/songs? Finding the name from the Spotify link and then searching on youtube?

covert sigil

whats a good js library for doing youtube searches for videos?

modest olive

The link is

fervent estuary
fervent estuary

Not official ones. U will most likely be able to find unofficial ones tho

lime bough

How do i make the music bot join a channel when i type !join?

empty torrent
lime bough

The first one “joinVoiceChannel”?

Cuz I don’t see any command for that like !join

empty torrent
lime bough

Can you please show me how cuz I’m kinda new to this

I just need to make the !join command and then I’m fully done

empty torrent
empty torrent
lime bough
solid bronze

Is it possible to stream files from Google Drive?

zenith raven

Hey can anyone tell me how to get a position of the current playing stream and how to seek using discordjs Voice ?

south ice
dusk hawk

v13 record

error?

You added the intent GUILD_VOICE_STATES?

in your client

rugged talon

someone can't teach me how to make bot music ?

chrome junco
const { joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayerStatus } = require('@discordjs/voice');


module.exports = {
    data: new SlashCommandBuilder()
        .setName('test')
        .setDescription('This is a command for testing'),
    async execute(interaction) {
        await interaction.reply('Loading Data');
        const channel = interaction.member.voice.channel;
        const connection = joinVoiceChannel({
            channelId: channel.id,
            guildId: channel.guild.id,
            adapterCreator: channel.guild.voiceAdapterCreator,
        });

        const player = createAudioPlayer({});
        const resource = createAudioResource('../music/song.mp3');


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


        player.on(AudioPlayerStatus.Playing, () => {
            console.log('The audio player has started playing!');
        });

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

    },
};``` Does somebody know what is wrong with my code, it gives no errors it even prints: ' The audio player has started playing!' . But no sound is comming out of the bot
dusk hawk

no:

const Discord = require('discord.js');
Intents = Discord.Intents;
const client = new Client({ intents: [Intents.FLAGS.GUILD_VOICE_STATES]});

try this

quaint bear
dusk hawk
const Discord = require('discord.js');
Intents = Discord.Intents;
const client = new Discord.Client({ intents: [Intents.FLAGS.GUILD_VOICE_STATES], disableeveryone: true});

try this

an error?

yes

euhhh idk sorry

empty torrent

Above everything else, you need GUILDS, GUILD_MESSAGES and GUILD_VOICE_STATES intents. Enable those and try again with your code.

Yes, add GUILDS, GUILD_MESSAGES also

river cypress

1 sec

yep not workin

empty torrent

Can you add GUILD_MEMBERS and enable privileged intents also from dev portal?

Not sure but that’s the last thing i can think of

empty torrent

Any error or anything?

south ice

module.exports = {
    data: new SlashCommandBuilder()
        .setName('play')
        .setDescription('Play music'),
    async execute(interaction) {
        const { createAudioResource, createAudioPlayer, joinVoiceChannel } = require('@discordjs/voice');
        const ytdl = require("ytdl-core");

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

        await interaction.reply(`Track duration: ${stream.readableLength} s`);
    },
};``` Can somebody help me with this, it joins the channel, no errors, but doenst play anything
chrome junco

does someone have a working music bot that i can borrow to see if the problem is on my pc or not?

short gust

my music bot using ytdl is just randomly aborting for no apparent reason. how can i prevent this?

carmine timber
short gust
carmine timber
short gust

ye i used that before and got something functional working, ill just try to go with that thanks

carmine timber

Ok no issues 👍

carmine timber
crisp furnace
chrome junco
carmine timber

👍

outer kraken
green marsh
        .then(connection => console.log('Connected!'))
        .catch(console.error);```why?
 ```               joinVoiceChannel.join()
                                 ^
TypeError: Cannot read property 'join' of undefined```

GC_Florks_tea

south ice

does somebody know how to disconnect a bot from a voice channel

south ice
green marsh
else if (command === 'vc'){
        const member = message.member;
        
            const channel = member.voice.channel;
            const connection = joinVoiceChannel({
                channelId: channel.id,
                guildId: channel.guild.id,
                adapterCreator: channel.guild.voiceAdapterCreator,
            });
        }```const connection = joinVoiceChannel({
                                           ^
TypeError: joinVoiceChannel is not a function
soft spindle

Hi!

There is any way I can listen for the user talking event?

I don't want to listen to mute or unmute event, I want the talking event. I found the old event, but I think it is deprecated (guildMemberSpeaking)

Thank you!

empty torrent
green marsh
empty torrent

Did you require* it in your bot?

green marsh

yes

joinVoiceChannel

green marsh
icy echo
client.on('voiceStateUpdate', (oldChannel, newChannel) => {
    if(newChannel.channelID === "23948567239769"){
        let Name = newChannel.member.nickname.split('[')[0]
        console.log(newChannel.members.size)
        //console.log(Name.length)
    }
})```
Im trying to get the count of how many members are in the newChannel. but no matter what i research, it keeps leading me to members.size which doesnt seem to work
crisp furnace

hey, iam trying to detect when someone joines special channel. I got the voiceStateUpdate with oldState and newState. In version 12 all worked fine. But if i want to get the channel id in v13 i get indefined
respectively null and i dont know why.

Can someone explain me how to get this working?

  id: 'id',
  serverDeaf: false,
  serverMute: false,
  selfDeaf: false,
  selfMute: false,
  selfVideo: false,
  sessionId: 'sessionId',
  streaming: false,
  channelId: null,
  suppress: false,
  requestToSpeakTimestamp: null
zenith raven

Okay so I have a live video stream from my own website that is using HLS and I want to take the stream convert that to ogg and stream it through a voice channel is that possible?

glad tiger

Am i doing this right

lime bough

Can someone help me with the bot so it can join the channel when i type !join

worldly raft

Hi! I'm not sure why but when console.log(oldState) while a voiceStateUpdate I get undefined, but doing it with newState actually prints what it's supposed, does anyone now why this could be happening?

summer thorn

My music bot throws up this error sometimes when trying to play something from youtube but not everytime. I am using play-dl

fervent estuary

not a voice related error

summer thorn

okay thanks

craggy tide
queen reef

Is there a way to destroy an AudioPlayer?

I know they're designed to be re-used, but is there no way to destroy them?

covert obsidian
queen reef

I see, I was just wishing to see if there was an official manner beyond that, as with VoiceConnection.destroy().

Thank you very much, I also wasn't sure if those docs were official 😅 .

worldly raft

@subtle granite ? xd

twilit quarry

Does @discordjs/voice's connections support extracting a channel from it?

zenith raven
fading palm

@vocal valley Is there a streamtime property available to find the current time elapsed since streaming?

zenith raven

??

craggy tide
storm nova
craggy tide
interaction.member.voice.channel.id```

VoiceChannel.guild.id

Think about that one for a second.

storm nova

ohhhhhhh i understand now thanks

craggy tide

np

queen reef

You can fetch the voice channel that the bot is currently in through this, if I am not mistaken, as well.

await Guild.channels.fetch(djsVoice.getVoiceConnection(Guild.id).joinConfig.channelId)```
heady sapphire

The issue with the AudioPlayer that keeps aborting. Is that a Discord.JS issue or the library ytdl-core for the music?

subtle granite

Nvm my bad

heady sapphire

It plays the music avg. 3 mins until it just crashes and the error is AudioPlayer: Aborted

@subtle granite It is not there

weary spade

How do i check if someone is in a voice channel and then get that voice channel? An example in DJS 12 would be message.member.voice.channel.id

subtle granite

Still works but you need voice intents

weary spade
craggy tide
hardy salmon
craggy tide
hardy salmon
function play(msg) {
    const connection = joinVoiceChannel({
    channelId: "605804242493636757",
    guildId: msg.guild.id,
    adapterCreator: msg.guild.voiceAdapterCreator,
});

const connection2 = joinVoiceChannel({
    channelId: "594999501203177473",
    guildId: msg.guild.id,
    adapterCreator: msg.guild.voiceAdapterCreator,
});

const player = createAudioPlayer();
const stream = ytdl('https://www.youtube.com/watch?v=hFPMDH0TwFg', { filter: 'audioonly' })

const resource = createAudioResource(stream);
player.play(resource);
        
connection.subscribe(player);
connection2.subscribe(player);
}```

that's good but I tried with a simple way and it's not working

i mean it will play only on connection2

weary spade
craggy tide

From what I understand, it's for cross guilds.

ex) Server 1 and Server 2 can listen to the same playlist

hardy salmon

ooooh. . . that means, i see now makes sense, that's why i got confused, so was for cross guilds 👍 thanks

verbal moth

how to play a hight quality audio ?

finite echo

So whenever a channel is deleted while the bot is in it, the voice state still shows the channelId as the deleted channel

wild zephyr
finite echo

You can check the voice state

wild zephyr

How

finite echo

member.voice

wild zephyr

So you're just calling it at a random point in time after the channel is deleted?

wild zephyr

I can't get that to happen. It's null for me

weary spade

How do I get a members voice channel ID they are in using interaction? Would it be something like interaction.member.voice.channel.id?

distant osprey

try it and see

you need @discordjs/voice package iirc

weary spade
weary spade
distant osprey

I don't think so

weary spade
wild zephyr

Do you have the intents required?

weary spade
wild zephyr

Maybe they're not in voice?

weary spade
wild zephyr

Well... kind of a duh moment, lol

weary spade

Now I get this... time to go to the package discord

weary spade
wild zephyr

Unsure

weary spade

Working now

full grove

Okay I am running v13 so I am now using an audioplayer to play mp3 files but is there a way to instead of playing mp3 files play a live broadcast?

From for example youtube

craggy tide
icy maple

Unless there’s a way with voice activities

craggy tide
rose helm

"live broadcast" is pretty broad. m3u8stream doesn't support shoutcast or icecast web servers (pretty common) iirc. You'd need to use a lib that changes the built in http's parser. Something like icy would work great which is what I use to stream all http source files. It's just the built in http lib under the hood, so it's simple to look up help articles for.
The built in http lib to use for everything else is pretty nice assuming it isn't an icecast or shoutcast web server since it's stream based

old sparrow

Are music bots still doable or has youtube done stuff to make it too hard?

Just looking at making a small one for me and my family

craggy tide

api is still open. nothing they can really do about it

old sparrow

awesome, thanks!

calm holly

Why doesn't this join a vc?

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

Look at the second line

calm holly

whats wrong with it ?

wild zephyr

You didn't pass an id

calm holly
wild zephyr

That isn't the second line

calm holly

OH

carmine timber
terse smelt

So my bot joins the voice channel, queues song, then shows the song popup, but is silent and doesn't start playing anything. Console logged for errors but no errors are produced, it just goes silent afterwards

terse smelt
let d = discordVoice.getVoiceConnection(interaction.guild.id);
                let v = global.songVolume[interaction.guild.id];
                let player = discordVoice.createAudioPlayer();
                let resource = discordVoice.createAudioResource(await base.yt.audio(song), {inlineVolume: true});
                async function start() {
                    player.play(resource);
                    try {
                        await discordVoice.entersState(player, discordVoice.AudioPlayerStatus.Playing, 5_000);
                        console.log('Playback has started!');
                    } catch (error) {
                        console.error(error);
                    }
                }
                void start();
craggy tide
cosmic coral

Hey so I'm trying to get my bot to join a channel through a SlashCommand but for some reason it just entirely fails to execute any command. I've checked my command manager and it runs any other commands just fine so I'm pretty sure it is to do with how I'm having the bot join the channel.

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

module.exports = {
    data: new SlashCommandBuilder()
        .setName('join')
        .setDescription('Joins your voice channel!'),
    async execute(interaction) {
        const connection = joinVoiceChannel({
            channelId: interaction.channelId,
            guildId: interaction.guildId,
            adapterCreator: interaction.guild.voiceAdapterCreator,
        });
    },
};

This is the code for my join.js command.

nvm i'm stupid

carmine timber
torn shoal

what Can I do to prevent this from happening?
It tried this but It didnt work:

const checkConnection = getVoiceConnection(message.guild.id);
           
            player.on(AudioPlayerStatus.Idle, () => {
                setTimeout(() => {
                    if(checkConnection){
                        connection.destroy()}
                    else return;
                }, 300000);;
            })
carmine timber

Try this