diff options
| author | Austin Hellyer <[email protected]> | 2016-11-26 13:16:42 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-26 13:16:42 -0800 |
| commit | 6328384eaff00cb1c8c91e95d5550c39d561bd1f (patch) | |
| tree | 9b50c0dd95be3104439e1fd6dc27fa7d20cafbc1 | |
| parent | Add a bit more docs (diff) | |
| download | serenity-6328384eaff00cb1c8c91e95d5550c39d561bd1f.tar.xz serenity-6328384eaff00cb1c8c91e95d5550c39d561bd1f.zip | |
Voice example no longer requires 'extras'
| -rw-r--r-- | examples/07_voice.rs | 12 | ||||
| -rw-r--r-- | src/client/context.rs | 8 | ||||
| -rw-r--r-- | src/model/gateway.rs | 1 |
3 files changed, 8 insertions, 13 deletions
diff --git a/examples/07_voice.rs b/examples/07_voice.rs index 5938c2f..377947e 100644 --- a/examples/07_voice.rs +++ b/examples/07_voice.rs @@ -9,12 +9,12 @@ use serenity::model::{ChannelId, Message}; #[cfg(feature = "voice")] use std::env; -#[cfg(any(not(feature = "extras"), not(feature = "voice")))] +#[cfg(not(feature = "voice"))] fn main() { panic!("'extras' and 'voice' must be enabled"); } -#[cfg(all(feature = "extras", feature = "voice"))] +#[cfg(feature = "voice")] fn main() { // Configure the client with your Discord bot token in the environment. let token = env::var("DISCORD_TOKEN") @@ -36,7 +36,7 @@ fn main() { let _ = client.start(); } -#[cfg(all(feature = "extras", feature = "voice"))] +#[cfg(feature = "voice")] fn deafen(context: Context, message: Message, _args: Vec<String>) { let guild_id = match CACHE.read().unwrap().get_guild_channel(message.channel_id) { Some(channel) => channel.guild_id, @@ -67,7 +67,7 @@ fn deafen(context: Context, message: Message, _args: Vec<String>) { } } -#[cfg(all(feature = "extras", feature = "voice"))] +#[cfg(feature = "voice")] fn join(context: Context, message: Message, args: Vec<String>) { let connect_to = match args.get(0) { Some(arg) => match arg.parse::<u64>() { @@ -102,7 +102,7 @@ fn join(context: Context, message: Message, args: Vec<String>) { let _ = context.say(&format!("Joined {}", connect_to.mention())); } -#[cfg(all(feature = "extras", feature = "voice"))] +#[cfg(feature = "voice")] fn leave(context: Context, message: Message, _args: Vec<String>) { let guild_id = match CACHE.read().unwrap().get_guild_channel(message.channel_id) { Some(channel) => channel.guild_id, @@ -127,7 +127,7 @@ fn leave(context: Context, message: Message, _args: Vec<String>) { } } -#[cfg(all(feature = "extras", feature = "voice"))] +#[cfg(feature = "voice")] fn mute(context: Context, message: Message, _args: Vec<String>) { let guild_id = match CACHE.read().unwrap().get_guild_channel(message.channel_id) { Some(channel) => channel.guild_id, diff --git a/src/client/context.rs b/src/client/context.rs index f420537..c0fe43f 100644 --- a/src/client/context.rs +++ b/src/client/context.rs @@ -1159,11 +1159,7 @@ impl Context { /// /// fn ping(context: Context, message: Message, _arguments: Vec<String>) { /// let cache = CACHE.read().unwrap(); - /// let ch = cache.get_channel(message.channel_id); - /// let name = match ch { - /// Some(Channel::Guild(ch)) => ch.name.clone(), - /// _ => "Unknown".to_owned(), - /// }; + /// let channel = cache.get_guild_channel(message.channel_id); /// /// let _ = context.send_message(message.channel_id, |m| m /// .content("Pong! Here's some info") @@ -1188,7 +1184,7 @@ impl Context { /// .field(|f| f /// .inline(true) /// .name("Channel name:") - /// .value(&name)) + /// .value(&channel.map_or_else(|| "Unknown", |c| &c.name))) /// .footer(|mut f| { /// f = f.text(&format!("Generated by {}", cache.user.name)); /// diff --git a/src/model/gateway.rs b/src/model/gateway.rs index cda1c59..101f050 100644 --- a/src/model/gateway.rs +++ b/src/model/gateway.rs @@ -1,7 +1,6 @@ use super::utils::*; use super::*; use ::internal::prelude::*; -use ::utils::decode_array; impl Game { #[cfg(feature="methods")] |