diff --git a/src/main.rs b/src/main.rs index 315215a..58c6f5e 100755 --- a/src/main.rs +++ b/src/main.rs @@ -67,6 +67,11 @@ fn main() { let mut client = Client::new(&env::var("DISCORD_TOKEN").expect("Invalid token"), Handler) .expect("Error creating client"); + { + let mut data = client.data.write(); + data.insert::(Arc::clone(&client.shard_manager)); + } + client.with_framework( StandardFramework::new() .configure(|c| { @@ -135,8 +140,16 @@ fn init(ctx: &mut Context, message: &Message) -> CommandResult { fn ping(ctx: &mut Context, message: &Message) -> CommandResult { // I have no idea if this works but its 5æm and I need to sleep help let data = ctx.data.read(); - let shards = data.get::().unwrap().lock(); - let runners = shards.runners.lock(); + + let shard_manager = match data.get::() { + Some(v) => v, + None => { + return Err(CommandError("There was a problem getting the shard manager!".to_string())); + }, + }; + + let manager = shard_manager.lock(); + let runners = manager.runners.lock(); let runner = match runners.get(&ShardId(ctx.shard_id)) { Some(v) => v,