From 2c092d8e1b8778be11fdde8c8e3ae5987f10b5e3 Mon Sep 17 00:00:00 2001 From: xToxette Date: Mon, 30 Oct 2023 22:10:45 +0100 Subject: [PATCH] Made progress adding songbird to the stack --- Cargo.lock | 53 ++++++++++++++-------------- Cargo.toml | 3 +- src/dal/events/voice_state_update.rs | 12 +++---- src/main.rs | 13 ++++--- 4 files changed, 44 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1946ee0..966acf7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -179,6 +179,7 @@ version = "0.1.0" dependencies = [ "dotenv", "env_logger", + "log", "poise", "songbird", "sqlx", @@ -1528,9 +1529,9 @@ dependencies = [ [[package]] name = "poise" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "649248bcf202ebd1fe3202a7eaf2f705466c92f8d32a644ef565d9221e3ff6f1" +checksum = "d104e4b5847283b2fbd6a7ec19fb6a8af328e2145623d056b66d750a30073fdf" dependencies = [ "async-trait", "derivative", @@ -1541,15 +1542,15 @@ dependencies = [ "parking_lot", "poise_macros", "regex", - "serenity 0.11.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serenity 0.11.7", "tokio", ] [[package]] name = "poise_macros" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05960fe87728cef0533d13f8ead89da228f5eb7840bee5602eeaa8db150084a0" +checksum = "4fb516a8cf4e4ae4bd7ef5819d08c6ca408976461a9bea3ee3eec5138ac070c1" dependencies = [ "darling", "proc-macro2", @@ -2093,58 +2094,58 @@ dependencies = [ [[package]] name = "serenity" version = "0.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d007dc45584ecc47e791f2a9a7cf17bf98ac386728106f111159c846d624be3f" +source = "git+https://github.com/serenity-rs/serenity?branch=next#136330ada75c6988cfd6813dccc3fb78542cd389" dependencies = [ + "arrayvec", "async-trait", - "async-tungstenite", - "base64 0.13.1", - "bitflags 1.3.2", + "base64 0.21.4", + "bitflags 2.4.1", "bytes", - "cfg-if", - "chrono", - "dashmap", "flate2", "futures", - "mime", "mime_guess", - "parking_lot", "percent-encoding", "reqwest", - "rustversion", + "secrecy", "serde", - "serde-value", "serde_json", "time", "tokio", + "tokio-tungstenite 0.20.1", "tracing", - "typemap_rev 0.1.5", + "typemap_rev 0.3.0", "url", ] [[package]] name = "serenity" -version = "0.11.6" -source = "git+https://github.com/serenity-rs/serenity?branch=next#136330ada75c6988cfd6813dccc3fb78542cd389" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a7a89cef23483fc9d4caf2df41e6d3928e18aada84c56abd237439d929622c6" dependencies = [ - "arrayvec", "async-trait", + "async-tungstenite", "base64 0.21.4", - "bitflags 2.4.1", + "bitflags 1.3.2", "bytes", + "cfg-if", + "chrono", + "dashmap", "flate2", "futures", + "mime", "mime_guess", + "parking_lot", "percent-encoding", "reqwest", - "secrecy", + "rustversion", "serde", + "serde-value", "serde_json", "time", "tokio", - "tokio-tungstenite 0.20.1", "tracing", - "typemap_rev 0.3.0", + "typemap_rev 0.1.5", "url", ] @@ -2282,7 +2283,7 @@ dependencies = [ "serde", "serde-aux", "serde_json", - "serenity 0.11.6 (git+https://github.com/serenity-rs/serenity?branch=next)", + "serenity 0.11.6", "serenity-voice-model", "socket2 0.5.4", "streamcatcher", diff --git a/Cargo.toml b/Cargo.toml index e664ec9..6ba7b49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,8 +8,9 @@ edition = "2021" [dependencies] dotenv = "0.15" env_logger = "0.10.0" +log = "0.4.20" poise = "0.5.6" -songbird = { git = "https://github.com/serenity-rs/songbird.git", branch = "next" } +songbird = { git = "https://github.com/serenity-rs/songbird.git", branch = "next"} sqlx = { version = "0.7.2", features = ["runtime-tokio", "time", "sqlite"] } sysinfo = "0.29.10" tokio = { version = "1.33.0", features = ["rt-multi-thread"] } diff --git a/src/dal/events/voice_state_update.rs b/src/dal/events/voice_state_update.rs index 34bf7b6..a065ebe 100644 --- a/src/dal/events/voice_state_update.rs +++ b/src/dal/events/voice_state_update.rs @@ -5,11 +5,11 @@ use crate::{dal, dal::models}; /// Inserts a voice state update event into the table /// Automatically handles inserting a new row into the general_info table pub async fn insert(executor: &SqlitePool, voice_state: &VoiceState) -> Result { - let general_info_result = - dal::events::general_info::insert(&executor, - std::time::UNIX_EPOCH.elapsed().unwrap().as_secs() as i64, - voice_state.user_id.0 as i64, - voice_state.guild_id.map(|i| i.0 as i64)).await?; + let general_info_result = dal::events::general_info::insert(&executor, + std::time::UNIX_EPOCH.elapsed().unwrap().as_secs() as i64, + voice_state.user_id.0 as i64, + voice_state.guild_id.map(|i| i.0 as i64) + ).await?; let general_info_id = general_info_result.last_insert_rowid(); @@ -63,4 +63,4 @@ pub async fn get_voice_state_updates(executor: &SqlitePool, user_id: i64, guild_ let voice_state_updates = db_voice_state_updates.iter().map(|row| models::DBVoiceStateUpdate::from_joined(row)).collect(); Ok(voice_state_updates) -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index 8f615bc..243c068 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,18 +1,22 @@ #![warn(clippy::str_to_string)] +#[macro_use] +extern crate log; + mod dal; mod event_handler; mod commands; mod handlers; -use poise::{serenity_prelude as serenity}; -use std::{env::var}; -use sqlx::{SqlitePool}; -// use songbird::serenity::SerenityInit; +use poise::serenity_prelude as serenity; +use songbird::SerenityInit; +use std::env::var; +use sqlx::SqlitePool; type Error = Box; type Context<'a> = poise::Context<'a, Data, Error>; + // Custom user data passes to all command functions pub struct Data { conn_pool: SqlitePool, @@ -51,6 +55,7 @@ async fn main() { poise::Framework::builder() .token(var("DISCORD_TOKEN").expect("Missing `DISCORD_TOKEN` env var") ) .setup(handlers::setup::handler) + .client_settings(|c| c.register_songbird()) .options(options) .intents( serenity::GatewayIntents::GUILD_MESSAGES