aboutsummaryrefslogtreecommitdiff
path: root/src/commands/mod.rs
blob: 4893e7303e920b8f96fe26a1179f31a7e75635f0 (plain) (blame)
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
54
55
use log::info;
use serenity::framework::{
    standard::macros::group,
    StandardFramework,
};

#[cfg(feature = "diesel")]
pub use self::meme::*;
pub use self::{
    playback::*,
    roll::ROLL_COMMAND,
    today::{
        today,
        TODAY_COMMAND,
    },
};

pub(crate) mod playback;
pub(crate) mod roll;
pub(crate) mod sound_levels;
pub(crate) mod today;

mod help;

#[group]
#[prefix = ""]
#[only_in(guild)]
#[commands(roll, today)]
struct General;

pub fn register_commands(f: StandardFramework) -> StandardFramework {
    let result = f.group(&PLAYBACK_GROUP).group(&GENERAL_GROUP);

    #[cfg(feature = "diesel")]
    let result = result.group(&MEMES_GROUP);

    #[cfg(feature = "games")]
    let result = result.group(&crate::game::GAME_GROUP);

    result.help(&help::HELP).unrecognised_command(|ctx, msg, unrec| {
        let url = match msg.content.split_whitespace().skip(1).next() {
            Some(x) if x.starts_with("http") => x,
            _ => {
                info!("bad command formatting: '{}'", unrec);
                let _ = ctx.send(msg.channel_id, "format your commands right. fuck you.", msg.tts);
                return;
            },
        };

        let _ = _play(ctx, msg, &url);
    })
}

#[cfg(feature = "diesel")]
mod meme;