diff --git a/src/main.rs b/src/main.rs index 3f686b0..f4979da 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,29 +39,30 @@ fn main() { }) .unwrap(); - let guild_list = wynncraft::guild_list().unwrap(); - let conn = establish_connection(); + if let Ok(guild_list) = wynncraft::guild_list() { + let conn = establish_connection(); - guild_list.into_iter().for_each(|name| { - thread::sleep_ms(2500); - println!("Getting {:?}", name); - if let Ok(Some(prefix)) = wynncraft::guild(&name).map(|x| x.map(|x| x.prefix)) { - let guild = Guild { prefix: prefix.trim().to_owned(), name }; - if let Ok(_) = diesel::insert_into(guilds::table) - .values(&guild) - .on_conflict(guilds::prefix) - .do_nothing() - .execute(&conn) { - let _ = reqwest::get("https://wynnapi.herokuapp.com/").unwrap(); + guild_list.into_iter().for_each(|name| { + thread::sleep_ms(2500); + println!("Getting {:?}", name); + if let Ok(Some(prefix)) = wynncraft::guild(&name).map(|x| x.map(|x| x.prefix)) { + let guild = Guild { prefix: prefix.trim().to_owned(), name }; + if let Ok(_) = diesel::insert_into(guilds::table) + .values(&guild) + .on_conflict(guilds::prefix) + .do_nothing() + .execute(&conn) { + let _ = reqwest::get("https://wynnapi.herokuapp.com/").unwrap(); + } else { + println!("Fail!"); + } } else { println!("Fail!"); } - } else { - println!("Fail!"); - } - }); - - println!("Guilds updated!"); + }); + + println!("Guilds updated!"); + } server_handle.join().unwrap(); }