From 5ffc46ae5c746287b84e96f2b60d7a2ff07deddf Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 17 Oct 2022 18:51:42 +0000 Subject: change the order of event in handle fn --- azalea/src/lib.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'azalea/src/lib.rs') diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs index 8ef02e7c..493745cb 100644 --- a/azalea/src/lib.rs +++ b/azalea/src/lib.rs @@ -11,10 +11,9 @@ use thiserror::Error; /// Plugins can keep their own personal state, listen to events, and add new functions to Client. #[async_trait] pub trait Plugin: Send + Sync { - async fn handle(self: Arc, bot: Client, event: Arc); + async fn handle(self: Arc, event: Arc, bot: Client); } -// pub type HeuristicFn = fn(start: &Vertex, current: &Vertex) -> W; pub type HandleFn = fn(Client, Arc, Arc>) -> Fut; pub struct Options @@ -65,18 +64,18 @@ pub async fn start< while let Some(event) = rx.recv().await { // we put it into an Arc so it's cheaper to clone + let event = Arc::new(event); for plugin in &options.plugins { - tokio::spawn(plugin.clone().handle(bot.clone(), event.clone())); + tokio::spawn(plugin.clone().handle(event.clone(), bot.clone())); } - { - let bot_plugin = bot_plugin.clone(); - let bot = bot.clone(); - let event = event.clone(); - tokio::spawn(bot::Plugin::handle(bot_plugin, bot, event)); - }; + tokio::spawn(bot::Plugin::handle( + bot_plugin.clone(), + event.clone(), + bot.clone(), + )); tokio::spawn((options.handle)(bot.clone(), event.clone(), state.clone())); } -- cgit v1.2.3