2023-11-22 20:38:21 +00:00
|
|
|
mod commands;
|
|
|
|
mod events;
|
|
|
|
pub mod utils;
|
2023-11-25 21:01:02 +00:00
|
|
|
pub mod error;
|
2023-11-22 20:38:21 +00:00
|
|
|
|
|
|
|
use poise::FrameworkBuilder;
|
|
|
|
use utils::serenity;
|
|
|
|
|
2023-11-23 01:09:45 +00:00
|
|
|
use commands::logging;
|
2023-11-22 20:38:21 +00:00
|
|
|
use utils::{BotData, Context, Error};
|
|
|
|
|
2023-11-23 22:39:30 +00:00
|
|
|
use self::events::event_handler;
|
|
|
|
|
|
|
|
pub type Result = ::std::result::Result<(), Error>;
|
|
|
|
|
2023-11-25 21:01:02 +00:00
|
|
|
/// Bootstraps the Discord bot.
|
|
|
|
///
|
|
|
|
/// # Panics
|
|
|
|
///
|
|
|
|
/// Panics if the environment `DISCORD_TOKEN` is unavailable.
|
2023-11-23 21:15:47 +00:00
|
|
|
pub fn make_bot() -> FrameworkBuilder<BotData, Error> {
|
|
|
|
poise::Framework::builder()
|
2023-11-22 20:38:21 +00:00
|
|
|
.options(poise::FrameworkOptions {
|
2023-11-23 01:09:45 +00:00
|
|
|
commands: vec![logging()],
|
2023-11-23 22:39:30 +00:00
|
|
|
event_handler: |ctx, event, framework, data| {
|
|
|
|
Box::pin(event_handler(ctx, event, framework, data))
|
|
|
|
},
|
2023-11-22 20:38:21 +00:00
|
|
|
..Default::default()
|
|
|
|
})
|
|
|
|
.token(std::env::var("DISCORD_TOKEN").expect("missing DISCORD_TOKEN"))
|
|
|
|
.intents(serenity::GatewayIntents::non_privileged())
|
|
|
|
.setup(|ctx, _ready, framework| {
|
|
|
|
Box::pin(async move {
|
|
|
|
poise::builtins::register_globally(
|
|
|
|
ctx,
|
|
|
|
&framework.options().commands,
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
Ok(BotData::new().await?)
|
|
|
|
})
|
2023-11-23 21:15:47 +00:00
|
|
|
})
|
2023-11-22 20:38:21 +00:00
|
|
|
}
|