#archive-voice
30636 messages · Page 31 of 31 (latest)
well, I'm on 16.13.1, which version was it released on
It does log ended: true, but endEmitted is still false
Where did you find endEmitted?
Looks like an issue with node Readable to me. Since the end event stems directly from there and it should emit it when it ends…
I have a music discord bot. It can play youtube music using ytdl-core and radio stream with basic stream url. But whenever I try to listen radio stream after playing a youtube music, it doesn't work. My bot stop playing youtube music but doesn't play radio stream. I don't get any error message. I am using player.play(<radio_stream_source>) method in order to change resource. Do you have any idea why this is not working ?
Do you pass the radio stream as URL or as AudioResource into the player?
as Audio Resource. Actually, I am adding youtube music feature to my bot. I finished the radio part and it works. It just happens when i try to listen radio after playing some youtube music.
I think I saw something related in github issues
Yes, and the workaround for that was to not use URLs directly but pass them into a createAudioResource() and then pass that to the player
i can share my code if you want ?
Firstly, i thought destroying audioResource object is not enough and i should destroy ytdl-core's readable stream and i destroyed it but it doesn't change anything.
Any idea ?
(node:9896) Warning: [DiscordPlayerWarning] Unhandled "connectionError" event! Events "error", "connectionError" must have event listeners!```I got this error when i use `discord-player` dependency, while the bot is playing the song, suddenly in the middle it abruptly stopped and left the voice channel, is it related to djs or the audio dependencies i use like `ffmpeg-static` and `discord-player`, inlcuding `@discordjs/opus` and `@discordjs/voice`?
if (resource.ended) {```
what does this mean
bro what causes the error, djs or third-party dependency?
What could cause a DiscordPlayerWarning? Definitely not discord.js
hmmm, ok
there isn't even an error there
Yeah, ill send tomorrow the whole prompt
How can i make my bot to record voice from vc?
record discord audio js on google
first hit: https://stackoverflow.com/questions/66385291/discord-js-record-mp3-of-voice-channel
And that uses DJSv12 so not really a helpful answer
not like they even went here to check but good one
I have a music discord bot. It can play youtube music using ytdl-core and radio stream with basic stream url. But whenever I try to listen radio stream after playing a youtube music, it doesn't work. My bot stop playing youtube music but doesn't play radio stream. I don't get any error message. I am using player.play(<radio_stream_source>) method in order to change resource. Do you have any idea why this is not working ?
If it doesn't work with passing the radio url into createAudioResource, no, no idea
Do bots automatically leave voice channels after certain time of inactivity?
Hello, does someone know how can I send the listening stream to Google Speech API?
seems like it's not the right format using the following code:
module.exports.attachStream = (stream) => {
const audio = connection.receiver.subscribe('422820341791064085', {
end: {
behavior: EndBehaviorType.Manual
}
});
audio.pipe(stream);
return audio;
}
stream is the Google Speech API stream (I need to send the audio stream there)
I got this error
issue fixed, instead of using a stream I used requests one by one to speech
does anyone know how can I seek using ffmpeg?
add '-ss', time, '-accurate_seek' to args
alright alright
one question tho
I pipe the current playing stream to this ffmpeg
right? like so...
@fiery blade
try it and see
I tried, it seeks to a completely random time
is it in ms
still, I input like 10, it goes to half of the song
if I try seeking again to 0 (beginning of the song), it goes to the end, and the song ends
probably because of the pipe
wdym?
I do think the stream I need is the one on ffmpegProcess.stdio[4] but
when I try playing that it doesn't play anything
stdio[4] is incorrect. You should be piping to 0 (stdin aka standard input) and listening to 1 (stdout aka standard output). 2 is stderr (standard error) and > 2 doesn't exist and will give you undefined.
btw, If you're not listening to stderr, select ignore instead of pipe
@rose helm dude
how do I play pipe:4 on the bot?
when I put song.mp3 instead of pipe:4, it gives me exactly what I want to play, but as a mp3 file
I want to play pipe:4 on the music bot, but I can't put that in a audio resource and make it play
why do you want to use pipe:4 when it doesn't exist? I just told you what each pipe is and documentation to prove it. Why would you intentionally want to divert from developer standards?
how do I play the output then?
"-i", "pipe:0"
…
"pipe:1"
my dude
what is the difference in the numbers
I am 100% sure changing the numbers won't make it work
read the node documentation
I did
and do you understand the concept of stdin and stdout
no
stdin is the pipe you input data into a child process
stdout is the pipe the child process outputs data after its done processing the input or whatever
and of course stderr is the pipe it will log errors to
As I said earlier, stdin is 0, stdout is 1 and stderr is 2
you're saying is I need stdout[4] instead of stdio[4]?
I tried that already, didn't work, stdout is undefined

