please work aaaaaaa
This commit is contained in:
parent
5b5720a6b7
commit
2d1efe15c9
17
src/main.rs
17
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::<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,
|
||||
|
|
Loading…
Reference in New Issue