Skip to content

Commit

Permalink
move commands to a submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
timlathy committed Aug 4, 2020
1 parent fb10dcf commit 2713193
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mod chain;
mod img2msg;
mod joker;
mod taki;
mod wdyt;

pub use chain::Chain;
pub use img2msg::Img2msg;
pub use joker::Joker;
pub use taki::Taki;
pub use wdyt::Wdyt;
File renamed without changes.
File renamed without changes.
27 changes: 11 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,19 @@ use std::sync::Arc;

pub type JoeResult<T> = Result<T, Box<dyn Error>>;

mod commands;
mod messages;
mod storage;
mod utils;

use serenity::{model::prelude::*, prelude::*, utils::MessageBuilder};

mod chain;
mod img2msg;
mod joker;
mod taki;
mod wdyt;

struct MessageHandlers {
taki: taki::Taki,
chain: chain::Chain,
joker: joker::Joker,
wdyt: wdyt::Wdyt,
img2msg: img2msg::Img2msg,
taki: commands::Taki,
chain: commands::Chain,
joker: commands::Joker,
wdyt: commands::Wdyt,
img2msg: commands::Img2msg,
}

struct Handler {
Expand Down Expand Up @@ -135,11 +130,11 @@ fn init_handlers(channel_id: u64, redis: &storage::Redis) -> MessageHandlers {
let chain_data: joebot_markov_chain::MarkovChain =
bincode::deserialize_from(File::open("chain.bin").unwrap()).unwrap();

let taki = taki::Taki::new(messages.clone(), channel_id, redis);
let chain = chain::Chain::new(chain_data);
let joker = joker::Joker::new(messages.clone()).unwrap();
let wdyt = wdyt::Wdyt::new(messages.clone()).unwrap();
let img2msg = img2msg::Img2msg::new(messages.clone()).unwrap();
let taki = commands::Taki::new(messages.clone(), channel_id, redis);
let chain = commands::Chain::new(chain_data);
let joker = commands::Joker::new(messages.clone()).unwrap();
let wdyt = commands::Wdyt::new(messages.clone()).unwrap();
let img2msg = commands::Img2msg::new(messages.clone()).unwrap();

MessageHandlers {
taki,
Expand Down

0 comments on commit 2713193

Please sign in to comment.