no. Ignore the 4. 4 doesn't exist. stdout automatically links to the ReadableStream that is the child process' output assuming you properly configured the pipes, which you didn't
WAIT
idk why you're so fixated on 4
it is what comes after 3
Okay. What's so special about 3
so this?
now I would need to create a new audio resource with ffmpegProcess.stdout[1]?
0 is input for on error, so use 2
output is 1
uh, so this?
No, you'd pipe to 0 at the bottom. That you had proper. You would create a resource from 1
hmmm, and the rest keep 2?
oh also at the top to input, change to 0
hmmm I see
and then I create a new audio resource from ffmpegProcess.std__out__[1]?
You don't need the index accessor on stdout since it isn't an Array. stdout is already a ReadableStream
oh, so that is why it gave me undefined when I tried stdout, interesting
ye, now it gives me errors for stuff that aren't even on my code
Then google will be your friend
I need help scaling a bot with @discordjs/voice, like literally it gets so laggy and I have no idea what to do 
shard & use hosting software
How can I make my Discord bot join a voice channel and stay there 24/7 doing nothing?
Why would you want that
Literally just a waste of bandwidth
is there a way to edit the current playing resource stream, without having to create a new resource?
theoretically yes but no recommended way
when a bot plays music in a voice channel, what's the default bitrate?
if (resource.ended) {
^
TypeError: Cannot read properties of undefined (reading 'ended')
at AudioPlayer.play (/home/dumitru/Desktop/cringe-main/node_modules/@discordjs/voice/dist/index.js:944:18)
at Object.<anonymous> (/home/dumitru/Desktop/cringe-main/main.js:12:8)
at Module._compile (node:internal/modules/cjs/loader:1099:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
Node.js v17.9.0```
The bitrate of the AudioResource it plays 🤷♂️
Show main.js line 12 (and probably the lines before that)
const Discord = require("discord.js");
const TOKEN = "sus";
const { createAudioPlayer , getVoiceConnection } = require('@discordjs/voice');
const client = new Discord.Client({
intents: [
"GUILDS",
"GUILD_MESSAGES"
]
});
const connection = getVoiceConnection(987282287714533410);
const player = createAudioPlayer('/home/dumitru/Desktop/cringe-main/the_perfect_girl_-_mareux_slowed.mp3');
player.play();
connection.destroy();
client.login(TOKEN).then(() => {
client.user.setPresence({ activities: [{ name: "Minecraft", type: "PLAYING" }], status: "online" })
});
That’s not how you create a AudioPlayer. You need a AudioResource to pass to the play, not pass a path to the constructor
Suggestion for @loud dome:
Library: Audio Player
read more
Also IDs need to be strings, not integer
oh makes sense
do i need to provide any guild id to the VoiceConnection?
@waxen wedge
/home/dumitru/Desktop/cringe-main/node_modules/prism-media/src/core/FFmpeg.js:143
throw new Error('FFmpeg/avconv not found!');
^
Error: FFmpeg/avconv not found!
at Function.getInfo (/home/dumitru/Desktop/cringe-main/node_modules/prism-media/src/core/FFmpeg.js:143:11)
at Function.create (/home/dumitru/Desktop/cringe-main/node_modules/prism-media/src/core/FFmpeg.js:156:38)
at new FFmpeg (/home/dumitru/Desktop/cringe-main/node_modules/prism-media/src/core/FFmpeg.js:45:27)
at Object.transformer (/home/dumitru/Desktop/cringe-main/node_modules/@discordjs/voice/dist/index.js:1780:27)
at /home/dumitru/Desktop/cringe-main/node_modules/@discordjs/voice/dist/index.js:1936:58
at Array.map (<anonymous>)
at createAudioResource (/home/dumitru/Desktop/cringe-main/node_modules/@discordjs/voice/dist/index.js:1936:39)
at Object.<anonymous> (/home/dumitru/Desktop/cringe-main/main.js:16:16)
at Module._compile (node:internal/modules/cjs/loader:1099:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
Node.js v17.9.0```
const Discord = require("discord.js");
const TOKEN = "sus";
const { createAudioPlayer , createAudioResource ,getVoiceConnection , NoSubscriberBehavior } = require('@discordjs/voice');
const client = new Discord.Client({
intents: [
"GUILDS",
"GUILD_MESSAGES"
]
});
const connection = getVoiceConnection("987282287714533410");
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});
const source = createAudioResource('~/Desktop/cringe-main/the_perfect_girl_-_mareux_slowed.mp3');
player.play(source);
connection.destroy();
client.login(TOKEN).then(() => {
client.user.setPresence({ activities: [{ name: "Minecraft", type: "PLAYING" }], status: "online" })
});
nvm i solved it
const Discord = require("discord.js");
const TOKEN = "sus";
const { createAudioPlayer , createAudioResource ,getVoiceConnection , NoSubscriberBehavior } = require('@discordjs/voice');
const client = new Discord.Client({
intents: [
"GUILDS",
"GUILD_MESSAGES"
]
});
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}`)
});
const connection = getVoiceConnection("987282287714533410");
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});
const source = createAudioResource('~/Desktop/cringe-main/the_perfect_girl_-_mareux_slowed.mp3');
player.play(source);
client.login(TOKEN).then(() => {
client.user.setPresence({ activities: [{ name: "Minecraft", type: "PLAYING" }], status: "online" })
});
``` Made a few changes though couldn't make the bot join the VC, perhaps I didn't specify anywhere the guild id
Maybe read the rest of the Voice guide too…
another quiestion, did discord.js change a lot since 2021? I think I will understand better if a watch a video
Many videos out there are outdated. Make sure they are for v13
okay i will thank you
but what if the bitrate of the audio resource is higher than discord's limit
Heyo,
how to get the player state?
<AudioPlayer>.state
you could also manage by listening to each state as an event with <AudioPlayer>.on(<state>, ...)
Thanks
Do bots automatically leave voice channels after certain time of inactivity? If so, is there an event to detect when they do?
this is a more accurate channel to ask in, but generally please don't crosspost without waiting for an answer
Lol sorry
#992669226403909652 is the new place for site-discussions (or lib- or guide- )
In audioResource, is there a way in order to change highwatermark and what is default hightwatermark value ?
What does “Did not find the EBML tag at the start of the stream” mean?
subscribe to them, get the opus stream, probably need to transform into a stream that a stt api accepts, put in stt api, get text
And respect the privacy of users when doing that, so sending their voice to a stt api might not be legal…
Write up a Privacy Policy and link it in your bot, so the users agree to it before using it?
So I managed to get through all the errors that happened to appear, but still couldn't manage to get the bot into the voice chat
Actually nvm it joined the vc but didn't play anything
if the bot is on deafen, can it prevent from playing audio?
does changing the bitrate of a voice channel affect the bitrate of an AudioResource
hi
so basically I am trying to run different discord.js music bots but on the same process
like this:```js
tokens.forEach(token => {
const client = new Client({ intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_VOICE_STATES", "GUILD_MESSAGE_REACTIONS"] });
const player = new Player(client);
// music code
client.login(token);
});
the issue I am having is that joinVoiceChannel method only allows 1 client to be in a voice channel
I don't see intents
oh that's just an example...
that should work ig
only 1 client joins the voice channel for some reason
also I tried this simple code inside ```js
client.on("ready", () => {
const guild = client.guilds.cache.get(client.subscription.server);
if (!guild) return;
joinVoiceChannel({
guildId: guild.id,
channelId: "994198851982458890",
adapterCreator: guild.voiceAdapterCreator,
selfDeaf: true
});
});
and only 1 bot joins the voice channel
anyone got any idea why?
ok I found this: https://github.com/discordjs/voice/issues/230
heya!
can i volume up the sound?
If you set inlineVolume to true you can by setVolume
cool ty
hmm weird it reads short words but not long sentence
ohh it because of the file size?
found this on stackoverflow
I can easily play files with several megabytes, so shouldnt be a problem
but a tts package i use generates wav instead of something like mp3 so it kinda make sense now
now im looking for a way to compress wav or convert it to mp3
do you know how to use @ discordjs/opus
You can use ffmpeg apparently https://devtails.medium.com/how-to-convert-audio-from-wav-to-mp3-in-node-js-using-ffmpeg-e5cb4af2da6
And before you ping me, no, I don’t know how to use /opus directly
ok :) thank yoi
if (AudioPlayerStatus.Playing)
``` ```js
if (AudioPlayerStatus === Playing)
```Which is correct to check if the audio is playing?
Neither… player.state === AudioPlayerStatus.Playing
With player being an AudioPlayer instance
Oh ok thnx
How do I then get the voice channel the bot is in?
<Guild>.me.voice.channel
I'm grabbing audio in electron via getUserMedia and then using that as the audio for the bot, but it's completely corrupted and there is extremely loud static with the audio 😦
that's the code I'm using and this is what the audio sounds like
what am I doing wrong :/
whats audio resource volume range? (with inlineVolume true ofc)
lets not cross-post
this channel dead tho
again, lets not cross-post
The range is pretty open ended. But 1 would be 100%, so values 0-1 would be advisable,
Oh ye thanks, I couldnt find it anywhere (setting it to 100 was not so good)
how can I change the audio source from one file to another while a connection is made with a voice channel
you're welcome to call <AudioPlayer>.play() or <VoiceConnection>.subscribe() at any point in time (while they're not destroyed)
if I use createAudioResource to use a different audio file and play that while another is already playing, does it just replace the already playing file with the new one?
Yes
got it, thanks
so I'm using this
let resource = createAudioResource("cool/file/path", {
inlineVolume: true
});
let player = createAudioPlayer()
player.play(resource);
but I can't get the new audio to play
is the voice connection subscribed to the new audio player?
oh 🤦♂️
if I'm staying in the same vc, do I just use this:
const connection = getVoiceConnection(interaction.guild.id)
connection.subscribe(player);
before I play from the player
sure
that worked. thank you so much
Or just keep the player and call play on it with the new resources
how come getVoiceConnection works inconsistently - it sometimes requires both a guild and user id to function and other times it won't function when given a user id
well I'm not sure under what conditions you're passing a user id to getVoiceConnection, given that it doesn't require that
are you using a user id as the group?
I was told to add it as a parameter and it has been working fine but now I'm trying to disconnect the player when not using Distube and am now running into the same problem
well as pat mentioned above distube is setting the group to client.user.id, which would be the reason you need to get the voice connection with client.user.id as the group
if it's inconsistent, that'd be an issue to take up with distube, given that you're not calling joinVoiceChannel yourself
ended up just using a try and catch lol
try {
let connection = getVoiceConnection(interaction.guild.id)
connection.destroy();
await radioSchema.findOneAndDelete({ GuildID: interaction.guild.id })
} catch (e) {
let connection = getVoiceConnection(interaction.guild.id, client.user.id)
connection.destroy();
}
voice.getVoiceConnection(`guild_id`).disconnect();
does this still works in djs 13?
not only is that not how it worked in v12, that's not how it works in v13
getVoiceConnection() is a top level function exported by @discordjs/voice
<VoiceConnection>.destroy() is how to disconnect
Library: Voice Connections
read more
mmmmmm
first ihave to import @discordjs/voice then
you should probably also read the voice guide intro
Suggestion for @shadow lava:
Getting Started: Introduction
read more
yes reading that only
Could not join the channel: TypeError: channel.join is not a function
Seems like you didn’t read it. Go. To. Sleep!
what file type can discord.js play
discord.js itself: none; djs-voice sends Opus packets to discord. But it also uses ffmpeg to transcode virtually anything into Opus. So I guess the answer to your intended question is: anything ffmpeg can
Question..
Discord dont have a package for music that works with lavalink?
Discord don’t have any npm packages, no
How to remove all slash commands of my bot from all servers ?
Deploy an empty array of commands
How?
Same way you deployed them in the first place. But instead of passing an array with all your commands in it pass []
i am trying to make a bot that plays a certain song when a user joins the call now the bot joins the call successfully but the music for some reason doesnt play i have installed sodium and ffmpeg
i have been told to go here
nvm i fixed it
Is there a way to make the bot leave when it finishes playing mp3?
check for when the player goes into the idle state
thank you, so you know how to use discord.js/opus?
assuming you're good at these kind of things
Did you read the README of that?
yea… but bots on github that have d.js/opus installed don't even do require at the top, im not really about sure about that usage
because voice uses it internally
you don't need to use a function from opus, but voice uses it for codec
I tried to solve it, everything seems to be in vain, can anyone suggest me the method to fix it.
AbortError: The user aborted a request.
A request took longer than the specified restRequestTimeout (15 seconds default), and was aborted to not lock up the request handler.
• This can be caused by an internal server error on Discord's side, or just a slow connection.
• In case of a slow connection, the restRequestTimeout option in ClientOptions can be increased to prevent future AbortErrors.
oh
nice, thanks you
That's for the discord.js main lib, not for discord.js voice.
The actual solution is to use this function instead of the default Discord.entersState since it has issues with locking the thread:
https://github.com/AmandaDiscord/Volcano/blob/main/src/worker.ts#L80
if you wrote a better function why not pr it
If you don't use typescript, you'll have to remove the typescript decorators
Because they want to use node internal modules which is the issue
oh thanks you
how do i get member voice channel id if the member is on vc? in discordjs/voice
member.voice.channel
should i include the .id?
if you need to use the id sure
aight
what access does this require: https://discord.js.org/#/docs/main/stable/class/VoiceState?scrollTo=setSuppressed
using it returns: Unhandled promise rejection: Missing Access.
how can i fix this?
not an @discordjs/voice issue but ensure that client is correctly defined
I'm trying to determine when a user has left a channel but I's getting an error saying the connection is undefined
client.on("voiceStateUpdate", async function(oldState, newState){
const connection = getVoiceConnection(newState.member.guild.id, newState.member.id);
if (VoiceConnectionStatus.Disconnected === connection.status) {
[random code]
}
});
Your client may not be connected
Why are you passing the memberId into the getVoiceConnection? That would mean your bot has a seperate connection for each GuildMember (before that member even joins a VC). So what you want to check is if connection is undefined, because then that means that connection doesn’t exist, hence not connected.
Well, actually you want to check if oldState.channelId exists but newState.channelId doesn’t. Because that would tell you if they left a channel
your bot must be a stage moderator
how can i fix this?
Tag suggestion for @subtle granite:
• ReferenceError: "x" is not defined: learn more
• TypeError: Cannot read properties of undefined/null (reading "x"): learn more
Error [DISALLOWED_INTENTS]: Privileged intent provided is not enabled or whitelisted.
If you are using the GUILD_MEMBERS, GUILD_PRESENCES, or MESSAGE_CONTENT intents, you need to enable them in the developer portal:
• Developer Portal > Your app > Bot > Privileged Gateway Intents
How do I seek in a song? it seems that most v13 bots either use lavalink or dont implement a seek command.
gotta use ffmpeg
what format is best?
opus?
pcm?
the output needs to be opus. Anything imported into ffmpeg will be converted to ffmpeg pcm and then back to the output
why is this happening, out of no where, everything was working fine, I restarted the bot and now this
Install ffmpeg or ffmpeg-static
but, did discord.js/voice always require ffmpeg?
For encoding certain streams it did. So maybe you just didn’t have streams needing it before?
Or your host just updated/uninstalled ffmpeg
I never had ffmpeg installed
but I guess that is because the lib I use always give opus encoded streams
Yup, opus doesn’t need ffmpeg. PCM or other would
@waxen wedge I have a weird problem dude, idk if you can help me
but even after installing ffmpeg, in many different ways, it still not working
with ffmpeg installed, it doesn't give the error, but still doesn't play anything
and the exact same code runs fine on my pc (without ffmpeg installed)
but on the vps, it doesn't work, even with or without ffmpeg
really don't know what to do
hey can I ask a question?
can you play song from external links?
links that end with .mp3
Yeah
which file formats can it play (from a link), I know ogg and mp3 works, what else does?
also, how do I check if a link is a playable media file
Anything that ffmpeg can convert (which is virtually any audio stream afaik)
Is there a common way to seek AudioResources in discord.js v13? I tried fluent-ffmpeg but that is way to slow.
I do want to pause the current track, play something else, and then resume playback of the current track
ffmpeg is the only native way. Some bots use lavalink instead
Do you maybe know how v12 did it? It seems v12 did that without re-encoding just skipping the stream until it reached the given duration i guess?
I have no knowledge of v12🤷♂️
Guess it is lavalink then. Tho this does increase complexity of my bot more than exponentially compared to the previous version.
@waxen wedge You maybe know what is the best lavalink client to use?
No
v12 just used ffmpeg
Wish i knew how to do it with ffmpeg without transcoding. Integrating lavalink rn but it has its own set of issues
You must restart the track for this to work as you can seek backwards. These are the base ffmpeg options you need to use: https://github.com/AmandaDiscord/Volcano/blob/main/src/worker.ts#L198
append "-af" to the end of that Array and then apply this: https://github.com/AmandaDiscord/Volcano/blob/main/src/worker.ts#L347
Without piping through ffmpeg is currently impossible unless you did it with another language and somehow interfaced with that
A node addon could be created, but they're usually painful
How do i check if audio is already playing before i pause
I've been devoting a lot of my development and research time to looking for native audio transforming
a method player.playing would be nice, but what is the alternative
There should be a property to track the state on the player like paused or something
Now integrated lavalink but it is equally slow when resumeing/seeking :/ All i want is to play TTS inbetween
Hi,
I want to play a .opus audio file but I always get the following error:
capture_pattern is not OggS
Code: ```js
import { createReadStream } from 'fs';
import { createAudioPlayer, createAudioResource, joinVoiceChannel, StreamType } from '@discordjs/voice';
export async function play(interaction)
{
const channelId = interaction.member.voice.channelId;
const connection = joinVoiceChannel({
channelId: channelId,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
let player = createAudioPlayer();
player.on('error', error =>
{
console.log('AudioPlayer threw an error!');
console.log(`Name: ${error.name}\nResource: ${error.resource}\nMessage: ${error.message}\nError: ${error}`);
});
connection.subscribe(player);
const resource = createAudioResource(createReadStream('music.opus'), { inputType: StreamType.OggOpus });
player.play(resource);
}
I can't find anything on how to fix this.
is the file oggopus or is it opus
.opus
have you tried setting inputtype to streamtype.opus then
is it possible to indicate as a audio source a url? if so, how?
It doesn't throw an error anymore but I also can't hear anything. It used to work with oggopus
createAudioResource(url)
If it's a radio you'd need to set it to raw inputtype iirc
and if its a youtube video?
He's referring to the path of the audio file with url
I think it would be a little better if you used the join function from path when creating a reading stream
different story entirely
tell me about it
passing a url for a youtube video won't work, there might be an npm package for getting the audio but I doubt that should be explicitly supported here because scraping youtube apis is against discord tos
It works! Thanks
Is there any advantage in using Streamtype?
so that the decoder knows what codec it is
would it still be against the tos if i would use spotify url instead?
maybe. all I know is that getting from the youtube api isn't meant to be free and getting the data for free isn't what youtube wants
I tested it with other types and now it works with every stream type
WHY?
what
so the other music bots basically pay youtube money so that the music can be listened there,right?
most probably just break tos or source the audio from somewhere else by getting the same song metadata anyways. I dont know of any that actually pay lol
Ah no I just forgot some brackets and it worked with everything magically
I love javascript
It's WebmOpus now for some reason. It used to work with OggOpus.
yeah lol, however I found npm modules that basically download youtube videos and they are available for some reason
you mean it's not in decibels?
oh.
oh dear
Is opus v0.5.3 not available for ubuntu?
Hi, how can i remove player? I destroyed the connection but i still see ffmpeg process in htop
connection23.state.subscription.player should be the player. Call stop() on it
still seeing this
After stopping all AudioPlayer?
yes
Are you certain that is the only player / resource active in your bot?
yes
my working bot today suddenly shutdown i download my file to replit and run and show this error i download ffmpeg-static not work
We aren’t distube support, you don’t even have djs-voice installed
theres a mem leak in prism ffmpeg afaik
it never actually terminates the process
i had the same issue
No way to fix?
you can kill it by executing a terminal cmd within ur code
dont remember exactly how it was done but i remember that it worked for me
Oh god
Hey there, I need some help. I'm getting some weird errors.
RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 10. Received 11
at new NodeError (node:internal/errors:371:5)
at boundsError (node:internal/buffer:86:9)
at Buffer.readUInt8 (node:internal/buffer:252:5)
at VoiceReceiver.parsePacket (/home/dzlandis/Discord-Scriptly-Free/node_modules/@discordjs/voice/dist/index.js:1303:27)
at VoiceReceiver.onUdpMessage (/home/dzlandis/Discord-Scriptly-Free/node_modules/@discordjs/voice/dist/index.js:1322:27)
at VoiceUDPSocket.emit (node:events:390:28)
at VoiceUDPSocket.onMessage (/home/dzlandis/Discord-Scriptly-Free/node_modules/@discordjs/voice/dist/index.js:311:10)
at Socket.<anonymous> (/home/dzlandis/Discord-Scriptly-Free/node_modules/@discordjs/voice/dist/index.js:293:48)
at Socket.emit (node:events:390:28)
at UDP.onMessage [as onmessage] (node:dgram:931:8) {
code: 'ERR_OUT_OF_RANGE'
}
and this next error causes the bot to restart and crash:
16:08:42: FATAL ERROR: Error::ThrowAsJavaScriptException napi_throw
16:08:42: 1: 0xb02ec0 node::Abort() [node /home/dzlandis/Discord-Scriptly-Free/index.js]
16:08:42: 2: 0xa181fb node::FatalError(char const*, char const*) [node /home/dzlandis/Discord-Scriptly-Free/index.js]
16:08:42: 3: 0xa18204 [node /home/dzlandis/Discord-Scriptly-Free/index.js]
16:08:42: 4: 0xaca77b napi_fatal_error [node /home/dzlandis/Discord-Scriptly-Free/index.js]
16:08:42: 5: 0x7f25fc472c9e [/home/dzlandis/Discord-Scriptly-Free/node_modules/@discordjs/opus/prebuild/node-v93-napi-v3-linux-x64-glibc-2.31/opus.node]
16:08:42: 6: 0x7f25fc4733fc Napi::Error::ThrowAsJavaScriptException() const [/home/dzlandis/Discord-Scriptly-Free/node_modules/@discordjs/opus/prebuild/node-v93-napi-v3-linux-x64-glibc-2.31/opus.node]
16:08:42: 7: 0x7f25fc47fdeb OpusEncoder::Decode(Napi::CallbackInfo const&) [/home/dzlandis/Discord-Scriptly-Free/node_modules/@discordjs/opus/prebuild/node-v93-napi-v3-linux-x64-glibc-2.31/opus.node]
16:08:42: 8: 0x7f25fc476aba Napi::InstanceWrap<OpusEncoder>::InstanceMethodCallbackWrapper(napi_env__*, napi_callback_info__*) [/home/dzlandis/Discord-Scriptly-Free/node_modules/@discordjs/opus/prebuild/node-v93-napi-v3-linux-x64-glibc-2.31/opus.node]
16:08:42: 9: 0xaadf9d [node /home/dzlandis/Discord-Scriptly-Free/index.js]
16:08:42: 10: 0xd4a18e [node /home/dzlandis/Discord-Scriptly-Free/index.js]
16:08:42: 11: 0xd4b5af v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node /home/dzlandis/Discord-Scriptly-Free/index.js]
16:08:42: 12: 0x15e7959 [node /home/dzlandis/Discord-Scriptly-Free/index.js]
Any help is greatly appreciated 🙏
Any idea why I would be receiving 11 👁️
What could cause an AudioPlayer to abort while playing? Also wondering how could I handle AudioPlayer errors if I have a queue array that has json of per sever audioplayers?
const {
SlashCommandBuilder
} = require('@discordjs/builders');
const { getVoiceConnection } = require('@discordjs/voice');
module.exports = {
async getConnection(client, interaction, cache) {
let connection = getVoiceConnection(interaction.guild.id);
console.log(connection)
return connection;
}
}
❓ The var, "connection" is undefined, tell me if you want more info.
How would I get the current connection? -- I do not have opus installed if that changes anything -- it results in an error when I try to install it :/
_ _
if ( !connection ) {
const connection = await connectionF.getConnection(client, interaction, cache);
console.log("New connection is " + connection);
serverQueue.connection = connection;
cache.set(interaction.guild.id, serverQueue);
}
you could kill it like this
const { exec } = require("child_process");
exec("killall ffmpeg", (err) => {
if(err) console.error(err);
});
It kills all players
didn't you want it to kill ffmpeg when it was done
getVoiceConnection only gets you existing connections. To establish a new one you need to use joinVoiceChannel
joinVoiceChannel
Creates a VoiceConnection to a Discord voice channel.
Hi! When I'm execute this command, my bot don't join my vocal. Why?
Code: ```js
const { MessageEmbed, Interaction } = require('discord.js');
const { generateDependencyReport, AudioPlayerStatus, createAudioPlayer, createAudioResource } = require('@discordjs/voice');
const { joinVoiceChannel } = require('@discordjs/voice');
const config = require('../config.json');
module.exports = {
run: async (client, message, args) => {
//get the voice channel id
const voiceChannelId = config.musicChannelId;
const voiceChannel = client.channels.cache.get(voiceChannelId);
const guildId = config.guildId;
const player = createAudioPlayer();
player.on(AudioPlayerStatus.Playing, () => {
console.log('The audio player has started');
});
player.on('error', error => {
console.log('error');
});
const resource = createAudioResource('C:\\Users\\pierr\\Desktop\\Bot music\\music\\test.mp3');
player.play(resource);
const channel = client.channels.cache.get(message.member.voice.channel.id);
const connection = joinVoiceChannel({
channelId: channel,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
message.reply("created voice connection");
const subscription = connection.subscribe(player);
if (subscription) {
setTimeout(() => subscription.unsubscribe(), 15_000);
}
},
name: 'p',
aliases: ['p'],
desciption: "p"
}
Terminal: ```
[nodemon] starting node index.js
Musicbot#1511 est opérationnel !
Tue Jul 12 2022 09:44:41 GMT+0200 (Central European Summer Time)
The audio player has started
Because you provide a Channel object for the channelId field of joinVoiceChannel instead of the id
How do I enter the ID? with ' ' or " "?
and how I can automate the ID?
You get the channel with the id. No need to get it, pass the id directly
is there a way to get the AudioResource an AudioPlayer is currently playing
AudioPlayerState
The various states that the player can be in.
The Playing state has a resource property
ok but how? just the id or ' id '?
can you send me an example?
I already have one
I'm trying to get it and I cannot
Pretty much this is what I did:
- I ran the
/joincommand. - I restarted the bot
- I ran the
/playcommand and the connection was undefined.
Is tehre a way to fix this?
existing connections gone after restart, its not persistent
Then you don’t have a connection. Restarting the bot destroyed the connection
?
An id is always a String in djs. So I don’t understand your question
ok
Any way to get the connection then or no?
Calling joinVoiceChannel
What im basically doing is recording the users in voice chat, so yeah.
Code: https://pastecord.com/apihazopip
The probelm:
bot recording for some time, when I went silent the bot stops the record automatically
Try setting the endBehavior to manual
I tried to, the same, but wait is the method called 'endBehavior' not 'end'?
It is end, mb
EndBehavior is the type
What module do I need for NodeJS audio server to run on a linux server
I have Discord Voice, Ffmpeg, Opus, Lib
Could you add stream.once("end", () => console.stack("Stopped listening")) w/ end: "manual"?
The deps are listed in the voice guide in the topic
You need all core deps and one from each of the following categories listed
Where can I find the guide
in the topic
every single one of those are installed but it still yet to work on a linux server host
Is there an error?
} else if
(commandName === 'orlando') {
interaction.channel.send('Joined Voice Channel')
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator
})
let resource = createAudioResource(("https://live.amperwave.net/manifest/audacy-womxfmaac-hlsc.m3u8?source=aud-webplayer&ifa=cookie:66d07c4a-cfbc-482d-812f-8ffb175f0fbf"), { inlineVolume: true })
resource.volume.setVolume(1)
connection.subscribe(player);
player.play(resource);
interaction.channel.send("Now Playing: **Orlando Radio**")
console.log("Playing, Orlando Radio");
Nope
Does the bot join the vc?
Yes, just doesn't play audio
Can you use add the player.stateChange event to see if the player is actually changing states?
Just log the old and new state.status
So just replace the console.log() with console.log.player.stateChange
Not like that but you know what I mean
Listen to the stateChange event on player
U able to write a quick line I'm on my phone
I’m on my phone too
I don't see the options to do player.stateChange
It’s an event, not a property
I know that
Whenever I try to run my player.play(resource) I always get this error. Whats happening?
What’s the resource?
player.addListener("stateChange", (oldOne, newOne) => {
if (newOne.status == "idle") {
console.log("The song finished");
}
});
Didn't do anything to help
I want you to log the old and new state.status
No conditions
The should be placed right below where the player is created
so
player.addListener("stateChange", (oldOne, newOne) => {
console.log(oldone,newOne);
}
});
Add .status for both
oldone.status?
Yes
} else if
(commandName === 'lovesongs') {
interaction.channel.send('Joined Voice Channel')
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator
})
let resource = createAudioResource(("https://audio.jukehost.co.uk/QYWK7vTfem5yKxM63wG49oZtAetUZ50x"), { inlineVolume: true })
resource.volume.setVolume(1)
connection.subscribe(player);
player.play(resource);
interaction.channel.send("Now Playing: **Love Songs**")
console.log("Playing, Love Songs");
player.addListener("stateChange", (oldOne, newOne) => {
console.log(oldOne.status,newOne.status);
});
Didn't log anything
fixed it but new issue. It won't play audio, and I receive 0 errors.
Whats the issue here?
The listener should be registered when you create the player, not after you play smth
Is that path relative to the working directory?
its in the same area where my index.js is
Is it in the same directory as the package.json file?
yep
Then use ./
bruh why it be like that
thanks tho
Here is what came out
buffering
playing
playing
idle
Idk if createAudioResource supports url as stream
It works fine using Visual Studio but not a Linux Hosting Server how
should work
I did something and it worked but I can't remember
Idk how else to debug it w/o getting the stream manually
Can you run node -p "require('@discordjs/voice').generateDependencyReport()"?
On ur linux machine
Gotta ask them how don't know how the company set it up
I’m more concerned abt how audio resource and player handles errors. Ik an invalid file path is silently ignored when played
heh, maybe that should get pr'd
Maybe it’s in debug event? I’ve never tried it
oh right, each player/resource extends event emitter iirc
- and has an option for debug:true when creating it?
It has a debug event typed
player has a debug option, no description
https://github.com/discordjs/discord.js/blob/96c8d21f95eb366c46ae23505ba9054f44821b25/packages/voice/src/audio/AudioPlayer.ts#L244
It has to be enabled to receive debug events?
yup
Oh, that’s when the resource is changed
that would be cleaning data when resource is changed
I don’t see debug being used anywhere other than in stateChange
Unless it’s used in a different file
I’m tempted to try adding an error listener to resource.playStream
eh, it shows info about the oldstate and newstate when changing state: https://github.com/discordjs/discord.js/blob/96c8d21f95eb366c46ae23505ba9054f44821b25/packages/voice/src/audio/AudioPlayer.ts#L358
That’s all I saw
No info that isn’t alr available
but it stringifies the state too
I can't triger the command the company I use limits it
I ran it on my personal console and it said
Method invocation failed because [System.String] does not contain a method named 'generateDependencyReport'.
Just print it manually ig
console.log(require("@discordjs/voice").generateDependencyReport())
Where would I put it cause I put it down and it didn't work
nvm ik where
Core Dependencies
- @discordjs/voice: 0.10.0-dev
- prism-media: 1.3.4
Opus Libraries
- @discordjs/opus: not found
- opusscript: 0.0.8
Encryption Libraries
- sodium-native: not found
- sodium: 3.0.2
- libsodium-wrappers: 0.7.10
- tweetnacl: not found
FFmpeg
- version: 5.0.1-static https://johnvansickle.com/ffmpeg/
- libopus: yes
@icy maple Sry for ping but incase ^^
hey, I recently encountered this error. Is there a way to fix this error???
Voice still uses miniget? 
503 means service unavailable
The site is prob down
Do you know a better module?
node-fetch and undici
Soon, we'll get a native fetch in node.js
ty <3
Been trying to make a slash command that plays an mp3 file in vc, this is what I have atm
const { SlashCommandBuilder } = require("@discordjs/builders");
const {joinVoiceChannel, createAudioPlayer, createAudioResource, entersState, StreamType, AudioPlayerStatus, VoiceConnectionStatus} = require("@discordjs/voice");
const discord = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('tts')
.setDescription('A text to speech command for voice channels!'),
//.addStringOption(option => option.setName('message').setDescription('The message you wish to send.').setRequired(true)),
async execute(interaction) {
let channel = interaction.member.guild.channels.cache.get(interaction.member.voice.channel.id);
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
selfDeaf: false,
selfMute: false
})
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});
connection.subscribe(player)
const resource = createAudioResource("/home/fibreopticbroadbean/Geoff/FileName.mp3")
player.play(resource);
},
}
The bot is able to join the vc, but nothing happens afterwards. This is the error I'm getting, not sure why (if it helps I'm using a Raspberry Pi 2 Model B)
This error seems to come from an embed message you try to create
const { joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayerStatus } = require("@discordjs/voice");
const { Message } = require("discord.js");
const googleTTS = require("google-tts-api")
module.exports = {
data: new SlashCommandBuilder()
.setName("speak")
.setDescription("Make me speak in a vc")
.addStringOption(option =>
option.setName("text").setDescription("What do i say?").setRequired(true)
),
async execute(interaction) {
const text = interaction.options.getString("text")
const voicechannel = interaction.member.voice.channel
if(!voicechannel) {
return interaction.reply("Please join a voice channel to use that command")
}
if(text.lenght > 200) {
return interaction.reply("Please input less than 200 characters")
}
let audioUrl = googleTTS.getAudioUrl(text, {
lang: "en",
slow: false,
host: 'https://translate.google.com',
})
let player = createAudioPlayer()
let recource = createAudioResource(audioUrl)
let connection = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.channel.guild.id,
adapterCreator: interaction.channel.guild.voiceAdapterCreator,
});
player.play(recource)
connection.subscribe(player);
await interaction.reply(":)")
}
}``` How can i make the bot disconnect after it played the url?
I tried adding: ```player.on(AudioPlayerStatus.Idle, () => {
connection.disconnect();
})```but it disconnected way too early
index.js line 117 you pass an invalid embed to <CommandInteraction>.reply
First wait for it to enter Playing state, then attach the listener you have there
can u explain it a bit more?
player.once(AudioPlayerStatus.Playing, () => player.on(AudioPlayerStatus.Idle, …))
ah okay, lemme try it rq
works, thanks you 
is there any way to make a bot play video in a vc with djs, or in general?
i have a thing that sends images of the game board, but it fills up the channel a lot...
No, bots cannot send video
aight thx
My bot keeps idling
Installed Packages
Logged in as cfsgames#2941!
idle
buffering
Playing, Orlando Radio
buffering
playing
playing
autopaused
autopaused
playing
playing
idle
- @discordjs/voice: 0.10.0-dev
- prism-media: 1.3.4
Opus Libraries
- @discordjs/opus: 0.8.0
- opusscript: 0.0.8
Encryption Libraries
- sodium-native: 3.3.0
- sodium: 3.0.2
- libsodium-wrappers: 0.7.10
- tweetnacl: 1.0.3
FFmpeg
- version: 5.0.1-static https://johnvansickle.com/ffmpeg/
- libopus: yes
Autopaused means that the player paused since there are no more connections subscribed to it
But there is a connected established there is a mp3 link
This happens when I try to install pulse audio
npm ERR! gyp ERR! find Python You need to install the latest version of Python.
npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm ERR! gyp ERR! find Python you can try one of the following options:
npm ERR! gyp ERR! find Python - Use the switch --python="C:\Path\To\python.exe"
npm ERR! gyp ERR! find Python (accepted by both node-gyp and npm)
npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
npm ERR! gyp ERR! find Python npm config set python "C:\Path\To\python.exe"
npm ERR! gyp ERR! find Python For more information consult the documentation at:
npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
not really djs related, and also it tells you where to go for more info https://github.com/nodejs/node-gyp#installation
It does its what happened when I installed pulse audio which is for linux servers
I must be very blind never seen that
Ok, so I get no errors I have all the core dependencies but audio still won't play on a linux server but plays on Visual Studio Code
The Owner of the hosting company fixed it
If I have multiple Discord bots connected to Discord, is there a way to join a voice channel with a specific bot?
An example of what I want to do:
const client1 = new Discord.Client({ ... })
const client2 = new Discord.Client({ ... })
const client3 = new Discord.Client({ ... })
// join voice channel with client2
The end goal is to join a voice channel with multiple bots, but when I use ```ts
// iteration over clients, where vc = await client.channels.fetch(id) for each client
joinVoiceChannel({
channelId: vc.id,
guildId: vc.guild.id,
adapterCreator: vc.guild.voiceAdapterCreator as DiscordGatewayAdapterCreator
})
it only joins with 1
Hey, this code is recording the voice chat members from disocrd and send it as file
But i have the probelm, when i went silence, the sound start to lagging ,
The code file: https://pastecord.com/wyfehygizu
The record file: record_9.mp3
You can see this record file so you can know what i mean with lagging
Use group: option and provide different values per bot. For example use the client.user.id
how can I check if two audio resources are the same?
im trying to make a remove dups command
Anyone
is there a way to record a voice Channel to a pipe instead of a file then Play that same pipe to a 2nd Channel.
trying to create a relay without using the hard drive just ram.
any thoughts?
reading thanks.
hey i need help with this., So this code is recording the voice chat members from disocrd and send it as file
But i have the probelm, when i went silence, the sound start to lagging ,
The code file: https://pastecord.com/wyfehygizu
The record file: record_9.mp3
You can see this record file so you can know what i mean with lagging
How do you think typing everything in bold will get more help? If anything it annoys people more. As I said this is a very niche use-case so very few people might be able to help you at all, don’t make them not help you because of the way you ask
Hey guys, Im having an issue where the bot connects, starts reproducing the resource and then, exactly after 1 minute, the voice connection goes to the signalling status, I have swapped from ytdl to play-dl, I also checked the 'GUILD_VOICE_STATES'
some logs here
Player, new state => buffering
Voice Connection, new State => ready
Player, new state => playing
Voice Connection, new State => connecting
Voice Connection, new State => signalling
If i forcefully move the bot from another channel he will reconnect and keep playing, and stops after 1 minute
Voice Connection, new State => connecting
Voice Connection, new State => connecting
Voice Connection, new State => connecting
Voice Connection, new State => connecting
Voice Connection, new State => ready
Is there some kind of protection or "afk" system or anything that would remove the voice connection from ready to signalling?
i get this error Error: aborted can anyone tell me how and why this occurs?
AbortError: The user aborted a request.
A request took longer than the specified restRequestTimeout (15 seconds default), and was aborted to not lock up the request handler.
• This can be caused by an internal server error on Discord's side, or just a slow connection.
• In case of a slow connection, the restRequestTimeout option in ClientOptions can be increased to prevent future AbortErrors.
@cursive sapphire
thanks
what's the alias of it?
Wdym?
i mean how can i use it?
oh you need to include it in your client constructor
oh yea
where you put your intents
after intents i put there, it shows the option for me :) thanks
what parameter i should put and what will it do?
i cant understand what they put in description in the docs
also if u reply, ping and reply
@regal fulcrum
sorry hey wassup
Uhh put 30 or 45
30000?
yea sorry ms
hmm
its 15000 by default
i put 100000, nothing will happen right?
That means its got 100s before it will error out if i understand correctly
hmmmm
i changed to 30000 ms itself, anyways
yea that should be fine
same result
damn, ill create a thread because this slowmode is...... ok ok i control myself
pain in the backside
Someone know how to fix this?
Just want to connect to a voice channel (normally joining):
const { joinVoiceChannel } = require('@discordjs/voice');
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
Like the docs..
Error : channel is not defined
channel must be a VoiceChannel
Hey, I'm using "joinVoiceChannel" to join a voice channel, but after 1 minute the state goes from "ready" to connecting and then signaling, and the only way to go back to ready is by forcing a channel change, and if I do that, 1 min later it will go back again to connecting and then signaling.
Is there a way to prevent this?
Don’t crosspost
sry i dont understand (iam german and very not good in englisch xD)
Es reicht wenn du in einem Kanal Hilfe bekommst😉
haha ok
going from ready to connecting/signaling usually means it disconnected for some reason and is trying to reconnect
this could be an internet issue or a discord issue
unfortunately there isn't really a solution other than to ensure your internet connection is stable
Could it be WSL related?
probably not
if (cmd === 'speak') {
if (!args[1]) return message.reply('Please specify text.');
if (args[2]) return message.reply('Too many arguments.');
const { voice } = message.member;
let string = args[1];
let voiceChannel = message.member.voice.channel;
if (string.length > 500) return message.channel.send("I can only speak 500 words!");
if (!voiceChannel) return message.channel.send("Please join a voice channel to use this command!");
let audioUrl = getAudioUrl(string, {
lang: "en",
slow: false,
host: 'https://translate.google.com',
timeout: 20000,
});
let player = createAudioPlayer();
let resource = createAudioResource(audioUrl);
let connection = joinVoiceChannel({
channelId: message.member.voice.channel.id,
guildId: message.channel.guild.id,
adapterCreator: message.channel.guild.voiceAdapterCreator,
});
player.play(resource);
connection.subscribe(player);
player.on(AudioPlayerStatus.Idle, () => {
connection.disconnect();
});
};
No errors just won't play audio
.on('finish', queue => queue.textChannel.send('Finished!')),
how i can make it when finish bot leave from channel?
<VoiceConnection>.destroy() is how to disconnect
VoiceConnection#destroy()
Destroys the VoiceConnection, preventing it from connecting to voice again. This method should be called when you no longer require the VoiceConnection to prevent memory leaks.
.on('finish', queue => {queue.voiceChannel.destroy(); queue.textChannel.send('Finished!');}),
^
TypeError: queue.voiceChannel.destroy is not a function
I don't imagine your voice channel is your voice connection
the top level getVoiceConnection from djs/voice might help
im new at js and discord.js sry 😛
Suggestion for @rough knot:
Library: Cheat sheet - Access
read more
.on('finish', queue => {
const connection = getVoiceConnection(guild.id)
connection.destroy();
queue.textChannel.send('Finished!');
}),
@rough knot
edited
👍
const connection = getVoiceConnection(guild.id)
^
ReferenceError: getVoiceConnection is not defined
oh yea my bad!
how i can define the guild?
I imagine your queue is instanced to each guild with some identifier, but even if that doesn't involve the guild id, if queue.voiceChannel is a djs VoiceChannel object, <VoiceChannel>.guildId should be your guild id
so
i can use queue.guild.id?
I don't know what queue is or how you set it up
client.distube
.on('playSong', (queue, song) =>
queue.textChannel.send(
`${client.emotes.play} | Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${
song.user
}\n${status(queue)}`
)
)
.on('finish', queue => {
const connection = getVoiceConnection(queue.guild.id)
connection.destroy();
queue.textChannel.send('Finished!');
}),
sounds like you should check out the distube docs to see the most reliable way to access a queue's guild id
guildId and guild.id is the same?
they would be the same id
<VoiceChannel>.guildId is technically more stable than <VoiceChannel>.guild.id, as guildId is guaranteed to be there while guild is only present if djs is able to resolve a guild for that guildId
though I'm genuinely unsure if it's possible to receive a VoiceChannel object without the guild being cached
might require some shenanigans on the developer's part
hm
message.member.voice.channel
this not working in new discordjs?
not working how?
is question
well those are properties that potentially exist
my question is what makes you think it's not working?
im new in discordjs as i said, i start it 1 hour before :D, and i found this in a old code (2021)
can anyone tell that how to start a discordjs/@voice ?
The bot joins the voice room well and leaves it well but it always remains in the same place if we move to another voice
if(interaction.options.getString('option') === 'voc_join'){
if(interaction.member.permissions.has("ADMINISTRATOR")){
joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator
})
interaction.reply({content: `Je rejoind le salon vocal <#${interaction.member.voice.channel.id}>`, ephemeral: true})
}
}
if(interaction.options.getString('option') === 'voc_leave'){
if(interaction.member.permissions.has("ADMINISTRATOR")){
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator
})
interaction.reply({content: `Je quitte le salon vocal <#${interaction.member.voice.channel.id}>`, ephemeral: true})
connection.destroy();
}
}
if you want the bot to join a new voice channel upon all members in the channel changing channels, you'd have to listen to the voiceStateUpdate event and add some logic for conditions to join a different voice channel
hey, guys. help me fix this error
const stream = await ytdl(track.url, guildQueue?.filter?.value || null);
const resource = createAudioResource(stream, { inputType: StreamType.OggOpus, inlineVolume: true });
const guildDispatcher = guildQueue.dispatcher;
try {
await entersState(connection, VoiceConnectionStatus.Ready, 10_000);
guildDispatcher.setMaxListeners(0);
guildDispatcher.play(resource);
(connection.state as any).subscription?.player ? false : connection.subscribe(guildDispatcher);
}catch(error){
if(connection.state.status != VoiceConnectionStatus.Destroyed) connection.destroy();
return this.emit('error', { channel: { text: track.channel.text, voice: track.channel.voice }, requested: track.requested, method: 'initGuildTrack', error: error });
}
Could someone help me with this error ?
I use >> member.setMute(true, "reason");
and it said
member.setMute is not a function
.voice.setMute
Error came from discord-music-player, so report it to then
thank you
hello
so im making my bot leave and join a voice channel when I make it leave it for some reason send the ip and port of the users running the command
or maybe its sending the ip of the machine its running on
at Socket.<anonymous> (C:\Users\User\Desktop\Development Tools\Coding\Upgrading Discord\Uni-Mod-Bot\node_modules\@discordjs\voice\dist\index.js:353:46)
at Object.onceWrapper (node:events:645:28)
at Socket.emit (node:events:538:35)
at socketCloseNT (node:dgram:746:8)
at processTicksAndRejections (node:internal/process/task_queues:82:21)```
basically sends this but the ip and port are filled in
Definitely that, the IP of users isn’t exposed through discord
yea i tested it its the ip of the MACHINE MACHINE
Or IP of discord server
what type of data am i meant to enter in .subscribe
i installed ffempeg from what ive seen others do and then they simply just use the filepath to get the audio file and it works for them
Suggestion for @coarse topaz:
Library: Cheat sheet - Playing audio
read more
it should be an AudioPlayer
but yes you can create an AudioResource from filepath
thanks
No, the problem is clearly not in it, since everything works fine with all other links ...
Well, the package is in the stack trace
Meaning it caused it error
Unless ur messing w/ that package's internals or privates
How do you explain the fact that this happens with 1 link?
Idk, I’m not familiar w/ that package
I just use /voice directly
FFmpeg arguments
That’s not relevant, it says that it tried to play a resource that ended
Well, the resource has been created, I can’t delete it either, it turns out that the wrong resource is initially created?
Ur supposed to create a new one every time you provide one for player.play
I just don't understand why it only happens with 1 link
I can only help if ur able to recreate the issue w/o any 3rd party packages
You could actually open an issue if you do
is there anyway to check the length of audio the player is playing
{
op: 'event',
reason: 'Session is no longer valid.',
code: 4006,
byRemote: true,
type: 'WebSocketClosedEvent',
guildId: ''
}```
When my bot is in a voice channel for too long
I am facing this problem
why are you making a variable for the console.. when you don’t need to
what is the basic code to make the bot play an audio?
can anyone gimme an example?
const { MessageEmbed } = require('discord.js');
const { joinVoiceChannel, createAudioPlayer, NoSubscriberBehavior, AudioResource, createAudioResource } = require('@discordjs/voice');
const yts = require('yt-search');
const ytdl = require('ytdl-core');
module.exports = {
description: `Plays a song for you!`,
run: async (client, msg, args) => {
if (!msg.member.voice.channel) return msg.reply(`Join a voice channel first!`);
const search = args.join(' ').trim();
const url = await yts(search).then(x => x.all[0].url);
let downloadInfo = await ytdl.getInfo(url);
let channel = joinVoiceChannel({
channelId: msg.member.voice.channel.id,
guildId: msg.guild.id,
adapterCreator: msg.guild.voiceAdapterCreator
});
let stream = await ytdl(downloadInfo.videoDetails.video_url)
let embed = new MessageEmbed()
.setDescription(`Playing **[${downloadInfo.videoDetails.title}](${downloadInfo.videoDetails.video_url})** now!`)
const player = createAudioPlayer({ behaviors: NoSubscriberBehavior.Play });
let resouce = createAudioResource(stream);
try {
player.play(resouce);
channel.subscribe(player);
await msg.reply({
embeds: [embed], allowedMentions: { repliedUser: false }
});
} catch (e) {
console.log(e);
return msg.reply(`I went through some problems sorry!`);
}
}
}```the bot is not playing the music but sends the embed message
issue with the package you're using to play music
but that's not playing
audioplayer from @discordjs/voice
Where is throwed the VOICE_SERVER_UPDATEevent?
huh?
wait no I think that this is something the bot should send
mb
example?
thats the discord dev docs
Ik, that's why I'm searching it in djs...
it doesn't even throw any error bro
just sends the embed message but not playing the searched song
you can listen to that via ws as in client.ws.on(…) every gateway event can be found there
Because I'm too lazy to edit all wrong console's i have,
find replace exist for some reason
Ik, i just need help in the problem i have, all this i will edit after fixing the problem
Can anyone help me in this?
hey i need help with this., So my code is recording the voice chat members from disocrd and send it as file
But i have the probelm, when i change silence to manual, the sound start to lagging, which is weird?
channel.members.filter(mo => mo.user.id !== bot.user.id).forEach(async abb => {
const receiver = connection.receiver.createStream(abb, {
mode: "pcm",
end: "manual"
});
})
You can see this record file so you can know what i mean with lagging
Archived to focus conversation on #998942774994927646 (our shiny forum channel) and kept read-only to facilitate in-app search (CTRL+F) for solutions to problems that have already been asked.
If your issue has not been solved yet, feel free to re-post in the new channel