aboutsummaryrefslogtreecommitdiff
path: root/src/model/user.rs
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-11-15 11:36:53 -0800
committerAustin Hellyer <[email protected]>2016-11-15 11:36:53 -0800
commit5ccfaaa3b1a030b1fd0dcd364bdae001347d36e4 (patch)
tree7cf531e4790109d6d7edd26bc5b483378d5ba5ac /src/model/user.rs
parentEmbed Author: everything but 'name' is optional (diff)
downloadserenity-5ccfaaa3b1a030b1fd0dcd364bdae001347d36e4.tar.xz
serenity-5ccfaaa3b1a030b1fd0dcd364bdae001347d36e4.zip
Add state/framework/etc. conditional compile flags
This adds conditional compilation for the following features, in addition to the voice conditional compilation flag: - extras (message builder) - framework - methods - state These 4 are enabled _by default_, while the `voice` feature flag is disabled. Disabling the state will allow incredibly low-memory bots.
Diffstat (limited to 'src/model/user.rs')
-rw-r--r--src/model/user.rs25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/model/user.rs b/src/model/user.rs
index f748d67..ce3d3a5 100644
--- a/src/model/user.rs
+++ b/src/model/user.rs
@@ -1,4 +1,3 @@
-use serde_json::builder::ObjectBuilder;
use std::fmt;
use super::utils::{into_map, into_string, remove, warn_field};
use super::{
@@ -6,15 +5,23 @@ use super::{
GuildContainer,
GuildId,
Mention,
- Message,
RoleId,
UserSettings,
User
};
-use ::client::{STATE, http};
use ::internal::prelude::*;
use ::utils::decode_array;
+#[cfg(feature = "methods")]
+use serde_json::builder::ObjectBuilder;
+#[cfg(feature = "methods")]
+use super::Message;
+#[cfg(feature = "methods")]
+use ::client::http;
+
+#[cfg(feature = "state")]
+use ::client::STATE;
+
impl User {
/// Returns the formatted URL of the user's icon, if one exists.
pub fn avatar_url(&self) -> Option<String> {
@@ -25,6 +32,7 @@ impl User {
/// This is an alias of [direct_message].
///
/// [direct_message]: #method.direct_message
+ #[cfg(feature="methods")]
pub fn dm(&self, content: &str) -> Result<Message> {
self.direct_message(content)
}
@@ -32,6 +40,7 @@ impl User {
/// Send a direct message to a user. This will create or retrieve the
/// PrivateChannel over REST if one is not already in the State, and then
/// send a message to it.
+ #[cfg(feature="methods")]
pub fn direct_message(&self, content: &str)
-> Result<Message> {
let private_channel_id = {
@@ -94,12 +103,16 @@ impl User {
match guild.into() {
GuildContainer::Guild(guild) => {
- guild.find_role(role_id).is_some()
+ guild.roles.get(&role_id).is_some()
},
GuildContainer::Id(guild_id) => {
- let state = STATE.lock().unwrap();
+ feature_state! {{
+ let state = STATE.lock().unwrap();
- state.find_role(guild_id, role_id).is_some()
+ state.find_role(guild_id, role_id).is_some()
+ } else {
+ true
+ }}
},
}
}