feat: enhance voice connection testing with better timeout handling
- Add 45s manual timeout for connection testing - Add Promise.race for better timeout control - Enhanced error reporting with connection timing - Better disconnect handling in test command - More detailed connection success information
This commit is contained in:
parent
c5cf8f0488
commit
603032f1db
2 changed files with 33 additions and 10 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit 5014823f695ddefdeba332450a59dfbc23b98b1b
|
||||
Subproject commit 174c89f18e2171461d838b0c1586acbabb9be7e1
|
||||
|
|
@ -412,11 +412,13 @@ class CommandHandler {
|
|||
return null;
|
||||
}
|
||||
|
||||
msg.channel.send("🔧 Testing voice server connectivity...");
|
||||
msg.channel.send("🔧 Testing basic voice server connectivity...");
|
||||
|
||||
try {
|
||||
const testStart = Date.now();
|
||||
const connection = await context.client.voice.joinChannel(
|
||||
|
||||
// Simple connection test with timeout promise
|
||||
const connectionPromise = context.client.voice.joinChannel(
|
||||
voiceChannel.id,
|
||||
{
|
||||
selfMute: true,
|
||||
|
|
@ -425,20 +427,40 @@ class CommandHandler {
|
|||
}
|
||||
);
|
||||
|
||||
const timeoutPromise = new Promise((_, reject) => {
|
||||
setTimeout(
|
||||
() => reject(new Error("Manual timeout after 45 seconds")),
|
||||
45000
|
||||
);
|
||||
});
|
||||
|
||||
const connection = await Promise.race([
|
||||
connectionPromise,
|
||||
timeoutPromise,
|
||||
]);
|
||||
const connectTime = Date.now() - testStart;
|
||||
|
||||
msg.channel.send(
|
||||
`✅ Voice connection successful!\n` +
|
||||
`• Connect time: ${connectTime}ms\n` +
|
||||
`• Voice server: ${connection.voiceServerURL || "Unknown"}\n` +
|
||||
`• Status: ${connection.status}\n` +
|
||||
`• Channel: ${voiceChannel.name}`
|
||||
`• Channel: ${voiceChannel.name}\n` +
|
||||
`• Authentication: ${
|
||||
connection.authentication ? "Ready" : "Pending"
|
||||
}`
|
||||
);
|
||||
|
||||
// Disconnect after test
|
||||
setTimeout(() => {
|
||||
connection.disconnect();
|
||||
}, 2000);
|
||||
try {
|
||||
connection.disconnect();
|
||||
} catch (e) {
|
||||
console.log(
|
||||
"[Docker] Error disconnecting test connection:",
|
||||
e.message
|
||||
);
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
return {
|
||||
action: {
|
||||
|
|
@ -448,11 +470,12 @@ class CommandHandler {
|
|||
},
|
||||
};
|
||||
} catch (error) {
|
||||
const connectTime = Date.now() - testStart;
|
||||
msg.channel.send(
|
||||
`❌ Voice connection failed!\n` +
|
||||
`❌ Voice connection failed after ${connectTime}ms!\n` +
|
||||
`• Error: ${error.message}\n` +
|
||||
`• This may indicate Discord voice server issues\n` +
|
||||
`• Try again in a few minutes`
|
||||
`• This indicates Discord voice server or network issues\n` +
|
||||
`• Try switching voice channels or try again later`
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Reference in a new issue