Attempting to protect against call echo AND fix new call registry which wasn't working correctly it seems...

This commit is contained in:
Bradley Bickford 2024-01-07 15:30:15 -05:00
parent 934fa4d37f
commit 6012351b3e
2 changed files with 27 additions and 23 deletions

View File

@ -135,6 +135,7 @@ 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
if (receiver.speaking.listenerCount("start") == 0) {
receiver.speaking.on("start", (user_id) => { receiver.speaking.on("start", (user_id) => {
receiver.subscribe(user_id, { receiver.subscribe(user_id, {
end: { end: {
@ -158,6 +159,9 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
receiver.speaking.on("end", (user_id) => { receiver.speaking.on("end", (user_id) => {
logger.info(`User ${user_id} stopped speaking`) 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)
} }

View File

@ -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