From ffba60b278162707bc4eb004c3bfb6b2e9595213 Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Wed, 8 May 2024 12:55:35 -0400 Subject: rework to use songbird --- src/main.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index ab5db5d..3b8c2af 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,12 +5,9 @@ #![feature(box_patterns)] #![allow(deprecated)] -use std::{ - thread, - time::{ - Duration, - Instant, - }, +use std::time::{ + Duration, + Instant, }; use log::{ @@ -39,7 +36,6 @@ mod game { } } -mod audio; mod bot; mod commands; mod config; @@ -55,7 +51,8 @@ const BACKOFF_INIT: f64 = 100.0; const MIN_RUN_DURATION: Duration = Duration::from_secs(120); -fn main() { +#[tokio::main] +async fn main() { log_setup::init(false).expect("initializing logging"); let mut backoff_count: usize = 0; @@ -64,13 +61,13 @@ fn main() { let start = Instant::now(); info!("starting bot"); - match bot::run() { + match bot::run().await { Err(e) => { error!("error encountered running client: {:?}", e); }, _ => { // NOTE: we MUST have gotten here through SIGINT/SIGTERM handlers - ::std::process::exit(0); + std::process::exit(0); }, } @@ -87,6 +84,6 @@ fn main() { let backoff_millis = (BACKOFF_INIT * BACKOFF_FACTOR.powi(backoff_count as i32)) as u64; info!("bot died too quickly. backing off, retrying in {}ms.", backoff_millis); - thread::sleep(Duration::from_millis(backoff_millis)); + tokio::time::sleep(Duration::from_millis(backoff_millis)).await; } } -- cgit v1.3.1