diff options
| author | Austin Hellyer <[email protected]> | 2017-01-08 19:30:39 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2017-01-08 19:30:39 -0800 |
| commit | 9a80be04a0ba5c6066606286f71285e5aa2949d5 (patch) | |
| tree | 7e945710f788efdb5af3842e7b24c0c3b26907fb /src/model/user.rs | |
| parent | Add more shard logging (diff) | |
| download | serenity-9a80be04a0ba5c6066606286f71285e5aa2949d5.tar.xz serenity-9a80be04a0ba5c6066606286f71285e5aa2949d5.zip | |
Alphabetize model method names
Diffstat (limited to 'src/model/user.rs')
| -rw-r--r-- | src/model/user.rs | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/src/model/user.rs b/src/model/user.rs index d5d7027..d0b2f10 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -17,9 +17,9 @@ use ::model::misc::Mentionable; use serde_json::builder::ObjectBuilder; #[cfg(feature="methods")] use std::mem; -#[cfg(feature = "methods")] +#[cfg(feature="methods")] use super::Message; -#[cfg(all(feature = "cache", feature = "methods"))] +#[cfg(all(feature="cache", feature="methods"))] use super::Member; #[cfg(feature="methods")] use time::Timespec; @@ -50,6 +50,12 @@ impl CurrentUser { }) } + /// Returns the DiscordTag™ of a User. + #[cfg(feature="methods")] + pub fn distinct(&self) -> String { + format!("{}#{}", self.name, self.discriminator) + } + /// Edits the current user's profile settings. /// /// This mutates the current user in-place. @@ -94,12 +100,6 @@ impl CurrentUser { } } - /// 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>> { @@ -132,15 +132,6 @@ impl User { }) } - /// Gets user as `Member` of a guild. - #[cfg(all(feature="cache", feature="methods"))] - pub fn member<G>(&self, guild_id: G) -> Option<Member> - where G: Into<GuildId> { - let cache = CACHE.read().unwrap(); - - cache.get_member(guild_id.into(), self.id).cloned() - } - /// Retrieves the time that this user was created at. #[cfg(feature="methods")] #[inline] @@ -148,14 +139,6 @@ impl User { self.id.created_at() } - /// 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) - } - /// Send a direct message to a user. This will create or retrieve the /// PrivateChannel over REST if one is not already in the cache, and then /// send a message to it. @@ -196,6 +179,15 @@ impl User { rest::send_message(private_channel_id.0, map) } + /// This is an alias of [direct_message]. + /// + /// [direct_message]: #method.direct_message + #[cfg(feature="methods")] + #[inline] + pub fn dm(&self, content: &str) -> Result<Message> { + self.direct_message(content) + } + /// Check if a user has a [`Role`]. This will retrieve the /// [`Guild`] from the [`Cache`] if it is available, and then check if that /// guild has the given [`Role`]. @@ -243,6 +235,15 @@ impl User { } } + /// Gets the user's member instance for a guild. + #[cfg(all(feature="cache", feature="methods"))] + pub fn member<G>(&self, guild_id: G) -> Option<Member> + where G: Into<GuildId> { + let cache = CACHE.read().unwrap(); + + cache.get_member(guild_id.into(), self.id).cloned() + } + /// Returns a static formatted URL of the user's icon, if one exists. /// /// This will always produce a WEBP image URL. |