1#![deny(clippy::all)]
7
8mod cache;
9mod config;
10mod event;
11mod preview;
12
13use crate::{
14 config::{BabyriteConfig, EnvConfig},
15 event::BabyriteEventHandler,
16};
17use serenity::all::GatewayIntents;
18
19#[tokio::main]
20async fn main() -> anyhow::Result<()> {
21 dotenvy::dotenv().ok();
22
23 BabyriteConfig::init()?;
24 let envs = EnvConfig::get();
25
26 match BabyriteConfig::get().json_logging {
27 true => tracing_subscriber::fmt().json().init(),
28 false => tracing_subscriber::fmt().compact().init(),
29 }
30 tracing::debug!("Config: {:?}", BabyriteConfig::get());
31
32 let mut client = serenity::Client::builder(
33 &envs.discord_api_token,
34 GatewayIntents::MESSAGE_CONTENT | GatewayIntents::GUILD_MESSAGES,
35 )
36 .event_handler(BabyriteEventHandler)
37 .await
38 .expect("Failed to initialize client.");
39
40 if let Err(why) = client.start().await {
41 return Err(anyhow::anyhow!(why));
42 }
43
44 Ok(())
45}