please work aaaaaaa

This commit is contained in:
Agatha Rose 2020-04-29 05:30:45 +03:00
parent 5b5720a6b7
commit 2d1efe15c9
1 changed files with 15 additions and 2 deletions

View File

@ -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::<ShardManagerContainer>(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::<ShardManagerContainer>().unwrap().lock();
let runners = shards.runners.lock();
let shard_manager = match data.get::<ShardManagerContainer>() {
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,