diff --git a/src/service.rs b/src/service.rs new file mode 100644 index 0000000..aaafff1 --- /dev/null +++ b/src/service.rs @@ -0,0 +1,20 @@ +use crate::{Data, Error}; + +pub(crate) struct NanoBot { + pub discord: poise::FrameworkBuilder, + pub router: axum::Router, +} + +#[shuttle_runtime::async_trait] +impl shuttle_runtime::Service for NanoBot { + async fn bind(mut self, addr: std::net::SocketAddr) -> Result<(), shuttle_runtime::Error> { + let serve = axum::Server::bind(&addr).serve(self.router.into_make_service()); + + tokio::select! { + _ = self.discord.run_autosharded() => {}, + _ = serve => {}, + }; + + Ok(()) + } +}