summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 79371f9263d3607929fc732e3696886db1893d96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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);

    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");

    println!("starting the client");
    client.start().await.expect("client error");
}