summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock6
-rw-r--r--Cargo.toml4
-rw-r--r--src/commands.rs42
-rw-r--r--src/main.rs2
4 files changed, 38 insertions, 16 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 7f4cae7..013783e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -783,7 +783,7 @@ dependencies = [
[[package]]
name = "serenity"
version = "0.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
+source = "git+https://github.com/zeyla/serenity?rev=b71d99#b71d99fde84135fa66f73c4817d340ffbe8bddae"
dependencies = [
"base64 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -910,7 +910,7 @@ dependencies = [
"fern 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "serenity 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serenity 0.5.1 (git+https://github.com/zeyla/serenity?rev=b71d99)",
"typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1152,7 +1152,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "f4ba7591cfe93755e89eeecdbcc668885624829b020050e6aec99c2a03bd3fd0"
"checksum serde_derive_internals 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6e03f1c9530c3fb0a0a5c9b826bdd9246a5921ae995d75f512ac917fc4dd55b5"
"checksum serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c9db7266c7d63a4c4b7fe8719656ccdd51acf1bed6124b174f933b009fb10bcb"
-"checksum serenity 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a159595548584ec79489db9c3a05903517c75fd0c484b7ea05a0caf13c390b55"
+"checksum serenity 0.5.1 (git+https://github.com/zeyla/serenity?rev=b71d99)" = "<none>"
"checksum sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc30b1e1e8c40c121ca33b86c23308a090d19974ef001b4bf6e61fd1a0fb095c"
"checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537"
"checksum smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44db0ecb22921ef790d17ae13a3f6d15784183ff5f2a01aa32098c7498d2b4b9"
diff --git a/Cargo.toml b/Cargo.toml
index 5f5e341..6952dd8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,6 +20,8 @@ diesel = { version = "1.0.0", features = ["postgres"], optional = true }
cfg-if = "0.1"
[dependencies.serenity]
-version = "0.5"
+# version = "~0.5"
default-features = false
features = ["builder", "cache", "client", "framework", "model", "utils", "voice", "standard_framework"]
+git = "https://github.com/zeyla/serenity"
+rev = "b71d99"
diff --git a/src/commands.rs b/src/commands.rs
index 7023ebd..5671f44 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -8,6 +8,7 @@ use serenity::client::bridge::voice::ClientVoiceManager;
use serenity::framework::StandardFramework;
use serenity::model::id::ChannelId;
use serenity::voice::{LockedAudio, ytdl};
+use serenity::model::channel::Message;
use typemap::Key;
@@ -185,17 +186,22 @@ pub fn register_commands(f: StandardFramework) -> StandardFramework {
.desc("queue a request")
.guild_only(true)
.cmd(play))
-}
+ .unrecognised_command(|ctx, msg, unrec| {
+ let url = match msg.content.split_whitespace().skip(1).next() {
+ Some(x) => x,
+ None => {
+ info!("received unrecognized command: {}", unrec);
+ let _ = send(msg.channel_id, "format your commands right. fuck you.", msg.tts);
+ return;
+ }
+ };
-command!(play(ctx, msg, args) {
- let url = match args.single::<String>() {
- Ok(url) => url,
- Err(_) => {
- send(msg.channel_id, "BAD LINK", msg.tts)?;
- return Ok(());
- }
- };
+ let _ = _play(ctx, msg, &url);
+ })
+}
+fn _play(ctx: &Context, msg: &Message, url: &str) -> Result<()> {
+ debug!("playing '{}'", url);
if !url.starts_with("http") {
send(msg.channel_id, "bAD LiNk", msg.tts)?;
return Ok(());
@@ -208,16 +214,30 @@ command!(play(ctx, msg, args) {
trace!("acquiring queue lock");
- let mut queue_lock = ctx.data.lock().get::<PlayQueue>().cloned().unwrap();
+ let queue_lock = ctx.data.lock().get::<PlayQueue>().cloned().unwrap();
let mut play_queue = queue_lock.write().unwrap();
trace!("queue lock acquired");
play_queue.queue.push_back(PlayArgs{
initiator: msg.author.name.clone(),
- url,
+ url: url.to_owned(),
sender_channel: msg.channel_id,
});
+
+ Ok(())
+}
+
+command!(play(ctx, msg, args) {
+ let url = match args.single::<String>() {
+ Ok(url) => url,
+ Err(_) => {
+ send(msg.channel_id, "BAD LINK", msg.tts)?;
+ return Ok(());
+ }
+ };
+
+ _play(ctx, msg, &url)?;
});
command!(pause(ctx, msg) {
diff --git a/src/main.rs b/src/main.rs
index 0a03cfd..8d5baa2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -87,7 +87,7 @@ fn run() -> Result<()> {
)
.before(|_ctx, message, cmd| {
let result = message.guild_id().map_or(false, |x| x.0 == *TARGET_GUILD);
- debug!("got command {} from user '{}' ({}). accept: {}", cmd, message.author.name, message.author.id, result);
+ debug!("got command '{}' from user '{}' ({}). accept: {}", cmd, message.author.name, message.author.id, result);
result
})