diff options
author | Ashelyn Rose <git@ashen.earth> | 2024-10-05 20:05:36 -0600 |
---|---|---|
committer | Ashelyn Rose <git@ashen.earth> | 2024-10-05 20:05:36 -0600 |
commit | f2cd49662f74deb894518d5169fae533454bd6a6 (patch) | |
tree | 2eebd051d5fe3ec8d739e7ec9dfe8f2c0c102de1 /src/system | |
parent | ca4b0e32be531053f19ce2895b994130b247af4a (diff) |
System manager now knows user_id of each bot
Diffstat (limited to 'src/system')
-rw-r--r-- | src/system/bot/gateway.rs | 4 | ||||
-rw-r--r-- | src/system/mod.rs | 5 | ||||
-rw-r--r-- | src/system/types.rs | 2 |
3 files changed, 7 insertions, 4 deletions
diff --git a/src/system/bot/gateway.rs b/src/system/bot/gateway.rs index 5a343d1..bfe4603 100644 --- a/src/system/bot/gateway.rs +++ b/src/system/bot/gateway.rs @@ -80,9 +80,9 @@ impl Gateway { } } Ok(event) => match event { - twilight_gateway::Event::Ready(_) => { + twilight_gateway::Event::Ready(ready) => { system_channel - .send(SystemEvent::GatewayConnected(bot_conf.member_id)) + .send(SystemEvent::GatewayConnected(bot_conf.member_id, ready.user.id)) .await; } diff --git a/src/system/mod.rs b/src/system/mod.rs index bd27f4a..6c4d95f 100644 --- a/src/system/mod.rs +++ b/src/system/mod.rs @@ -84,7 +84,10 @@ impl Manager { loop { match system_receiver.recv().await { - Some(SystemEvent::GatewayConnected(member_id)) => { + Some(SystemEvent::GatewayConnected(member_id, user_id)) => { + self.config.members.iter_mut().enumerate() + .find(|(id, _)| *id == member_id).unwrap().1.user_id = Some(user_id); + let member = self.find_member_by_id(member_id).unwrap(); println!("Gateway client {} ({}) connected", member.name, member_id); diff --git a/src/system/types.rs b/src/system/types.rs index 89eb189..bef6d6d 100644 --- a/src/system/types.rs +++ b/src/system/types.rs @@ -24,7 +24,7 @@ pub type CommandEvent = (Timestamp, ()); pub enum SystemEvent { // Process of operation - GatewayConnected(MemberId), + GatewayConnected(MemberId, UserId), GatewayError(MemberId, String), GatewayClosed(MemberId), RefetchMessage(MemberId, MessageId, ChannelId), |