aboutsummaryrefslogtreecommitdiff
path: root/src/model/user.rs
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-12-10 10:16:35 -0800
committerAustin Hellyer <[email protected]>2016-12-10 10:16:35 -0800
commit530de25aa5345223fa924e76eb69bb32e484a62a (patch)
treea243a073855f4a8fdc57e122dc52538be76e9414 /src/model/user.rs
parentDeprecate embed image/thumbnail height/width (diff)
downloadserenity-530de25aa5345223fa924e76eb69bb32e484a62a.tar.xz
serenity-530de25aa5345223fa924e76eb69bb32e484a62a.zip
Fix no-cache+method conditional compiles
Additionally, flag imports behind feature flags to avoid unused imports.
Diffstat (limited to 'src/model/user.rs')
-rw-r--r--src/model/user.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/model/user.rs b/src/model/user.rs
index f5906ab..adc766f 100644
--- a/src/model/user.rs
+++ b/src/model/user.rs
@@ -1,29 +1,32 @@
-use std::{fmt, mem};
+use std::fmt;
use super::utils::{into_map, into_string, remove};
use super::{
CurrentUser,
FriendSourceFlags,
GuildContainer,
GuildId,
- GuildInfo,
RoleId,
UserSettings,
User,
};
-use ::client::rest::GuildPagination;
use ::internal::prelude::*;
-use ::utils::builder::EditProfile;
use ::utils::decode_array;
use ::model::misc::Mentionable;
#[cfg(feature = "methods")]
use serde_json::builder::ObjectBuilder;
+#[cfg(feature="methods")]
+use std::mem;
#[cfg(feature = "methods")]
use super::Message;
#[cfg(feature = "methods")]
use time::Timespec;
#[cfg(feature = "methods")]
-use ::client::rest;
+use ::client::rest::{self, GuildPagination};
+#[cfg(feature="methods")]
+use super::GuildInfo;
+#[cfg(feature="methods")]
+use ::utils::builder::EditProfile;
#[cfg(feature = "cache")]
use ::client::CACHE;
@@ -45,7 +48,7 @@ impl CurrentUser {
///
/// Change the avatar:
///
- /// ```rust,no_run
+ /// ```rust,ignore
/// use serenity::client::CACHE;
///
/// let avatar = serenity::utils::read_image("./avatar.png").unwrap();
@@ -79,12 +82,14 @@ impl CurrentUser {
}
}
- /// Returns the DiscordTag(tm) of a User.
+ /// Returns the DiscordTag™ of a User.
+ #[cfg(feature="methods")]
pub fn distinct(&self) -> String {
format!("{}#{}", self.name, self.discriminator)
}
/// Gets a list of guilds that the current user is in.
+ #[cfg(feature="methods")]
pub fn guilds(&self) -> Result<Vec<GuildInfo>> {
rest::get_guilds(GuildPagination::After(GuildId(0)), 100)
}
@@ -178,6 +183,8 @@ impl User {
/// [`GuildId`]: struct.GuildId.html
/// [`Role`]: struct.Role.html
/// [`Cache`]: ../ext/cache/struct.Cache.html
+ #[allow(unused_variables)]
+ // no-cache would warn on guild_id.
pub fn has_role<G, R>(&self, guild: G, role: R) -> bool
where G: Into<GuildContainer>, R: Into<RoleId> {
let role_id = role.into();