#[macro_use] extern crate lazy_static; use commands::*; use serenity::model::channel::Message; use serenity::model::id::ChannelId; use serenity::prelude::*; mod commands; mod file; pub fn main() { /* Client::new( file::read_file("secret") .next() .expect("The file containing the login secret is present but empty"), Handler, ) .expect("Error creating client") .start() .expect("Could not connect to discord"); */ print_commands(); } const PREFIX: char = '$'; pub struct Handler; impl EventHandler for Handler { fn message(&self, ctx: Context, msg: Message) { if !msg.content.starts_with(PREFIX) { return; } if let Some(command) = find_matching(&msg.content) { let response = match command.execute(&msg) { Err(e) => e, // TODO: maybe check the return code here? Ok(()) => "Done", }; send(msg.channel_id, response, &ctx); } } } pub fn send(target: ChannelId, message: &str, ctx: &Context) { if let Err(cause) = target.say(&ctx.http, message) { println!("Could not send message: {}", cause); } }