Cleanup, database structure backup, and an additional log item for breadmixer to try to figure out where the ffmpeg command structure is wrong

This commit is contained in:
Bradley Bickford 2024-01-05 18:51:11 -05:00
parent f7e0c4b15a
commit 3b33bb6ee4
3 changed files with 106 additions and 39 deletions

View File

@ -139,6 +139,8 @@ for i in range(0, len(file_dict_items), args.filespercycle):
command_list.append(output_file_name)
print(' '.join(command_list))
ffmpeg_process = subprocess.Popen(command_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = ffmpeg_process.communicate()

View File

@ -59,11 +59,9 @@ getAllFiles('.' + path.sep + 'commands', [])
if ('enabled' in command && command.enabled && 'data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
//console.log(`[INFO] Loaded command at ${file}`);
logger.info(`Loaded command at ${file}`)
}
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`)
}
});
@ -74,7 +72,6 @@ client.on(Events.InteractionCreate, async interaction => {
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
//console.error(`No command matching ${interaction.commandName} was found.`);
logger.error(`No command matching ${interaction.commandName} was found`)
return;
}
@ -83,7 +80,6 @@ client.on(Events.InteractionCreate, async interaction => {
await command.execute(interaction);
}
catch (error) {
//console.error(error);
logger.error(error)
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
@ -91,18 +87,12 @@ client.on(Events.InteractionCreate, async interaction => {
client.on(Events.GuildCreate, async guild => {
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}`)
sqlutil.registerServerIfMissing(guild.id, guild.name, guild.description).then(server_added => {
if(server_added) {
//console.log(`Server Added ${guild.name}`)
logger.info(`Server Added ${guild.name}`)
} else {
//console.log(`Server failed to add ${guild.name}`)
logger.error(`Server failed to add ${guild.name}`)
}
})
@ -110,7 +100,6 @@ client.on(Events.GuildCreate, async guild => {
})
client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
//console.log("Voice State Update Fired")
logger.info("Voice State Update Fired")
if (oldState.channel == null && newState.channel != null) {
@ -118,25 +107,20 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
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}`)
var existingCallID = await sqlutil.inCall(newState.guild.id, newState.channelId)
//console.log(`\tExisting call ID ${existingCallID}`)
logger.info(`Existing call ID ${existingCallID}`)
if (existingCallID == -1) {
//console.log("\tJoining a call")
logger.info("Joining a call")
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
//console.log(`\tNext 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})
const connection = joinVoiceChannel({
@ -148,7 +132,6 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
})
try {
// What the hell does 20e3 mean, is that supposed to be sci notation?
await entersState(connection, VoiceConnectionStatus.Ready, 20e3)
const receiver = connection.receiver
@ -173,12 +156,10 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
})
receiver.speaking.on("end", (user_id) => {
//console.log(`User ${user_id} stopped speaking`)
logger.info(`User ${user_id} stopped speaking`)
})
} catch (error) {
logger.error(error)
//console.warn(error)
}
}
@ -188,11 +169,9 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
var markedUserInCall = await sqlutil.registerUserInCall(existingCallID, newState.member.id)
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}`)
}
} 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}`)
}
} else if (oldState.channel != null && newState.channel == null) {
@ -200,12 +179,10 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
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}`)
var existingCallID = await sqlutil.inCall(oldState.guild.id, oldState.channelId)
//console.log(`Existing call ID: ${existingCallID}`)
logger.info(`Existing call ID ${existingCallID}`)
if (existingCallID != -1) {
@ -220,33 +197,26 @@ client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
var didUpdateEndTime = await sqlutil.updateCallEndTime(existingCallID, new Date())
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`)
}
}
} 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?")
}
}
})
client.on(Events.MessageCreate, async message => {
//console.log("Message Create Fired")
console.info("Message Create Fired")
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)
//console.log(`Channel OK? ${channel_ok}`)
//console.log(`User OK? ${user_ok}`)
logger.info(`Channel Ok? ${channel_ok} User 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 => {
if(message_add) {
//console.log("Message Added")
logger.info("Message Added")
if (message.attachments.size != 0) {
@ -261,12 +231,10 @@ client.on(Events.MessageCreate, async message => {
))
await Promise.all(all_attachments).catch((error) => {
//console.log(error)
logger.error(error)
})
}
} else {
//console.log("Failed to log message")
logger.error("Failed to log message")
}
})
@ -274,10 +242,6 @@ client.on(Events.MessageCreate, async message => {
})
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(`Old Message Snowflake: ${oldMessage.id} New Message Snowflake: ${newMessage.id}`)
@ -313,7 +277,6 @@ client.on(Events.MessageDelete, async deletedMessage => {
})
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}`)
});

View File

@ -1,5 +1,5 @@
-- --------------------------------------------------------
-- Host: 192.168.1.194
-- Host: 192.168.1.196
-- Server version: 8.0.33 - MySQL Community Server - GPL
-- Server OS: Linux
-- HeidiSQL Version: 12.5.0.6677
@ -19,6 +19,55 @@
CREATE DATABASE IF NOT EXISTS `breadbot_test` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
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
CREATE TABLE IF NOT EXISTS `channels` (
`channel_snowflake` bigint unsigned NOT NULL,
@ -38,7 +87,6 @@ CREATE TABLE IF NOT EXISTS `messages` (
`user_snowflake` bigint unsigned NOT NULL,
`message_content` text NOT NULL,
`message_timestamp` datetime NOT NULL,
`message_edited` bit(1) NOT NULL DEFAULT (0),
`message_deleted` bit(1) NOT NULL DEFAULT (0),
PRIMARY KEY (`message_snowflake`),
KEY `fk_snowflake_message_to_channel` (`channel_snowflake`),
@ -49,6 +97,36 @@ CREATE TABLE IF NOT EXISTS `messages` (
-- 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
CREATE TABLE IF NOT EXISTS `servers` (
`server_snowflake` bigint unsigned NOT NULL,
@ -69,6 +147,30 @@ CREATE TABLE IF NOT EXISTS `users` (
-- 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') */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;