aboutsummaryrefslogtreecommitdiff
path: root/src/commands/mod.rs
blob: 2729580b3b9a2de2bf2656dc001d15cdefbb7602 (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 poise::builtins::PrettyHelpConfiguration;

use crate::{
    commands::playback::_play,
    PoiseContext,
};

#[cfg(feature = "games")]
pub mod game;

#[cfg(feature = "db")]
pub(crate) mod meme;
pub(crate) mod playback;
pub(crate) mod roll;
pub(crate) mod sound_levels;
pub(crate) mod today;

#[cfg(feature = "db")]
pub use self::meme::*;

pub fn commands() -> Vec<poise::Command<crate::PoiseData, anyhow::Error>> {
    let mut commands =
        vec![sound_levels::mute(), sound_levels::unmute(), roll::roll(), today::today(), help()];

    commands.extend(playback::commands());

    #[cfg(feature = "games")]
    commands.extend(game::commands());

    #[cfg(feature = "db")]
    commands.extend(meme::commands());

    commands
}

/// Print this help text.
#[poise::command(prefix_command, aliases("halp"))]
pub async fn help(ctx: PoiseContext<'_>, command: Option<String>) -> anyhow::Result<()> {
    poise::builtins::pretty_help(
        ctx,
        command.as_ref().map(|x| x.as_str()),
        PrettyHelpConfiguration {
            ..Default::default()
        },
    )
    .await?;

    Ok(())
}

pub async fn link_unrecognized(ctx: PoiseContext<'_>, u: url::Url) -> anyhow::Result<()> {
    let _ = _play(ctx, &u).await?;

    Ok(())
}