mod config; mod discord; mod error; mod imgur; mod wallet; use crate::config::{create_story_channel, Args, BotConfig, GlobalData, StoryRecv, StorySend}; use crate::discord::unrecognised_command_hook; use serenity::framework::standard::macros::{command, group, help, hook}; use serenity::framework::standard::StandardFramework; use serenity::prelude::*; use structopt::StructOpt; const BAD_APPLE: &str = include_str!("assets/bad_apple.txt"); #[tokio::main] async fn main() { let args: Args = Args::from_args(); let cfg = match BotConfig::new(&args.cfg_path) { Ok(cfg) => cfg, Err(err) => { println!("Unable to open config: {}", err); return; } }; let global_data = match GlobalData::new(args, cfg).await { Ok(global_data) => global_data, Err(err) => { println!("Error parsing config: {}", err); return; } }; let framework = StandardFramework::new() .configure(|c| c.with_whitespace(true).prefix("!").ignore_bots(true)) .group(&discord::color::COLOR_GROUP) .group(&discord::album::ALBUM_GROUP) .group(&discord::celeryman::CELERYMAN_GROUP) .group(&discord::joke::JOKE_GROUP) .group(&discord::admin::ADMIN_GROUP) .group(&discord::story::STORY_GROUP) .group(&discord::fren_coin::FRENCOIN_GROUP) .unrecognised_command(unrecognised_command_hook) .bucket("bad_apple", |b| b.delay(60 * 10)) .await .help(&discord::MY_HELP) .after(discord::after); let (send, recv) = create_story_channel(); let intents = GatewayIntents::all(); let mut client = Client::builder(&global_data.cfg.bot_token, intents) .framework(framework) .type_map_insert::(global_data) .type_map_insert::(send) .type_map_insert::(recv) .event_handler(discord::Handler) .await .expect("Unable to create client."); if let Err(err) = client.start().await { println!("Client error: {:?}", err); } }