AlexInCube
AlexInCube
DIAdiscord.js - Imagine an app
Created by AlexInCube on 4/19/2023 in #djs-questions
Random disconnect from websocket
I have periodically reconnecting to websocket every 1-2 hours and I do not know how to fix it. I thought it was my internet problem and I ended up moving the bot to Microsoft Azure and it has the same problem. These disconnects disturb me, because it stops the audio player
15 replies
DIAdiscord.js - Imagine an app
Created by AlexInCube on 4/17/2023 in #djs-voice
Problem with reconnecting to voice channel and resuming of audio.
My internet connection is not stable and when lag spike is appear, i catch the disconnect from Websocket (i listen ShardDisconnect, ShardResume events). So i want to make "reconnect" when ShardResume is triggered. This code i use when iterate through all existing players. But i am stucking in signalling state and i dont know why
const voice = Audio.distube.voices.get(player.textChannel.guild)
const connection = getVoiceConnection(player.textChannel.guild.id, player.textChannel.guild.client.user.id)
if (!voice) return
loggerSend(`Status: ${connection?.state.status}`)
if (!connection) return

connection.once('stateChange', (oldState, newState) => {
loggerSend(`OldState: ${oldState.status}, NewState: ${newState.status}`)
if (!connection) return
if (newState.status === VoiceConnectionStatus.Ready) {
connection.configureNetworking()
loggerSend(connection.state.status)
const VoicePlayer = voice.audioPlayer

loggerSend("subscribe audioplayer")
connection.subscribe(VoicePlayer)

const audioRes = voice.audioResource
if (audioRes){
VoicePlayer.unpause()
loggerSend("player audioResource")
VoicePlayer.play(audioRes)
}
}
})

setTimeout(() => {
if (voice.channel.joinable){
loggerSend("Try to rejoin")
connection?.rejoin()
}

// connection = joinVoiceChannel({
// channelId: voice.channel.id,
// guildId: player.textChannel.guild.id,
// adapterCreator: player.textChannel.guild.voiceAdapterCreator
// })

loggerSend(`Status After Join: ${connection?.state.status}, Channel ${voice.channel.id}`)
}, 2000)
const voice = Audio.distube.voices.get(player.textChannel.guild)
const connection = getVoiceConnection(player.textChannel.guild.id, player.textChannel.guild.client.user.id)
if (!voice) return
loggerSend(`Status: ${connection?.state.status}`)
if (!connection) return

connection.once('stateChange', (oldState, newState) => {
loggerSend(`OldState: ${oldState.status}, NewState: ${newState.status}`)
if (!connection) return
if (newState.status === VoiceConnectionStatus.Ready) {
connection.configureNetworking()
loggerSend(connection.state.status)
const VoicePlayer = voice.audioPlayer

loggerSend("subscribe audioplayer")
connection.subscribe(VoicePlayer)

const audioRes = voice.audioResource
if (audioRes){
VoicePlayer.unpause()
loggerSend("player audioResource")
VoicePlayer.play(audioRes)
}
}
})

setTimeout(() => {
if (voice.channel.joinable){
loggerSend("Try to rejoin")
connection?.rejoin()
}

// connection = joinVoiceChannel({
// channelId: voice.channel.id,
// guildId: player.textChannel.guild.id,
// adapterCreator: player.textChannel.guild.voiceAdapterCreator
// })

loggerSend(`Status After Join: ${connection?.state.status}, Channel ${voice.channel.id}`)
}, 2000)
3 replies
DIAdiscord.js - Imagine an app
Created by AlexInCube on 3/30/2023 in #djs-questions
How can I prevent the messageDelete event from emitting if the bot deletes the message?
I dont want emit the messageDelete when i use message.delete()
23 replies
DIAdiscord.js - Imagine an app
Created by AlexInCube on 8/22/2022 in #djs-voice
VoiceConnection always return undefined on discord.js V14
3 replies