Adding another protection to try to avoid multiple recordings of the same audio happening
This commit is contained in:
parent
6012351b3e
commit
6c6c2655f2
@ -137,6 +137,7 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
|
||||
|
||||
if (receiver.speaking.listenerCount("start") == 0) {
|
||||
receiver.speaking.on("start", (user_id) => {
|
||||
if(!receiver.subscriptions.has(user_id)) {
|
||||
receiver.subscribe(user_id, {
|
||||
end: {
|
||||
behavior: EndBehaviorType.AfterSilence,
|
||||
@ -153,14 +154,16 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
|
||||
}
|
||||
}))
|
||||
.pipe(fs.createWriteStream(media_voice_folder + path.sep + newCallID + path.sep + `${Date.now()}-${user_id}.ogg`))
|
||||
|
||||
} else {
|
||||
logger.warn(`Attempted to create new user subscriber for ${user_id} even though one already exists, receiver arm if statement protected against this`)
|
||||
}
|
||||
})
|
||||
|
||||
receiver.speaking.on("end", (user_id) => {
|
||||
logger.info(`User ${user_id} stopped speaking`)
|
||||
})
|
||||
} else {
|
||||
logger.info("Attempted to create a new start and end listener for users who are speaking for some reason, receiver armor if statement protected against this")
|
||||
logger.warn("Attempted to create a new start and end listener for users who are speaking for some reason, receiver armor if statement protected against this")
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(error)
|
||||
|
Loading…
Reference in New Issue
Block a user