#archive-voice
30636 messages · Page 21 of 31
You need that.
ok i'm sorry
No need to apologize, it's a easy mistake to fall into.
Hello! To use an audio bot in different servers i need to create an audioplayer for each one? If i start an audio in a server it goes in ALL where it's actived
you can subscribe the same audioplayer to multiple connections then it will play the same
it's normal when i kick my client in the voice channel, the player.on idle repeating itself?
can one define adaptorcreator? (i want the bot to join the voice channel without anyone having to send a message)
So i've to create an audio player per each server and attach the connection to the related player?
/home/runner/b1/index.js:28
radio.channels.cache.get(log).send(reset)
^
ReferenceError: reset is not defined
at StreamDispatcher.<anonymous> (/home/runner/b1/index.js:28:44)
at StreamDispatcher.emit (events.js:326:22)
at finishMaybe (_stream_writable.js:639:14)
at _stream_writable.js:616:5
at StreamDispatcher._final (/home/runner/b1/node_modules/discord.js/src/client/voice/dispatcher/StreamDispatcher.js:248:5)
at callFinal (_stream_writable.js:609:10)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
exit status 1
Help Plz
adapterCreator: client.guilds.cache.get('The guildId').voiceAdapterCreator
That depends on what you want if you want it to play the same audio in all servers you could use a single player and subscribe to multiple connections if you want separate audio in the servers you would need a player for each server
ok and a player for each server? how can i create it? i'm searching on the docs, but there aren't an identification for the player, such an id
You would need to keep track of them yourself for example by using a map with the serverID (guildID) as an identifier
hi
i make it, with an object in the map that holds the connection and the audioplayer
but it doesn't work, the audio doesn't play
if i subscribe a voice connection to a player, will it automaticly destroy when song is ended or bot is removed from channel and what events are there?
Hi! When my bot plays music i get the following error sometimes
I read online that this error is cause by the discord js version
i am doing a music bot, but v13 isnt working as v12...
const stream = ytdl(video.url, {filter: 'audioonly'});
connection.play(stream, {seek: 0, volume: 1})
.on('finish', () => {
voiceChannel.leave();
});
``` doesnt work anymore, `connection.play()` is not a function. is there any other function that works the same?
BRH!
yes me too... anyone have an idea on how to fix this?
read the new voice guide
i have got it working
not a djs voice error. Thats from ytdl-core
and i need to downgrade my discord js version?
ive read on github that the setting ytdl-core highWatermark to 32MiB fixes this issue... havent tested it yet tho
that shouldnt have anything to do with it @subtle granite
it was apparently an issue with node v16+ and ytdl
dev said that this fixes it
how can i check how much people are in a voice channel? When i log channel?.members the result in console is Collection(0) [Map] {} so that channel?.members.size is always 0
do you have GUILD_VOICE_STATES intent?
yes
any one knows something about implementa tions of genius api
this is for djs voice support. Not genius api
how can i change volume of the player?
resource.volume.setVolume(1);
do i have to enable inline volume or it works without that?
You have to enable inline volume
ok
dude i cant find audio resource options in djs voice docs
how can i check how much people are in a voice channel? When i log channel?.members the result in console is Collection(0) [Map] {} so that channel?.members.size is always 0. There are all intents in a client.
Its mapped between 0 and 1
okk
TypeError: Cannot read properties of undefined (reading 'setVolume')
can you show the code where you implement it
const player = createAudioPlayer();
resource = createAudioResource("C:/Users/HP/Desktop/bt/d-bot/cc_1.ogg",{inlineVolume:true})
resource.volume.setVolume(0.6)```
wait it works now idk how but ok
Okay great
thx
hello, I am not sure how to fix this:
can i seek audio to 0?
Like an automatic transition?
yeah bcs my audio start from 2 sec like that
You would have to write a function to do that yourself it is not build in
how can i check how much people are in a voice channel? When i log channel?.members the result in console is Collection(0) [Map] {} so that channel?.members.size is always 0. There are all intents in a client.
Whenever I make my bot to join stage channel, it joins as an audience. How to make it join as a speaker? Please reply with a ping 🙏
Btw its a Music Bot and uses Erela.js. I have added the following code which didn't work:
try {
await player.guild.me.voice.setSuppressed(false);
} catch (e) {
return;
}
}```
Do you have the GUILD_VOICE_STATES intent?
Anyone?
@rugged sky yep
member.voice.setSuppressed(false);
if(player.voiceChannel.type === "GUILD_STAGE_VOICE" && server.me.voice.suppress) {
try {
await server.me.voice.setSuppressed(false);
} catch(e) {
server.me.voice.setRequestToSpeak(true);
}} ```
Why doesn't this work 🥲
hello, how can i use "finish" event in new voice?
Do i have to create a new audioPlayer for every guild i am connecting a voice to?
or is that a waste of resources?
That depends on if you want to play different things in different guilds a player can only play a single resource. so yeah you may need one for every single guild
thanks :)
<AudioPlayer>.on('idle', () => {})
Hello! How do I get the AudioPlayer from VoiceConnection?
<Connection>.state.subscription.player, assuming it’s subscribed
Okay thanks!
How can I set the volume in AudioPlayer?
resource.volume.setVolume(1);
Thank you!
Why I don't have that volume object in the resource object?
It says undefined
You have to enable inline volume on the resource
okay
any answers?
You have to destroy the connection I don't believe you have to worry about the player
Hello guys ! just a little question. Do you guys know how to detect if someone is speaking on a voice channel ? I used voiceStateUpdate event but it's only for mute/leaf detection. Thanks!
Hello! Sometimes the bot returns at RequestHandler.js and sometimes AudioPlayerError: aborted.
Sometimes when i start the audio/music, sometimes, polaying it, it stops and gives that error.
Are you using ytdl because that has been having problems if that is the case I would recommend switching to playdl
Yes i'm using ytdl. Thanks for advice, i'm going to switch it. It woreks as ytdl? It returns a stream to pass to createAudioResource()?
Hello! The following code makes typescript very angry and I do not know how to fix it considering this is the very first few lines in the guides.
Type 'InternalDiscordGatewayAdapterCreator' is not assignable to type 'DiscordGatewayAdapterCreator' and a few other errors that come with the adapterCreator property.
just @ts-ignore it, it's basically just typescript complaining
Ok IDK why it's mad, so can someone explain why it's telling me this isnt a function when the docs say that it is a function
(the channel ID is hardcoded for testing)
connection.subscribe takes a Player, not a Stream
discordjs.guide results:
• Library: Audio Player
• Library: Cheat sheet
Would recommend reading the voice guide more thoroughly
can some one at here help me https://sourceb.in/bPJWuNm9gw whit my coede it is joinig but it isn't playing anithing can you pls help me
and then it crashes
What error do you get?
it just crashes and TypeError: Cannot read properties of undefined (reading '0')
at Object.execute (C:\Users\rauno\OneDrive\Töölaud\bot v2\commands\play.js:10:18)
at Client.<anonymous> (C:\Users\rauno\OneDrive\Töölaud\bot v2\index.js:39:35)
at Client.emit (node:events:390:28)
at MessageCreateAction.handle (C:\Users\rauno\OneDrive\Töölaud\bot v2\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\rauno\OneDrive\Töölaud\bot v2\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\rauno\OneDrive\Töölaud\bot v2\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\rauno\OneDrive\Töölaud\bot v2\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\rauno\OneDrive\Töölaud\bot v2\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\rauno\OneDrive\Töölaud\bot v2\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (node:events:390:28)
Also, this is v12 code. Should be discussed in #archive-djs-v12-voice-deprecated .
oh
you mean node v 12 ??
Ops i have 17.0.1 version
No, Discordjs v12.
what does That v12 means
Version 12.
for what
Of Discordjs, the library you are using.
shall i upgrade it or what
I would recommend so, often good to be on the latest version of stuff. V13 does change a lot about playing audio, so you would have to do a bit more research.
ok
Why does the bot stops playing the resource after a few seconds although the audio stream is longer (10 seconds)? This happens only in short audio streams.
How would I detect when someone first joins a vc and who it is and then send a message in a channel tagging a role, and when the last person leaves the vc edit the message
im getting the same result. I wonder what the issue is
Do connections and the player that is subscribed to a connection share the same stateChange event listener?
if (connection.listeners('stateChange').length < 1) {
connection.on('stateChange', (oS, nS) => {
if (nS.status == 'disconnected') {
stop();
}
});
}
i have this bit of code to stop the player if the connection is terminated but the listener never registered, and im not registering any other listeners on the connection, but i do have listeners on the player
And if i dont do checks then i get maximum listener threshold warnings
Hello! How could i implement a stop function for a queue audio bot? I handle the "stop" with the audioplayer idle event, but i do not know how to stop it, for because, for a queue if there are songs it still play. Also if i put a flag variable it's in "play" status (for because it plays the songs at start"
If you want it to just stop playing but not remove anything you can just do player.pause()
and then player.unpause() to start again
hi, how can i fix this error ?
i installed @discordjs/opus v0.6.0
how can i made a command to see in how many channels are connected my bot
how to set volume in @discordjs/voice ?
<AudioResource>.volume.setVolume()
thank you , btw can i get current audio resource from any function if anything is playing using resource ?
Does anyone know why this happens?
getVoiceConnections().size
error: stream: Error: aborted
node:events:371
throw er; // Unhandled 'error' event
^
AudioPlayerError: aborted
at connResetException (node:internal/errors:683:14)
at TLSSocket.socketCloseListener (node:_http_client:407:19)
at TLSSocket.emit (node:events:406:35)
at node:net:662:12
at TCP.done (node:_tls_wrap:580:7)
Emitted 'error' event on AudioPlayer instance at:
at OggDemuxer.onStreamError (/home/ubuntu/Desktop/cellbot/CELL-bot/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:213:22)
at Object.onceWrapper (node:events:514:26)
at OggDemuxer.emit (node:events:406:35)
at emitErrorNT (node:internal/streams/destroy:193:8)
at emitErrorCloseNT (node:internal/streams/destroy:158:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
resource: <ref *4> AudioResource {
any idea hat causes this error?
any script where i can get currently connected member list to a certain voice channel
voiceChannel.members is a collection of all the currently connected members
YTDL-core does, i recommend switching to play-dl.
How do I wait for the current audio resource to finish playing before starting the next one?
Listen for the Player idle event
Well then what do I put in the player idle event?
Play the next song, if any
How do I add songs to like a queue then?
Actually wait nvm I have an idea
I fixed it 
sounds good, thank you
How detect in what voice channel is the bot
i can't install @discordjs/opus, this is the logs, anyone help me pls 😦
Hmm.
You might be doing something worng.
here is the error
The photo above is the logs
And what are u trying to do?
i'm trying to install @discordjs/opus v0.6.0
i have error like this guy
Hmm
oh i found out why it can't install
its because i'm using node v17.0.1
the glibc of node doesn't matches with the glibc of @discordjs/opus
I reverted to node v16.8.0 and it worked fine
Lol.
when i play an audio it dont get completed till ends sometimes any fixes?
No you don't have make installed.
https://askubuntu.com/questions/161104/how-do-i-install-make
You can install discordjs opus in node 17 also.
really? but why when i’m in node v17 it throw error, when i revert to node v16.8.0 it working fine
See here it is written that make command is not found
anyway, tysm for helped me
👍
emm i think djs will be update again because the same like me i use node js v17 it having error if v16 no
yea its working fine in node v16 but when i upgrade to node v17 it throw error
ye i hope upgraded djs will not change other like djs v12 to v13

Hey. Why does the bot stop playing short audio streams before they actually finish? This happens when the audio stream is shorter than 20 seconds.
Hello I try to send a song on a vocal channel, but I receive an error:
connection.play is not a function
My code:
connection = await joinVoiceChannel({
channelId: vocalChannel.id,
guildId: vocalChannel.guild.id,
adapterCreator: vocalChannel.guild.voiceAdapterCreator,
});
(...)
let songInfo = await ytdl.getInfo("https://www.youtube.com/watch?v=yUXJjIvhZz8");
let song = {
title: songInfo.videoDetails.title,
url: songInfo.videoDetails.video_url,
};
const dispatcher = connection
.play(ytdl(song.url))
.on("finish", () => {
channel.send("fini")
})
.on("error", error => console.error(error));
dispatcher.setVolumeLogarithmic(1);
Can you help me please?
Thank you
And when I replace
.play(ytdl(song.url))
By
.playFile(ytdl(song.url))
I receive the same error
discordjs.guide results:
• Library: Audio Player
• Library: Cheat sheet
It’s not the job of the connection to play songs anymore, audio players handle that
Like this?
let songInfo = await ytdl.getInfo("https://www.youtube.com/watch?v=yUXJjIvhZz8");
let song = {
title: songInfo.videoDetails.title,
url: songInfo.videoDetails.video_url,
};
const player = createAudioPlayer();
const resource = createAudioResource(ytdl(song.url), {
metadata: {
title: 'A good song!',
},
});
player.play(resource);
Yeah, but note you should also subscribe the connection to the player if you haven't already.
What?
The voice connection needs to be told to stream whatever your player is playing by subscribing it.
ah
It good I have added the subscribe but I have a new error:
Error: FFmpeg/avconv not found!
I try npm i ffmpeg-static....
Now I don't have error but I don't have the song...
And I don't have any idea to resolve the problem
My new code
connection = await joinVoiceChannel({
channelId: vocalChannel.id,
guildId: vocalChannel.guild.id,
adapterCreator: vocalChannel.guild.voiceAdapterCreator,
});
let songInfo = await ytdl.getInfo("https://www.youtube.com/watch?v=yUXJjIvhZz8");
let song = {
title: songInfo.videoDetails.title,
url: songInfo.videoDetails.video_url,
};
const player = createAudioPlayer();
const resource = createAudioResource(ytdl(song.url), {
metadata: {
title: 'A good song!',
},
});
player.play(resource);
connection.subscribe(player);
Have you an idea?
You need to set inputType as arbitrary while creating resource.
I have to put what?
This?
const resource = createAudioResource(ytdl(song.url), {
metadata: {
title: 'A good song!',
inputType: "???"
},
});
I have try:
inputType: StreamType.Arbitrary
inputType: ytdl(song.url).type
inputType: song.type
And it not work
and ```JS
const resource = createAudioResource(ytdl(song.url), {
inputType: StreamType.Arbitrary,
metadata: {
title: 'A good song!',
},
});
What is ytdl here ??
const ytdl = require('ytdl-core');
All my code is here:
https://replit.com/@kik11/paqbo#commands/startchallenge.js
at the line 122
in commands/startchallenge.js
how to check if client has GUILD_VOICE_STATES intent
TypeError: Cannot read properties of undefined (reading 'setVolume')
at /home/runner/Astroz-Support/index.js:36:29```
is there any voice event handler?
need to enable inline volume ig
why is my boy not playing audio?
hi all i have start to code my bot with typescript
know i need some help with the permission settings by my auto channel (temp channel) code
my temp channel runs know with permissions that i incloud in the code:
await newChannel.overwritePermissions([ { id: member.id, allow: ['MANAGE_CHANNELS'], }, { id: guild.id, allow: ['VIEW_CHANNEL'], }, ]); console.log(`created new temp voice channel for ${effectiveName}: ${newChannel.id}`); return newChannel;}
but i want that the bot synchron with the master channel by the permissions
does anyone have a minute or two i have question? it's about getting a bot to join a vc which i've been having trouble with.
my music bot shows as its speaking but its not playing anything
Hello! I've perms problems. I've a voice bot that should take perms only from a text channel. In the other channels i've thaat the bot could ONLY see the channel (sync with category where there are the voice channles too), but it cannot read message. Why if i put the command "-play" for example it reads the command (so join the channel), but obviusly crash for missing permission.
Hi, it happens to me that sometimes the bot crashes when it is playing something, it tells me AudioPlayerError: aborted and much more, the log is here: https://pastebin.com/UFjbEHgx
why does that happen? and how can i solve it?
i use
audioPlayer.play(createAudioResource(await ytdl(this.link)))
well it works in different classes but the code is basically that, it works but sometimes it crashes after a while
This is an issue of ytdl-core. Discordjs voice can't help at all
Even if you disable read message history permission, bot gets messageCreate event whenever a message is created.
Code ??
Ask the questions
Oh, i understand
how can we get a channel from a voice connection??
How memory heavy is a music bot? What can I expect?
connection.joinConfig.channelId I think this should get channel ID
This can be memory light or memory heavy depending upon how you code your music bot and which packages you choose to make it.
are there any docs to it?
bcs i didnt find joinconfig in djs voice
yeah didnt find it here
i mean doc for join config isnt there
this dosent shows the methods and properties of it actually
JoinConfig have same options that you provide in joinVoiceChannel function
oh
but how we can come to know about that?
basically what i wanna do is in the play command to check for if something is playing or not
Then why do you need voice connection ?? Just get subscribed player attached to connection and check if it is playing or not
how can we get it?
cant figure out
Just make sure you have attached a audio player with connection and then get player by
const player = connection.state.subscription.player
ooo
thank you so much!
Then you can check player status by
if(player.state.status === "playing")
Or use AudioPlayerState instead of playing
yeah
thx
👍
Hey 👋 I made a music bot with a loop system but sometimes it stops playing because of an Http 403 forbidden error. How can i fix it ?
which package ??
Play-dl
ask in their support server not here
Ok
Oh ok thank, you. So how can i handle that? I can put the permissions check for send messages/etc directly at the start of the message create event? Or there is a better way?
just disable view channel permission for bot in that text channel
it's inherited from category. If i remove that perm, the bot doesn't see the voice channels too
I told to remove from text channel not category.
yes but in that way i the sync from category
i need all the text channels to be synced with category
hm
In your messageCreate listener just make the first line be a check for if the message is coming from that specific channel, and if it is ignore it.
You can check for read message history permission before running your command. If your bot don't have it, just return.
Thanks for all tips :)
this is my code to get the bot to join a voice channel: https://pastebin.com/HxQAiL7z
i can't get it to join, I've been trying for hours. I'm assuming its a simple problem but I have no idea how to use discordjs 13
You are connecting to a text channel.
const connection = joinVoiceChannel ({
channelId : message.member.voice.channel.id,
guildId : message.guild.id,
adapterCreator : message.guild.voiceAdapterCreator
})
Spelling can be wrong so make sure to cross check
the event player.on idle status is called even when we suscribe the player?
Is there a way to record a user's audio while they are in a vc ?
using createListeningStream ?
I can't tell you much more than yes it's possible and refer you to the example, sorry.
I just really don't know how
oh ok np then, anyways ty tho
Hi, is there a way I can create multiple players ?
example:
const palyer1 = createAudioPlayer();
const palyer2 = createAudioPlayer();
Yes you can
I just found out, that wasn't the issue...
can you let 2 or more different clients join seperate channels in the same guild from one script?
sth like this:
const client1 = new Client({ intents: 32767 });
const client2 = new Client({ intents: 32767 });
const connection1 = joinVoiceChannel({ channelId: channel1.id, guildId: guild.id, adapterCreator: guild.voiceAdapterCreator })
const connection2 = joinVoiceChannel({ channelId: channel2.id, guildId: guild.id, adapterCreator: guild.voiceAdapterCreator })
It was possible in v12
how to get time passed in playing songs ?
how can you set the volume of a player
Okay here we go again
<AudioResource>.volume.setVolume() And you have to enable inline volume
https://www.toptal.com/developers/hastebin/pevekanuwe.coffeescript
I can't install @discordjs/opus & @discordjs/voice
Debian: 8
latest npm & nodejs
all required packages installed
interesting is, that i can install it on another vps with same specs, just with debian 9 or higher
After copying the node_modules using scp, it all worked fine for me...
Does anyone have an example of a voice recording bot? Mine kinda works but when I try to open the saved recording VLC can't read it.
Haven't seen anyone with a fix yet, I'd recommend switching to play-dl.
Yes this is possible but make sure the guild in both cases should be different like channel2.guild.id or channel2.guild.voiceAdapterCreator
I'm not entirely sure but I thought the problem was that ytdl sometimes isn't able to get the YouTube download link which would return a 403 error and will make the stream unreadable for the AudioPlayer
You could also use a try with catch function to create the stream or you could create an issue at https://github.com/fent/node-ytdl-core/issues
403 error is a known issue
How do i set that the bot, after a time of not use, leaves the channel alone?
Hey is there a tutorial for receiving audio with djs/voice?
use setInterval to periodically check the number of members in the voice channel. if there's not a certain amount of non bot members then make ur bot leave
There is a possibility to set a behavior in your AudioPlayer which will stop the player once there are no subscribes in the voice channel (https://discordjs.github.io/voice/enums/nosubscriberbehavior.html)
As far as I know there isn't. You can use the documentations about voice receiving here https://discordjs.github.io/voice/classes/audioreceivestream.html
oof
I would just be able to use intellisense if my vs code would work like its supposed to
my bot isn't joining the call, but it answers the interaction and no error is logged in console. what's happening?
Show code
const { joinVoiceChannel, createAudioPlayer, createAudioResource, NoSubscriberBehavior } = require('@discordjs/voice');
module.exports = {
name: 'play',
execute(interaction) {
const connection = joinVoiceChannel({
channelId: interaction.channelId,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator
});
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
}
});
const resource = createAudioResource('./audio.mp3')
player.play(resource);
connection.subscribe(player);
interaction.reply('playing :thumbsup:');
}
}```
I'm guessing you're manually storing the channel and guild id in the interaction as channelId and guildId, right?
what do you mean?
Nevermind, I'm not thinking straight, just change interaction.channelId to interaction.member.voice.channel.id. You're currently trying to connect to a text channel as if it were a voice channel.
damn, i didn't notice that
thanks
np
Hi, guys! Why <VoiceState>.channel.members is always Collection(0) [Map] {}? I have all necessary intents, and <VoiceState>.channel is defined.
Can you show your code?
@rugged sky ```client.on('voiceStateUpdate', async (newVoice: VoiceState, oldVoice: VoiceState) => {
const member = await newVoice.guild.members.fetch(newVoice.id);
...//code, which creates a channel
await member.guild.members.fetch();
console.log(newVoice.channel?.members);
if (
oldVoice.channel?.parentId === getConfig().channels.voice.createRoomCategory &&
oldVoice!.channel!.id !== getConfig().channels.voice.createRoom &&
oldVoice!.channel!.members.size == 0
) {
oldVoice!.channel!.delete().catch(() => {});
}
});
I'm not sure if this is the cause of your issue, but I think voiceStateUpdate parameters are the other way around (i.e. (oldstate, newstate)).
@rugged sky if rename parameters it doesn`t work too
When I try to log the same thing you're logging it works perfectly fine, must be going something wrong on your end. If you're willing to send all of your code I can try to take a look at it.
@rugged sky i resolved this problem: GuildMemberManager in client was 0 :D
npm ERR! code 1
npm ERR! path D:\Desktop_main\voice\node_modules\@discordjs\opus
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-pre-gyp install --fallback-to-build
I am gettting this error when i am trying to install @discordjs/opus . How can I solve this error
has nothing related to discordjs
search up npm ERR! code 1
Show more of the ERR! lines
Or bin the entire error
You are missing build essential tools
Install them and you are good to go
when I am trying npm i -g windows-build-tools
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated windows-build-tools@5.2.2: Node.js now includes build tools for Windows. You probably no longer need this tool. See https://github.com/felixrieseberg/windows-build-tools for details.
npm ERR! code 1
npm ERR! path C:\Users\vedan\AppData\Roaming\npm\node_modules\windows-build-tools
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node ./dist/index.js
Downloading python-2.7.15.amd64.msi
npm ERR! [> ] 0.0% (0 B/s)
npm ERR! Downloaded python-2.7.15.amd64.msi. Saved to C:\Users\vedan\.windows-build-tools\python-2.7.15.amd64.msi.
Downloading vs_BuildTools.exe
npm ERR! [> ] 0.0% (0 B/s)
npm ERR! Downloaded vs_BuildTools.exe. Saved to C:\Users\vedan\.windows-build-tools\vs_BuildTools.exe.
npm ERR!
npm ERR! Starting installation...
npm ERR! Please restart this script from an administrative PowerShell!
npm ERR! The build tools cannot be installed without administrative rights.
npm ERR! To fix, right-click on PowerShell and run "as Administrator".
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\vedan\AppData\Local\npm-cache\_logs\2021-10-28T08_56_30_564Z-debug.log```
You need to run the terminal as admin
i tried as admin but still same
It still says the same thing on the bottom?
Please restart this script from an administrative PowerShell!
ok
still same err
It still says that when running as admin?
ya
Are you using PS or command prompt?
cmd
https://pastebin.com/vJXnaaLi when i tried second time these were the errors
use powershell
still same error
I try to get the bot to join and play a stream in a stage channel sometimes it works sometimes it dont.
The error comes back as
at VoiceState.setSuppressed (C:\Dans Stuff\Beats Radio\DiscordBot\node_modules\discord.js\src\structures\VoiceState.js:248:59)
at Client.<anonymous> (C:\Dans Stuff\Beats Radio\DiscordBot\index.js:56:41)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
[Symbol(code)]: 'VOICE_NOT_STAGE_CHANNEL'
}``` yet it is a stage channel
const stageChannel = await client.channels.fetch('903216515967500288')
if(!stageChannel) return;
if(!stageChannel.stageInstance) {
await stageChannel.createStageInstance({
topic: "Playing you the latest beats from around the world.",
privacyLevel: "PUBLIC"
});
}
connection = joinVoiceChannel({
channelId: stageChannel.id,
guildId: stageChannel.guild.id,
adapterCreator: stageChannel.guild.voiceAdapterCreator,
});
let resource = createAudioResource(('STREAM URL'), { inlineVolume: true });
resource.volume.setVolume(0.7);
const player = createAudioPlayer();
connection.subscribe(player);
player.play(resource)
stageChannel.guild.me.voice.setSuppressed(false);
if(stageChannel.guild.me.voice.channel?.type === 'GUILD_STAGE_VOICE') {
stageChannel.guild.me.voice.setDeaf(true);
}```this is the code
Hi, does anyone know how I could add filters like bass boost?
I'm using play-dl and discord.js/voice.
how to use youtube-dl in discordjs/voice?
Use youtube-dl to create an AudioResource and play it.
it's i want to pipe this for an AudioResource. https://www.npmjs.com/package/youtube-dl-exec
I don't know how to use that package, you should ask in their support discord if they have one.
unfortunately no, they have no discord. And no matter how much I inquire, I can't find how to retrieve the music stream, even with ffmpeg I can't retrieve the stream.
else with youtube-dl, you have a idea for creatre an audio resource and play it?
Have you read the documentation?
yes
of youtube-dl?
Yeah, because I just looked at it and the second header explains how to get a youtube resource stream that you can input into your createAudioResource() function.
I have already tried but no it does not work.
Can I see your code?
Show the surrounding code as well, and can you give a description of what is happening, what isn't happening, and what you're expecting?
i have this error:
If you're using youtube-dl-exec you should be using their method of calling the package like they describe on their npm page.
yes but this return a json object. And this don't contains the stream
They say it's the same as the youtubedl method in youtube-dl. If that's not the case I can't help you. Either way I'd recommend using play-dl instead.
ok but the stream of play-dl when i repeat the same function to play the youtube url is...:
Never seen that error before, but they have a support server if I'm not mistaken. And if not, you can ask NIP, he made it.
no response from them after several days
Then probably no one knows the answer, which kinda sucks but it happens. Means, you'll have to be the one to figure it out and bring the solution to them.
ok thx 🙂
define channel
my bad i didnt know it wouldnt work
since i dont use the library
if I put the playing song code from the discord.js guide into a play command (in a command handler) how do I interact with it in another command?
Like, I have a /play command, I want to have a /pause command and other commands of the sort
my bot joins the voice channnel, but it doesn't plays the song and doesn't logs any error in the console
code:
module.exports = {
name: 'play',
execute(interaction) {
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator
});
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause
}
});
const resource = createAudioResource('./audio.mp3');
player.play(resource);
connection.subscribe(player);
interaction.reply('playing :thumbsup:');
}
}```
What's this AudioPlayerError: Status code: 403
Forbidden ik, but how it occurred
Please ping me on reply
Do you pass url or stream to audio Resource ??
Stream
Which package stream ??
play-dl never closes stream so if you close stream with player.stop() it will throw that error.
So not a play-dl issue.
AudioResource.playbackDuration , what is returns ?
the time it has been played ? substracting paused time ?
Why discord.js/voice is getting all my ram ?
this issue has been already reported but no one care of this
With lavalink I have only 2gb used
so the issue is from this package
Yep it is an issue when you use inLineVolume with this package.
Is there an alternative to inLineVolume ?
Idk, lol, I just used ytdl, and streamed like in djs12
That is sending you 403 errors.
This is a known issue of ytdl-core
Sad
Not yet but there will be soon.
Any alt, or fix
play-dl
Okey
When is soon ?
because my bot was using 18gb ram
18gb ram wtf

stress
I have 32gb on my server but...

Which package?
My bot don't even need 1 gb ram
discord.js/voice
Yes but how much connections do you have ?
1 connection on 1 time, sometimes 2
yes me it's with 500 connections
And it plays music 5+ hours,
No, you can check badges yourself
Wooh , his bot has 2k+ servers
How he didn't got badge,
You can't get the badge anymore
Sad
Yeah, a lot of people would like that badge :D, the problem is people made bot and invited to 75 servers just to get the badge. Its "early verified bot developer" now, but let's keep off topic somewhere else
@wide mirage btw same hobby, I also like listening music while coding
Oo
👌Yeah very good hobby
:D
2-3 weeks
Hmm I will wait 👌
How do I make my bot, automatically move to the speaking section of a stage channel?
Documentation suggestion for @brazen pecan:
VoiceState#setSuppressed()
Suppress/unsuppress the user. Only applicable for stage channels.
indeed and that's not really it I just reopened a streeam by destroying it with playdl.stream (...). then ((stream) => ... stream.stream.destroy), and I took over a player who never destroyed himself. So indeed I'm just very stupid ^^
Is there a way to remove the Live now message at the top of the channels?
When using Stage channels
in v12 creating a broadcast was like this
client.voice.createBroadcast()
how is it now
const channel = message.member.voice.channel;
if(!channel) return message.reply(`join voice channel`);
const{
createAudioPlayer,
getVoiceConnection,
joinVoiceChannel,
NoSubscriberBehavior,
createAudioResource
} = require('@discordjs/voice');
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
getVoiceConnection: getVoiceConnection(message.guild.id)
})
const player = createAudioPlayer()
const song = createAudioResource('demosong.mp3')
player.play(song)
connection.subscribe(player);
}
my bot is connecting but why it is not playing song?
Do you have the GUILD_VOICE_STATES intent?
thanks it solved the problem
Great
I am sorry I know how to use Voice in djs v12 but I am totally lost in djs v13 is there any way to use normal dispatcher on djs v13 ?
Where is the docs for voice lib?
Thanks!
TypeError: stream.on is not a function
at destroyer (node:internal/streams/pipeline:41:10)
at Function.pipeline (node:internal/streams/pipeline:209:21)
at new AudioResource (C:\Users\HP\Desktop\ARYAN\dc-bot\node_modules\@discordjs\voice\dist\audio\AudioResource.js:29:57)
at createAudioResource (C:\Users\HP\Desktop\ARYAN\dc-bot\node_modules\@discordjs\voice\dist\audio\AudioResource.js:159:12)
at Music.playFirstTime (C:\Users\HP\Desktop\ARYAN\dc-bot\helpers\Music.js:162:24)
at Object.execute (C:\Users\HP\Desktop\ARYAN\dc-bot\commands\slash-commands\play.js:62:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.execute (C:\Users\HP\Desktop\ARYAN\dc-bot\events\interactionCreate.js:27:17)```
why its showing like that there is no stream.on in ther code there dk what is creating it
Which music package is good for spotify streams in a voice channel?
you cant stream from spotify
then how to play spotify in a voice channel?
you cant
ok
you can use spotify song metadata to search it up and stream from another source
how to destroy the player?
Guys, is there a way to access the AudioResource from the AudioPlayer object ?
When creating a listening stream like this
end: {
behavior: EndBehaviorType.Manual,
},
});```
How do I manually end it? I tried doing ```connection.destroy()``` but that throws an error saying 'Premature close'
I tried looking into the voice api code but couldn't find anything
Appreciate the help, thanks 🙂
I have the last version of opus and ffmpeg and ffmpeg-static
<AudioPlayer>.state.resource
Debug dependencies like so https://discordjs.guide/voice/#debugging-dependencies.
thanks
is it possible to see which users in the same voice channel have muted my bot?
I don't think so.
I got this error after updating to v0.7.0
downgrading to 0.6.0 worked
@steel crescent
thanks 🙂
Hello. How to play songs in v13?
You should start by reading the guide, it explains most things: https://discordjs.guide/voice/.
Thx
updated my bot to discordjs v14 a few days ago, and trying to port my voice playback code over, but hitting a bit problem: createAudioResource dumps this lovely error:
Require stack:
- _bot_\node_modules@discordjs\opus\lib\index.js
<snip>
Error: Cannot find module 'node-opus'
Require stack:
- _bot_\node_modules\prism-media\src\util\loader.js
<snip>
Error: Cannot find module 'opusscript'
Require stack:
- _bot_\node_modules\prism-media\src\util\loader.js
<snip>
at Object.loader [as require] (_bot_\node_modules\prism-media\src\util\loader.js:12:9)
at loadOpus (_bot_\node_modules\prism-media\src\opus\Opus.js:17:17)
at new OpusStream (_bot_\node_modules\prism-media\src\opus\Opus.js:46:10)
at new Encoder (_bot_\node_modules\prism-media\src\opus\Opus.js:149:5)
at Object.transformer (_bot_\node_modules@discordjs\voice\dist\audio\TransformerGraph.js:120:24)
at _bot_\node_modules@discordjs\voice\dist\audio\AudioResource.js:156:60
at Array.map (<anonymous>)
at createAudioResource (_bot_\node_modules@discordjs\voice\dist\audio\AudioResource.js:156:41)
at playFile (_bot_\build\misc\music core.js:230:61)
at refreshQueue (_bot_\build\misc\music core.js:218:23)```
no idea what cause this, and it worked just fine before the update, so any ideas?
U need to install node-opus and opusscript
Okay, i have a new question. How do i make my bot to leave from voice channel?
I didn`t found any information about that
Call .disconnect() or .destroy() on your VoiceConnection object.
I have @discordjs/opus already
Okay, but errors tells u to install this modules.
I ask because the documentation says to install one, not all, so it doesn't seem like that's the right option
You should only need one.
You can try debugging dependencies.
yeah, everything looked correct there as well too
still got this error after updating to v0.7.1 @steel crescent sorry for disturbing and thank you in advance
the same?
that can't be, I changed how I import it, the error should at least look different 
the generated index.mjs looks the same
it looks like the same error
ugh
I hate modules 
its fine if you downgrade to a version that works btw
no real "new" things got released
its all just for documentation purposes that I bumped it to 0.7.x
ill try to get this sorted out in the meantime
no problem, thank you
I checked index.mjs and found that
yeah just saw it too
but you changed that in your code so 🤔
I guess esbuild does some automatic optimizations for that
since we aren't using tsc
yes, maybe there is a flag to disable a specific optimization, idk
is it enough to import the voice module to get this error? @teal nymph
or do I need to call something specific
let me check
yes it is enough
aight
so if I manage to do this
import { VoiceConnection } from './dist/index.mjs';
console.log(VoiceConnection);
and get this
❯ node .\test.mjs
[class Z extends EventEmitter]
we should be fine right?
replacing the import with @discordjs/voice on your end obv
yes
perfect
ill publish a fix then
thx 😄
should be published as 0.7.2
libsodium-wrappers is installed
but now there is no more esm error
@discordjs/opus is also installed
🤔
can you try installing tweetnacl instead
still not found
that is interesting
is it feasible for you to try cjs instead of mjs?
just to see if it shows up there at all
yes
with cjs
ugh
expected as much
will investigate further
thanks for letting me know
no problem
@steel crescent
https://github.com/discordjs/voice/blob/7e493c77c379da5629d9218c57589d89f94bd5c5/src/util/Secretbox.ts#L48
https://github.com/discordjs/voice/blob/9c924834dd7b3de5f5f3f09c3b2a5f5695024403/src/util/generateDependencyReport.ts#L60
Maybe you should replace require() by async import syntax
for example const pkg = require(attemptedPath); (assuming attemptedPath is absolute)
const pkg = await import('file://' + attemptedPath)
why this error occurs?
i have this loop
this.on('startQueue', queue => {
this.voiceConnection.subscribe(this.audioPlayer)
this.audioPlayer.play(this.queue.first().resource)
this.channel?.send(`Reproduciendo ${this.queue.first()}`).catch(()=>{})
})
this.audioPlayer.on('idle', async () => {
this.history.add(this.queue.first())
if(this.loop.mode == 0) this.queue.shift()
else if(this.loop.mode == 1) this.queue.add(await this.queue.shift().restore())
if(this.queue.size > 0) this.emit('startQueue', this.queue)
else {
console.log('disconnect')
this.voiceConnection.disconnect()
this.voiceConnection = null
}
})
it works but stops at an hour or less approximately
@quick lantern are you using ytdl-core ?
yes
this.queue.first().resource is
createAudioResource(this.type == 'file' ? this.link : await ytdld(this.link, { highWaterMark: 1<<25, filter: 'audioonly' }))
your error is a known issue of ytdl-core
I'd recommend switching to play-dl
I will keep it in mind tnx
Is there any state change when we pause the player manually
reject Promise {
[
{
status: 'connecting',
adapter: [Object],
networking: [Networking]
},
{ status: 'ready', adapter: [Object], networking: [Networking] }
]
} AbortError: The operation was aborted
at abortListener (node:events:838:14)
at EventTarget.<anonymous> (node:events:874:47)
at EventTarget.[nodejs.internal.kHybridDispatch] (node:internal/event_target:562:20)
at EventTarget.dispatchEvent (node:internal/event_target:504:26)
at abortSignal (node:internal/abort_controller:97:10)
at AbortController.abort (node:internal/abort_controller:122:5)
at Object.entersState (D:\Programing\coding\My Code\v13 - Copy\node_modules@discordjs\voice\dist\util\entersState.js:20:56)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: 'ABORT_ERR'
how to fix
im having this issue as well on v0.7.2
no i am using discord-player
This happens when you use entersState
Remove entersState from your code.
I cant find the get voice connection in the new docs at official page?had some things changed?
But i use only distube
Ask distube developer then
No one know 🙂
Just tell them not to use entersState function in their code. Instead listen to ready or connecting event
Hi! Could someone tell me how to manually end an AudioReceiveStream https://discord.js.org/#/docs/voice/stable/class/AudioReceiveStream
I initialise it like this
end: {
behavior: EndBehaviorType.Manual,
},
});```
And then I try to output it in a file which works fine if my EndBehaviourType is silence or something but when I set it to manual and I destroy the opus stream it throws an error saying premature close, I tried looking at the docs but don't see a manual way to close it without throwing an error
Appreciate the help
hi can someone explain to me what adapterCreator in joinVoiceChannel do and what should i type in it to work?
I'm not quite sure what it does exactly, but you should just get it from your guild by guild.voiceAdapterCreator.
oh ok thx
hello there i use v13 how can i make bo join authors channel?
message.guild.members.cache.get(user.id).voiceChannel.join();
TypeError: Cannot read properties of undefined (reading 'join')
.join() no longer exists you now use:
const { joinVoiceChannel } = require('@discordjs/voice')
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
})
To make it join the channel of the author of a message just get it with const channel = message.member.voice.channel.
NODE EVENT: Unhandled rejection: TypeError: voiceChannel.join is not a function
Message above yours.
im installing the dependencies for v13 (according to the guide https://discordjs.guide/voice/#installation) but generateDependencyReport() keeps showing they are not installed. Anyone had this issue?
downgrade @discordjs/voice to v0.6.0
this is a known issue of v0.7.x when using the esm build
ty
@carmine timber I hate to ping, but was there ever a resolution to memory leaking with inlineVolume?
Don't forget to add selfDeaf: false as one of the parameters for connection
I need to create a separate package. No one is listening here.
Blegh. Okay. I look forward to it
I did try to update Voice and prism to not use that duplex stream lib, but gave up and was tempted to just pipe everything through ffmpeg, but that's not ideal
Yep not ideal at all.
TypeError: channel.join is not a function having error help
alr thanks
is there a way to seek music with the current discordjs
Not atm
#201 in discordjs/voice by Anonimatrix opened <t:1631464283:R>
Seek on audio resource
Here’s the issue currently tracking the feature request for seek
How do I get decibals of a user
A question, is it possible to make my bot connect to multiple vcs? (and make it play different musics for each vc)
You can only join on vc in a guild at a time
oh
You probably cant like that, you need to store the recording somewhere then process it somehow to get volume
I cant live stream it?
You can but you need to develop a system, because discord will stop sending audio packets if user stops speaking so yeah you need to resubscribe to the user
You mean djs not discord
const { joinVoiceChannel } = require("@discordjs/voice");
client.on("ready", () => {
const channel = client.channels.cache.get("903660399268876349");
const guild = client.guilds.cache.get("881543330763259974");
joinVoiceChannel({ channelId: "903660399268876349", guildId: "881543330763259974", adapterCreator: guild.voiceAdapterCreator});
})
How to connect bot to voice? this code didn't work
help
Are you sure you have the right IDs? It is often better in my experience to just get the guild ID from the guild as an object with guild.id and if you have the channel you want to connect to as an object you can get that ID in the same way. That way you're always sure the IDs are right.
In this case I am referring to the objects if you didn't get them by requesting them from the IDs manually in the first place of course.
how do i do,
const channel = message.member?.voice.channel
in
client.voice.channel.cache.get()??? how do i het a voice channel by client ?
or i just do ... client.channels.cache.get
I think voice channels are just part of the channels property on a client so if you know the ID you can just do this.
This error occurs everytime
IDs are correct
@whole vector you can get the guild from the channel
for the channel id you can use channel.id, and for the guild id channel.guild.id
not worked
So what exactly the problem? Does it just do nothing, do you get an error?
no error
console.log channel
I did it, put it in the ready.js event and it worked
Did you do the same for guild?
@carmine timber Any idea ? 🤔
paste the result
working...
I was talking about console.log
but okay
I'm deleted
hi someone can help with this: Cannot play a resource that has already ended.
If you're attempting to reuse AudioResources, you can't. You just have to make a new one.
Thx man
Is it possible to get the bot's voice ping?
guys how can I get the voice channel id? I am making a lavalink music bot and to make the player I need the voice channel id
how to set deafen to bot auto?
let server = client.guilds.cache.get(bot.server)
if(server) {
if(server.guild.me.voice){
server.guild.me.voice.setSelfDeaf(true)
}
}
voiceChannel.id if you have access to a guildMember you can use member.voice.channel.id
could somuane help me?
Possibly. What is the problem you are experiencing?
i will share my code and then the error
this is my ready.js
const Discord = require("discord.js");
const { joinVoiceChannel, createAudioPlayer, createAudioResource, } = require("@discordjs/voice");
const fetch = require("node-fetch");
const client = new Discord.Client({
intents: [
Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.GUILD_MEMBERS,
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Discord.Intents.FLAGS.GUILD_WEBHOOKS,
Discord.Intents.FLAGS.GUILD_VOICE_STATES,
Discord.Intents.FLAGS.GUILD_INVITES,
Discord.Intents.FLAGS.GUILD_BANS,
Discord.Intents.FLAGS.GUILD_PRESENCES,
],
ws: {properties: { $browser: "Discord IOS" }}
});
module.exports = async () => {
console.log('EriksRoadhouseBluesBot is nu online!');
console.log('Radio is begonnen en werkt perfect!');
const connect = joinVoiceChannel({
channelId: "904522891679379506",
guildId: "901086504154169374",
adapterCreator: client.guild.voiceAdapterCreator,
});
const audioPlayer = createAudioPlayer();
const res = fetch("https://joeyjunge.radioca.st/stream.mp3");
if (!res.ok) console.log("Der is een was een probleem tijdens het fetching!");
const stream = res.body;
const resource = createAudioResource(stream);
connection.subscribe(audioPlayer.play(resource));
}
now the error i get
PS C:\Users\semeg\Desktop\EriksRoadhouseBot> node .
EriksRoadhouseBluesBot is nu online!
Radio is begonnen en werkt perfect!
C:\Users\semeg\Desktop\EriksRoadhouseBot\events\client\ready.js:25
adapterCreator: client.guild.voiceAdapterCreator,
^
TypeError: Cannot read properties of undefined (reading 'voiceAdapterCreator')
at module.exports (C:\Users\semeg\Desktop\EriksRoadhouseBot\events\client\ready.js:25:36)
at Client.emit (node:events:390:28)
at WebSocketManager.triggerClientReady (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:383:17)
at WebSocketManager.checkShardsReady (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:366:10)
at WebSocketShard.<anonymous> (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:188:14)
at WebSocketShard.emit (node:events:390:28)
at WebSocketShard.checkReady (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:474:12)
at WebSocketShard.onPacket (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:446:16)
at WebSocketShard.onMessage (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10)
at WebSocket.onMessage (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\ws\lib\event-target.js:199:18)
Node.js v17.0.1
thanks
could you help me with this?
The problem is that your voiceAdapterCreator is for guild meaning you need get the specific guild and then get the voiceadaptercreator of that guild: client.guilds.cache.get('901086504154169374').voiceAdapterCreator
That should work
il try
it didnt
PS C:\Users\semeg\Desktop\EriksRoadhouseBot> node .
EriksRoadhouseBluesBot is nu online!
Radio is begonnen en werkt perfect!
C:\Users\semeg\Desktop\EriksRoadhouseBot\events\client\ready.js:25
adapterCreator: client.guilds.cache.get('901086504154169374').voiceAdapterCreator,
^
TypeError: Cannot read properties of undefined (reading 'voiceAdapterCreator')
at module.exports (C:\Users\semeg\Desktop\EriksRoadhouseBot\events\client\ready.js:25:68)
at Client.emit (node:events:390:28)
at WebSocketManager.triggerClientReady (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:383:17)
at WebSocketManager.checkShardsReady (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:366:10)
at WebSocketShard.<anonymous> (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:188:14)
at WebSocketShard.emit (node:events:390:28)
at WebSocketShard.checkReady (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:474:12)
at WebSocketShard.onPacket (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:446:16)
at WebSocketShard.onMessage (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10)
at WebSocket.onMessage (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules\ws\lib\event-target.js:199:18)
Node.js v17.0.1
Can you do a console log of this: client.guilds.cache
sure
it says
Collection(0) [Map] {}
Okay did you add the bot to a server?
Yes i did
but this is the error right? ```js
TypeError: Cannot read properties of undefined (reading 'voiceAdapterCreator')
Yes it is and that is because it cant find the server because the client doesn't have any servers which it should if the bot is added to a server
strange bc it is in a server
Do you have a client.login call?
where you use the bot token
yes
const Discord = require("discord.js");
require('dotenv').config();
const client = new Discord.Client({
intents: [
Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.GUILD_MEMBERS,
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Discord.Intents.FLAGS.GUILD_WEBHOOKS,
Discord.Intents.FLAGS.GUILD_VOICE_STATES,
Discord.Intents.FLAGS.GUILD_INVITES,
Discord.Intents.FLAGS.GUILD_BANS,
Discord.Intents.FLAGS.GUILD_PRESENCES,
],
ws: {properties: { $browser: "Discord IOS" }}
});
const { DiscordTogether } = require('discord-together');
client.discordTogether = new DiscordTogether(client);
client.on('guildMemberAdd', async member => {
let welcomeRole = member.guild.roles.cache.find(role => role.name === 'luisteraar🎶');
member.roles.add(welcomeRole);
const welcomechannel = client.channels.cache.get('903332220612255794');
welcomechannel.send(`:wave: Hey ${member}, Welkom in ${member.guild.name}!`);
});
client.commands = new Discord.Collection();
client.events = new Discord.Collection();
['command_handler', 'event_handler'].forEach(handler =>{
require(`./handlers/${handler}`)(client, Discord);
})
client.login(process.env.DISCORD_TOKEN);
this is the main.js
and is the radio code run on the client.once('ready', {function that runs on startup}) of the client because if it is run before hand the client has no data
this is the ready.js
and it works bc in the error it says EriksRoadhouseBluesBot is nu online!
Yeah the function gets called but that might be before the client is connected and ready and then it will still do the console.log but not the functions which need the client.
how do i fix that?
by running it once the client is ready with client.once('ready', {function that runs on startup})
now it says this ```js
PS C:\Users\semeg\Desktop\EriksRoadhouseBot> node .
EriksRoadhouseBluesBot is nu online!
EriksRoadhouseBluesBot is nu online!
Radio is begonnen en werkt perfect!
Der is een was een probleem tijdens het fetching!
node:internal/errors:464
ErrorCaptureStackTrace(err);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "body" argument must be of type function or an instance of Blob, ReadableStream, WritableStream, Stream, Iterable, AsyncIterable, or Promise or { readable, writable } pair. Received undefined
at new NodeError (node:internal/errors:371:5)
at duplexify (node:internal/streams/duplexify:199:9)
at Function.Duplex.from (node:internal/streams/duplex:143:10)
at pipelineImpl (node:internal/streams/pipeline:245:22)
at pipeline (node:internal/streams/pipeline:169:10)
at new j (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules@discordjs\voice\dist\index.js:8:15591)
at je (C:\Users\semeg\Desktop\EriksRoadhouseBot\node_modules@discordjs\voice\dist\index.js:8:17218)
at Client.<anonymous> (C:\Users\semeg\Desktop\EriksRoadhouseBot\main.js:49:22)
at Object.onceWrapper (node:events:510:26)
at Client.emit (node:events:402:35) {
code: 'ERR_INVALID_ARG_TYPE'
}
Node.js v17.0.1
Yeah with fetch I don't really have any experience but it might be worth a try just putting the link directly into the audio resource because it can handle quite a decent amount of types
okay
How would that look in the code? (im sorry im kinda new to this)
const resource = createAudioResource("https://joeyjunge.radioca.st/stream.mp3");
like this? ```js
client.once('ready', async () => {
console.log('EriksRoadhouseBluesBot is nu online!');
console.log('Radio is begonnen en werkt perfect!');
const connect = joinVoiceChannel({
channelId: "904522891679379506",
guildId: "901086504154169374",
adapterCreator: client.guilds.cache.get('901086504154169374').voiceAdapterCreator,
});
const audioPlayer = createAudioPlayer();
const resource = createAudioResource("https://joeyjunge.radioca.st/stream.mp3");
connection.subscribe(audioPlayer.play(resource));
});
Yes try that
okay
I get this error
Well first of all you are subscribing to 'connection' while the connection you created is called 'connect'
i changed that and i got the same error
i changed it to connection and same error
Can you try first subscribing the player to the connection and then separately do player.play(resource)
because player.play returns a void which you cant subscribe
ohw okay i will try
It works now thank you so much
i only have one question how do i change te volume bc its really loud xd
player.play(resource, {seek:0, volume: 1} where volume is mapped between 0 and 1
Absolutely no worries
still thx hahhaa
if i change the 1 to 0.1 nothing happends
Okey then I recomend using inline volume and changing it before you play you can find how in here: https://discordjs.guide/voice/audio-resources.html
thx
again 😋
help
MinigetError: Status code: 403
at ClientRequest.<anonymous> (/home/runner/Neox-Music-Bot/node_modules/miniget/dist/index.js:196:27)
at Object.onceWrapper (events.js:421:26)
at ClientRequest.emit (events.js:314:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:601:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:122:17)
at TLSSocket.socketOnData (_http_client.js:474:22)
at TLSSocket.emit (events.js:314:20)
at addChunk (_stream_readable.js:297:12)
at readableAddChunk (_stream_readable.js:272:9)
at TLSSocket.Readable.push (_stream_readable.js:213:10)
Emitted 'error' event on PassThrough instance at:
at errorOrDestroy (internal/streams/destroy.js:108:12)
at PassThrough.onerror (_stream_readable.js:754:7)
at PassThrough.emit (events.js:314:20)
at PassThrough.emit (events.js:314:20)
at ClientRequest.<anonymous> (/home/runner/Neox-Music-Bot/node_modules/miniget/dist/index.js:201:28)
at Object.onceWrapper (events.js:421:26)
[... lines matching original stack trace ...]
at TLSSocket.socketOnData (_http_client.js:474:22) {
statusCode: 403
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! evobot@0.9.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the evobot@0.9.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2021-10-31T02_03_09_404Z-debug.log
exit status 1```
what's this
Emitted 'error' event on AudioPlayer instance at: at OggDemuxer.onStreamError
Hello guys ! just a little question. Do you guys know how to detect if someone is speaking on a voice channel ? I used voiceStateUpdate event but it's only for mute/leaf detection. Thanks!
is there a way to set default volume for bot or the music it plays
is playing song from youtube in discord legal (with ytdl)?
any one know why my bot joining the room and after 2sec the bot leaves the room
no error
code: https://paste.gg/p/anonymous/cf8f1f545f724157b514609d998f8cc9
any one 
its against the youtube tos
but if i use a lavalink server? is it the same thing?
same thing
heres it mentioned in the youtube tos
Djs voice is capable of listening to multiple users continuously, correct?
anyone know why this is happening
How would I attempt to merge AudioResources for playing, seen as you can't subscribe to 2 Players, and there is no function to Play without stopping/overriding the other sound playing, however I don't need it to be the merging tactic if there is a better or easier & cleaner way.
I've looked into using Prism-Media for playing and modifying an Opus Stream, however I feel that would be a little too overcomplicated.
My main goal is to be able to play multiple sounds all overlapping each other allowing for stacking of multiple sounds.
If anyone knows a way that I'd be able to do this which would be simple-ish and easy, please let me know, any help is appreciated.
hey, i'm using the **demuxProbe **function, but I'm receiving this error: "Cannot probe a readable stream in object mode". My stream is created by ytdlCore. Anyone knows how to fix that?
Error: Cannot find module '/home/ubuntu/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-linux-x64-glibc-2.31/opus.node```
Is there a way to sense if a user is speaking in a voice channel? i.e. a bool value that returns true if a person is speaking in a voice channel and false if not
You need to install the package @discordjs/opus
The last commitment was on July 6 so I don't think so
-_-
hey umm so i downloaded discordjs/voice and i tried doing this thing which they shoed in the documentation but my bot still doesnt join the vc. any help woule be appreciated
is that if case of yours reached?
log something beforehand to make sure
ok
it logs this out but it doesnt join the vc. am i doing this function correctly?
nvm i got it
i had to give the id of the voice channel. but now the bot itself is deafened
const voice_connection = joinVoiceChannel({
channelId: message.channel.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
selfDeaf: false,
selfMute: false
});
This is only joining the voice channel btw, not playing something
oh
im using this voice_connection inside a switch case where im using cases for commands like case 'play' case 'dc'. so assume that i created this connection in the case 'play'. then is there a way to disconnect the bot from the case 'dc'? i tried and i run into scoping errors.
message.channel.id is wrong
Hi! Is there anyone to "view" a stream through discordjs?
me
Looking to capture video streams
Hey, idk if this is related to the voice section,
but i want to make some kind of script that detects when a user joins a specific voicechannel name and then the bot should need to make a new voicechannel and move the user to that channel and name the channel. also when they leave it needs to get removed
You are looking for event voiceStateUpdate, check if newState channel is defined channel and if it is do something
(Bump) anyway for a bot to watch a screencast?
no
😞
Thanks for your reply!
hey, i'm using the **demuxProbe **function, but I'm receiving this error: "Cannot probe a readable stream in object mode". My stream is created by ytdlCore. Anyone knows how to fix that?
Heyy, how can I check if a user is in a voice channel via an interaction? Do I need a special intent?
Does anyone here know how to use youtube-dl-exec? Any help would be much appreciated, I'm struggling quite a bit with it.
I looked at the pinned music bot example but for some reason I can't get it to work.
function createResource(url: any): Promise<AudioResource<any>> {
return new Promise((resolve, reject) => {
const process: any = youtubedl.raw(
url,
{
o: "-",
q: "",
f: "bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio",
r: "100K",
},
{ stdio: ["ignore", "pipe", "ignore"] }
);
if (!process.stdout) {
reject(new Error("No stdout"));
return;
}
const stream: any = process.stdout;
const onError = (error: any) => {
if (!process.killed) process.kill();
stream.resume();
reject(error);
};
process
.once("spawn", () => {
demuxProbe(stream) // https://discordjs.github.io/voice/modules.html#demuxprobe
.then((probe: { stream: any; type: any }) =>
resolve(
createAudioResource(probe.stream, {
// @ts-ignore: Unreachable code error
metadata: this,
inputType: probe.type,
})
)
)
.catch(onError);
})
.catch(onError);
});
}```
someone has idea?
why is member after message? arent you trying to get the channelID of the message? @hoary kernel
yep i try
so shouldnt it be message.channelId
member represents the author of message, channelId isnt a property of GuildMembers
if ur trying to the text channel, it should go from message.channelId, but if ur getting the VOICE channel i think it would need to be message.member.voice.channelId
im going for voice channel
try the second option
y try and this happen
https://discordjs.guide/voice/voice-connections.html#creation
did u follow this guide
Can you show the surrounding code?
all code
Where do you define voiceChannel and guild?
an other folderwith name config.js
Can I see that?
ok but wait me i need find that
Sure thing, so the issue is that you can't get it to join with joinVoiceChannel()? I noticed the previous code is different in the screenshot you just sent.
yea im trying dif codes
but not one works
are u just copy pasting from examples?
no copy just a guidingme
i dont really no code but it seems like it doesnt know how to find the voice channel ID of the requesting user
yea i dunno how to find that
In the last error you sent it couldn't find the member that sent the message, possibly because you're referring to it wrong. I suspect in general it has to do with the definitions of your voiceChannel and guild variables, but can't say for sure until I see them.
I can't find my definitions folder maybe I delete it and that's what's causing the error
definitions folder? are you splitting all ur code into different files and folders
yea i made a folder with all definition
or it doesnt works?
Only if you export it and import it in the file you refer to it in.
i made it
But in general you should try to just keep them in the file scope, in DJS you can do that for the most part.
@rugged sky i was guiding me in a guide for v13 im using v16, this affects in anything?
You should make sure to be on the latest version of node which I think is like 16 or 17. Discordjs is v13 though.
oh
i was using a guide for node 13
Is there any examples for seek command ? I want to change the position.
just gonna do this just to make sure someone still see's it.
The bot just suddenly stop with this error
this's the third time!
Are you using ytdl because it has some bugs and I believe that is one of them I would if so recomend switching over to playdl
my bot is joining the channel but is not playing audio
I've even tried debugging with console.log but it says it already has the video.
what do i do?
is it because of ytdl or something else??
ytdl
Add a watermark to the ytdl function and it will be fixed (I've used the 1048576 * 32 watermark which worked for me)
I've been looking for a fix to this for a while. You're amazing, thank you. Would you know how to handle ytdl-core 403 errors, by chance? @whole flare
What you can do is instead of using the ytdl() function to create a playable stream, use the downloadFromInfo function. This also will return a playable stream but if I'm right you'll be able to catch the error with the error event listener. I'm not entirely sure but I thought this would work. Here is an example: ```js
const ytdl = require('ytdl-core');
(async () => {
var info = null;
try {
info = await ytdl.getInfo(https://www.youtube.com/watch?v=dQw4w9WgXcQ);
} catch (error) {
console.log(error);
}
const stream = ytdl.downloadFromInfo(info, {
quality: 'highestaudio',
filter: 'audioonly',
watermark: 1048576 * 32
});
})();
how do I know if the bot actually disconnected or was just moved to another voice channel?
Use the client event listener voiceStateUpdate wich will return the old state en the new state. https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-voiceStateUpdate
:/
but I wanted to see it in this event
A regular disconnect will also be caught in the voiceStateUpdate so you can use that one for both.
but how am I going to connect this two?
What do you mean?
in this event, "disconnected", I clear the queue and player in case the bot is disconnected
Yeah, in voiceStateUpdate all you have to do is check if the event you get is a disconnect based on oldState and newState and then you can do all the same stuff that you did previously.
and there is literally no other way of checking?
Not that I'm aware of.
okay, voiceStateUpdate is not detecting when I switch voice channels
just when I actually join/leave
nvm, I am stupid
how can my bot disconnect people from voice channels?
If you have the user you want to disconnect as member you can do member.voice.disconnect().
Thank you very much
how to make a bot leave a voice channel if i don't have the connection/audioresource/etc variables of its connection
You can't, you need the connection to disconnect it. You can use the getVoiceConnection() or getVoiceConnections() to get your connection from anywhere.
I'm probably doing something wrong, but writing a stream from voiceConnection.receiver to a file and later trying to read it with a readStream and decode with prism.opus.Decoder produces an error, while passing the stream directly through the decoder works just fine. Is there something i'm missing?
Here's the error:
1: 0xb21900 node::Abort() [node]
2: 0xa361fc node::FatalError(char const*, char const*) [node]
3: 0xa36205 [node]
4: 0xaea96b napi_fatal_error [node]
5: 0x7fbcbc09dc8e [/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-linux-x64-glibc-2.31/opus.node]
6: 0x7fbcbc09e3ec Napi::Error::ThrowAsJavaScriptException() const [/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-linux-x64-glibc-2.31/opus.node]
7: 0x7fbcbc0aad68 OpusEncoder::Decode(Napi::CallbackInfo const&) [/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-linux-x64-glibc-2.31/opus.node]
8: 0x7fbcbc0a12da Napi::InstanceWrap<OpusEncoder>::InstanceMethodCallbackWrapper(napi_env__*, napi_callback_info__*) [/node_modules/@discordjs/opus/prebuild/node-v102-napi-v3-linux-x64-glibc-2.31/opus.node]
9: 0xacb54d [node]
10: 0xd6c26e [node]
11: 0xd6d68f v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
12: 0x160f579 [node]
[1] 30432 abort node test.js```
how do you make a bot join a stage channel as a speaker in v13
i got voiceChannel.join is not a function :-? can u guys tell me why?
It changed in v13.
See pins for a guide.
ty
I was trying to run the example music bot but i can't get it to run, some one can help me?
sorry, but where is these pins?
thank you
How would I get my bot to join & record a voice channel
Help me with this error?
```return await interaction.reply(Command currently in work and progress. Please use \s!help` for now!`)
^
TypeError: interaction.reply is not a function```
clear.js
https://sourceb.in/2tvRJVreqc
module.exports = (oldState, newState, client) => {
if (newState.channelID === '905893574015615117') {
if (client.channels.get('905893574015615117').members.size > 1) return client.channels.get('905893574015615117').members.forEach((member) => {member.send(`<${member.id}> There are more than one person in the queue.`)});
} else if (!newState.channelID === '905893574015615117') return;
}```
voiceStateUpdate.js
2 people in vc yet its not doing anything
Do you have the GUILD_VOICE_STATES intent?
thx it works
why does a bot, after joining a voice channel on one server, immediately play what is already playing on another
Watermark?
Hey can anyone tell how to define client voiceChannel
@viral root
hey uh,
are we getting the old seek option for the new discordjs/voice?
hey guys, how do i make my bot work on multiple vc's at once?
Multiple vcs in a single guild?
in multiple guilds
TypeError [ERR_INVALID_ARG_TYPE]: The "body" argument must be of type function or an instance of Blob, ReadableStream, WritableStream, Stream, Iterable, AsyncIterable, or Promise or { readable, writable } pair. Received null
const stream = interaction.options.getString('stream');
const resource = createAudioResource(stream, {
inputType: StreamType.Arbitrary,
});
player.play(resource);
async setFilter(message, filter) {
let queue = this.getQueue(message)
queue.queue[0].status.filters.push(filter)
let Encoder = await this.AllFilters(queue);
let res = ytdl(queue.queue[0]?.next[0].song.Link, {
opusEncoded: false,
filter: "audioonly",
quality: "highestaudio",
encoderArgs: Encoder,
highWaterMark: 1 << 25,
seek: this.streamTime(message)
})
let reso = createAudioResource(res, {
inlineVolume: true
})
queue.player.play(reso, {
})
queue.connection.subscribe(queue.player)
this.emit("trackFilterAdded", message, filter)
}```
filters are not working
anyone have a good example link for youtube with discord js?
try ytdl-core
the same way u define a channel. also don't ping people for no reason pls
hey, if i want to play a song after short time the song will aborted and it send this ERROR: errored: Error: aborted
How to install FFmpeg
• NPM: npm install ffmpeg-static
• Install: Download | chocolatey | homebrew | your distributions package manager
• Tutorial: YouTube
• ffmpeg-binaries is deprecated, uninstall it with npm rm ffmpeg-binaries
TypeError [ERR_INVALID_ARG_TYPE]: The "body" argument must be of type function or an instance of Blob, ReadableStream, WritableStream, Stream, Iterable, AsyncIterable, or Promise or { readable, writable } pair. Received null
const stream = interaction.options.getString('stream');
const resource = createAudioResource(stream, {
inputType: StreamType.Arbitrary,
});
player.play(resource);
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?
client.on("interactionCreate",
async interaction=>{
if(!interaction.isCommand()) return
if(interaction.commandName==="vc" && interaction.inGuild()){
if(!interaction.member.voice.channel) return interaction.reply({content:"JOIN A VC first"})
interaction.reply("Joining VC...")
let connection = joinVoiceChannel({
guildid:interaction.guild.id,
channelId:interaction.member.voice.channel.id,
adapterCreator:interaction.guild.voiceAdapterCreator
})
let player = createAudioPlayer();
let resource = createAudioResource('https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3', {
inputType:Voice.StreamType.arbitary
})
player.play(resource)
await entersState(player, Voice.AudioPlayerStatus.Playing, 10e3)
try{
await entersState(connection, Voice.VoiceConnectionStatus.Ready, 10e3)
interaction.editReply({content:"Joined VC"})
connection.subscribe(player)
}catch(e){
connection.destroy()
interaction.editReply({content:e.message});
console.error(e)
console.log("Failed to connect to VC")
}
}
})
Always aborts and logs "failed to connect to VC" to console and does not show up in my VC
Core dependencies report from Voice.generateDependencyReport():
Core Dependencies
- @discordjs/voice: 0.7.2
- prism-media: 1.3.2
Opus Libraries
- @discordjs/opus: 0.6.0
- opusscript: not found
Encryption Libraries
- sodium: not found
- libsodium-wrappers: 0.7.9
- tweetnacl: not found
FFmpeg
- version: 4.4-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------
Make sure to check permissions. Bot needs view channel and connect to join vc
i gave it admin in my test server
also when i checked connection._state it was stuck on "signalling"
node-opus is deprecated?
yes
You can use @discordjs/opus instead
What about the memory leak problem ?
you said that it will be fixed soon. It's not normal that your module uses 10gb ram after 1h
When discordjs/voice will fix that ram usage problem
this.currPlayingResource = await nextTrack.createAudioResource(); this.audioPlayer.play(this.currPlayingResource);
guys how can i play again my currPlayingResource after it's ended?
does .play use ffmpeg
Cannot play audio as no valid encryption package is installed.
What packages do i need for discord.js/voice to play?
How do I get the current speaking users in a voice channel?
you can check in the dependences
<VoiceChannel>.members
I mean I want to return member id when the user is speaking or is done speaking
hello, Is there a seek option in the v13 as in the v12 ?
how long will it take?
Hey there, I am struggling with getting my bot to play a song. I think I did everything the way it said in the official guide and I just can't figure out how to get it to work. The Bot successfully connects to the voice channel and I don't get any error messages. Some advice would be much appreciated!
const { createAudioPlayer, NoSubscriberBehavior, createAudioResource, getVoiceConnection } = require('@discordjs/voice');
const { config } = require("../config.json");
module.exports = {
data: new SlashCommandBuilder()
.setName('play')
.setDescription('Play song'),
async execute(interaction) {
const connection = getVoiceConnection("419444179404455937");
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});
const resource = createAudioResource('../music/test.mp3');
player.play(resource);
player.on('error', error => {
console.error(`Error: ${error.message} with resource ${error.resource.metadata.title}`);
player.play(getNextResource());
});
connection.subscribe(player);
},
};```
how do I get audioplayers the voiceconnection is subscribed to?
<Connection>.state.subscription.player
My bot is not playing an audio file. It successfully connects to the vc and does not throw any errors. This is the typescript code i am using```
const connection = voice.joinVoiceChannel({
channelId: args[0],
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
});
const player = voice.createAudioPlayer();
const resource = voice.createAudioResource('test.mp3');
player.play(resource);
connection.subscribe(player);
how can my bot become speaker in a stage channel?
Documentation suggestion for @neon cape:
VoiceState#setSuppressed()
Suppress/unsuppress the user. Only applicable for stage channels.
Why does the bot stops playing the resource after a few seconds although the resource stream is longer (10 seconds)? This happens only in short audio streams.
If you probe the stream, you should pass the probe.stream to the AudioResource because probing the stream could read it to the end.
i have a smillar issue, the player raises an error after starts playing the stream, the stream is like 2 minutes but the player only plays like 20 seconds
It didn't work
at connResetException (node:internal/errors:691:14)
at TLSSocket.socketCloseListener (node:_http_client:407:19)
at TLSSocket.emit (node:events:402:35)
at TLSSocket.emit (node:domain:475:12)
at node:net:687:12
at TCP.done (node:_tls_wrap:580:7) {
resource: j {
playStream: OggDemuxer {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 5,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: true,
_remainder: null,
_head: null,
_bitstream: null,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: [Function: bound onwrite]
},
edges: [ [Object], [Object] ],
metadata: null,
volume: undefined,
encoder: undefined,
audioPlayer: H {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
_state: [Object],
subscribers: [Array],
behaviors: [Object],
debug: [Function (anonymous)],
[Symbol(kCapture)]: false
},
playbackDuration: 125760,
started: true,
silencePaddingFrames: 5,
silenceRemaining: 5
}
}```
So im constantly getting this error at exacly 125760 ms (~2:05 minutes) i dont think its a problem with the stream im getting from ytdl, anyone was seen this before?
We don't get those errors because we have shifted to play-dl
thanks
why is it asking for all this packages?
I already have libsodium-wrappers installed!
You must install one of these packages: @discordjs/opus (I recommend this), opusscript or node-opus
so, yeah, I noticed that after a while, but for some reason that is only required when running on the host (Linux btw)
even so, I installed @discordjs/opus, and now it's giving me this weird error:
Have you tried using only opusscript?
turns out it was a problem with the host provider I am using
Okay
guys can u give me the link of package FFmpeg to play youtube music 😄
TypeError [ERR_INVALID_ARG_TYPE]: The "body" argument must be of type function or an instance of Blob, ReadableStream, WritableStream, Stream, Iterable, AsyncIterable, or Promise or { readable, writable } pair. Received null
const stream = interaction.options.getString('stream');
const resource = createAudioResource(stream, {
inputType: StreamType.Arbitrary,
});
player.play(resource);
How to check if the bot is playing something to avoid new play
How can I make a speaker when the bot enters the stage channel ? ;-;
worked like a charm
you can check the player status
Hi, how can I use Stage Channels in Discord.js v12?
no djs v12 support #769862166131245066
Discord.js V13 is very confused, I don't want to pass. I will only use Stage Channels. Do you have any other solution?
you will not receive any assistance for v12 in here. (v13 didnt change that much lol just interactions and threads, yes ik some other things too but theres a guide & and the docs for updating)
You can here find the changes which are easy to understand: https://discordjs.guide/additional-info/changes-in-v13.html#before-you-start
How would I detect when a user joins a specific voice channel? (since this bot is exclusive to one channel, the Join To Create VC won't change)
how do I create a seek command?
client.on('voiceStateUpdate', (oldMember, newMember) => {
let newUserChannel = newMember.voiceChannel
let oldUserChannel = oldMember.voiceChannel
newMember.send("welcome to vc")
})``` no error. it doesn't send anything either. I want it to send a message to a user when thye join a vc
When i go from playing a youtube clip to playing a local file my player goes from idle to buffering but then never to playing and will abort out after a few seconds. I am not sure how to trace it or debug it. any help appreciated
Do you have required intents?
Make sure the file path is correct
How to Update this code to djs v13
const voicechannel = message.member.voice.channel;
if (!voicechannel) return message.channel.send("Please join a voice channel first!");
const connection = await message.member.voice.channel.join();
const receiver = connection.receiver.createStream(message.member, {
mode: "pcm",
end: "silence"
});
const writer = receiver.pipe(fs.createWriteStream(`./recorded-${message.author.id}.pcm`));
writer.on("finish", () => {
message.member.voice.channel.leave();
message.channel.send("Finished writing audio");
});```
Receiving voice: https://github.com/discordjs/voice/releases/tag/v0.6.0
Joining/leaving VC is covered in the guide
discordjs.guide results:
• Library: Voice Connections
• Library: Cheat sheet
Well, leaving is <Connection>.destroy()
anybody have idea
const connection = await connectToChannel(msg?.member?.voice?.channel as VoiceChannel);
// serverInfo!.connection = connection;
if (serverInfo?.audioPlayer?.state.status === AudioPlayerStatus.Playing) {
return msg.channel.send(
trans('soundboard.join.speaking', sLng, {
author: Util.escapeMarkdown(msg.author.tag)
})
);
}
let res = await streamTTS(tts_language, content);
const player = createAudioPlayer();
serverInfo!.audioPlayer = player;
const resource = createAudioResource(res.data);
resource?.volume?.setVolume(2);
player.play(resource);
connection.subscribe(player);
how to get metadata from a stream?
VoiceState#streaming
Whether this member is streaming using "Screen Share"
Are music bots still something doable?
I think so?
It may not be allowed however you can still make some. Probably in future versions of discordjs they will remove the function to play music in a vc?
It is as in displaying it before I play it
how to send mp3 files in discord.js in channel
@fiery pond this is not a @discordjs/voice related question. You should ask this in #djs-help-v14 or #archive-djs-help-v13
GuildMember (extends Base) (implements TextBasedChannel)
Represents a member of a guild on Discord.
whops, sorry
any vc pros willing to help in dms? its a kinda big bug and i dont wanna do it here cuz 1. it will take a lot of time and we will lose our msgs and 2. dms is better for this
The best you can do is just ask and create a thread
can i delete the thread after?
Yes
I think so
Is @discordjs/voice abandoned?
or maybe @discordjs/opus?
neither is abandoned
how would i convert this: let audioStream = connection.receiver.createStream(user, { mode: 'pcm' }) to Discord js v13?
is it possible to play audio from a url into vc?
(url thats not from youtube
You have to find a way to get the stream and pipe it to the player
for example, youtube-dl is capable of getting sound stream from this sites: https://github.com/ytdl-org/youtube-dl/blob/master/docs/supportedsites.md
I want to play a mp3 livestream but it dont work
let sender = interaction.options.getString("Sender");
const voice = require("@discordjs/voice");
const connection = voice.joinVoiceChannel({
channelId: 872006664348401709,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator
});
const audioplayer = voice.createAudioPlayer();
connection.subscribe(audioplayer);
audioplayer.play(sender)
Any Idea?
Noww does anybody know how to get live bute data from voice
Hello i got this code:
var VC = msg.member.voice.channel;
if (!VC)
return msg.reply("MESSAGE IF NOT IN A VOICE CHANNEL")
VC.join()
.then(connection => {
const dispatcher = connection.play('giorno.mp3', { volume: 1 });
dispatcher.on('start', () => {
console.log('audio.mp3 is now playing!');
});
dispatcher.on('finish', () => {
console.log('audio.mp3 has finished playing!');
});
})
.catch(console.error);
But it dont play music just connects to channel
V12 voice is not supported
oh thx so much i was wondering why
Hello,
Can I still play music in a vocal channel?
?
you need to create a resource with a stream from something like ytdl-core
ytdl-core is only for Youtube Links...
something similar
Haven't looked into it, i stream only from yt
I dont find any alternatives
I know used this example and get this error https://github.com/discordjs/voice/tree/main/examples/radio-bot
play-dl seems to be the accepted alternative bc of the errors ytdl-core has
How to make a voice receiver that is in PCM format?
is AudioPlayerStauts#Playing the same as the old "start" event?
@compact tide was helping me with this so dont say i stole his code, but I'm really confused with the VC API as it was changed. what do i need to change to make my join VC command work again? thanks!
case "joinvc":
const s = e.member.voice.channel;
s ? s.join().then(() => {
msgReply(e, generateBotMessageEmbed("Connected", `I'm now in \`${s.name}\`, happy?\nFor me to leave, just use -leaveVC, I will automatically disconnect in 10 minutes if I'm left alone.`, 7935)),
client.user.setPresence({
activity: {
name: `to ${s.name}, because ${e.member.displayName} forced me to`,
type: "LISTENING"
},
status: "IDLE"
})
}
).catch(t => {
console.log(t),
msgReply(e, generateBotMessageEmbed("Error", `Could not connect to \`${s.name}\` for some reason.`, 13369344))
}
) : msgReply(e, generateBotMessageEmbed("Error", "You're not in a voice channel!", 13369344));
break;
case "leavevc":
const o = Platform.mainGuildF.members.cache.get(client.user.id).voice.channel;
o ? (o.leave(),
client.user.setPresence(Platform.lastStatus),
msgReply(e, generateBotMessageEmbed("Disconnected", `I was ejected from the VC, AKA \`${o.name}\` I guess.\n*PROTIP: To make me rejoin a VC, Just use -joinVC*`, 7935))) : msgReply(e, generateBotMessageEmbed("Error", "I'm not in a voice channel...", 13369344));
break;
Does anybody know how to get live data from voice
Hi guys!
I want to be able to reuse discorvoice audioResource's. The only way I can think of to do this is to duplicate the stream and then create two seperate AudioResources every time. This ofcourse requires double the memory and likely some extra computation aswell. Is there any other way that makes this possible? I am trying to do this to be able to 'cache' certain resources for instant playback as they require a good 1.5s to obtain.
Can someone give me an example or how to actually code the bot of playing an audio clip
hi, is there any way a bot can connect to a stage type voice channel?
how do I make a volume command?? basically I want to alter the volume using a listener..
home/ubuntu/Manbo/node_modules/@discordjs/voice/dist/index.js:1
import path from "path";
^^^^^^
SyntaxError: Cannot use import statement outside a module
uhh it worked at right befor today, i dont have any idea why this is happening
can i get some help w this?
Hey,
I'm trying to play an mp3 file over voice chat, I've built my bot similar to the 'dynamically executing commands' example.
Then I built a command, which joins VC and should play an audio file, right now its just a rickroll mp3.
But when I try to join I get this error in the 'entersState' method:
DiscordAPIError: Unknown interaction
at RequestHandler.execute (C:\GitProjects\LTTStoreDotCom\node_modules\discord.js\src\rest\RequestHandler.js:349:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\GitProjects\LTTStoreDotCom\node_modules\discord.js\src\rest\RequestHandler.js:50:14
)
at async CommandInteraction.deferReply (C:\GitProjects\LTTStoreDotCom\node_modules\discord.js\src\structures\interfa
ces\InteractionResponses.js:57:5) {
method: 'post',
path: '/interactions/908285328564060210/aW50ZXJhY3Rpb246OTA4Mjg1MzI4NTY0MDYwMjEwOkxKc0FGcFZ3QlRlNG15MkRhc0llY0NkRVZvMm
5lWHVaR0drdmxkbTZvdVhyZ3JCRFhRM0ZzOHlQTGJmbWJpZURSVlFpb3lXcnlDSDlBNHIzQzNYQ2xZREN3OG93S0tFajJRaTJ1dzhCSWNqVDNZanFJM3hrQT
FWaXZ6dWcwb3o0/callback',
code: 10062,
httpStatus: 404,
requestData: { json: { type: 5, data: [Object] }, files: [] }
} unhandledRejection
AbortError: The operation was aborted
at abortListener (node:events:838:14)
at EventTarget.<anonymous> (node:events:874:47)
at EventTarget.[nodejs.internal.kHybridDispatch] (node:internal/event_target:559:20)
at EventTarget.dispatchEvent (node:internal/event_target:504:26)
at abortSignal (node:internal/abort_controller:97:10)
at AbortController.abort (node:internal/abort_controller:122:5)
at Timeout.<anonymous> (C:\GitProjects\LTTStoreDotCom\node_modules\@discordjs\voice\dist\index.js:9:420)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7) {
code: 'ABORT_ERR'
}
This is the code I'm using:
const { SlashCommandBuilder } = require('@discordjs/builders')
const { createReadStream } = require('fs')
const { join } = require('path')
const { joinVoiceChannel, createAudioResource, createAudioPlayer, NoSubscriberBehavior , demuxProbe, entersState,
VoiceConnectionStatus
} = require('@discordjs/voice')
module.exports = {
data: new SlashCommandBuilder()
.setName('ltt')
.setDescription('Plays a random ltt advert in voice chat.'),
async connectoToChannel(channel) {
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
try {
await entersState(connection, VoiceConnectionStatus.Ready, 5_000); // <-- Error gets thrown here
return connection;
} catch (error) {
connection.destroy();
throw error;
}
},
async probeAndCreateResource(readbaleStream) {
const {stream, type} = await demuxProbe(readbaleStream)
return createAudioResource(stream, {inputType: type})
},
async execute(interaction) {
console.log('Playing Advert')
interaction.deferReply({ ephemeral: true })
const member = interaction.member;
const channel = member.voice.channel
if (!channel || !channel.joinable) {
return interaction.reply({
content: `You must be connected to a voice channel in order to use this command`,
ephemeral: true
})
}
const connection = await this.connectoToChannel(channel)
connection.on('stateChange', ((oldState, newState) => {
console.log(`Connection transitioned from ${oldState.status} to ${newState.status}`)
}))
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause
}
})
player.on('stateChange', ((oldState, newState) => {
console.log(`Connection transitioned from ${oldState.status} to ${newState.status}`)
}))
player.on('error', error => {
console.error('Error:', error.message, 'with track', error.resource.metadata.title)
});
const filePath = join(__dirname, 'media/rick.mp3')
console.log(filePath)
const readStream = createReadStream(filePath)
const resource = await this.probeAndCreateResource(readStream)
console.log(resource)
player.play(resource)
connection.subscribe(player)
return interaction.reply({content: 'LTT STORE DOT COM!', ephemeral: true})
},
};
/app/node_modules/@discordjs/voice/dist/index.js:1
import path from "path";
^^^^^^
SyntaxError: Cannot use import statement outside a module
i got the same error ^^
- use
require - rename your file extension to
.mjsso node will read your file in es6 syntax - add
"type": "module"to yourpackage.json(you will have to useimportin your whole project)
it's from @discordjs/voice itself, their latest pr added support for esm which broke cjs
doing npm install @discordjs/voice@0.7.2 should be a workaround for now until they revert/fix it
/src/user/app/node_modules/@discordjs/voice/dist/index.js:1
import path from "path";
^^^^^^
SyntaxError: Cannot use import statement outside a module
What is this error for ??
same error
same
That's due to es6 import and export statements
Downgrading the package works. Do npm i @discordjs/voice@0.7.2
In your package.json do "type": "module"
The error isn't coming from his code
Make it leave the channel if music is not playing
Is inline volume so bad?
how do i get my bot to join a channel?
how I can downgrade the @discordjs/voice version to 0.7.2?
joinVoiceChannel()
thanks for helping, I was looking at the guide and it didn't mention anything about entersState so that's why I was confused
entersState is just a promise form that bot whether joined the channel
I used entersState to get my bot to join the channel, is that what I'm supossed to do?
yep and also
const Voice = require('@discordjs/voice');
const voiceChannel = message.member.voice;
let player = Voice.joinVoiceChannel({
channelId: voiceChannel.channel.id,
guildId: voiceChannel.channel.guild.id,
adapterCreator: voiceChannel.channel.guild.voiceAdapterCreator,
selfDeaf: true,
});
try {
await Voice.entersState(
player,
Voice.VoiceConnectionStatus.Ready,
20000
);
} catch(e) {
console.log(e)
const embed = new Discord.MessageEmbed()
.setDescription(
`**Failed to join voice channel within 20 seconds, please try again later!**`
);
message.channel.send({ embeds: [embed] });
return;
}
``` an example if you confused
im getting this error guys
client.once('ready', async () => {
console.log('A revenit botu ca boxiour din pumni');
const connect = joinVoiceChannel({
channelId: "783047893065924611",
guildId: "395576333310230558",
adapterCreator: client.guilds.cache.get('783047892243447809').voiceAdapterCreator,
selfDeaf: true,
});
const audioPlayer = createAudioPlayer();
const resource = createAudioResource("https://youtube.com/Hlbbn2pduqE?list=RDHlbbn2pduqE");
connect.subscribe(audioPlayer);
audioPlayer.play(resource);
});
I use this code, but the bot doesn't connect to the channel, why?
you need to resource in the node form use playdl
const playdl = require('play-dl')
let stream = await playdl.stream('YOUR SONG URL')
let resource = createAudioResource(stream.stream, {
inputType: stream.type
})
ty
Could you help that?
same idk
still doesn't connect
replace client.guilds.cache.get('783047892243447809') by client.guilds.cache.get('395576333310230558') because 395576333310230558 is your guild id
you can remove selfDeaf which defaults to true
I have problem with finding all users connected to a voice channel. Sometimes it works sometimes it doesnt.
I personally never have problems, but when users run the command it sometimes doesnt work What do you guys think im missing?
can you show more?
Sure trying to use it to disconnect everyone in the voice channel
try const newSize = voice.members.size
and replace newSize.length by newSize
doesnt that just give me the amount of people and not a reference to them?
your var is "newSize"
yeah sorry the naming was wrong :)
I was thinking it was a size >.<
fixed naming
voice.members is a Collection https://discord.js.org/#/docs/collection/main/class/Collection
I think you are trying to convert this collection to an array but there is many method you can use instead by keeping the collection
So you think the problem occur because i move it away from a collection to an array?
I am not sure about that, but is there any error ?
what happens is when the problem occur it will tell me the list is empty, even tho there is like 50 people in the chat
but the big difference is im not there in the chat
voiceUsers is empty when the error occurs ?
Yep
did you check voice.members also?
will check that as a double check
try
const voiceChannel = await interaction.guild.channels.cache.get(process.env.voiceId)
await interaction.guild.members.fetch()
const voiceUsers = voiceChannel.members
console.log(`There are ${voiceUsers.size} users in the voice channel.`)
for (const [, voiceUser] of voiceUsers) {
await voiceUser.voice.disconnect()
}
@fleet glen
thanks. it works for me,but will se if works tomorrow too when we have an event where its being used :)
no pb
tell me if you don't understand anything in the code
its fine it looks like the idea i made myself after our talk. i just chose to use the foreach method from collection, but switched it for your code to test that first :)
hm yes you can also use forEach I guess!
voiceUsers.forEach(async voiceUser => {
await voiceUser.voice.disconnect()
})
I think forEach will run asynchronously so it could be safer to use for because it will wait until all users are disconnected
Does anyone have an example of how to get an "in" and "out" audio stream from a discord voice channel? I was checking out the examples from https://github.com/discordjs/voice/blob/main/examples and was trying to figure out what I actually need to create in order for this to work. Coming from good ol' discord.js master back when v12 was a dream, v13 is a little confusing for me so I maybe missing something. Any help is appreciated.
what's my error?
where I can find some documentation about yt-search?
yt search? are you talking about music bots?
yep
Probably on the yt-search npm page. This discord is exclusively for help with discordjs.
Hi, I'm having a problem with audio player automatically pausing itself.
I did several tests related with this issue but none of them worked for me:
- Tried logging subscribe count every time state changes and saw that subscriber was not changing
- Tried playing a song after subscribing to a voice channel
Versions:
- @discordjs/voice:
0.7.5 - discord.js:
13.1.0 - @discordjs/opus:
0.5.3
Code:
const resource = await createAudioResource(
"https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3",
{
inputType: StreamType.Arbitrary,
}
);
player.play(resource);
const connection = await joinVoiceChannel({
guildId: data.guild.id,
channelId: data.member.voice.channel.id,
selfDeaf: true,
selfMute: false,
adapterCreator: data.guild.voiceAdapterCreator,
});
connection.subscribe(player);
To be clear data variable inherits Message class and contains extra information related with bot.
How do I resume dispatcher?
dispatcher.resume() doesn't work
v12 voice is not supported anymore
What is line and when does the event gets emitted?
When inlineVolume memory leak fix?
Why is opus not working at all for me? I try to install and it just says it’s failed and I’m not too sure why
Wait nevermind
hello i have a problem with the player
when i try to play a song, the player goes on playing state and then on autopaused state without playing the music
So, am I crazy or is the voice module completely busted up when joining a VC using joinVoiceChannel - there is nothing wrong with my code from what I can tell, but I keep getting the most bizzare error of s is not a function
Moved from the general help channels^
I've been sitting here for an hour trying to figure this out and I don't think it's my code. I could share it if need be
Please share the code and the full error.
Aight, gimme 1 sec