1#![doc = include_str!("../README.md")]
2use std::net::SocketAddr;
3use std::sync::Arc;
4
5#[deprecated = "shuttle-poise for poise 0.5 is deprecated. To use poise 0.6 and Shuttle, check https://docs.rs/shuttle-serenity/latest/shuttle_serenity/"]
7pub struct PoiseService<T, E>(pub Arc<poise::Framework<T, E>>);
8
9#[shuttle_runtime::async_trait]
10impl<T, E> shuttle_runtime::Service for PoiseService<T, E>
11where
12 T: Send + Sync + 'static,
13 E: Send + Sync + 'static,
14{
15 async fn bind(mut self, _addr: SocketAddr) -> Result<(), shuttle_runtime::Error> {
16 self.0
17 .start_autosharded()
18 .await
19 .map_err(shuttle_runtime::CustomError::new)?;
20
21 Ok(())
22 }
23}
24
25impl<T, E> From<Arc<poise::Framework<T, E>>> for PoiseService<T, E> {
26 fn from(framework: Arc<poise::Framework<T, E>>) -> Self {
27 Self(framework)
28 }
29}
30
31#[doc = include_str!("../README.md")]
32pub type ShuttlePoise<T, E> = Result<PoiseService<T, E>, shuttle_runtime::Error>;