Did not enter state ready within 5000ms

const { Client, Events, GatewayIntentBits } = require('discord.js');
const { joinVoiceChannel, EndBehaviorType, createAudioPlayer, createAudioResource, entersState, VoiceConnectionStatus } = require('@discordjs/voice');
const { getAudioBuffer } = require('simple-tts-mp3');
const fs = require('fs');

const client = new Client({ intents: [GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
var connection;

client.login(token);

client.on(Events.MessageCreate, async msg =>{
if (!msg.content.startsWith("m!"))
return;
msg.content = msg.content.replace('m!', '');
msg.content = msg.content.split(" ");
if (msg.content[0] == "join") {
if (msg.member.voice.channel) {
connection = joinVoiceChannel({
channelId: msg.member.voice.channel.id,
guildId: msg.member.voice.channel.guild.id,
adapterCreator: msg.guild.voiceAdapterCreator,
selfDeaf: false,
selfMute: false,
});
connection.on('stateChange', (old_state, new_state) => {
if (old_state.status === VoiceConnectionStatus.Ready && new_state.status === VoiceConnectionStatus.Connecting) {
connection.configureNetworking();
}
});
}
} else if (msg.content[0] == "speak") {
msg.content.shift();
const buffer = await getAudioBuffer(msg.content.join(" "), 'en');
let resource = createAudioResource(buffer);
let player = createAudioPlayer();
try {
await entersState(connection, VoiceConnectionStatus.Ready, 5000);
} catch (error) {
return null;
}
connection.subscribe(player);
player.play(resource);
}
});
const { Client, Events, GatewayIntentBits } = require('discord.js');
const { joinVoiceChannel, EndBehaviorType, createAudioPlayer, createAudioResource, entersState, VoiceConnectionStatus } = require('@discordjs/voice');
const { getAudioBuffer } = require('simple-tts-mp3');
const fs = require('fs');

const client = new Client({ intents: [GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
var connection;

client.login(token);

client.on(Events.MessageCreate, async msg =>{
if (!msg.content.startsWith("m!"))
return;
msg.content = msg.content.replace('m!', '');
msg.content = msg.content.split(" ");
if (msg.content[0] == "join") {
if (msg.member.voice.channel) {
connection = joinVoiceChannel({
channelId: msg.member.voice.channel.id,
guildId: msg.member.voice.channel.guild.id,
adapterCreator: msg.guild.voiceAdapterCreator,
selfDeaf: false,
selfMute: false,
});
connection.on('stateChange', (old_state, new_state) => {
if (old_state.status === VoiceConnectionStatus.Ready && new_state.status === VoiceConnectionStatus.Connecting) {
connection.configureNetworking();
}
});
}
} else if (msg.content[0] == "speak") {
msg.content.shift();
const buffer = await getAudioBuffer(msg.content.join(" "), 'en');
let resource = createAudioResource(buffer);
let player = createAudioPlayer();
try {
await entersState(connection, VoiceConnectionStatus.Ready, 5000);
} catch (error) {
return null;
}
connection.subscribe(player);
player.play(resource);
}
});
npm list:
Hi, my problem is that my connection doesn't enter the state ready for some reason. I've looked up a lot of stuff and nada.
4 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
thechickenknight
thechickenknightOP2y ago
full error:
Did not enter state ready within 5000ms
at Timeout.<anonymous> (E:\GitHub repos\voice recognition\node_modules\@discordjs\voice\dist\util\entersState.js:17:49)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7)
Did not enter state ready within 5000ms
at Timeout.<anonymous> (E:\GitHub repos\voice recognition\node_modules\@discordjs\voice\dist\util\entersState.js:17:49)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7)
it wouldn't hurt to add that my bot does not join vc undeafened even though I expressely wrote the property selfDeaf to false is there some other way i can update it? other than npm because it's telling me I have the latest version nevermind i added @latest at the end of the install command and got the right version hopefully it works now i'll leave that up for tommorow me
semver <7.5.2
Severity: moderate
semver vulnerable to Regular Expression Denial of Service - https://github.com/advisories/GHSA-c2qf-rxjj-qqgw
fix available via `npm audit fix --force`
Will install @discordjs/[email protected], which is a breaking change
node_modules/make-dir/node_modules/semver
make-dir 2.0.0 - 3.1.0
Depends on vulnerable versions of semver
node_modules/make-dir
@discordjs/node-pre-gyp >=0.3.1
Depends on vulnerable versions of make-dir
node_modules/@discordjs/node-pre-gyp
@discordjs/opus >=0.5.0
Depends on vulnerable versions of @discordjs/node-pre-gyp
node_modules/@discordjs/opus
prism-media 1.2.9 - 1.3.5
Depends on vulnerable versions of @discordjs/opus
node_modules/prism-media
@discordjs/voice >=0.2.0
Depends on vulnerable versions of prism-media
node_modules/@discordjs/voice

6 moderate severity vulnerabilities
semver <7.5.2
Severity: moderate
semver vulnerable to Regular Expression Denial of Service - https://github.com/advisories/GHSA-c2qf-rxjj-qqgw
fix available via `npm audit fix --force`
Will install @discordjs/[email protected], which is a breaking change
node_modules/make-dir/node_modules/semver
make-dir 2.0.0 - 3.1.0
Depends on vulnerable versions of semver
node_modules/make-dir
@discordjs/node-pre-gyp >=0.3.1
Depends on vulnerable versions of make-dir
node_modules/@discordjs/node-pre-gyp
@discordjs/opus >=0.5.0
Depends on vulnerable versions of @discordjs/node-pre-gyp
node_modules/@discordjs/opus
prism-media 1.2.9 - 1.3.5
Depends on vulnerable versions of @discordjs/opus
node_modules/prism-media
@discordjs/voice >=0.2.0
Depends on vulnerable versions of prism-media
node_modules/@discordjs/voice

6 moderate severity vulnerabilities
so it seems there's some compatability error with discord opus and voice? it tries to get me to audit fix this
Morgan
Morgan2y ago
о
thechickenknight
thechickenknightOP2y ago
Will install @discordjs/[email protected], which is a breaking change so the problem is fixed as long as I have the latest voice version, but i constantly get severity vulnerabilities. Also my connection reciever immediately ends even if I continously play sound idk as in the buffer is empty okay i wrote that really wrong what i meant is that when i try to recieve audio with
const audio = connection.receiver.subscribe(msg.author.id, {
autoDestroy: false,
emitClose: false
});

let decoder = new prism.opus.Decoder({
channels: 2,
frameSize: 960,
rate: 48000
});

console.log(audio)
audio.pipe(decoder).pipe(exec('ffplay -').stdin);
console.log(Object.keys(audio._readableState))
const audio = connection.receiver.subscribe(msg.author.id, {
autoDestroy: false,
emitClose: false
});

let decoder = new prism.opus.Decoder({
channels: 2,
frameSize: 960,
rate: 48000
});

console.log(audio)
audio.pipe(decoder).pipe(exec('ffplay -').stdin);
console.log(Object.keys(audio._readableState))
I get a zero length buffer no matter if I constantly speak while I run the command or not thank you so much for all the help you've given me so far by the way
Want results from more Discord servers?
Add your server