diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index 86fa40d..79371f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,53 @@ +mod config; + use serenity::framework::StandardFramework; +use serenity::Client; + +fn configure(conf: &mut serenity::framework::standard::Configuration) { + conf.prefix("!<3").case_insensitivity(true); +} + +struct Handler; + +mod commands { + use serenity::client::Context; + use serenity::framework::standard::{macros::*, CommandResult}; + use serenity::model::channel::Message; + #[group] + #[description = "Commands for the cupido bot"] + #[default_command(help)] + #[commands(help)] + struct Group; + + #[command] + #[aliases("hepl", "?", "h")] + async fn help(ctx: &Context, msg: &Message) -> CommandResult { + msg.reply(ctx, crate::config::HELP_TEXT).await?; + Ok(()) + } +} + +impl serenity::client::EventHandler for Handler {} + +#[tokio::main] +async fn main() { + println!("crate framework"); + + let framework = StandardFramework::new() + .configure(|c| { + configure(c); + c + }) + .group(&commands::GROUP_GROUP); -fn configure(conf: &mut serenity::framework::standard::Configuration) {} + let token = std::env::var(config::TOKEN_ENV).expect("missing token"); + println!("crate a new client with token: \"{}\"", token); + let mut client = Client::new(token) + .framework(framework) + .event_handler(Handler) + .await + .expect("Error creating client"); -fn main() { - let framework = StandardFramework::new().configure(|c| { - configure(c); - c - }); + println!("starting the client"); + client.start().await.expect("client error"); } |