Attempting to protect against call echo AND fix new call registry which wasn't working correctly it seems...
This commit is contained in:
parent
934fa4d37f
commit
6012351b3e
46
breadbot.js
46
breadbot.js
@ -135,29 +135,33 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
|
|||||||
await entersState(connection, VoiceConnectionStatus.Ready, 20e3)
|
await entersState(connection, VoiceConnectionStatus.Ready, 20e3)
|
||||||
const receiver = connection.receiver
|
const receiver = connection.receiver
|
||||||
|
|
||||||
receiver.speaking.on("start", (user_id) => {
|
if (receiver.speaking.listenerCount("start") == 0) {
|
||||||
receiver.subscribe(user_id, {
|
receiver.speaking.on("start", (user_id) => {
|
||||||
end: {
|
receiver.subscribe(user_id, {
|
||||||
behavior: EndBehaviorType.AfterSilence,
|
end: {
|
||||||
duration: 500
|
behavior: EndBehaviorType.AfterSilence,
|
||||||
}
|
duration: 500
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.pipe(new prism.opus.OggLogicalBitstream({
|
||||||
|
opusHead: new prism.opus.OpusHead({
|
||||||
|
channelCount: 2,
|
||||||
|
sampleRate: 48000
|
||||||
|
}),
|
||||||
|
pageSizeControl: {
|
||||||
|
maxPackets: 10
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.pipe(fs.createWriteStream(media_voice_folder + path.sep + newCallID + path.sep + `${Date.now()}-${user_id}.ogg`))
|
||||||
|
|
||||||
})
|
})
|
||||||
.pipe(new prism.opus.OggLogicalBitstream({
|
|
||||||
opusHead: new prism.opus.OpusHead({
|
|
||||||
channelCount: 2,
|
|
||||||
sampleRate: 48000
|
|
||||||
}),
|
|
||||||
pageSizeControl: {
|
|
||||||
maxPackets: 10
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
.pipe(fs.createWriteStream(media_voice_folder + path.sep + newCallID + path.sep + `${Date.now()}-${user_id}.ogg`))
|
|
||||||
|
|
||||||
})
|
receiver.speaking.on("end", (user_id) => {
|
||||||
|
logger.info(`User ${user_id} stopped speaking`)
|
||||||
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")
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error)
|
logger.error(error)
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ async function inCall(server_snowflake, channel_snowflake) {
|
|||||||
|
|
||||||
async function registerNewCall(server_snowflake, channel_snowflake, call_start_time) {
|
async function registerNewCall(server_snowflake, channel_snowflake, call_start_time) {
|
||||||
return connection_pool.query("INSERT INTO call_states (server_snowflake, channel_snowflake, call_start_time, call_end_time, call_consolidated, call_transcribed, call_data_cleaned_up) VALUES (?, ?, ?, NULL, 0, 0, 0)", [server_snowflake, channel_snowflake, call_start_time]).then(async ([rows, fields]) => {
|
return connection_pool.query("INSERT INTO call_states (server_snowflake, channel_snowflake, call_start_time, call_end_time, call_consolidated, call_transcribed, call_data_cleaned_up) VALUES (?, ?, ?, NULL, 0, 0, 0)", [server_snowflake, channel_snowflake, call_start_time]).then(async ([rows, fields]) => {
|
||||||
if (rows.length == 0) {
|
if (typeof rows.insertId === 'undefined') {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return rows.insertId
|
return rows.insertId
|
||||||
|
Loading…
Reference in New Issue
Block a user