From 0ec6264bfaafc034d80c23209bd91d43c76566c0 Mon Sep 17 00:00:00 2001 From: Benjamin Sherriff Date: Sat, 7 Oct 2023 23:26:12 -0400 Subject: [PATCH] Got play to work --- service/migrations/000010_create_guilds/up.sql | 1 + service/src/bot/handler.rs | 6 +++++- service/src/db/guilds/model.rs | 2 ++ service/src/db/schema.rs | 1 + service/src/main.rs | 3 +-- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/service/migrations/000010_create_guilds/up.sql b/service/migrations/000010_create_guilds/up.sql index b66576f..d2dd580 100644 --- a/service/migrations/000010_create_guilds/up.sql +++ b/service/migrations/000010_create_guilds/up.sql @@ -1,4 +1,5 @@ CREATE TABLE IF NOT EXISTS guilds ( id BIGINT PRIMARY KEY NOT NULL, + bot_id BIGINT NOT NULL, volume DOUBLE PRECISION NOT NULL ); \ No newline at end of file diff --git a/service/src/bot/handler.rs b/service/src/bot/handler.rs index c0bbd0d..de09fee 100644 --- a/service/src/bot/handler.rs +++ b/service/src/bot/handler.rs @@ -74,7 +74,11 @@ impl EventHandler for Handler { warn!("No ready guilds found"); } for guild in ready.guilds { - let _ = InsertGuild::insert(InsertGuild { id: (guild.id.0 as i64), volume: 100.0 }); + let _ = InsertGuild::insert(InsertGuild { + id: (guild.id.0 as i64), + bot_id: ctx.cache.current_user().id.0 as i64, + volume: 100.0 + }); let commands = guild.id.set_application_commands(&ctx.http, |commands| { commands.create_application_command(|command: &mut serenity::builder::CreateApplicationCommand| { commands::ping::register(command) }) .create_application_command(|command: &mut serenity::builder::CreateApplicationCommand| { commands::audio::play::register(command) }) diff --git a/service/src/db/guilds/model.rs b/service/src/db/guilds/model.rs index ccc6904..2c3039f 100644 --- a/service/src/db/guilds/model.rs +++ b/service/src/db/guilds/model.rs @@ -8,6 +8,7 @@ use crate::db::{schema::guilds, connection}; #[diesel(table_name = guilds)] pub struct QueryGuild { pub id: i64, + pub bot_id: i64, pub volume: f64 } @@ -23,6 +24,7 @@ impl QueryGuild { #[diesel(table_name = guilds)] pub struct InsertGuild { pub id: i64, + pub bot_id: i64, pub volume: f64 } diff --git a/service/src/db/schema.rs b/service/src/db/schema.rs index 290464b..64b84e5 100644 --- a/service/src/db/schema.rs +++ b/service/src/db/schema.rs @@ -34,6 +34,7 @@ diesel::table! { diesel::table! { guilds (id) { id -> BigInt, + bot_id -> BigInt, volume -> Float8, } } \ No newline at end of file diff --git a/service/src/main.rs b/service/src/main.rs index 200bf01..e76172e 100644 --- a/service/src/main.rs +++ b/service/src/main.rs @@ -79,7 +79,7 @@ async fn main() -> std::io::Result<()> { .event_handler(handler) .framework(StandardFramework::new() .configure(|c| c.owners(owners))) - .register_songbird() + .register_songbird_with(Arc::clone(&songbird)) .await .expect("Error creating client"); @@ -116,7 +116,6 @@ async fn main() -> std::io::Result<()> { .allow_any_header() .max_age(3600); App::new() - // .app_data(web::Data::new(Arc::clone(&http))) .app_data(web::Data::new(Arc::clone(&app_data))) .configure(crate::db::messages::init_routes) .configure(crate::db::spells::init_routes)