diff --git a/package.json b/package.json index cfb6c9a..5d5b8be 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,12 @@ "dependencies": { "discord.js": "^14.20.0", "dotenv": "^16.5.0", - "sqlite3": "^5.1.7" + "sqlite3": "^5.1.7", + "@discordjs/opus": "^0.9.0", + "@discordjs/voice": "^0.16.0", + "libsodium-wrappers": "^0.7.13", + "node-crc": "1.3.2", + "prism-media": "^2.0.0-alpha.0" }, "devDependencies": { "tsup": "^8.5.0", diff --git a/src/breadbot.ts b/src/breadbot.ts index 064332a..ce926f2 100644 --- a/src/breadbot.ts +++ b/src/breadbot.ts @@ -9,7 +9,8 @@ export const client : Client = new Client({ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMembers, - GatewayIntentBits.MessageContent + GatewayIntentBits.MessageContent, + GatewayIntentBits.GuildVoiceStates ] }) diff --git a/src/utilties/discord/channels.ts b/src/utilties/discord/channels.ts index d543cc1..524f386 100644 --- a/src/utilties/discord/channels.ts +++ b/src/utilties/discord/channels.ts @@ -30,17 +30,16 @@ export async function insertChannel(db: SQLCommon, channel: GuildBasedChannel | try { if (channel.isDMBased()) { await db.runParameterized( - "INSERT INTO channels VALUES (?, ?, ?, ?, ?)", - [channel.id, null, channel.recipient?.username, channel.isThread(), channel.isDMBased()] + "INSERT INTO channels VALUES (?, ?, ?, ?, ?, ?)", + [channel.id, null, channel.recipient?.username, channel.isThread(), channel.isDMBased(), channel.isVoiceBased()] ) } else { await db.runParameterized( - "INSERT INTO channels VALUES (?, ?, ?, ?, ?)", - [channel.id, channel.guild.id, channel.name, channel.isThread(), channel.isDMBased()] + "INSERT INTO channels VALUES (?, ?, ?, ?, ?, ?)", + [channel.id, channel.guild.id, channel.name, channel.isThread(), channel.isDMBased(), channel.isVoiceBased()] ) } - return SQLResult.CREATED } catch (err) { //TODO Winston should handle this diff --git a/src/utilties/discord/voice.ts b/src/utilties/discord/voice.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/utilties/events/voice.ts b/src/utilties/events/voice.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/utilties/storage/tables.ts b/src/utilties/storage/tables.ts index e62a2c8..a3e1869 100644 --- a/src/utilties/storage/tables.ts +++ b/src/utilties/storage/tables.ts @@ -2,7 +2,7 @@ import { SQLCommon } from "./interfaces"; const tables: string[] = [ "CREATE TABLE IF NOT EXISTS servers (server_snowflake bigint NOT NULL PRIMARY KEY,server_name text NOT NULL,server_description mediumtext);", - "CREATE TABLE IF NOT EXISTS channels (channel_snowflake bigint NOT NULL PRIMARY KEY,server_snowflake bigint,channel_name text,is_thread bit NOT NULL,is_dm bit NOT NULL);", + "CREATE TABLE IF NOT EXISTS channels (channel_snowflake bigint NOT NULL PRIMARY KEY,server_snowflake bigint,channel_name text,is_thread bit NOT NULL,is_dm bit NOT NULL,is_voice bit NOT NULL);", "CREATE TABLE IF NOT EXISTS users (user_snowflake bigint NOT NULL PRIMARY KEY,user_name text NOT NULL,user_displayname text);", "CREATE TABLE IF NOT EXISTS messages (message_snowflake bigint NOT NULL PRIMARY KEY,channel_snowflake bigint NOT NULL,user_snowflake bigint NOT NULL,message_content longtext NOT NULL,message_timestamp datetime NOT NULL,message_deleted bit NOT NULL);", "CREATE TABLE IF NOT EXISTS message_content_changes (message_change_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,message_snowflake bigint NOT NULL,message_change_old_timestamp datetime NOT NULL,message_change_old_content longtext NOT NULL);", @@ -12,7 +12,10 @@ const tables: string[] = [ "CREATE TABLE IF NOT EXISTS message_scan_regex_matches (message_scan_regex_matches_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,message_snowflake bigint NOT NULL,message_regexes_id bigint NOT NULL);", "CREATE TABLE IF NOT EXISTS message_regex_no_role_check (message_regex_no_role_check_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,server_snowflake bigint NOT NULL,role_snowflake bigint NOT NULL);", "CREATE TABLE IF NOT EXISTS message_regexes (message_regexes_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,server_snowflake bigint NOT NULL,regex text NOT NULL,priority int NOT NULL,severity int NOT NULL);", - "CREATE TABLE IF NOT EXISTS message_regex_words (message_regex_words_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,message_regexes_id bigint,word text NOT NULL);" + "CREATE TABLE IF NOT EXISTS message_regex_words (message_regex_words_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,message_regexes_id bigint,word text NOT NULL);", + "CREATE TABLE IF NOT EXISTS calls (call_id bigint NOT NULL PRIMARY KEY AUTOINCREMENT, channel_snowflake bigint NOT NULL, call_start_time datetime NOT NULL, call_end_time datetime DEFAULT NULL, call_consolidated INTEGER DEFAULT 0 CHECK(call_consolidated IN (0, 1)), call_transcribed INTEGER DEFAULT 0 CHECK(call_transcribed IN (0, 1)), call_data_cleaned_up INTEGER DEFAULT 0 CHECK(call_data_cleaned_up IN (0, 1)));", + "CREATE TABLE IF NOT EXISTS call_transcriptions (transcription_id bitint NOT NULL PRIMARY KEY AUTOINCREMENT, call_id bigint NOT NULL, user_snowflake bigint NOT NULL, speaking_start_time datetime NOT NULL, text TEXT NOT NULL);", + "CREATE TABLE IF NOT EXISTS call_users (call_users_id bigint NOT NULL PRIMARY KEY AUTOINCREMENT, call_id bigint NOT NULL, user_snowflake bigint NOT NULL, call_join_time datetime NOT NULL, call_leave_time datetime DEFAULT NULL);" ] const constraints: string[] = [