+ Split all message handling into message_router.rs + Added whisper command + Updated serenity version + Fmt, but clippy failing
45 lines
1.1 KiB
Rust
45 lines
1.1 KiB
Rust
use std::sync::Arc;
|
|
|
|
use serenity::prelude::*;
|
|
use structopt::StructOpt;
|
|
|
|
use discord::commands::command_framework;
|
|
use discord::event_handler::Handler;
|
|
use game::global_data::GlobalData;
|
|
|
|
use crate::config::{Args, BotConfig};
|
|
|
|
mod config;
|
|
mod discord;
|
|
mod error;
|
|
mod game;
|
|
mod imgur;
|
|
mod messages;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let args: Args = Args::from_args();
|
|
|
|
let bot_cfg: BotConfig = BotConfig::new(&args.cfg_path).expect("Unable to parse cfg");
|
|
|
|
let mut global_data = GlobalData::new(bot_cfg.clone());
|
|
|
|
if global_data.game_state_exists() {
|
|
println!("Resuming game...");
|
|
global_data
|
|
.load_game_state()
|
|
.expect("Unable to open saved game state.");
|
|
}
|
|
|
|
let mut client = Client::builder(&bot_cfg.discord_config.token, GatewayIntents::all())
|
|
.event_handler(Handler {})
|
|
.framework(command_framework())
|
|
.type_map_insert::<GlobalData>(Arc::new(Mutex::new(global_data)))
|
|
.await
|
|
.expect("Err creating client");
|
|
|
|
if let Err(why) = client.start().await {
|
|
println!("Client error: {:?}", why);
|
|
}
|
|
}
|