aboutsummaryrefslogtreecommitdiff
path: root/src/commands/mod.rs
blob: 619335c9663789822b76352d6aa55fb68b79831f (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
use serenity::{
    framework::StandardFramework,
};

use crate::{
    util::CtxExt,
};
#[cfg(feature = "games")]
use crate::game::*;

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

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

group!("playback", {
    options: {
        only_in: "guild",
    },
    commands: [
        skip,
        pause,
        resume,
        list,
        die,
        mute,
        unmute,
        play,
        volume,
    ],
});

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

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(&GAME_GROUP);

    result.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 = "games")]
group!("game", {
    options: {
        only_in: "guild",
    },
    commands: [
        installedgame,
        ownedgame,
        updategaem,
    ],
});

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

#[cfg(feature = "diesel")]
group!("memes", {
    options: {
        only_in: "guild",
    },
    commands: [
        meme,
        audio_meme,
        silent_Meme,
        addmeme,
        addaudiomeme,
        delmeme,
        wat,
        stats,
        history,
        rare_meme,
        memers,
        query,
    ],
});