aboutsummaryrefslogtreecommitdiff
path: root/src/commands/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/mod.rs')
-rw-r--r--src/commands/mod.rs137
1 files changed, 64 insertions, 73 deletions
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index 9ce518b..19615de 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -16,84 +16,75 @@ pub fn register_commands(f: StandardFramework) -> StandardFramework {
let f: StandardFramework = register_db(f);
f
.command("skip", |c| c
- .desc("skip the rest of the current request")
- .guild_only(true)
- .exec(skip))
- .command("pause", |c| c
- .desc("pause playback (currently broken)")
- .guild_only(true)
- .exec(pause))
- .command("resume", |c| c
- .desc("resume playing (currently broken)")
- .guild_only(true)
- .exec(resume))
- .command("list", |c| c
- .known_as("queue")
- .desc("list playing and queued requests")
- .guild_only(true)
- .exec(list))
- .command("die", |c| c
- .batch_known_as(vec!["sudoku", "stop"])
- .desc("stop playing and empty the queue")
- .guild_only(true)
- .exec(die))
- .command("mute", |c| c
- .desc("mute thulani (playback continues)")
- .guild_only(true)
- .exec(mute))
- .command("unmute", |c| c
- .desc("unmute thulani")
- .guild_only(true)
- .exec(unmute))
- .command("play", |c| c
- .desc("queue a request")
- .guild_only(true)
- .exec(play))
- .command("volume", |c| c
- .desc("set playback volume")
- .guild_only(true)
- .exec(volume))
- .unrecognised_command(|ctx, msg, unrec| {
- let url = match msg.content.split_whitespace().skip(1).next() {
- Some(x) if x.starts_with("http") => x,
- Some(x) => {
- let _ = db_fallback(ctx, msg, x);
- return;
- },
- None => {
- info!("bad command formatting: '{}'", unrec);
- let _ = send(msg.channel_id, "format your commands right. fuck you.", msg.tts);
- return;
- }
- };
+ .desc("skip the rest of the current request")
+ .guild_only(true)
+ .exec(skip))
+ .command("pause", |c| c
+ .desc("pause playback (currently broken)")
+ .guild_only(true)
+ .exec(pause))
+ .command("resume", |c| c
+ .desc("resume playing (currently broken)")
+ .guild_only(true)
+ .exec(resume))
+ .command("list", |c| c
+ .known_as("queue")
+ .desc("list playing and queued requests")
+ .guild_only(true)
+ .exec(list))
+ .command("die", |c| c
+ .batch_known_as(vec!["sudoku", "stop"])
+ .desc("stop playing and empty the queue")
+ .guild_only(true)
+ .exec(die))
+ .command("mute", |c| c
+ .desc("mute thulani (playback continues)")
+ .guild_only(true)
+ .exec(mute))
+ .command("unmute", |c| c
+ .desc("unmute thulani")
+ .guild_only(true)
+ .exec(unmute))
+ .command("play", |c| c
+ .desc("queue a request")
+ .guild_only(true)
+ .exec(play))
+ .command("volume", |c| c
+ .desc("set playback volume")
+ .guild_only(true)
+ .exec(volume))
+ .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 _ = send(msg.channel_id, "format your commands right. fuck you.", msg.tts);
+ return;
+ }
+ };
- let _ = self::playback::_play(ctx, msg, &url);
- })
+ let _ = self::playback::_play(ctx, msg, &url);
+ })
}
-cfg_if! {
- if #[cfg(feature = "diesel")] {
- mod meme;
- pub use self::meme::*;
+#[cfg(feature = "diesel")]
+mod meme;
- fn register_db(f: StandardFramework) -> StandardFramework {
- f
- .command("meme", |c| c
- .guild_only(true)
- .help_available(false)
- .cmd(meme))
- }
- } else {
- fn register_db(f: StandardFramework) -> StandardFramework {
- f
- }
+#[cfg(feature = "diesel")]
+pub use self::meme::*;
- fn db_fallback(_: &mut Context, msg: &Message, s: &str) -> Result<()> {
- info!("received unrecognized command: {}", s);
- let _ = send(msg.channel_id, "format your commands right. fuck you.", msg.tts)?;
- Ok(())
- }
- }
+#[cfg(feature = "diesel")]
+fn register_db(f: StandardFramework) -> StandardFramework {
+ f
+ .command("meme", |c| c
+ .guild_only(true)
+ .help_available(false)
+ .cmd(meme))
+}
+
+#[cfg(not(feature = "diesel"))]
+fn register_db(f: StandardFramework) -> StandardFramework {
+ f
}
fn send(channel: ChannelId, text: &str, tts: bool) -> Result<()> {