aboutsummaryrefslogtreecommitdiff
path: root/src/commands/mod.rs
blob: 3f69a3bcc01cd90ad2a6e1910a3e31fa128c2175 (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
56
57
58
59
60
use crate::util;
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_COMMAND,
};

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

mod help;

#[group]
#[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| {
        Box::pin(async move {
            let url = match msg.content.split_whitespace().skip(1).next() {
                Some(x) if x.starts_with("http") => x,
                _ => {
                    info!("bad command formatting: '{}'", unrec);
                    let _ = util::send(
                        ctx,
                        msg.channel_id,
                        "format your commands right. fuck you.",
                        msg.tts,
                    )
                    .await;
                    return;
                },
            };

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

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