aboutsummaryrefslogtreecommitdiff
path: root/src/commands/mod.rs
blob: 74cdaf51216487de8073ba2ba64297637471b1f2 (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
61
62
63
64
65
66
67
68
use log::info;
use serenity::{
    framework::{
        StandardFramework,
        standard::{
            macros::group,
        },
    },
};

use crate::{
    util::CtxExt,
};

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

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


group!({
    name: "general",
    options: {
        only_in: "guild",
    },
    commands: [
        roll,
    ],
});

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

    #[cfg(feature = "diesel")]
    let result = result.group(&self::meme::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 _ = self::playback::_play(ctx, msg, &url);
        })
}


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