#archive-voice
30636 messages · Page 30 of 31
Still, I think you should use absolute paths like the guide does
but my file is in the same directory
That doesn't really matter, even then people have some issues with path resolving and some people prefer ./x.mp3
Still not working
Can I use a test stream?
@spice flint try playing audio from a url instead of a local file
channelId: interaction.member.voice.channel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
const resource = createAudioResource("https://live.radio1.si/Radio1");
player.play(resource);
connection.subscribe(player);
await interaction.reply('Playing.');``` Still not working
hmm thats odd
have you added ffmpeg to path? like can you run ffmpeg in your terminal?
example😅
just run ffmpeg in your terminal (the same place you run npm i ... and other commands)
Reinstall ffmpeg?
try downloading it straight from the official website (https://ffmpeg.org/), in the installer it should have an option, something like "add to PATH", it will require you to restart your pc doe
if i remember correctly my bot started working when i did that and it also says so in the discordjs guide
the website is hard to navigate doe lol
Can I please see discordjs guide
ffmpeg- install and add to your system environment
I removed dependencies and reinstalled ffmpeg-static "dependencies": { "@discordjs/opus": "github:discordjs/opus", "@discordjs/rest": "^0.5.0", "@discordjs/voice": "^0.10.0", "discord-api-types": "^0.33.3", "discord-buttons": "^4.0.0-deprecated", "discord-voice": "^2.0.6", "discord.js": "^13.7.0", "ffmpeg-static": "^4.4.1", "libsodium-wrappers": "^0.7.10" } I installed ffmpeg on system using git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg and tried to run but...
you still havent added it to PATH (google "how to add ffmpeg to path windows")
what's the point of having ffmpeg?
discord voice can only run .ogg and .webm files, ffmpeg allows you to play many different file formats like .mp3
^ this is not a 100% correct explanation but its just so you get the idea
for my music feature I use these packages:
discord.js
@discordjs/voice
opusscript
ffpmeg-static
libsodium-wrappers
and play-dl
no need to install ffmpeg no?
im not an expert on using voice, but after struggling for hours to get my first music bot working, the solution was installing ffmpeg directly from the official website, it might not be the solution for everyone, but it was for me so im just speaking from my experience
I see
Somehow still does not work
well im out of ideas 
what was the issue?
My bot joins my channel but doesn't play audio.
can you show the code
const player = createAudioPlayer();
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
const resource = createAudioResource("https://live.radio1.si/Radio1");
player.play(resource);
connection.subscribe(player);
await interaction.reply('Playing.');```
probably something to do with the input type
defaults to StreamType.Arbitrary
in the resource?
No, that link works
I did it like this const resource = createAudioResource("https://live.radio1.si/Radio1", { inputType: StreamType.Arbitrary}); and it does not work
defaults to
StreamType.Arbitrary
https://discord.js.org/#/docs/voice/main/typedef/StreamType
try every type
Is your player in scope
tried none of them
In scope of function. YES
I'll try your code on my side
Is there more to the file than what you're posting?
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
const { createAudioPlayer, joinVoiceChannel, getVoiceConnection, createAudioResource, StreamType } = require('@discordjs/voice');
const player = createAudioPlayer();
// **Declerations** //
var radioID = 0;
var playing = false;
// **Login** //
client.once('ready', () => {
sendMessage(client.channels.cache.get("888939829176467506"), 99)
console.log( 'Bot is online!');
});
client.on('interactionCreate', async interaction => {
if (!interaction.isButton() || !interaction.channelId == '888939829176467506') return;
if(!interaction.member.voice.channelId){
return interaction.reply('You are not in the voice channel. Please join one and try again');
}
if(interaction.customId === '0'){
if(!playing){
playing = true;
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
const resource = createAudioResource("https://live.radio1.si/Radio1");
player.play(resource);
connection.subscribe(player);
await interaction.reply('Playing.');
}
else{
player.stop();
}
}
});```
Add voicestate intent
Like this const client = new Client({ intents: [Intents.FLAGS.GUILDS, VoiceState] }); doesn't work
No, the intent flag for voicestate
Intents.FLAGS.VoiceState
(static) Intents.FLAGS
Numeric WebSocket intents. All available properties: (more...)
You can check for yourself y'know
it works for me
here is my code:
const Discord = require('discord.js');
const Builders = require('@discordjs/builders');
const Voice = require('@discordjs/voice');
module.exports = {
guildOnly: true,
category: 'music',
data: new Builders.SlashCommandBuilder()
.setName('playy')
.setDescription('📤 Command to make the bot leave your voice channel.')
.setDMPermission(false),
/**
*
* @param {Discord.ChatInputCommandInteraction} interaction
*/
async execute(interaction) {
const connection = Voice.joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
const player = Voice.createAudioPlayer();
const resource = Voice.createAudioResource("https://live.radio1.si/Radio1");
player.play(resource);
connection.subscribe(player);
player.on('error', error => console.error(error));
await interaction.reply('Playing.');
},
};
They don't have the voicestate intent
I saw and I why this if statement didn't work ._.
This works what do you mean?
OMGGGG Intents.FLAGS.GUILD_VOICE_STATES this was the problem all along😭. Thank you all for help now it works
How do you post it in colors is it you IDE
Tag suggestion for @spice flint:
Codeblocks:
```js
const Discord = require("discord.js");
// further code
```
becomes
const Discord = require("discord.js");
// further code
Inline Code:
`console.log('inline!');` becomes console.log('inline!');
const player = new v.AudioPlayer();
if(!message.member.voice) return message.channel.send(`${Client.emotes.error}・Nyan.. Keira needs you to be in a voice channel!`);
if(!message.member.voice.channel) return message.channel.send(`${Client.emotes.error}・Nyan.. Keira needs you to be in a voice channel!`);
const connection = v.joinVoiceChannel({
channelId: message.member.voice?.channel?.id,
guildId: message.guild.id,
selfDeaf: true,
adapterCreator: message.guild.voiceAdapterCreator
});
const ressource = v.createAudioResource("../../rickroll.mp3");
player.play(ressource);
connection.subscribe(player);
player.on("stateChange", (oldState, newState) => {
if(newState === v.AudioPlayerStatus.Idle) {
connection.disconnect();
player.stop();
};
});
player.on("error", console.log);
player.on("debug", console.log);
nothing playing, know why?
maybe wrong path but idk how
ah it's better with voice states intent
but still nothing plays:
17:39:08 - [KeiraBot / Commands] Info ▪ Classy-sama.js#8097 used rickroll in keira with bread
state change:
from {"status":"buffering","resource":true,"stepTimeout":false}
to {"status":"playing","missedFrames":0,"playbackDuration":0,"resource":true,"stepTimeout":false}
state change:
from {"status":"playing","missedFrames":0,"playbackDuration":0,"resource":true,"stepTimeout":false}
to {"status":"autopaused","missedFrames":0,"playbackDuration":0,"resource":true,"silencePacketsRemaining":5,"stepTimeout":false}
[VOICE] received voice state update: {"member":{"user":{"username":"KeiraBot","id":"982972481788842024","discriminator":"6836","bot":true,"avatar":"cdea72358caa1d8ac626017d8083b175"},"roles":["982974346396069921"],"premium_since":null,"pending":false,"nick":null,"mute":false,"joined_at":"2022-06-05T11:49:07.127898+00:00","hoisted_role":null,"flags":0,"deaf":false,"communication_disabled_until":null,"avatar":null},"user_id":"982972481788842024","suppress":false,"session_id":"78ee5bc71dfd3dab69d2e15449ddbcc6","self_video":false,"self_mute":false,"self_deaf":true,"request_to_speak_timestamp":null,"mute":false,"guild_id":"942926069357498460","deaf":false,"channel_id":"942926069986639875"}
[VOICE] received voice server: {"t":"VOICE_SERVER_UPDATE","s":7,"op":0,"d":{"token":"6c6f85ffd15174be","guild_id":"942926069357498460","endpoint":"rotterdam5901.discord.media:443"}}
state change:
from {"status":"autopaused","missedFrames":0,"playbackDuration":100,"resource":true,"silencePacketsRemaining":0,"stepTimeout":false}
to {"status":"playing","missedFrames":0,"playbackDuration":100,"resource":true,"silencePacketsRemaining":0,"stepTimeout":false}
state change:
from {"status":"playing","missedFrames":0,"playbackDuration":200,"resource":true,"silencePacketsRemaining":0,"stepTimeout":false}
to {"status":"idle","resource":false,"stepTimeout":false}
oh i made it work
When using ytdl-core with @discordjs/voice it seems to randomly throw an error
Is it possible to fix this without having to try/catch it
aborted ECONNRESET?
any ideas?
If you convert a buffer into a readstream that works
That is vague, what error? Does it come from usage of ytdl or voice?
It appears to come from ytdl
AudioPlayerAborted IIRC
Has anyone who owns public Discord bots that use djs-voice experienced issues with memory (ram) usage? My bot uses what I feel is a ton of RAM for voice things and starts lagging pretty badly after a day of being online. How is everyone dealing with this and is there any fix?
Hello. I am making a soundboard command. I have two bots, one for developer use and one for regular, everyone use. The developer bot runs on windows while the regular bot runs on Linux. My issue is that the soundboard works fine on the developer bot but not the regular bot. Both are running the exact same code and have the exact same modules (well sort of, I'm pretty sure tweetnacl isn't the reason it's not working).
When the regular bot's command is run, it joins and leaves instantly without playing audio while the devbot Joins, plays the audio, and then leaves. Does anyone have a possible solution for this problem?
For voice receiving, what is the difference between EndBehaviorType Aftersilence and EndBehaviorType AfterInactivity?
Is there a benefit to using one over the other?
Additionally, I've been having problems where sometimes the same audio is received twice instead of once as well as audio being cut very quickly into short durations despite the user continuing to talk during the whole time. Any fix or reason as to why this may be happening?
Make sure to not store any VoiceConnection objects and use getVoiceConnection instead when you need an existing one. Also make sure to dereference your AudioPlayer and AudioResource vars once you don’t need them anymore so the garbage collection can do its thing.
So doing this is bad?
Cause I'm pretty in some examples for voice receiving, they do exactly that.
And by "dereference" do you mean destructuring or setting things as null once done with them?
make sure the scope they are defined in ends with their use (including event listeners that get defined in their scope), …
Hey!
I want to make an xp bot and I want it to give xp when users are also in voice. It seems to me that you have to use a Listener, right? Could you tell me how I can do this easily ?
you can use voiceStateUpdate to track how long a member stays in a vc
So you mean like, return it? Cause I think I'm already doing that, so that wouldn't solve the issue 🤷♂️
Return what? What I meant was to make sure listeners you define in the scope you define your VoiceConnection gets turned off when done
Like <AudioPlayer>.on etc.
Would would turning them off look like?
I apologize, probably a stupid question, but I'm not quite understanding what you are saying.
<AudioPlayer>.off('eventName', functionName)
Oh, I don't think I'm doing that
Can you turn it off within the on area? Like on run?
Wouldn't nodejs warn me if I had too many listeners though?
if you have nested listeners yes
if u wish for a listener to only emit once use .once
Ah, yeah I'm doing that.
no point in using .on and then .off right after
So for example, should this me .on or .once?
voice_Connection.on(VoiceConnectionStatus.Disconnected, async e => {
try {
await Promise.race([
entersState(voice_Connection, VoiceConnectionStatus.Signalling, 1_000),
entersState(voice_Connection, VoiceConnectionStatus.Connecting, 1_000)
]);
// Seems to be reconnecting to a new channel - ignore disconnect
} catch (error) {
// Seems to be a real disconnect which SHOULDN'T be recovered from
if (msg.guild.me.permissions.has("CHANGE_NICKNAME")) msg.guild.me.setNickname(null);
return functions.data(msg.guild.id).then(voice_Connection.destroy());
}
});
I think .on 🤷♂️
But then do I need to do some .off stuff in the catch area?
yeah sounds right
But do I need to do .off stuff in the catch area or can I just leave it as is?
iirc voiceConnection.destroy should remove all listeners
so that should work
Okay awesome
just add a proper function in that .then at the end
wdym
ur just passing the destroy function there now
then takes in a proper function that you can call destroy within
Wait what
I thought using <voice connection>.destroy() would just destroy the voice connection. Does it not?
They just show it like this in djs guide
it does. just the way youre calling it in that .then isnt right
Oh I see
you can just add a simple arrow function in front and should work just fine
Ah I see alright
So:
return functions.data(msg.guild.id).then(() => voice_Connection.destroy());
yeah just like that
Epic
Is voiceStateUpdate emmited when the bot disconnects?
yes
Good to know, thanks
Would love some answers to the following questions when someone gets the chance:
For voice receiving, what is the difference between EndBehaviorType Aftersilence and EndBehaviorType AfterInactivity?
Is there a benefit to using one over the other?
Additionally, I've been having problems where sometimes the same audio is received twice instead of once as well as audio being cut very quickly into short durations despite the user continuing to talk during the whole time. Any fix or reason as to why this may be happening?
How can i get stream time?
In real time or I'll do date.now() - dateJoinChannel ?
The latter is better in my opinion but it's up to you
The difference is that AfterSilence will ignore magic Silence packets received from the VoiceConnection, while AfterInactivity sees them as reason to reset the timeout used to end the stream.
I see, thanks for the response. Do you have any answer for my second question?
Additionally, I've been having problems where sometimes the same audio is received twice instead of once as well as audio being cut very quickly into short durations despite the user continuing to talk during the whole time. Any fix or reason as to why this may be happening?
Nope, sorry
No worries 👍
Hopefully someone else may know what is causing the problem 🙏
whichever you prefer. i would propably use date.now()
How can i get progress of the audio?
hey, how can i learn to use discord voice?
for example recording voice in channels
im pretty sure thats against discord TOS
its not against TOS if you doesnt abuse, for example you recording without telling the user that you are recording their voice
There's an example in the package called 'recorder-bot'
ok thanks
i only record if the user is executing the command
if i destroy a VoiceConnection, does the player subscribed to it also get destroyed, or do i have to clean it up manually?
The subscription gets destroyed too afaik. The player might be if there are no subscriptions to it but don’t quote me on that. I’d rather make sure and clean up after yourself
alright, so just player.stop() after destroying the connection?
my bot always has only one player per connection btw
That’s normal, it‘s more the question if you also only have one connection per player😉
i mean there should be only one connection per player, unless i managed to somehow create more. alright thanks ill go check it out
Will anyone teach me discord.js

they made a guide just for you: https://discordjs.guide/
Vdo turorials are available??
guide >> all yt tuto
Wht?
guide is better than YouTube/video tutorials
Hello, I'm making a bot play sounds in different guilds at the same time.
Problem is that when I get the player to work "per guild" I can't access the js player.on(AudioPlayerStatus.Idle
the way I managed to play different sounds in different guilds is to put the player as an object in the guild.
client.guilds.cache.get(guild).musicPlayer = createAudioPlayer();
Is there a way to work this out better so I can access the events from the player?
Or to get a player per guild?
Why can’t you access it like that? If you have it as a property you can access that property and call the .on it just fine.
for every joined guild it will be created as the musicPlayer in the guild itself,
can I access the event for the musicplayer within the guild? 😖
Here is most of the play function I'm testing. *note that I'm not the best coder *😂
getGuild.musicConnection = joinVoiceChannel({
channelId: getGuild.musicChannel,
guildId: guild,
adapterCreator: await client.guilds.cache.get(guild).voiceAdapterCreator
});
var stream = await ytdl(q, {
highWaterMark: 1 << 25,
filter: 'audioonly',
});
client.guilds.cache.get(guild).musicStream = stream;
const resource = createAudioResource(client.guilds.cache.get(guild).musicStream, { inputType: StreamType.Opus });
client.guilds.cache.get(guild).musicResource = resource;
client.guilds.cache.get(guild).musicConnection.subscribe(player);
client.guilds.cache.get(guild).musicPlayer = createAudioPlayer();
//var player = createAudioPlayer();
client.guilds.cache.get(guild).musicPlayer.play(client.guilds.cache.get(guild).musicResource); // play
opus support arch linux?
does voice even work on linux
Yes
is there a v13 example of ytdl-core
Nope
https://github.com/play-dl/play-dl/tree/main/examples/YouTube
it’s with play-dl, not ytdl-core
How can I take the audio stream for voice receiving for like sending as a stream to an API?
Like where can I get the literal stream from the voice receiving part to be sent elsewhere?
Like the audio/ogg stream
Any way to check if a voice channel has text chat in it? Would .isText() work for that? Iirc most servers for now have to turn it on explicitly and I don't want the bot to crash if it's not enabled, but I dunno how to check for that
It's a guild feature
i.e. guild.features, should be 8 since hasn't been added to the enum yet
Can't see it ;/
Yeah I doubt ddocs is updated
It's not in the Discord.js type either
That was also probably forgotten in 13.8
Don't see it in v14 either, so no clue what to type so that it works
you can check if <Guild>.features includes 'TEXT_IN_VOICE_ENABLED'. the array is not transformed by d.js so it's just the types that are missing
I'll try
Is there still a way to play youtube url songs?
Heya! I'm trying to make a music bot for my server and am relatively new to DJS, I am having problems connecting my bot to the voice channel.
Here is my code:
try {
console.log(": Beginning try statement");
const connection = joinVoiceChannel({
channelId: voiceChannel,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
console.log(": Initiated connection");
//await entersState(connection, VoiceConnectionStatus.Ready, 30e3);
//connection.subscribe(player);
queueConstruct.connection = connection;
console.log(": Got to the end!");
} catch (e) {
console.log(e);
interaction.reply(e);
}
I'm using this tutorial as reference
https://discordjs.guide/voice/voice-connections.html#voice-connections
_ _
I don't get any errors but the bot doesn't join the channel
Does the bot have the permission to join said channel? Does the bot see the said channel?
It has admin perms so it should be able to
And it has intents?
const { Client, Intents, CommandInteractionOptionResolver, MessageEmbed, Message, MessageAttachment, MessageActionRow, MessageButton, ButtonInteraction, } = require('discord.js');
const Discord = require("discord.js");
const { joinVoiceChannel, createAudioPlayer, createAudioResource, entersState, StreamType, AudioPlayerStatus, VoiceConnectionStatus } = require('@discordjs/voice')
const ytdl = require('ytdl-core');
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.DIRECT_MESSAGES,
Intents.FLAGS.DIRECT_MESSAGE_TYPING,
Intents.FLAGS.GUILD_INVITES,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_VOICE_STATES
],
partials: ['MESSAGE', 'REACTION', 'CHANNEL']
});
It should have everything, I'm using discordjs/voice
oop
GUILD_VOICE_STATES
Yes, should I put that in intents?
Please try and let me know if it worked
I changed my intents around
const { Client, Intents, CommandInteractionOptionResolver, MessageEmbed, Message, MessageAttachment, MessageActionRow, MessageButton, ButtonInteraction, } = require('discord.js');
const Discord = require("discord.js");
const { joinVoiceChannel, createAudioPlayer, createAudioResource, entersState, StreamType, AudioPlayerStatus, VoiceConnectionStatus } = require('@discordjs/voice')
const ytdl = require('ytdl-core');
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.DIRECT_MESSAGES,
Intents.FLAGS.DIRECT_MESSAGE_TYPING,
Intents.FLAGS.GUILD_INVITES,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_VOICE_STATES
],
partials: ['MESSAGE', 'REACTION', 'CHANNEL']
});
Still isn't working, not getting any errors and it isn't connecting :/
Better to use play-dl tho
Mhm
Maybe you have an invalid channel or guild id?
As in, passed via joinVoiceChannel
voiceChannel is a valid id and I would think that interaction.guild.id should work but I'll log it just to see
You can do a quick sanity check before calling the command to ensure that the variable does have the value you expect it to have
Yep the guild id returns 813443731922616321 (valid), and voiceChannel returns 877256208896131142 (valid)
Let me spin up a bot real quick, I'll let you know if I encounter a similar issue
alr, thanks so much
Alright got it to work, here is the code:
const { Client, Intents } = require('discord.js')
const { joinVoiceChannel } = require('@discordjs/voice')
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_VOICE_STATES] })
client.on('ready', () => {
const guild = client.guilds.fetch(guildID).then(guild => {
const channel = guild.channels.fetch(channelID).then(channel => {
const connection = joinVoiceChannel({
guildId: guildID,
channelId: channelID,
adapterCreator: guild.voiceAdapterCreator
})
setTimeout(() => {
connection.close()
.then(console.log)
.catch(console.error)
})
})
})
})```
mhm
Needless to say, guildID and channelID is where you put the specific guild and channel IDs respectively, whichever way you fetch it, interaction or w/e.
No special permissions required other than to see and be able to join the specific channel.
hmm
Well I got almost the same code as you and I think it should be working, it's possible there is a problem somewhere else somehow
Actually nvm
It's annoying that there isn't any error logged
I don't have any special perms, only using the bot scope and voice permissions [connect, speak].
Since you gave your bot full admin access, it should have the ability to join the voice channel.
Can you verify that you have @discordjs/voice package installed?
Alternatively, you could be rate limited if your bot did some funky stuff, try again in some time and see if this persists.
Does anyone know how to make the bot catch the radio link?
If it's passed by the user, then just cache that interaction input.
if it will be defined directly in the bot via case 1 and link, do the same or somehow different?
I don't follow... if you have the specific link, since you defined it manually in the bot, then just use the same variable again?
ok, thanks
👍
I am using @discordjs/voice to allow my bot to connect and discord-tts (https://www.npmjs.com/package/discord-tts) to give it the ability to TTS in chat. I can get it to connect and speak just fine. Issue I am having is if someone else sends the speak command while the bot is already speaking, it throws an Abort error and crashes the bot.
Code:
const audioResource=createAudioResource(stream, {inputType: StreamType.Arbitrary, inlineVolume:true});
const connectionCheck = getVoiceConnection(message.member.voice.channelId)
this.logger.info(connectionCheck);
if(!voiceConnection || voiceConnection?.status===VoiceConnectionStatus.Disconnected){
voiceConnection = joinVoiceChannel({
channelId: message.member.voice.channelId,
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);
}
audioPlayer.on(AudioPlayerStatus.Idle, () => {
voiceConnection.destroy();
})```
Error:
```{"error":{"code":"ABORT_ERR","name":"AbortError"},"level":"error","message":"unhandledRejection: The operation was aborted\nAbortError: The operation was aborted\n at abortListener (node:events:842:14)\n at EventTarget.<anonymous> (node:events:878:47)\n at EventTarget.[nodejs.internal.kHybridDispatch] (node:internal/event_target:559:20)\n at EventTarget.dispatchEvent (node:internal/event_target:504:26)\n at abortSignal (node:internal/abort_controller:97:10)\n at AbortController.abort (node:internal/abort_controller:122:5)\n at Timeout.<anonymous> (/home/bots/ModBot/node_modules/@discordjs/voice/dist/index.js:2004:39)\n at listOnTimeout (node:internal/timers:557:17)\n at processTimers (node:internal/timers:500:7)","stack":"AbortError: The operation was aborted\n at abortListener (node:events:842:14)\n at EventTarget.<anonymous> (node:events:878:47)\n at EventTarget.[nodejs.internal.kHybridDispatch] (node:internal/event_target:559:20)\n at EventTarget.dispatchEvent (node:internal/event_target:504:26)\n at abortSignal (node:internal/abort_controller:97:10)\n at AbortController.abort (node:internal/abort_controller:122:5)\n at Timeout.<anonymous> (/home/bots/ModBot/node_modules/@discordjs/voice/dist/index.js:2004:39)\n at listOnTimeout (node:internal/timers:557:17)\n at processTimers```
I snipped the second half of the error because it is just system information.
I think the voiceConnection status checker does not work. I tried to swap it for if(AudioPlayerStatus.Playing)return; but that causes the bot to always just not play audio even if it was already disconnected before
how do i check if a audioplayer is playing
That is also my question I suppose, just mine was more long winded
Is this what you mean?
throw new Error("Cannot play a resource that has already ended."); Why does this exist?
cc @brazen siren
My bot is currently self hosted and essentially has the same IP address as me, would this influence anything?
_ _
No, I ran the bot from my machine as well. You could simply be polling Discord APIs too fast and were placed on a timeout. Again, just a theory.
Alr, I'll give it a break for the day and try again tmrw 😉
thanks so much
No worries, take it easy.
how would i make a loop command
Create a loop variable that will be set to true if some arbitrary command or interaction is executed.
Create a variable curRes that stores the current player resource.
Then,
player.on(AudioPlayerStatus.Idle, () => {
// Edit: Probably should check if we're looping and execute that first
// Instead of needlessly shifting tracks from the queue... my bad :D
if(loop) {
player.play(curRes)
} else {
const newRes = createAudioResource(tracksList.shift())
if(newRes) {
player.play(newRes)
curRes = newRes
} else {
// You probably want to notify the user or log that there was an error creating an audio resource
}
}
})```
how to solve? this disconnects my bot from the channel and prevents it from streaming my playlist
It's a Discord API error, it took too long to send the request and it was aborted, hence the AbortError that was thrown.
i did it similar to this but it returns cannot play song that has already ended
trying to make a ambience command that loops until somebody types /stop
or if there are no people in the voice channel
You can specify restRequestTimeout in your Client as a parameter(number type, milliseconds value).
So, let's say you want requests to time out after a minute, you'd set restRequestTimeout = 6e4.
ty
No worries 😛
In this case, store the path of the song, or use a specific ambiance song path, and create a new audio resource with it via createAudioResource and pass the variable as a parameter to the player.play function.
// Super mega cool ultra giga player 9000
player.on(AudioPlayerStatus.Idle, () => {
const audioResource = createAudioResource(loop ? someStaticSongPathOrLastKnownSongPath : tracksList.shift())
if(audioResource) player.play(audioResource)
else console.log('funny stuff happening guys')
})```
i did the latter and memory leaks every where
also how do you adjust the volume
It's weird, the event shouldn't be emitted that often to cause a leak.
Consider taking a look at the TIP part of the Subscribing to Individual Events section:
👉 https://discordjs.guide/voice/life-cycles.html#subscribing-to-individual-events
Just modify that to suit your own needs 😛
this is my code for reference
https://www.toptal.com/developers/hastebin/mucegapufe.js @brazen siren 99
let resource = createAudioResource('rickrolled.mp3')
resource.volume.setVolume(0.5) //0 for muted, 1 for 100% audio
@brazen siren i did this ```js
player.on(AudioPlayerStatus.Idle, () => {
let loop = createAudioResource(stream);
player.play(loop);
});
and it did not loop, i am also using ytdl-core ```js
(node:1760) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [PassThrough]. Use emitter.setMaxListeners() to increase limit
Put the player.on(event, cb) outside... you keep making new event listeners on each interactions, rather than having one global listener.
I tested it, it works just fine with no memory leaks.
How can check that if player exist for a particular server or not
depends on how you store players
It's simple like
const player = createaudioplayer
That doesn’t store it outside of that scope. So you can’t access it anymore
Any idea how can I do that like i am messing around with that thing from 15 days
Like what if i store that things in a map? And use it can it be possible?
Sure. Attach the map to the client and you‘ll always have it around everywhere
Ohk so how do I do that like 8 would set key as guild id and value as const player = newaudio player
Then what to do to get that if player exists or not?
client.players = new Collection() somewhere after your client definition, client.players.set(guildId, player) when you created a player and client.players.get(guildId) to get one if it exists (Same way you interact with caches in djs, since they are Collection too)
Okay,
- so can't i put const
player=new audio player...as value ? - the third part
client.player.get(guildId)so how do I use this to get that if player exist or not should I delete the .set(guildId) thing on completion? And then how do I use it?
- of course you can. Your var is called player, my code snippet assumes a var named player already
- as I Said, the same you do with caches. If it doesn’t exist it will return undefined
And yes, you .delete(guildId) when you don’t need the player anymore
Hello, is possible somewhat to play a raw source of music? e.g. If I have a radio which is not providing an endless mp3 file, but a file without any extension.
For example, here is a link http://mp3.polskieradio.pl:8900/; (the semicolon belongs to this link)
when I try to use it as endless mp3 file, it just ends with Error: Cannot play a resource that has already ended.
not really sure what you mean by endless mp3
but passing a raw pcm stream would require you to declare the "raw" inputType in the createAudioResource options
alr, I try it and if it goes wrong, I'll try to contact you
okay, bot joins without error, but nothing is playing
and nothing seems to have a problem
How can I get the audio stream when receiving audio?
Like is there a .getAudioStream() or something 🤷♂️
Additionally, I need help with frameSize. I'm not exactly understanding what is supposed to go there and how I calculate it relative to bits and whatnot.
Does @discordjs/opus require frameSize when using pipeline with prism opus?
Hello, this is going to be a stupid sounding question. I have my bot set up to play a track that is in the directory, called title.mp3. I have ffmpeg, ffmpeg-static, and libsodium-wrappers installed. I know I'm supposed to use @discordjs/opus but I can't do that on Replit so I opted to try an alternative I heard was supposed to work called opusscript. However, when I call the command, it successfully joins the channel, shows the green circle as if it is supposed to be talking, but does not actually play sound. I know this is supposed to be a problem with not having opus, but I cannot use @discordjs/opus. Does anyone know what I'm doing wrong/how to fix this? The source code is here if it helps https://replit.com/@Kestron/SMOMusicBot-1
Did you try running it on your local machine? If so, did you have the same outcome?
Looking at your code, I don't see why you would need the module declaration on line 5:
const opus=require('opusscript');
Anyway, it could just be that replit doesn't allow wasm modules from being run or it could be a free account limitation.
Again, try running on your computer as a test.
Hi,
After several tries, I still haven't managed to create the code I want. New to discordJS, I would like to be able to follow a code pattern.
Does anyone have code to do the following:
- When writing "example" in a channel, the bot reacts to the word "example" then connects to the voice channel where the user is
- It will play the music located in ./audio/try.mp3 and disconnect when the music is finished.
(can you tell me the requirements please thank you)
thank you !
I suggest you take a look at the pinned guide, with that in mind you should be able to make it do that on message.
I still dont understand the second part like how can I cache it?
Like do i have to use?
if (client.players.cache.get !=== guildid){interaction reply(lol)}
By calling .set on the collection you already cache it. And with .get you access the cached player
How would you get a channel from client.channels and make sure it exists?
Or a guild from client.guilds.cache or a message from <Channel>.messages.cache, …
So the thing I sent should be right like i do similar ways
Umm, so you‘re telling me you’d do if (client.channels.cache.get !== undefined) ?
That doesn’t sound right does it?
Why undefined tho like i am using cache
Yes? And there are things that aren’t cached (yet)
client.player is map and it is being cached
You’d do const channel = client.channels.cache.get(channelId) and then check if channel is undefined. Same for your Collection
No. It’s a Collection (unless you somehow changed it to Map yesterday) and it’s not being cached, it is your cache in this case.
Oh sry i replaced collection to map
Oh so i ic
Like
Const this = client.players.cache.get(guildId);
If (this) {}
Scratch the .cache (players is already a Collection). And maybe not name a variable this. But other than that: yes
No need to include .cache anywhere i i would change var
the client.guilds.cache is a Collection. Your client.players is a Collection.
You need .cache in djs properties to get a Collection you can work with. You don‘t need it here as you already have a Collection
Ohk ic
I declared the opus out of desperation that probably could be deleted. Real fast, before I get it running locally, would this affect anything?
Sure, this will not let you hear the users - receiving audio data.
It does not prevent your from speaking to the users - sending audio data.
Okay, dang. I didn't know if bots were affected by being deafened, as this bot seems to have been. I'll try getting it local real fast, but I was really hoping to get it running on Replit so I could have it online 24/7
discord.js voice module deafens by default, I assume this was a decision for privacy reasons or to prevent malicious collection of voice activity
spin up a digitalocean droplet, it's like $5 a month without any restrictions... if it's free, either you are the product(by selling your data), or it will be heavily limited in resources and ability
I suspect that replit does not allow wasm modules from being loaded, thus opusscript not working for your on replit. If the same code runs without issue on your local machine, then that suspicion is probably the reality.
Okay. What would be the workaround if it is the case? (The zip is taking forever to download)
what zip? just install node, copy your package.json and index.js and just run npm install
it will take care of all dependencies, and when complete, just run node index and that's it
if you're downloading the node_modules folder, you are doing it wrong
Oh, LOL.
Okay so now I'm running it locally, I uninstalled opusscript and installed @discordjs/opus, and it still shows the green circle as if it was talking, but is still silent.
Then there's something wrong with your audio track
It loads fine in an mp3 player, and I've gotten this exact track to work before in another bot. (a bot that was djs v12)
I'll try to spin up a bot real quick, give me a moment
Alright, running this code, I've had no issues with the voice activity being heard by me.
Just declare guildID and channelID variables with where you want the bot to play the audio.
If it's still not working then I'm afraid it's something else.
const { Client, Intents } = require('discord.js')
const { createAudioPlayer, AudioPlayerStatus, NoSubscriberBehavior, createAudioResource, joinVoiceChannel } = require('@discordjs/voice')
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_VOICE_STATES
],
restRequestTimeout: 60000
})
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Play
}
})
player.on(AudioPlayerStatus.Idle, () => {
const song = createAudioResource('test.mp3')
player.play(song)
})
client.on('ready', () => {
const guild = client.guilds.fetch(guildID).then(guild => {
const channel = guild.channels.fetch(channelID).then(channel => {
let connection = joinVoiceChannel({
guildId: guildID,
channelId: channelID,
adapterCreator: guild.voiceAdapterCreator
})
if(connection) {
connection.subscribe(player)
}
})
})
})```
I'll test this real fast, thanks
Obviously you also login at the bottom with your token, omitted for this example, but do the usual client.login(token) thingy.
Yeah I already put that at the bottom
It still didn't work so I'm going to uninstall all node stuff and reinstall the ones I need real fast
I tried it with opusscript, ffmpeg-static, libsodium-wrappers which are the libraries you have, so it should work at least on your local machine
It worked for a second - it joined the VC and played the first note, and then just stopped.
Maybe your bot is rate limited?
By who? Discord?
Yes
Hmm
You can try debugging dependencies as well to ensure they are found:
const { generateDependencyReport } = require('@discordjs/voice')
console.log(generateDependencyReport())
Noted! Will run in a second...
I tried uninstalling and installing a couple different libraries which is why this list will look different than originally stated.
try removing sodium and installing libsodium-wrappers
Reinstalled it all, I changed the if(connection) block to this, see if that makes it work:
if(connection) {
connection.subscribe(player)
const song = createAudioResource('test.mp3')
player.play(song)
}```
Core Dependencies
- @discordjs/voice: 0.10.0-dev
- prism-media: 1.3.2
Opus Libraries
- @discordjs/opus: not found
- opusscript: 0.0.8
Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.10
- tweetnacl: not found
FFmpeg
- version: 4.4.1-essentials_build-www.gyan.dev
- libopus: yes
It logged that it's playing, and shows the green circle still. I'm going to uninstall discordjs/opus and go back to opusscript
Still no sound
opusscript takes a while to load, only used it since that's what you had on replit
maybe try setting a timeout and force playing another song, see if it's a bug where the first song doesn't play?
WAIT! IT'S WORKING!
Woot woot! 😄
No idea what changed, but it's going. Thanks for your help!
No worries, maybe discord finally decided to cooperate 😛
Who knows? LOL
anyone know how to interact with new discord voice text channels?
same way you do with regular text channels
Hi guys,
I tried this and dosn't work, console said me "ReferenceError: message is not defined" ?
const { Client, Intents } = require('discord.js');
const { joinVoiceChannel } = require('@discordjs/voice');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_VOICE_STATES] });
client.on('ready', () => {
console.log('Connexion réussie au bot!');
const guild = client.guilds.fetch(guildID).then(guild => {
const channel = guild.channels.fetch(channelID).then(channel => {
const connection = joinVoiceChannel({
guildId: guildID,
channelId: channelID,
adapterCreator: guild.voiceAdapterCreator
})
setTimeout(() => {
connection.close()
.then(console.log)
.catch(console.error)
})
})
})
});
const connection = joinVoiceChannel({
channelId: message.member.voice.channel.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator
});
const EXEMPLE = ['Exemple', 'EXEMPLE'];
const player = createAudioPlayer();
const resource = createAudioResource('./audio/essaie.mp3');
client.on('messageCreate', (message) => {
if (message.author.bot) return false;
EXEMPLE.forEach((word) => {
if (message.content.includes(word)) {
player.play(resource);
connection.subscribe(player);
};
});
});
client.login(process.env.TOKEN);
you are creating the connection outside of any message context
is it the same channel ID as voice?
yes
ok thanks
What do I have to do ? 🤔
Thx but another error ; createAudioPlayer is not defined
( I have two const defined player/ressource for audio player ??)
Just keep the player definition in the global scope(outside of any function), and then define your resource and play via the player as needed(interaction response, command, etc)
Hey folks. Not quite sure what's going on. I migrated my bot from discordjs-12 to discordjs-13 over the past few weeks. I got it all set up working with sound and everything. Had no issues since.
Tried using it today, and it joins, but never emits sound. No errors occur. No code changes have occurred, either. I'm able to reproduce both locally and on my remotely hosted instance of the bot
Not sure how to provide any debug logs since nothing is throwing an exception
is there anyway for me to queue.destroy() when the bot is disconnected from a voice channel
Wdym? The voice package doesn’t have a queue
You just want to detect when the bot gets disconnected?
its another package called discord player, im just looking for a way to easily detect when a bot gets disconnected
I’m not familiar w/ that package
yeah something like that
You would just listen to the connection.disconnected event
yeah i looked that up but it just tuned to a tutorial of a guy using databases and mongo and whatnot so im kinda confused af on that topic,
something about new state and old state event listners
Could also use stateChange
im not familiar, havent seen that one in the docs any tips on using it?
or you know like what it is
It fires when the connection changes state
You get the old and new state
Basically a catch all for the state changes, the individual events only check the new state providing the old state as the param
ill test it out but just to be sure i dont need to use mongo right? im not in the mood to learn databases and whatnot
You don’t need mongo
😅
bruh
its djs-voice problem, not @discordjs/voice.
How can I play a YouTube video from a specific timestamp?
Not DJS-Voice related as there is no YouTube support built into it
There appears to be support for it in ffmpeg.
Don't know if it's possible to pass ffmpeg options in discord.js/voice.
I found this, but it seems outdated.
see play-dl implementation
Thank you.
How can I adjust volume?
I was using resource.volume.setVolume(variable) before, but when I CTRL+F'd for volume in the play-dl documentation I came up blank.
That’s how you do it in djs voice. And since you still use AudioResource from djs voice that’s still how you do it.
volume is from prism-media iirc
I don’t think play-dl can adjust volume
Just make sure to create the AudioResource with inlineVolume true
I'm daft, I forgot to set inlineVolume: true; thank you!
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
How do I got about making the bot be a speaker when joining a stage channel? I know it's to do with setsuppressed, but I can't figure how to do it with this?
How do I make the bot leave when everybody is not in the vc?
Listen to voiceStateUpdate event and if oldState.channel is the bots VC check if the bots VC now has members.size of 1
let oldChannel = oldState.voiceChannel
let newChannel = newState.voiceChannel
if (oldChannel != newChannel) {
console.log("user moved")
}
});
I'm using this but literally nothing happens..
i don't exactly get what's going wrong here
Do you have the GUILD_VOICE_STATES intent activated?
yeah iv tried another method which worked but now its just really weird as i have the bot log whenever the bot is moved/added/removed from a call but whenever the bot is removed it just sends the same log twice
You reassigned the id in the voiceStateUpdate event in the if statement
How can I get the members inside a voice channel after a voice state update?
I tried newState.channel.members.size
how to solve?
that should work according to the djs docs
according to node.js size does not exist for members
Does it work when you try ```js
const vc = newState.guild.channels.cache.get(newState.channel.id);
vc.members.size
no ```js
bot.on('voiceStateUpdate', (oldState, newState) => {
if (oldState.channelId !== oldState.guild.me.voice.channelId || newState.channelId) return;
const vc = newState.guild.channels.cache.get(newState.channel.id);
if (vc.members.size === 1) {
bot.player.destroy();
}
});
I'm trying to make my bot automatically leave when it is the only one in the voice channel
I get that the function needs to return if the channel is not the same channel as where the bot is in, but why does it need to return when there is a channelId provided at the newState?
some kid told me they changed discord.js.Client.on() to discord.js.Client.once()
try using bot.once
By changing it to once the event only gets emitted once time so you shouldn't do that
^
oh
.on executes when the event happens
You only should do that for events like ready that only get emitted once
yeah I got it
Client.on-> executes the event whenever it happens, regardless the amount of times it happened
Client.once-> executes the event whenever it happens, only once
correct
Yeah
How can I know player is playing or not?
Does djs have such events, methods or properties?
My music bot isnt running lavalink so isnt outputting audio can someone either help get it workign or convert it to lavalink?
its running on replit
Suggestion for @subtle granite:
Library: Life cycle
read more
ty
hello, @waxen wedge, I have got stream like this: http://mp3.polskieradio.pl:8900/; and I would like to play it in voice channel, if I set a raw type, it runs without error, but nothing will play
any ideas for solve?
#rules 6, don't ping me, just write your question and whoever sees it can try to help. I can't...
okay, sorry, I know, that you've helped me much in the past, so I tried to contact you
update, it just stucks in buffering state
can someone help me on this error? .on('playSong', (queue, song) =>
^
TypeError: Cannot read properties of undefined (reading 'on') the code is here if needed: https://sourceb.in/Yn97RXRvxz
Its from a plugin called 'distube'
doesn't sound djs related
vanilla djs does not have a distube property, and it sounds like either distube doesn't create such a property for you, or you didn't set it up properly
oh alright
is there a way to detect when an audio resource has been finished playing?
Listen for the player.idle event
not playing audio, any ideas?
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});
const resource = createAudioResource('path/to/audio/1.mp3', {
metadata: {
title: 'Test song!',
},
});
player.play(resource);
player.on('error', error => {
console.error(`Error: ${error.message} with resource ${error.resource.metadata.title}`);
player.play(getNextResource());
});
player.on(AudioPlayerStatus.Playing, () => {
message.channel.send({content: "Song started."})
});
Dependencies Report
Did you call connection.subscribe(player)?
yep, still not working
There was an uncaught error: Error: Cannot play audio as no valid encryption package is installed.
The error is correct according to ur dep report
I am just unable to install @discordjs/opus
I could install opusscript and sodium-native, but @discordjs/opus gives me that weird node-gyp error, because I am on windows
Tag suggestion for @mystic fable:
• 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).
getting errors
Show it
What error do you get from installing @discordjs/opus?
that node-gyp error
Did you install the C++ thing it mentioned?
Or nvm, you just need to set the msvs_version
Run npm config set msvs_version 2022 and try installing it again
Seems like you conveniently have VS installed
that seemed to work, but it plays nothing
Can you check if the player.idle event is running?
how to do that?
player.on("idle", () => console.log("Done playing song"))
yeah it's idle
The resource path is prob invalid
Did you provide a relative path, or absolute?
const resource = createAudioResource(__dirname + '../Audio/1.mp3', {
I tried like this now, not working
also tried
const resource = createAudioResource('C:/Users/VLADY/Desktop/Discord/Drake 3/Audio/1.mp3', {
I would use path.join for the former instead of string concatenation
oh, I figured it out and now it works. Thanks.
But I have one more question
how do I do to make commands like play, stop, pause to be corelated
like, to be the same connection as in play
if I do connection.destroy() in stop.js
to reffer to the same connection defined in play.js
Use getVoiceConnection(guildId) to get the connection
that's it?
The player is accessed by connection.state.subscription.player
Assuming the connection is connected, .subscription is undefined otherwise
and if I want to make an array of resources, from an array of files, do I do
resources.map(e => player.play(e))
connection.subscribe(player)
or?
Calling player.play multiple times will just make the last one play
If you want a queue, you would have to implement that manually
like to make an array of resources and then
resources.map(song => connection.subscribe(song))
sorry for asking a lot of things, I am new to this
that won't work...
github copilot gave me this
let resources = fs.readdirSync('C:/Users/VLADY/Desktop/Discord/Drake 3/Audio').filter((file) => file.endsWith(".mp3"));
for (const song of resources)
{
const resource = createAudioResource(`C:/Users/VLADY/Desktop/Discord/Drake 3/Audio/${song}`);
player.add(resource);
}
yeah that doesn't work
I wonder whose code it copied
I wonder too
Just call createAudioResource on all resources to create a Resource
let resources = fs.readdirSync('C:/Users/VLADY/Desktop/Discord/Drake 3/Audio').filter((file) => file.endsWith(".mp3"));
let songs;
for (const song of resources)
{
const resource = createAudioResource(`C:/Users/VLADY/Desktop/Discord/Drake 3/Audio/${song}`);
songs = resource;
}
player.play(songs)
connection.subscribe(player)
like this?
yeah...no
That reassigns song
I would just map the Array
yeah, then how to create resource from array?
By mapping the Array
Array.prototype.map()
The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.
I know how to map
What I don't understand is how to add to the player
You can only play one song at a time
Hint: use the player.idle event
hm, alright
player.on("idle", () => message.channel.send({content: "Song ended."}), i = i + 1, player.play(createAudioResource(songs[i])), connection.subscribe(player));
tried like this, but doesn't seem to work
songs is an array of what exactly?
paths to audio files
figured that out
const connection2 = getVoiceConnection(message.channel.guild.id);
if (connection2 == undefined)
return message.channel.send({
content: "Not connected to voice.",
});
else
{
connection2.pause();
message.channel.send({content: "Paused."});
}
how to pause or resume?
player.pause/unpause()
it's in another file, player not defined
const {
VoiceConnectionStatus,
entersState,
joinVoiceChannel,
getVoiceConnection,
createAudioPlayer,
NoSubscriberBehavior,
createAudioResource,
AudioPlayerStatus,
} = require("@discordjs/voice");
module.exports = {
name: "pause",
usage: "d2dev pause",
description: "Debug",
hidden: true,
async execute(message, args, client) {
const connection2 = getVoiceConnection(message.channel.guild.id);
if (connection2 == undefined)
return message.channel.send({
content: "Not connected to voice.",
});
else
{
console.log(connection2.subscription)
connection2.subscription.player.pause();
message.channel.send({content: "Paused."});
}
}
}
connection2._state.subscription.player.pause();
this works, but resume doesn't
Why _state?
Just use state
because that's what logging connection2 gives
state is prob a getter
You shouldn’t be using private props anyways
Unhandled promise rejection: TypeError
TypeError: connection2.state.subscription.player.resume is not a function
could it be cause by this?
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});
unpause, not resume
ohh..
Like I said, state is a getter
yeah, that worked
Doesn’t seem like our ts docs supports getters yet
how to solve?
That’s most definitely not djs related but the connection to a stream you try to use…
guys, i cant install djs opus
wat do for these?
Add a description to your embed. The other error isn’t djs related
there are descriptions
https://pastebin.com/raw/JkXZkybz for the play script
The embed error is not from that file, as it references a TextChannel.send and in your code you only reply/editReply to an Interaction (so webhooks, not direct channel send)
so what would i need to do then
Add a description to the embed in your code that is missing one. Project wide find should help
Or find out when the error gets thrown to get an idea in which event/command to look for it
its when i play a song when i got another one going to add it to the q
Then look for the embed in all parts of your code that get called in that case (not just this one file in which it definitely didn’t happen)
13/06/2022, 17:41:27 -> {"channel":2064,"debugOutput":{"session":"main","output":" ^\r\n\r\nError: Cannot find module 'node:events'\r\nRequire stack:\r\n- /home/runner/lavamusic/node_modules/discord.js/src/client/BaseClient.js\r\n- /home/runner/lavamusic/node_modules/discord.js/src/index.js\r\n- /home/runner/lavamusic/src/structures/MusicClient.js\r\n- /home/runner/lavamusic/index.js\r\n\u001b[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)\u001b[39m\r\n\u001b[90m at Function.Module._load (internal/modules/cjs/loader.js:667:27)\u001b[39m\r\n\u001b[90m at Module.require (internal/modules/cjs/loader.js:887:19)\u001b[39m\r\n\u001b[90m at require (internal/modules/cjs/helpers.js:74:18)\u001b[39m\r\n at Object.<anonymous> (/home/runner/lavamusic/node_modules/\u001b[4mdiscord.js\u001b[24m/src/client/BaseClient.js:3:22)\r\n\u001b[90m at Module._compile (internal/modules/cjs/loader.js:999:30)\u001b[39m\r\n\u001b[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)\u001b[39m\r\n\u001b[90m at Module.load (internal/modules/cjs/loader.js:863:32)\u001b[39m\r\n\u001b[90m at Function.Module._load (internal/modules/cjs/loader.js:708:14)\u001b[39m\r\n\u001b[90m at Module.require (internal/modules/cjs/loader.js:887:19)\u001b[39m {\r\n code: \u001b[32m'MODULE_NOT_FOUND'\u001b[39m,\r\n requireStack: [\r\n \u001b[32m'/home/runner/lavamusic/node_modules/discord.js/src/client/BaseClient.js'\u001b[39m,\r\n \u001b[32m'/home/runner/lavamusic/node_modules/discord.js/src/index.js'\u001b[39m,\r\n \u001b[32m'/home/runner/lavamusic/src/structures/MusicClient.js'\u001b[39m,\r\n \u001b[32m'/home/runner/lavamusic/index.js'\u001b[39m\r\n ]\r\n}\r\n"}}
13
Tag suggestion for @subtle granite:
Codeblocks:
```js
const Discord = require("discord.js");
// further code
```
becomes
const Discord = require("discord.js");
// further code
Inline Code:
`console.log('inline!');` becomes console.log('inline!');
But it looks like you should update node, you‘re on an old version djs doesn’t support
how do i update the node?
Please update node.js to version 16.6.0 or newer!
• Download
• Linux (nodesource)
its running on replit
Definitely Not a good host for discord bots. but I‘m sure you can find out how to switch node version on replit, just not djs related anymore
eh its free and online
this error again
DiscordAPIError: Invalid Form Body
embeds[0].description: This field is required
at RequestHandler.execute (/home/runner/lavamusic/node_modules/discord.js/src/rest/RequestHandler.js:349:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/home/runner/lavamusic/node_modules/discord.js/src/rest/RequestHandler.js:50:14)
at async TextChannel.send (/home/runner/lavamusic/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:172:15) {
method: 'post',
path: '/channels/972518177114296381/messages',
code: 50035,
httpStatus: 400,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: [Array],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
i'm using ytdl-core with djs voice. However, when i try to stream links which's live. i get the error:
AudioPlayerError: Did not find the EBML tag at the start of the stream.
So you didn’t look for the embed and instead post the error message again hoping that would solve anything?
Afaik ytdl doesn’t work anymore. play-dl apparently does
How do I fix The operation was aborted?
Tag suggestion for @heavy sage:
AbortError: The user aborted a request.
A request took longer than the specified restRequestTimeout (15 seconds default), and was aborted to not lock up the request handler.
• This can be caused by an internal server error on Discord's side, or just a slow connection.
• In case of a slow connection, the restRequestTimeout option in ClientOptions can be increased to prevent future AbortErrors.
Hello I come here because my bot doesn't play the audio I give him even if it connects to the voice channel. Sadly I need to go bed soon and I hope I will not annoy anyone because I need to go.
Here is my code
https://pastebin.com/ynHvq8sn
Thank you in advance
are there any errors?
have you logged throughout to ensure everything runs as intended?
have you ensured that your audio streaming module functions properly?
do you know if the data being streamed would require you to declare a specific stream type when creating the audio resource?
One time I tried to open an mp3 and it didn't work so I think it's not that, there is absolutely no error...and I put console log everywhere and everything was executed so.... I can't find any solution...
you opened an mp3 and it didn't work, so you don't think that's the issue?
Well if with an mp3 loaded with fs didn't worked I thought the problem couldn't be from the spdl module
The bot just doesn't play audio
mb I thought you meant you were checking that spdl worked by streaming to a file, then reading the file didn't work
how about the other questions then?
Well I already tried to solve any of those issues but.... nothing and sadly I need to go...
Thanks and good night
I have that same problem
same questions then
How do I move people into a different voice chat?
<GuildMember>.voice.setChannel()
Documentation suggestion for @stoic thunder:
VoiceState#setChannel()
Moves the member to a different channel, or disconnects them from the one they're in.
That works, now how do I move everybody inside a voice channel to another one?
i addded
const player = createAudioPlayer();
and
player.play(stream, {seek: 0,volume:1})
but error
TypeError: Cannot read properties of undefined (reading 'once')
player.play takes a AudioResource, not a Stream
Library: Audio Resources
read more
I tried increasing it till it works and now its 50 seconds and doesnt work 
looks like it my host problem 
how to change volume of audiosource?
if you declare inlineVolume: true when creating the resource, you can do <AudioResource>.volume.setVolume()
here's the docs for the VolumeTransformer class https://amishshah.github.io/prism-media/?api#new-core.VolumeTransformer
any idea why player stops even though the song is not over?
player.on('idle', () => {
console.log(queue.length)
if (queue.length > 0) {
let song = queue.shift();
let createEmbed =
...
it just randomly stops
console.log("AAA")
})```
doesnt execute console.log("AAA"), when joining a channel
GUILD_VOICE_STATES intent
Thx
Ohh like ik I'll check guide hopefully it works
PlayerError: [PlayerError] Cannot play a resource that has already ended.
ideas?
if u want to replay a song create a new resource
there youre trying to play an already played resource
const Discord = require('discord.js');
const ytdl = require('ytdl-core');
const ytSearch = require('yt-search');
const { joinVoiceChannel } = require('@discordjs/voice');
const { createAudioPlayer,createAudioResource } = require('@discordjs/voice');
const player = createAudioPlayer({
});
module.exports = {
name: 'play',
aliases: ['p'],
run: async (client, message, args) => {
const voicechannel = message.member.voice.channel;
if(!voicechannel) return message.reply(`you must be in a voicechannel to use this commmand`)
if(!args[0]) return message.reply(`Please provide link you want me to play`)
const connection = await joinVoiceChannel({
channelId: voicechannel.id,
guildId: message.guild.id,
adapterCreator: message.channel.guild.voiceAdapterCreator,
})
const videofinder = async (query) =>{
const videoresult = await ytSearch(query);
return (videoresult.videos.length >1) ? videoresult.videos[0] : null;
}
const video =await videofinder(args.join(" "));
if(video){
const stream = ytdl(video.url, {filter: 'audio'});
resource = createAudioResource(stream, { inlineVolume: true });
resource.volume.setVolume(100);
player.play(resource)
client.on('finish', ()=>{
voicechannel.leave();
});
await message.reply(`:thumbsup: Now playing ***${video.title}***`)
}else {
message.reply(`No video was founded`)
}
}
}```
the error is that no errors in console but not playing anything
ytdl doesn’t work anymore afaik. play-dl does though
k i'll check how it works and use it thanks
is it same as like ytdl?
no little bit different https://npmjs.com/package/play-dl
So i have a weird problem - i have a music bot that plays radio stations, it has 10 radio stations to choose from, but 2 of them don't play anything. The weird thing is that if i switch to a different radio station and then back to the bugged one, it starts playing. I'm very confused, is the link broken or what might be the issue? This is so weird i dont know how to even approach fixing this lmao
does it happen when switching from certain stations or randomly?
no its 2 certain stations that dont play the first time, the other ones work fine
does that happen every time?
and when exactly is the first time? after every restart?
const track = await client.player.search(query, {
requestedBy: message.author
}).then(x => {
console.log(x.playlist != null)
if(x.playlist == null) return x.tracks[0]
else
{
queue.addTracks(x.tracks);
console.log(x.tracks.length)
return x.tracks[0]
}
});
if (!track) return await message.channel.send({ content: `❌ | Track **${query}** not found!` });
if(track.playlist == undefined || track.playlist == null) queue.play(track);
else queue.play()
what I have so far..
Playing a single track works, but when trying to add a playlist, it gives errors
Hey, whenever i play a local mp3 file on Windows, it works as expected. However, when i try to run the same code from a Debian machine, the bot will join the channel and then immediately leave (its coded to leave when the audio is done playing). Both machines have ffmpeg installed and the same dependencies. What could be the problem? Thanks
Dependency report from the Debian machine:
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.10.0-dev
- prism-media: 1.3.2
Opus Libraries
- @discordjs/opus: 0.7.0
- opusscript: 0.0.8
Encryption Libraries
- sodium-native: not found
- sodium: 3.0.2
- libsodium-wrappers: 0.7.10
- tweetnacl: 1.0.3
FFmpeg
- version: 4.3.4-0+deb11u1
- libopus: yes
--------------------------------------------------
ah i fixed it, for some reason player noSubscriber behavior being set as "stop" was giving me some issues, now that i removed it, it works perfectly, anyways thanks 😄
so i have this command which joins and plays a mp3 from my pc, but it randomly stops after a couple oof seconds https://sourceb.in/hQgrA62T6D
how to check if members in voice room on AudioPlayerStatus.Idle
When using voice receive, are there any issues I should be made aware of when trying to receive audio in a sharded bot with multiple servers receiving audio at the same time? I've had some issues with the bot only appearing to be able to listen to one voice at a time and rapidly switching between the multiple by quickly ending when the person is speaking despite them speaking continuously the whole time.
dont you think this has something to do with it? 😄
How I solve this
npm i libsodium-wrappers@latest
thx
I suddenly got this error while playing the song:```
AudioPlayerError: aborted
at connResetException (node:internal/errors:692:14)
at TLSSocket.socketCloseListener (node:_http_client:414:19)
at TLSSocket.emit (node:events:539:35)
at node:net:709:12
at TCP.done (node:_tls_wrap:582:7) {
resource: AudioResource {
playStream: OggDemuxer {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 5,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: true,
_remainder: null,
_head: null,
_bitstream: null,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: [Function: bound onwrite]
},
edges: [ [Object], [Object] ],
metadata: null,
volume: undefined,
encoder: undefined,
audioPlayer: AudioPlayer {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
_state: [Object],
subscribers: [Array],
behaviors: [Object],
debug: [Function (anonymous)],
[Symbol(kCapture)]: false
},
playbackDuration: 44700,
started: true,
silencePaddingFrames: 5,
silenceRemaining: -1
}
}
how would i make it when the mp3 ends the bot leaves the channel https://srcb.in/O1OT2W4A6w
i think this should work
player.on(AudioPlayerStatus.Idle, () => connection.destroy())
also you should probably do player.stop() after destroying the connection
why?
so would i just do a .then ?
player.on(AudioPlayerStatus.Idle, () => player.stop(), connection.destroy())

thats not how js works
was gonna say
no you dont need .then, you can just pass both connection.destroy() and player.stop() into the callback, just make it multiline with {}
in his case he doesnt need the player to exist after the connection is destroyed, so you use .stop() to prevent memory leaks
it correctly logs them
im confused on what im doing with {} lol
yes but thats not the point
sorry
player.on(AudioPlayerStatus.Idle, () => {
connection.destroy()
player.stop()
})
you said that's not how JS works ._.
ty
you can pass it as a argument into the function sure AND IT WILL RUN, but why would you do that, its not supposed to be an argument
besides it wont run on the callback, it will run when the even listener is created
didn't get wdym but I know that what I sent works
are you using ytdl-core?
yes but it was fixed after switching to play-dl
The problem is actually the highWaterMark from ytdl-core which you should set to 1048576 * 32 but play-dl is also an excellent alternative, just so you know 🙂
Thank you for the information.
Disconnecting bot after done finished playing mp3 wav audio file
player.on(AudioPlayerStatus.Idle, () => {connection.disconnect()})
no
Sure there is, just none djs itself supports
Hey im trying to play audio in a voice channel, the bot is joining the channel but it is not playing anything, it has some mute icon that i cannot seem to get rid of.
Here is the code that i call when executing a slash command:
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
const audioPlayer = new AudioPlayer();
const stream = createReadStream(join(__dirname, 'audio.ogg'));
const resource = createAudioResource(stream, {
inputType: StreamType.OggOpus,
});
const subscription = connection.subscribe(audioPlayer);
if (subscription) {
audioPlayer.play(resource);
}
intr.reply('playing audio');
My dependency report looks like this:
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.10.0-dev
- prism-media: 1.3.2
Opus Libraries
- @discordjs/opus: 0.7.0
- opusscript: not found
Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.10
- tweetnacl: not found
FFmpeg
- version: n5.0
- libopus: yes
--------------------------------------------------
I have the GUILD_VOICE_STATES Intent and i have the Connect and Speak voice permissions. I also dont get any errors and when i log the audio player state changes it switches to playing but it never goes back to idle
I don't see a mute sign it just deafen
If i hover over it, it shows a tooltip "Input and Output disabled"
So what fixed it was adding inlineVolume: true
const resource = createAudioResource(stream, {
inputType: StreamType.OggOpus,
inlineVolume: true
});
Does someone know why?
so volume wasn't there
what exactly do you mean by this
i thought the icon meant the bot is muted but it turned out it was just deafened how A7mooz said. And the tooltip was me translating what it said in german :S
Also, I recommend using the preferred method of creating an audio player (that might fix the requirement of inlineVolume) -> createAudioPlayer()
thank you i will try that
can i count voice chat time
yeah
What is the group suppose to be in reference to the joinConfig?
"the group that the voice connection was registered with"
default is "default" and I don't know if it's even useful
So just setting it to "default" is enough?
yeah for anything you want to do
Very blessed, thank you 🙏
i guess you could use it for tracking voice connections
Is voice receiving capable of working in multiple servers in multiple different channels at once? I'm having problems where it seems when more than one server is sending audio for the bot to receive at once things start to break and it starts to cut off receiving despite the user still talking and then restarts it again. I've been asking about this for a while, any solution?
How
I wrote a function with DiscordTTS. (DiscordTTS is the module that converts text to speech) when I run the function, speak("hi you can call me friday", user) hi you can call me friday is interrupted. (it works normally when I do it without function). what would be the reason?
async function speak(words, user) {
const stream = discordTTS.getVoiceStream(words);
const player = createAudioPlayer();
const resource = createAudioResource(stream, {
inputType: StreamType.Arbitrary
});
const connection = joinVoiceChannel({
channelId: user.member.voice.channel.id,
guildId: user.guild.id,
adapterCreator: user.guild.voiceAdapterCreator
});
player.play(resource);
connection.subscribe(player);
player.on(AudioPlayerStatus.Idle, () => {
})
}```
how can I server mute someone ?
Documentation suggestion for @subtle granite:
VoiceState#setMute()
Mutes/unmutes the member of this voice state.
Why is djs voice archived on Github?
discord.js is a monorepo now, all packages are in that repository
okay, thank you for the info. I was inactive for a long time
Because UDP is used for both receiving and transmitting voice data, your client must be able to receive UDP packets, even through a firewall or NAT (see UDP Hole Punching for more information).
Yes
I have the Intents.FLAGS.GUILD_VOICE_STATES, package installed, and the bot has administrator permissions
Hello guys, i want to make a function that if the bot gets disconnected from a voice channel it automatically does smth. But i don't get my Bot to run, can any1 help me?
Tag suggestion for @vagrant wagon:
To help you we need more information:
• What are you trying to do?
• What is your code?
• What errors and debug logs do you have?
hey guys, i have no idea about how to play an audio in a voice channel😔can anyone gimme an example code or explain about that?
Suggestion for @cursive sapphire:
Library: Voice Connections
read more
Start here and follow that voice guide
how can I disconnect from vc?
<Connection>.disconnect();
const { getVoiceConnection } = require("@discordjs/voice"); // import the required module
let connection = getVoiceConnection("put your guild id here"); // get the connection of a guild
connection.destroy(); // so ".destroy()" will make the bot disconnect from the vc!```
For context: disconnect simply leaves the vc, and the connection can be used again while destroy will.. destroy the connection (and disconnect). Use destroy if you don't need to reuse the connection
Hello everyone, how I can use discordjs/voice with multiple bots? I have 2 discord clients( one for radio 24 / 7, second is music bot ) and when I use joinVoiceChannel it connects only the first one. There seems to be no way to choose which discord client should be connected
Pass the group: option with different values for each bot to joinVoiceChannel
And make sure to get the adapterCreator from the correct client
Thank you very much!
None of those parameters are correct, see https://discord.js.org/#/docs/discord.js/stable/class/Client?scrollTo=e-voiceStateUpdate
so? what's the issue
it's a logic error then
If you only care when it joins a stage channel (to make sure joining from a different channel works) , just remove the check for oldState here;
if (!oldState.channelId && newState.channelId) {
Also you might aswell just do this when you actually call joinVoiceChannel, it seems like that would be easier
Oh dude
These params are backwards
it's (oldState, newState) not (newState, oldState)
joinVoiceChannel.reciever.createStream isn't a function? Was it moved? v 13.8 with discordjs/voice
no?
sounds like a function from v12 or something else
fwiw connection.receiver.subscribe(userid, { opts }) returns an audioreceivestream so maybe that's the equivalent?
How do larger bots which utilize voice (like music bots and other things) deal with scaling? I've been having some issues with scaling with my bots. The audio quality just seems to go downhill and lag and stutter no matter what I do. Any advice?
You should be making your music streaming code separate from your bot code and putting audio nodes on separate server(s). A great example is https://github.com/freyacodes/LavaLink
If you want something like LavaLink, but using NodeJS and Discord.js/voice, then take a look at https://github.com/AmandaDiscord/Volcano
The general rule when making integrated music bots is to shard and cluster sooner and smaller. ~1500 was usually the baseline to start sharding because that's roughly when you'd run into single core performance issues. This can be ignored when using an approach like LavaLink as you can spread the audio nodes across many servers and worry about only meeting the needs of your shards when they would normally run into single core performance issues unaffected by audio de/encode
In my case, I'm not using a music bot. I'm playing audio directly from a URL. Any tips for that scenario?
I'd still probably use something similar unless you're doing something like radio
You can only really optimize when you do something like radio when you have 1 resource player playing on multiple connections
Oh I see, its not that. It's the same base URL for all audio but slightly modified so different audio outputs
I'm still a little unclear about what to do though. Do I need something to load it on an external thing and just send it to the bot somehow 
Any recommendations on where to start?
It kinda falls under "music", so the basic concept is to just separate your audio streaming code from your bot code. Something like LavaLink might be a bit overkill and have too much overhead for what you want to do. You'd be better off making your own proprietary system where you tell a service to play audio. In this case though, you could really benefit from looking at Volcano's source code, specifically this:
https://github.com/AmandaDiscord/Volcano/blob/main/src/worker.ts
Not that you need to copy the whole thing, but a lot of the stuff is kinda stuff I had to do to get a stable experience. Might be a bit hard to traverse without comments
Thank you, I will take a look :)
please, help me with this error while trying to install @discordjs/opus
not really djs related
but it looks like msvs_version was set improperly in your npm config
and how can I change the msvs_version in the npm config?
as you probably followed from node-gyp's installation, npm config set msvs_version <year>
and what year I need to put?
the one you have installed
for the record, it says it in your error, but I'm leaving it to you to discover since you should know what's installed on your computer
okay, ty
the year is 2022 right?
yes
are there any up to date guides on how to make a music bot like rythm or fredboat? i have no clue how to make one myself
i was following this guide from codelyon but its really out of date and i can't find any up to date version https://www.youtube.com/watch?v=q0lsD7U0JSI
i think we dropped our music bot example so that people don't go breaking youtube tos following our lead, but it probably still works
i just want one for my server with me and my friends so that we only need 1 bot with all the features we want in our server
not sure what that has to do with what i said, music bots inherently break tos if they scrape youtube, so we don't support doing it, but the old example that was removed probably still works
oh
how is it against youtubes tos to play youtube videos from a discord bot? you can already play videos fine by just pasting the link in chat
"The following restrictions apply to your use of the Service. You are not allowed to... use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)"
I don't know fully, I didn't pay attention to the music bot drama, u can prob ask in general and get a better response
huh, mee6 still has a music addon and its not being banned or anything
Hi, how do I detect if my bot has been forcefully disconnected by an admin?
you can check the audit logs on voiceStateUpdate
Ah
Ok thanks!
is it possible to basically record a voice chat through the bot?
yes
Don't worry this is consensual, it is for a DnD session for the recaps.
Is it possible to learn this power? || Do not say not from a Jedi ||
not from a Jedi
<VoiceConnection>.receiver.subscribe(<userId>) returns an opus packet stream
can i transcribe it into a mp3 and do discord bots have a upload limit?
and is userid to a specific user or is it just the bot's user id
specific, and yes they have an upload limit
planning on doing a /recap command that just sends the recording of the session
and yes ffmpeg or some other library can transcribe to mp3
I believe ffmpeg can handle opus packets directly, but if not, prism-media can decode to raw pcm which ffmpeg does handle
also is possible to record while the bot is playing music
ya
ok, i know this sounds kinda sus but promise it is consensual
can it only record one at a time or is it possible to record everybody speaking in the voice channel?
should be able to record multiple users at a time
cause vsc is telling me ```js
(method) VoiceReceiver.subscribe(userId: string, options?: Partial<AudioReceiveStreamOptions> | undefined): AudioReceiveStream
Creates a subscription for the given user id.
@param target — The id of the user to subscribe to
@returns — A readable stream of Opus packets received from the target
or is it a optional parameter?
it's not an optional parameter
you'd need to subscribe multiple times
that would return a different stream
oh so like ```js
for (let i = 0; i < interaction.member.voice.channel.members.length; i++) {
connection.receiver.subscribe(interaction.member.voice.channel.members[i].id);
}
sure
bit lost on this one but is there like a good sample i could follow?
ignore the install instructions, they're wrong, you need to use yarn if you want to use that
alright
thanks, but can it record multiple people
yes and no
the issue with recording multiple people is that you can't just merge opus packets, so you have to get individual streams of people talking, then do stuff with that
"can it record multiple people" - it will record every time a subscribed users speaks, then pipe that stream into an ogg file when they stop speaking
and also it's a bit hard to tell if people aren't talking, i guess you'd need to append silence frames for every time they aren't in order to have it match up correctly? (unless you use manual end behavior)
hardest part might even be knowing when to merge them, because you'd have one user start speaking, then it'd create the stream for them, even if it's appending silence frames, when another user starts speaking ffmpeg won't know to merge them so that user1 starts speaking, stops, then user2 starts speaking, it would just merge them and they'd be beginning at the same time
You need either ffmpeg (not npm) or ffmpeg-static (npm)
how can i get a sound of user in vocal channel ?
i have a pr guide, beware, you need prism-media alpha to use ogglogicalbitstream
https://deploy-preview-1159--discordjs-guide.netlify.app/voice/voice-receive.html
i run /join to try make the bot join vc, it says "the application did not respond" goes offline then back online, eventually throws an abort error then goes offline?
nvm i realised the issue
So you don’t reply to your /join Interaction. Without knowing anything about your code that’s all I can say
pretty sure i weren't trying to reply to /join, i can show the code if you want
You need to acknowledge the command though. Else discord will always show the application did not respond
} else if
(commandName === 'dominiontheme') {
interaction.channel.send('Joined Voice Channel')
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator
})
let resource = createAudioResource(("linkhidden"), { inlineVolume: true })
resource.volume.setVolume(1)
connection.subscribe(player);
player.play(resource);
interaction.channel.send("Now Playing: **Dominion Theme**")
console.log("Playing, Dominion Theme");
How can I make this so if the bot loses connection for playing audio it will resume playing
loses connection?
oh I get what you mean
yeah i'm not really sure that's possible without modifying internals of the library if it doesn't already resume audio. you'd need to persist resources and track when it actually dropped so you know where to begin playing again, then when the connection drops (and there isn't an event or anything for this) you start playing the resource again at a specified time
Alright
Would hosting it on my computer be a issue, I got good network and all
No, hosting it yourself wouldn't be a problem, but if your computer does lose connection (whether it be powering off, or the internet drops) the bot will die too
Hi I have a question guys
I'm working on a discord bot which play radio stream and I'm using ffmpeg-static for it. Is there a way to set a bitrate or sound quality in audio resource in v13 ?
technically no, but you can do it with prism-media
okay I will that thank you
I will look*
If you create an opus stream using prism-media , it will have the method setBitrate
or, more correctly, if you pipe a stream into an opus stream
im trying to make the bot leave the vc its in, however its saying that connection.disconnect() isn't a function??
then getVoiceConnection didn't return a connection
huh
what is channel.guildId coming from?
notice they defined it as interaction.member.voice.channel
nevermind, just check if connection exists before using the methods
alr ty
how to play mp3 file on the current voice channel of bot
i mean how to just get the current voice channel of bot
ty
can someone point me to the "joinVoiceChannel" method in the docs?
Documentation suggestion for @civic furnace:
joinVoiceChannel
Creates a VoiceConnection to a Discord voice channel.
thank you! Idk why I couldn't seem to find it
you have to switch to "voice" on the top left
const connection = getVoiceConnection(interaction.guild.id);
connection.destroy();
returns:
TypeError: Cannot read property 'destroy' of undefined
check if it exists i guess
that part of the code only runs if it exists but logging it only returns undefined
well i doubt it only runs if it exists then
you've got a point there
I've tested it with audio playing from the bot when I check for a connection and still get nothing
what's your connecting/full disconnecting code?
how are u connecting
handled via distube
there's probably a distube method for that, but it looks like they changed the group to client.user.id so if you really must use this, you can use getVoiceConnection(guild.id, client.user.id)
i would recommend checking out their discord and asking if there's a native get connection method
they have a native disconnection method but it's only applicable when the voice channel has a "queue"
this worked. thank you!
expect it to break functionality though
hi I have this error when installing discordjs/opus. I already tried installing discordjs/voice and it keeps asking me for opus. Any idea of solution?https://cdn.discordapp.com/attachments/881978618018951258/988986430489526343/unknown.png
install those desktop build tools from vs
The function <voiceChannel>.receiver.createStream(), is available in Discord.js v13?
<VoiceChannel>.receiver isn't a thing
Do you know if it will be possible to record the conversation of a voice channel?
it is but dunno how
Thanks mate
I entered sound with module @discordjs/voice, but how do I turn on the microphone?
?????????????????????????????
that will definitely not make anyone answer faster
thanks I check this
Im trying to make a play command in lavalink using erela.js
module.exports = {
name: 'play',
developer: true,
run: async(client,message,args) => {
const { channel } = message.member.voice;
if (!channel) return message.reply('you need to join a voice channel.');
if (!args.length) return message.reply('you need to give me a URL or a search term.');
const player = client.player.create({
guild: message.guild.id,
voiceChannel: channel.id,
textChannel: message.channel.id,
});
if (player.state !== "CONNECTED") player.connect();
const search = args.join(' ');
let res;
res = await player.search(search, message.author);
if (res.loadType === 'LOAD_FAILED') {
if (!player.queue.current) player.destroy();
throw res.exception;
}
player.queue.add(res.tracks[0])
message.reply('Added track to the queue!')
await player.play();
}
}
The thing is that it sends the track to the lavalink server and return it, add it to the queue but doesnt play music
I adddd the error event listener but no errors
@heavy sage firstly, channel must be message.member.voice.channel . Your code is getting the voice state of member and I don't know that you configure the players' functions correctly but you should use connection.subscribe to play something on voice channel.
How I get the current channel where the bot is in?
with the player
guild.me.voice.channel
no i mean with player
well that doesn't really make much sense
OR when I can check if the bot is connected?
When the player connects to the channel?
After createAudioResource or earlier
there is no player connecting, but there is a subscription event for connection and a playing status for the player
okay thanks
I dont know how im gonna do connection.subscribe with that player...
How do people use lavalink then
you are using methods that dont exist
In lavalink, there is one player for each guild and you can fetch player with voice.players.get("guild id") but this voice is not discordjs's property, this is lavalink's voice object which is created with const voice = new Node(); and you should import Node with const { Node } = require('lavalink'); . I recommend you to read the documentation from here : https://github.com/lavalibs/lavalink.js#readme
Is there any way to avoid lag when listening to music in my bot?
use worker threads
ok thanks
How can I change the volume of the stream during playing?
why my bot join to voice channel defined by defaultt
@frosty dome ^
Is there a way to have the streamTime in d.js 13 ? (The image is d.js 12)
anyone knows how to fix this:
Error: Cannot perform IP discovery - socket closed
reject Promise
Because UDP is used for both receiving and transmitting voice data, your client must be able to receive UDP packets, even through a firewall or NAT (see UDP Hole Punching for more information).
enable inlineVolume when joining , it's on the guide
<AudioResource>.playbackDuration
client.guilds.cache.forEach((guild) => {
if(guild.me.voice.channel){
guild.me.voice.channel.leave()
};
});```
I try to leave connect voice channel when i start my bot in all guilds, i have do this, but when my bot is in a voice channel and execute `guild.me.voice.channel.leave()` he return me `leave is not a function` but `guild.me.voice.channel` successfully returned the voice channel object.. how can i do ?
How did your bot join the VC?
with a package discord-player to listen music
discord opus & ffmpeg
is not a problem with the package
is a problem when i try to simply leave the vc bc i try to execute this when my bot start
Yes, but to leave a channel you‘d do the same as to join one, but since you apparently don’t join with djs functions it‘s not djs related
Destroy voiceConnection object with connection.destroy() and fetch voice connection with getVoiceConnection(guild_id) . Those are @discordjs/voice functions
when i write /play, the bot joins the voice channel but it doesnt play anything. Why is that?```js
const player = createAudioPlayer();
const connection = joinVoiceChannel({
channelId: interaction.guild.members.cache.get(interaction.member.user.id).voice.channelId,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator
})
const resource = createAudioResource("C:\Users\jkant\OneDrive\Documents\Coding\discord\tc-bot\song.mp3");
player.play(resource);
connection.subscribe(player);```Discord is not showing any error

Back slashes would have to be escaped
i mean i am using slash commands
I’m taking abt the path string
oh
so i use forward slashes?
Escape the back slashes
\\ instead of \
I would prob just use path.join(__dirname, relativePath) instead of an absolute one
ohh
like this?js const resource = createAudioResource("C:\\Users\\jkant\\OneDrive\\Documents\\Coding\\discord\\tc-bot\\song.mp3");
That should work
lemme try
still doesnt do anything
yea...
Can you log fs.existsSync(…) using the path you provided?
sure
bro it worked :_)
it was cause i was stupid and took out the connection.subscribe
Well, it shouldn’t change anything, you can remove the log
Oh
yea i didnt add that code yet
How to record voice from vc after user uses record command.
I'm using a really basic portion of code to join a VC but I can't seem to figure out what's the issue. The bot has admin permissions. I get an err: TypeError: Cannot read properties of undefined (reading 'set') on the line where I define the connection.
const channel = msg.member.voice.channel
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
None of that looks related to your error, have a look at the error stack and it will tell you what line it comes from
It shows at Object.execute (C:\Users\ryanv\music bot\commands\play.js:17:28) and line 17 is where I define the connection, is there another part of the stack I should be looking for?
Then I guess it could be from an internal function, what's the entire error?
TypeError: Cannot read properties of undefined (reading 'set')
at C:\Users\ryanv\music bot\node_modules\discord.js\src\structures\Guild.js:1380:34
at new VoiceConnection (C:\Users\ryanv\music bot\node_modules\@discordjs\voice\dist\index.js:1377:21)
at createVoiceConnection (C:\Users\ryanv\music bot\node_modules\@discordjs\voice\dist\index.js:1671:27)
at joinVoiceChannel (C:\Users\ryanv\music bot\node_modules\@discordjs\voice\dist\index.js:1694:10)
at Object.execute (C:\Users\ryanv\music bot\commands\play.js:17:28)
at Client.<anonymous> (C:\Users\ryanv\music bot\index.js:49:66)
at Client.emit (node:events:390:28)
at MessageCreateAction.handle (C:\Users\ryanv\music bot\node_modules\discord.js\src\client\actions\MessageCreate.js:26:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\ryanv\music bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\ryanv\music bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:351:31) ```
Promise {
<rejected> TypeError: Cannot read properties of undefined (reading 'set')
at C:\Users\ryanv\music bot\node_modules\discord.js\src\structures\Guild.js:1380:34
at new VoiceConnection (C:\Users\ryanv\music bot\node_modules\@discordjs\voice\dist\index.js:1377:21)
at createVoiceConnection (C:\Users\ryanv\music bot\node_modules\@discordjs\voice\dist\index.js:1671:27)
at joinVoiceChannel (C:\Users\ryanv\music bot\node_modules\@discordjs\voice\dist\index.js:1694:10)
at Object.execute (C:\Users\ryanv\music bot\commands\play.js:17:28)
at Client.<anonymous> (C:\Users\ryanv\music bot\index.js:49:66)
at Client.emit (node:events:390:28)
at MessageCreateAction.handle (C:\Users\ryanv\music bot\node_modules\discord.js\src\client\actions\MessageCreate.js:26:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\ryanv\music bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\ryanv\music bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:351:31)
``` (full err)
what version of djs are you on
13.7.0
🤔 are you changing anything about the client? the error is implying one of the client managers is undefined
or perhaps, is this sharded?
I'm not entirely sure how to change my client. I define the client and pass it through a command handler but I never change it. It's also not sharded
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Intents.FLAGS.GUILD_VOICE_STATES,
],
partials: ["MESSAGE", "REACTION", "USER"],
});
Wtf lol
try logging client.voice just before you try to make a connection
client.voice returned the below
hmm that's not right
Out of curiosity what should it return
Alright I'm gonna sleep on this, hopefully find a solution with a fresh mind, thanks for your help up until now
When you come back feel free to ping but: are there any other dependencies that could be causing a clash? npm list discord.js anything that modifies voice like another npm package such as discord-player, and whatever the other ones are
...
Kk
**Guild: **
read more
Not a bad idea, I checked the npm packages that were installed and cleared out a few unneeded ones. However I still don't see any packages that would be clashing
How do ik if any player exist or not in that guild when i have declared player anywhere else which isn't accessible in a different thing?
Like can I get player as we get connection?
const connection = getVoiceConnection(interaction.guildId);
SO
const player = getVoicePlayer(interaction.guildId);
Is this valid case?
check the doc
I can't find anywhere there
yes, getVoicePlayer doesn’t exist
const player = connection.state.subscription.player
Oh ic
Thanks it works!
For some reason my bot isn't joining voice and is printing no errors...
const { SlashCommandBuilder } = require('@discordjs/builders');
const dcVoice = require('@discordjs/voice');
module.exports = {
data: new SlashCommandBuilder()
.setName('join')
.setDescription('Join your voice channel.'),
async execute(interaction) {
channel=interaction.member.voice
const connection = dcVoice.joinVoiceChannel({
channelId: channel.id,
guildId: interaction.member.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator
});
},
};
const { joinVoiceChannel } = require('@discordjs/voice');
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
(I’m on mobile so formatting is bad, sorry)
Also make sure you have the right intents
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES] });
It works now
i'm trying to pipe the discord voice channel to an express server, how can i do that ? i've tried this but it didn't work```app.get(/, async (req,res) => {
try {
const channel = await client.channels.cache.get('818300593058611203');
const connection = joinVoiceChannel({
channelId: channel?.id,
guildId: channel?.guild?.id,
selfDeaf: false,
selfMute: true,
adapterCreator: channel?.guild?.voiceAdapterCreator,
});
const receiver = connection.receiver.subscribe();
receiver.pipe(res); })```
please ping me if you know how
like i need the connection.receiver.subscribe to return a stream
why am i getting this error?Error: Cannot perform IP discovery - socket closed
i suspect it is coming from this js const resource = createAudioResource((path.join(__dirname, "..", "..", "songs") + `/${id}.mp4`));
how that is related, you are trying to join voice channel not creating resource. the problem is you cant perform ip discovery. most likely your firewall issue
Can someone explain me how does @discord.js/opus work, please? 🙂
anyone ?
Can someone help me make a voice bot/music bot that would join vc channels and play music of the user choice
using slash commands
no
Umm....trying form when but can't make out how do I make this interaction guild specific only ?
#rules rule 2, rule 4, rule 5.
didn't get
Like to know that does player sxist in that server where comand was used not globally
you can get the voice connection with the guild id, and get the player with the connection
why isnt the voice documentation loading?
everything else works perfectly fine
Probably better to ask in #archive-site-discussion
oops sorry
i don't get it
Oh ic thanks :()
your client cant send udp packets
What is wrong with this code? the bot is connecting to the voice channel but it doesn't play anything or gives an error
You never subscribed the connection to the player
can you show me how to do this?
connection.subscribe(player)
yt-dlp-wrap execStream() error
problem:
error on second and above songs, (first song without errors)
code:
resourse() {
this.soundStream = yt_dlp.execStream([
"-f", "bestaudio[acodec=opus]/worst[acodec=opus]",
"-c", "",
"-i", "",
"--audio-quality", "0",
"-r", "100K",
"-R", "infinite",
"-o", "-",
"--ffmpeg-location", "C:\\ffmpeg\\bin\\ffmpeg.exe",
"ytsearch:", this.songs[0].url
]);
}
stream() {
if (this.isPlaying == false) {
this.isPlaying = true;
}
this.resourse();
this.soundStream.on("error", e => {
console.log(e);
});
this.audioPlayer.play(createAudioResource(this.soundStream));
this.audioPlayer.on("idle", () => {
this.songs.shift();
if (this.songs.length == 0) {
this.soundStream.destroy();
// this.soundStream.kill();
this.disconect();
} else {
this.soundStream.destroy();
this.resourse();
this.audioPlayer.play(createAudioResource(this.soundStream));
this.controller("update");
}
});
}
error code:
R [Error]:
Error code: 1
Stderr:
ERROR: [generic] '' is not a valid URL. Set --default-search "ytsearch" (or run yt-dlp "ytsearch:" ) to search YouTube
ERROR: [generic] '' is not a valid URL. Set --default-search "ytsearch" (or run yt-dlp "ytsearch:" ) to search YouTube
[generic] ytsearch:: Requesting header
WARNING: [generic] Could not send HEAD request to ytsearch:: <urlopen error unknown url type: ytsearch>
[generic] ytsearch:: Downloading webpage
ERROR: [generic] Unable to download webpage: <urlopen error unknown url type: ytsearch> (caused by URLError('unknown url type: ytsearch'))
[youtube] QJJYpsA5tv8: Downloading webpage
[youtube] QJJYpsA5tv8: Downloading android player API JSON
[info] QJJYpsA5tv8: Downloading 1 format(s): 251
[download] Destination: -
[download] 100% of 3.44MiB in 00:35
at YTDlpWrap.createError (...)
at ChildProcess.<anonymous> (...)
at ChildProcess.emit (node:events:537:28)
at maybeClose (node:internal/child_process:1091:16)
at ChildProcess._handle.onexit (node:internal/child_process:302:5) {
resource: T {
playStream: OggDemuxer {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 5,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: true,
_remainder: null,
_head: null,
_bitstream: null,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: [Function: bound onwrite]
},
edges: [ [Object], [Object] ],
metadata: null,
volume: undefined,
encoder: undefined,
audioPlayer: B {
_events: [Object: null prototype],
_eventsCount: 1,
_maxListeners: undefined,
_state: [Object],
subscribers: [Array],
behaviors: [Object],
debug: [Function (anonymous)],
[Symbol(kCapture)]: false
},
playbackDuration: 35100,
started: true,
silencePaddingFrames: 5,
silenceRemaining: -1
}
}
libs:
@discord.js/Voice
yt-dlp-wrap
How do I get it to automatically exit when finished playing mp3?
if (msg.member.voice.channel) {
//join
const conn = joinVoiceChannel({
channelId: msg.member.voice.channelId,
guildId: msg.guildId,
adapterCreator: msg.guild.voiceAdapterCreator
});
playSound(msg, conn);
function playSound(msg, conn) {
const player = createAudioPlayer();
const resource = createAudioResource(sounds[msg.content]);
conn.subscribe(player);
const dispatcher = player.play(resource);
dispatcher.on("speaking", speaking => {
if (!speaking) {
conn.destroy()
}
});
}
ask in the support server of yt-dl-wrap
basically how do get it to just join a voice channel
via an eval command?
I'm installing I'm but it stayed like this, is it normal? it takes about 1 or 2 minutes
Hello I am having troubles using the @discordjs/voice module
Error: Cannot find module '/home/user/Desktop/cringe-main/node_modules/@discordjs/voice/dist/index.js'
try reinstalling it?
is it possible to have the AudioPlayerStatus default to idle? if not, what is the default?
(From what I can tell Idle isnt the default)
What is it then?
the module, the whole discord.js or node?
Have you logged the status?
nope
i mean the package
I don't think they were asking you
oops
ok i will
I must be logging it wrong, because this is what console.log(AudioPlayerStatus) returns:
{
Idle: 'idle',
Buffering: 'buffering',
Paused: 'paused',
Playing: 'playing',
AutoPaused: 'autopaused'
}
it worked @young sail
It’s autopaused
Or idk
That’s the enum
I thought you were checking the player.state.status?
I just did that rn, default is idle, so I guess some part of my code is faulty
it's idle if it doesn't have a song to play and isn't playing one at the current moment iirc
yea its Idle. but its kinda acting a bit weird, because e.g.
player.on(AudioPlayer.Idle, () => console.log("idle"));
doesn't work and neither does
player.on(player.state.status === "idle", () => console.log("idle"));
The former is correct
It only runs when the player becomes idle
As in the player was in a different state before becoming idle
well that sucks
for what im doing rn atleast lmao
I mean, you can just run whatever you want to run when you create the player
hello, i can´t download @discordjs/opus
help xd
Do you get any error messages?
sorry, can someone teach me this?
any ideas on how i would go about getting audio from the person speaking, and logging it in the bots console as text?
If I am getting an audiostream from a users microphone as MediaStream and I then want to pipe it into a voice channel, do I have to re-encode it with prism FFMPEG or can I just pipe it to prism as well?
Hey, Im having a bit of an issue here, hope someone can help me
// add to queue if already playing something
if(state === 'idle' && fileContent !== '[]' || state === 'playing') {
// add new requests to queue
[...]
i.reply({ content: 'added to queue', ephemeral: true });
}
// this right here logs once for every /play done until current track finished
player.once(AudioPlayerStatus.Idle || AudioPlayerStatus.Buffering, () => console.log('next'));
I'm trying to add URLs to a queue, which by itself works fine, let me explain:
if you do /play <url> the url will get added to the queue, you get a reply and once the player turns to "idle", the next url will be played.
the problem:
for every /play done, until the currently running resource is over, it will log "next" one time (so, if the command was run 5 times, it will get logged 5 times), I have tried adding return in front of the the i.reply(...) in the above if clause, but then it never gets to the player.once part.
Whats the best way to go from here?
I currently have all of this inside of my play.js file.
Edit: Tried the discord-player npm package instead of creating queue by myself , but seems to have the same outcome
message.member.voice.channel.join();
why does this not work
Im having a issue with my bot randomly disconnecting after 10-30 seconds while it still playing muisic. Im using discord-player and this is the code ```js
if (!interaction.member.voice.channelId) return await interaction.reply({ content: "You are not in a voice channel!", ephemeral: true });
if (interaction.guild.me.voice.channelId && interaction.member.voice.channelId !== interaction.guild.me.voice.channelId) return await interaction.reply({ content: "You are not in my voice channel!", ephemeral: true });
const query = interaction.options.get("query").value;
const queue = player.createQueue(interaction.guild, {
metadata: {
channel: interaction.channel
}
});
try {
if (!queue.connection) await queue.connect(interaction.member.voice.channel);
} catch {
queue.destroy();
return await interaction.reply({ content: "Could not join your voice channel!", ephemeral: true });
}
await interaction.deferReply();
const track = await player.search(query, {
requestedBy: interaction.user
}).then(x => x.tracks[0]);
if (!track) return await interaction.followUp({ content: `❌ | Track **${query}** not found!` });
queue.play(track);
return await interaction.followUp({ content: `⏱️ | Loading track **${track.title}**!` });
We don’t support 3rd party libraries
then what should i use to play music?
Whatever you want. But ask that library‘s support for support, not us
alright mb thanks
if (this.isPlaying == false) {
this.isPlaying = true;
}
is literally the same thing as this.isPlaying = true
the voice docs isnt opening
alright thanks
i'm running voice in the node:latest docker container, i've added the ffmpeg package, and i'm getting this error: Error: FFmpeg/avconv not found!
wondering if there's anything else i need to do in order to make ffmpeg available to node
nvm, rebuilt the container again and it worked
Does anyone know why the AudioReceiveStream doesn't emit end/close or anything like that when I pass
end: {
behavior: EndBehaviorType.AfterSilence,
duration: 3000,
}
to the subscribe method?
After I stop speaking and wait 3 seconds, nothing happens. When I speak again it throws
Error [ERR_STREAM_PUSH_AFTER_EOF]: stream.push() after EOF
at new NodeError (node:internal/errors:371:5)
at readableAddChunk (node:internal/streams/readable:277:30)
at AudioReceiveStream.Readable.push (node:internal/streams/readable:228:10)
at AudioReceiveStream.push (C:\Users\soere\dev\voice\node_modules\@discordjs\voice\dist\index.js:1148:18)
at VoiceReceiver.onUdpMessage (C:\Users\soere\dev\voice\node_modules\@discordjs\voice\dist\index.js:1324:16)
at VoiceUDPSocket.emit (node:events:390:28)
at VoiceUDPSocket.onMessage (C:\Users\soere\dev\voice\node_modules\@discordjs\voice\dist\index.js:311:10)
at Socket.<anonymous> (C:\Users\soere\dev\voice\node_modules\@discordjs\voice\dist\index.js:293:48)
at Socket.emit (node:events:390:28)
at UDP.onMessage [as onmessage] (node:dgram:939:8) {
code: 'ERR_STREAM_PUSH_AFTER_EOF'
}
How would I determine that the bot has been disconnected from a voice channel
Ignore: just found what I needed in the guide
is there something to see the status of the player
like player.status or something to see if idle/playing or paused
nvm
Hey, I've had a user request support for stage channels. Is this difficult to implement if I already support regular voice channels? I'm not seeing much in the docs
Only thing youll have to do with stages is whether ur bot is a speaker or in the audience
other than that its identical
And StageChannels don’t have TiV feature
are you doing anything else to the stream? i'm pretty sure putting the endbehavior to that isn't enough for that error
getVoiceConnection() doesn't work after a bot restart, is there something i can do to fix this
joinVoiceChannel again, the connection is lost after restart obviously
sounds about right, thx
Not that I know.
My guess would be the way I receive voice, that its trying to create a new stream and then fails.
https://imageing.org/shared/gClJSE3.png