mod settings; mod status; mod types; use crate::settings::settings; use crate::status::status; use crate::types::AppData; use anyhow::Result; use poise::serenity_prelude as serenity; use serenity::all::{ActivityData, ActivityType, ChannelId, MessageId, OnlineStatus}; use std::sync::Arc; use std::time::Duration; use tracing::{Level, info}; use fjall::Config; #[tokio::main] async fn main() -> Result<()> { tracing_subscriber::fmt::fmt() .with_max_level(Level::INFO) .init(); let token = std::env::var("DISCORD_TOKEN").expect("Expected a DISCORD_TOKEN in the environment"); let intents = serenity::GatewayIntents::non_privileged(); let keyspace = Config::new("./db").open()?; let framework = poise::Framework::builder() .options(poise::FrameworkOptions { commands: vec![settings(), status()], prefix_options: poise::PrefixFrameworkOptions { edit_tracker: Some(Arc::new(poise::EditTracker::for_timespan( Duration::from_secs(3600), ))), ..Default::default() }, pre_command: |ctx| { Box::pin(async move { let name = &ctx.author().name; let id = &ctx.author().id; let cmd = &ctx.command().name; let args = &ctx.invocation_string(); info!("{} ({}) is calling '{}' with {:?}.", name, id, cmd, args); }) }, ..Default::default() }) .setup(|ctx, _ready, framework| { ctx.set_presence( Some(ActivityData { name: "...".into(), kind: ActivityType::Watching, state: None, url: None, }), OnlineStatus::Online, ); Box::pin(async move { poise::builtins::register_globally(ctx, &framework.options().commands).await?; Ok(AppData { keyspace }) }) }) .build(); let client = serenity::ClientBuilder::new(token, intents) .framework(framework) .await; let mut client = client?; client.start().await?; Ok(()) }