diff --git a/src/commands/minecraft.rs b/src/commands/minecraft.rs index caf4817..0f3e363 100644 --- a/src/commands/minecraft.rs +++ b/src/commands/minecraft.rs @@ -118,6 +118,7 @@ pub(crate) mod server { use super::*; pub(crate) mod add { + use serenity::model::id::GuildId; use sqlx::Error; // this is to managfe the server side of commands related to minecraft use super::*; @@ -166,20 +167,11 @@ pub(crate) mod server { }; let db = db_lock.read().await; - let server_data = match get_server_config(&db, &g_id).await { - None => { - return "No existing server config, have you used ``/add``?".to_string(); - } - Some(x) => { - x - } - }; - - match add_server(&db, *server_data.server.as_u64() as i64, &server_minecraft).await { + match add_server(&db, &g_id, &server_minecraft).await { Ok(_) => {} Err(e) => { println!("{:?}", e); - return format!("Failure to insert into Minecraft {} {}", *server_data.server.as_u64(), &server_minecraft); + return format!("Failure to insert into Minecraft {} {}", &g_id, &server_minecraft); } } @@ -194,14 +186,14 @@ pub(crate) mod server { "Added/Updated minecraft_server info".to_string() } - async fn add_server(db: &Pool, discord: i64, minecraft: &str) -> Result, Error> { + async fn add_server(db: &Pool, discord: &GuildId, minecraft: &str) -> Result, Error> { sqlx::query_as::<_, Servers>( " INSERT OR REPLACE INTO minecraft (server_discord, server_minecraft) VALUES (?1, ?2) ", ) - .bind(discord) + .bind(*discord.as_u64() as i64) .bind(minecraft) .fetch_optional(db) .await