26 lines
626 B
Rust
26 lines
626 B
Rust
use crate::db::Database;
|
|
|
|
pub use poise::serenity_prelude as serenity;
|
|
pub struct BotData {
|
|
pub database: Database,
|
|
}
|
|
|
|
impl BotData {
|
|
/// Initialize state data for bot.
|
|
///
|
|
/// For now, this only includes a connector to its database.
|
|
///
|
|
/// # Errors
|
|
///
|
|
/// This function will return an error if the database fails to
|
|
/// initialize.
|
|
pub async fn new() -> color_eyre::Result<Self> {
|
|
Ok(Self {
|
|
database: Database::new().await?,
|
|
})
|
|
}
|
|
}
|
|
|
|
pub type Error = Box<dyn std::error::Error + Send + Sync>;
|
|
pub type Context<'a> = poise::Context<'a, BotData, Error>;
|