Compare commits

..

No commits in common. "81f91df8ac9482cfc705cec917d9d6d1ad1116dd" and "f7e0c4b15a31969eceee4aba4417c145444b6b9d" have entirely different histories.

4 changed files with 65 additions and 146 deletions

View File

@ -52,7 +52,6 @@ mydb = mysql.connector.connect(
password=json_config["mysql_password"], password=json_config["mysql_password"],
database=json_config["mysql_db_name"] database=json_config["mysql_db_name"]
) )
mydb.autocommit = True
cursor = mydb.cursor() cursor = mydb.cursor()
@ -63,8 +62,6 @@ cursor.execute("SELECT call_start_time FROM call_states WHERE call_id = %s", [ar
call_start_time = cursor.fetchall() call_start_time = cursor.fetchall()
cursor.close()
if len(call_start_time) == 0: if len(call_start_time) == 0:
print('{call_id} does not exist in the database'.format(call_id=args.callid)) print('{call_id} does not exist in the database'.format(call_id=args.callid))
@ -126,7 +123,7 @@ for i in range(0, len(file_dict_items), args.filespercycle):
for j in range(i, next_endpoint, 1): for j in range(i, next_endpoint, 1):
filter_string = filter_string + "[a{inputid}]".format(inputid=j - i) filter_string = filter_string + "[a{inputid}]".format(inputid=j - i)
filter_string = filter_string + "amix=inputs={input_count}:normalize=0[a]\"".format(input_count = next_endpoint - i) filter_string = "amix=inputs={input_count}:normalize=0[a]\"".format(input_count = next_endpoint - i)
command_list.append(filter_string) command_list.append(filter_string)
command_list.append("-map") command_list.append("-map")
@ -142,8 +139,7 @@ for i in range(0, len(file_dict_items), args.filespercycle):
command_list.append(output_file_name) command_list.append(output_file_name)
ffmpeg_process = subprocess.Popen(' '.join(command_list), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) ffmpeg_process = subprocess.Popen(command_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print(ffmpeg_process.args)
stdout, stderr = ffmpeg_process.communicate() stdout, stderr = ffmpeg_process.communicate()
@ -164,7 +160,7 @@ final_command_list.append("-filter_complex")
filter_string = "\"" filter_string = "\""
for i in range(len(list_of_final_merges)): for i in range(len(list_of_final_merges)):
filter_string = filter_string + "[{inputid}]".format(inputid=i) filter_string = filter_string + "[a{inputid}]".format(inputid=i)
filter_string = filter_string + "amix=inputs={input_count}:normalize=0[a];[a]volume=3[boosted]\"".format(input_count=len(list_of_final_merges)) filter_string = filter_string + "amix=inputs={input_count}:normalize=0[a];[a]volume=3[boosted]\"".format(input_count=len(list_of_final_merges))
@ -173,7 +169,7 @@ final_command_list.append("-map")
final_command_list.append("\"[boosted]\"") final_command_list.append("\"[boosted]\"")
final_command_list.append(os.path.join(json_config["media_voice_folder"], args.callid, "output.mp3")) final_command_list.append(os.path.join(json_config["media_voice_folder"], args.callid, "output.mp3"))
final_command_process = subprocess.Popen(' '.join(final_command_list), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) final_command_process = subprocess.Popen(final_command_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = final_command_process.communicate() stdout, stderr = final_command_process.communicate()
if (final_command_process.returncode != 0): if (final_command_process.returncode != 0):
@ -191,11 +187,9 @@ transcribe = Transcription("openai/whisper-base")
for (k, v) in file_dict.items(): for (k, v) in file_dict.items():
text = transcribe(k) text = transcribe(k)
cursor = mydb.cursor()
cursor.execute("INSERT INTO call_transcriptions (call_id, user_snowflake, speaking_start_time, text) VALUES (%s, %s, %s, %s)", [ cursor.execute("INSERT INTO call_transcriptions (call_id, user_snowflake, speaking_start_time, text) VALUES (%s, %s, %s, %s)", [
args.callid, args.callid,
v["user"], v["user"],
v["real_date"], v["real_date"],
text text
]) ])
cursor.close()

View File

@ -59,9 +59,11 @@ getAllFiles('.' + path.sep + 'commands', [])
if ('enabled' in command && command.enabled && 'data' in command && 'execute' in command) { if ('enabled' in command && command.enabled && 'data' in command && 'execute' in command) {
client.commands.set(command.data.name, command); client.commands.set(command.data.name, command);
//console.log(`[INFO] Loaded command at ${file}`);
logger.info(`Loaded command at ${file}`) logger.info(`Loaded command at ${file}`)
} }
else { else {
//console.log(`[WARNING] The command at ${file} is missing a required "data" or "execute" property or is not enabled.`);
logger.warn(`The command at ${file} is missing a required "data" or "execute" property or is not enabled`) logger.warn(`The command at ${file} is missing a required "data" or "execute" property or is not enabled`)
} }
}); });
@ -72,6 +74,7 @@ client.on(Events.InteractionCreate, async interaction => {
const command = interaction.client.commands.get(interaction.commandName); const command = interaction.client.commands.get(interaction.commandName);
if (!command) { if (!command) {
//console.error(`No command matching ${interaction.commandName} was found.`);
logger.error(`No command matching ${interaction.commandName} was found`) logger.error(`No command matching ${interaction.commandName} was found`)
return; return;
} }
@ -80,6 +83,7 @@ client.on(Events.InteractionCreate, async interaction => {
await command.execute(interaction); await command.execute(interaction);
} }
catch (error) { catch (error) {
//console.error(error);
logger.error(error) logger.error(error)
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }); await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
} }
@ -87,12 +91,18 @@ client.on(Events.InteractionCreate, async interaction => {
client.on(Events.GuildCreate, async guild => { client.on(Events.GuildCreate, async guild => {
if (guild.available) { if (guild.available) {
//console.log('Got into a server')
//console.log(`The server name is ${guild.name}`)
//console.log(`The server description is ${guild.description}`)
//console.log(`The server snowflake is ${guild.id}`)
logger.info(`Got into a server, ${guild.name}, ${guild.id}, ${guild.description}`) logger.info(`Got into a server, ${guild.name}, ${guild.id}, ${guild.description}`)
sqlutil.registerServerIfMissing(guild.id, guild.name, guild.description).then(server_added => { sqlutil.registerServerIfMissing(guild.id, guild.name, guild.description).then(server_added => {
if(server_added) { if(server_added) {
//console.log(`Server Added ${guild.name}`)
logger.info(`Server Added ${guild.name}`) logger.info(`Server Added ${guild.name}`)
} else { } else {
//console.log(`Server failed to add ${guild.name}`)
logger.error(`Server failed to add ${guild.name}`) logger.error(`Server failed to add ${guild.name}`)
} }
}) })
@ -100,6 +110,7 @@ client.on(Events.GuildCreate, async guild => {
}) })
client.on(Events.VoiceStateUpdate, async (oldState, newState) => { client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
//console.log("Voice State Update Fired")
logger.info("Voice State Update Fired") logger.info("Voice State Update Fired")
if (oldState.channel == null && newState.channel != null) { if (oldState.channel == null && newState.channel != null) {
@ -107,23 +118,25 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
return //If the user is breadbot, ignore and exit return //If the user is breadbot, ignore and exit
} }
//console.log(`\tChannel Join Detected ${newState.guild.id} - ${newState.channelId} - ${newState.member.id}`)
logger.info(`Channel Join Detected ${newState.guild.id} - ${newState.channelId} - ${newState.member.id}`) logger.info(`Channel Join Detected ${newState.guild.id} - ${newState.channelId} - ${newState.member.id}`)
//TODO Nothing should happen after this if the channel fails to register
await sqlutil.registerChannelIfMissing(newState.channel.id, newState.guild.id, newState.channel.name)
var existingCallID = await sqlutil.inCall(newState.guild.id, newState.channelId) var existingCallID = await sqlutil.inCall(newState.guild.id, newState.channelId)
//console.log(`\tExisting call ID ${existingCallID}`)
logger.info(`Existing call ID ${existingCallID}`) logger.info(`Existing call ID ${existingCallID}`)
if (existingCallID == -1) { if (existingCallID == -1) {
//console.log("\tJoining a call")
logger.info("Joining a call") logger.info("Joining a call")
var newCallID = await sqlutil.registerNewCall(newState.guild.id, newState.channelId, new Date()) var newCallID = await sqlutil.registerNewCall(newState.guild.id, newState.channelId, new Date())
existingCallID = newCallID // To ensure all the stuff that happens after call creation works existingCallID = newCallID // To ensure all the stuff that happens after call creation works
//console.log(`\tNext call ID ${newCallID}`)
logger.info(`Next call ID ${newCallID}`) logger.info(`Next call ID ${newCallID}`)
// This should always have something to do, as all callIDs should be unique
fs.mkdirSync(media_voice_folder + path.sep + newCallID, {recursive: true}) fs.mkdirSync(media_voice_folder + path.sep + newCallID, {recursive: true})
const connection = joinVoiceChannel({ const connection = joinVoiceChannel({
@ -135,41 +148,37 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
}) })
try { try {
// What the hell does 20e3 mean, is that supposed to be sci notation?
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, {
if(!receiver.subscriptions.has(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`))
} else {
logger.warn(`Attempted to create new user subscriber for ${user_id} even though one already exists, receiver arm if statement protected against this`)
} }
}) })
.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) => {
} else { //console.log(`User ${user_id} stopped speaking`)
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") logger.info(`User ${user_id} stopped speaking`)
} })
} catch (error) { } catch (error) {
logger.error(error) logger.error(error)
//console.warn(error)
} }
} }
@ -179,9 +188,11 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
var markedUserInCall = await sqlutil.registerUserInCall(existingCallID, newState.member.id) var markedUserInCall = await sqlutil.registerUserInCall(existingCallID, newState.member.id)
if (!markedUserInCall) { if (!markedUserInCall) {
//console.log(`Something went wrong when marking user in voice call: ${newState.member.id} - ${newState.channelId}`)
logger.error(`Something went wrong when marking user in voice call: ${newState.member.id} - ${newState.channelId}`) logger.error(`Something went wrong when marking user in voice call: ${newState.member.id} - ${newState.channelId}`)
} }
} else { } else {
//console.log(`Something went wrong when registering user for call: ${newState.member.id} - ${newState.member.username}`)
logger.error(`Something went wrong when registering user for call: ${newState.member.id} - ${newState.member.username}`) logger.error(`Something went wrong when registering user for call: ${newState.member.id} - ${newState.member.username}`)
} }
} else if (oldState.channel != null && newState.channel == null) { } else if (oldState.channel != null && newState.channel == null) {
@ -189,10 +200,12 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
return //If the user is breadbot, ignore and exit return //If the user is breadbot, ignore and exit
} }
//console.log(`Channel Exit Detected ${oldState.guild.id} - ${oldState.channelId} - ${oldState.member.id}`)
logger.info(`Channel Exit Detected ${oldState.guild.id} - ${oldState.channelId} - ${oldState.member.id}`) logger.info(`Channel Exit Detected ${oldState.guild.id} - ${oldState.channelId} - ${oldState.member.id}`)
var existingCallID = await sqlutil.inCall(oldState.guild.id, oldState.channelId) var existingCallID = await sqlutil.inCall(oldState.guild.id, oldState.channelId)
//console.log(`Existing call ID: ${existingCallID}`)
logger.info(`Existing call ID ${existingCallID}`) logger.info(`Existing call ID ${existingCallID}`)
if (existingCallID != -1) { if (existingCallID != -1) {
@ -207,26 +220,33 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
var didUpdateEndTime = await sqlutil.updateCallEndTime(existingCallID, new Date()) var didUpdateEndTime = await sqlutil.updateCallEndTime(existingCallID, new Date())
if (!didUpdateEndTime) { if (!didUpdateEndTime) {
//console.log(`Failed to mark call id ${existingCallID} as ended with an end date`)
logger.error(`Failed to mark call ID ${existingCallID} as ended with an end date`) logger.error(`Failed to mark call ID ${existingCallID} as ended with an end date`)
} }
} }
} else { } else {
//console.log("Couldn't find a call ID based on the guild and channel info, was Breadbot in the call?")
logger.error("Couldn't find a call ID based on the guild and channel info, was Breadbot in the call?") logger.error("Couldn't find a call ID based on the guild and channel info, was Breadbot in the call?")
} }
} }
}) })
client.on(Events.MessageCreate, async message => { client.on(Events.MessageCreate, async message => {
//console.log("Message Create Fired")
console.info("Message Create Fired") console.info("Message Create Fired")
var channel_ok = await sqlutil.registerChannelIfMissing(message.channelId, message.channel.guild.id, message.channel.name) var channel_ok = await sqlutil.registerChannelIfMissing(message.channelId, message.channel.guild.id, message.channel.name)
var user_ok = await sqlutil.registerUserIfMissing(message.author.id, message.author.username, message.author.displayName) var user_ok = await sqlutil.registerUserIfMissing(message.author.id, message.author.username, message.author.displayName)
//console.log(`Channel OK? ${channel_ok}`)
//console.log(`User OK? ${user_ok}`)
logger.info(`Channel Ok? ${channel_ok} User OK? ${user_ok}`) logger.info(`Channel Ok? ${channel_ok} User OK? ${user_ok}`)
if (channel_ok && user_ok) { if (channel_ok && user_ok) {
await sqlutil.registerMessage(message.id, message.channelId, message.author.id, message.content, message.createdAt).then(async message_add => { await sqlutil.registerMessage(message.id, message.channelId, message.author.id, message.content, message.createdAt).then(async message_add => {
if(message_add) { if(message_add) {
//console.log("Message Added")
logger.info("Message Added") logger.info("Message Added")
if (message.attachments.size != 0) { if (message.attachments.size != 0) {
@ -241,10 +261,12 @@ client.on(Events.MessageCreate, async message => {
)) ))
await Promise.all(all_attachments).catch((error) => { await Promise.all(all_attachments).catch((error) => {
//console.log(error)
logger.error(error) logger.error(error)
}) })
} }
} else { } else {
//console.log("Failed to log message")
logger.error("Failed to log message") logger.error("Failed to log message")
} }
}) })
@ -252,6 +274,10 @@ client.on(Events.MessageCreate, async message => {
}) })
client.on(Events.MessageUpdate, async (oldMessage, newMessage) => { client.on(Events.MessageUpdate, async (oldMessage, newMessage) => {
//console.log("Message Update Fired")
//console.log(`Old Message Snowflake: ${oldMessage.id}`)
//console.log(`New Message Snowflake: ${newMessage.id}`)
logger.info("Message Update Fired") logger.info("Message Update Fired")
logger.info(`Old Message Snowflake: ${oldMessage.id} New Message Snowflake: ${newMessage.id}`) logger.info(`Old Message Snowflake: ${oldMessage.id} New Message Snowflake: ${newMessage.id}`)
@ -287,6 +313,7 @@ client.on(Events.MessageDelete, async deletedMessage => {
}) })
client.once(Events.ClientReady, c => { client.once(Events.ClientReady, c => {
//console.log(`Ready! Logged in as ${c.user.tag} - ${c.user.id}`);
logger.info(`Ready! Logged in as ${c.user.tag} - ${c.user.id}`) logger.info(`Ready! Logged in as ${c.user.tag} - ${c.user.id}`)
}); });

View File

@ -1,5 +1,5 @@
-- -------------------------------------------------------- -- --------------------------------------------------------
-- Host: 192.168.1.196 -- Host: 192.168.1.194
-- Server version: 8.0.33 - MySQL Community Server - GPL -- Server version: 8.0.33 - MySQL Community Server - GPL
-- Server OS: Linux -- Server OS: Linux
-- HeidiSQL Version: 12.5.0.6677 -- HeidiSQL Version: 12.5.0.6677
@ -19,55 +19,6 @@
CREATE DATABASE IF NOT EXISTS `breadbot_test` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */; CREATE DATABASE IF NOT EXISTS `breadbot_test` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `breadbot_test`; USE `breadbot_test`;
-- Dumping structure for table breadbot_test.call_states
CREATE TABLE IF NOT EXISTS `call_states` (
`call_id` int NOT NULL AUTO_INCREMENT,
`server_snowflake` bigint unsigned NOT NULL,
`channel_snowflake` bigint unsigned NOT NULL,
`call_start_time` datetime NOT NULL,
`call_end_time` datetime DEFAULT NULL,
`call_consolidated` bit(1) NOT NULL DEFAULT (0),
`call_transcribed` bit(1) NOT NULL DEFAULT (0),
`call_data_cleaned_up` bit(1) NOT NULL DEFAULT (0),
PRIMARY KEY (`call_id`),
KEY `fk_snowflake_recording_to_server` (`server_snowflake`),
KEY `fk_snowflake_recording_to_channel` (`channel_snowflake`),
CONSTRAINT `fk_snowflake_recording_to_channel` FOREIGN KEY (`channel_snowflake`) REFERENCES `channels` (`channel_snowflake`) ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT `fk_snowflake_recording_to_server` FOREIGN KEY (`server_snowflake`) REFERENCES `servers` (`server_snowflake`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- Data exporting was unselected.
-- Dumping structure for table breadbot_test.call_transcriptions
CREATE TABLE IF NOT EXISTS `call_transcriptions` (
`transcription_id` int NOT NULL AUTO_INCREMENT,
`call_id` int NOT NULL,
`user_snowflake` bigint unsigned NOT NULL,
`speaking_start_time` datetime NOT NULL,
`text` longtext NOT NULL,
PRIMARY KEY (`transcription_id`),
KEY `fk_call_id_states_to_transcriptions` (`call_id`),
KEY `fk_snowflake_call_states_to_users` (`user_snowflake`),
CONSTRAINT `fk_call_id_states_to_transcriptions` FOREIGN KEY (`call_id`) REFERENCES `call_states` (`call_id`) ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT `fk_snowflake_call_states_to_users` FOREIGN KEY (`user_snowflake`) REFERENCES `users` (`user_snowflake`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- Data exporting was unselected.
-- Dumping structure for table breadbot_test.call_users
CREATE TABLE IF NOT EXISTS `call_users` (
`call_users_id` int NOT NULL AUTO_INCREMENT,
`call_id` int NOT NULL,
`user_snowflake` bigint unsigned NOT NULL,
PRIMARY KEY (`call_users_id`) USING BTREE,
KEY `fk_call_id_call_user_to_state` (`call_id`),
KEY `fk_snowflake_call_user_to_users` (`user_snowflake`),
CONSTRAINT `fk_call_id_call_user_to_state` FOREIGN KEY (`call_id`) REFERENCES `call_states` (`call_id`) ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT `fk_snowflake_call_user_to_users` FOREIGN KEY (`user_snowflake`) REFERENCES `users` (`user_snowflake`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- Data exporting was unselected.
-- Dumping structure for table breadbot_test.channels -- Dumping structure for table breadbot_test.channels
CREATE TABLE IF NOT EXISTS `channels` ( CREATE TABLE IF NOT EXISTS `channels` (
`channel_snowflake` bigint unsigned NOT NULL, `channel_snowflake` bigint unsigned NOT NULL,
@ -87,6 +38,7 @@ CREATE TABLE IF NOT EXISTS `messages` (
`user_snowflake` bigint unsigned NOT NULL, `user_snowflake` bigint unsigned NOT NULL,
`message_content` text NOT NULL, `message_content` text NOT NULL,
`message_timestamp` datetime NOT NULL, `message_timestamp` datetime NOT NULL,
`message_edited` bit(1) NOT NULL DEFAULT (0),
`message_deleted` bit(1) NOT NULL DEFAULT (0), `message_deleted` bit(1) NOT NULL DEFAULT (0),
PRIMARY KEY (`message_snowflake`), PRIMARY KEY (`message_snowflake`),
KEY `fk_snowflake_message_to_channel` (`channel_snowflake`), KEY `fk_snowflake_message_to_channel` (`channel_snowflake`),
@ -97,36 +49,6 @@ CREATE TABLE IF NOT EXISTS `messages` (
-- Data exporting was unselected. -- Data exporting was unselected.
-- Dumping structure for table breadbot_test.message_attachments
CREATE TABLE IF NOT EXISTS `message_attachments` (
`attachment_snowflake` bigint unsigned NOT NULL,
`message_snowflake` bigint unsigned NOT NULL DEFAULT (0),
`attachment_name` text NOT NULL,
`attachment_description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci,
`attachment_timestamp` datetime NOT NULL,
`attachment_mime_type` tinytext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci,
`attachment_url` text NOT NULL,
`attachment_downloaded` bit(1) NOT NULL DEFAULT (0),
PRIMARY KEY (`attachment_snowflake`) USING BTREE,
KEY `fk_snowflake_messages_to_attachments` (`message_snowflake`),
CONSTRAINT `fk_snowflake_messages_to_attachments` FOREIGN KEY (`message_snowflake`) REFERENCES `messages` (`message_snowflake`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- Data exporting was unselected.
-- Dumping structure for table breadbot_test.message_content_changes
CREATE TABLE IF NOT EXISTS `message_content_changes` (
`message_change_id` int unsigned NOT NULL AUTO_INCREMENT,
`message_snowflake` bigint unsigned NOT NULL,
`message_change_old_timestamp` datetime NOT NULL,
`message_change_old_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
PRIMARY KEY (`message_change_id`),
KEY `fk_snowflake_message_to_message_changes` (`message_snowflake`),
CONSTRAINT `fk_snowflake_message_to_message_changes` FOREIGN KEY (`message_snowflake`) REFERENCES `messages` (`message_snowflake`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- Data exporting was unselected.
-- Dumping structure for table breadbot_test.servers -- Dumping structure for table breadbot_test.servers
CREATE TABLE IF NOT EXISTS `servers` ( CREATE TABLE IF NOT EXISTS `servers` (
`server_snowflake` bigint unsigned NOT NULL, `server_snowflake` bigint unsigned NOT NULL,
@ -147,30 +69,6 @@ CREATE TABLE IF NOT EXISTS `users` (
-- Data exporting was unselected. -- Data exporting was unselected.
-- Dumping structure for table breadbot_test.winston_breadbot
CREATE TABLE IF NOT EXISTS `winston_breadbot` (
`id` int NOT NULL AUTO_INCREMENT,
`level` varchar(16) NOT NULL,
`message` varchar(2048) NOT NULL,
`meta` varchar(2048) NOT NULL,
`timestamp` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- Data exporting was unselected.
-- Dumping structure for table breadbot_test.winston_sqlutil
CREATE TABLE IF NOT EXISTS `winston_sqlutil` (
`id` int NOT NULL AUTO_INCREMENT,
`level` varchar(16) NOT NULL,
`message` varchar(2048) NOT NULL,
`meta` varchar(2048) NOT NULL,
`timestamp` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- Data exporting was unselected.
/*!40103 SET TIME_ZONE=IFNULL(@OLD_TIME_ZONE, 'system') */; /*!40103 SET TIME_ZONE=IFNULL(@OLD_TIME_ZONE, 'system') */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */; /*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;

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 (typeof rows.insertId === 'undefined') { if (rows.length == 0) {
return -1; return -1;
} else { } else {
return rows.insertId return rows.insertId