diff options
author | Nathan Ringo <nathan@remexre.com> | 2024-11-22 00:11:43 -0600 |
---|---|---|
committer | Nathan Ringo <nathan@remexre.com> | 2024-11-22 00:11:43 -0600 |
commit | dd0e6e45c35133ec8a3e2886b7b050484b388d03 (patch) | |
tree | 3ea9f5a098fc9c150473942c97e8b07833440803 /src/lib.rs |
Initial commit
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..3b11a48 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,27 @@ +mod labwatch; + +use serenity::{ + all::{ChannelId, Context, EventHandler, Ready}, + async_trait, +}; +use std::{path::PathBuf, sync::Arc}; + +pub struct Handler(Arc<HandlerConfig>); + +impl From<HandlerConfig> for Handler { + fn from(config: HandlerConfig) -> Handler { + Handler(Arc::new(config)) + } +} + +pub struct HandlerConfig { + pub db_dir: PathBuf, + pub labwatch_channel_id: ChannelId, +} + +#[async_trait] +impl EventHandler for Handler { + async fn ready(&self, ctx: Context, _data_about_bot: Ready) { + tokio::spawn(labwatch::start(self.0.clone(), ctx)); + } +} |