aboutsummaryrefslogtreecommitdiff
path: root/src/model/id.rs
diff options
context:
space:
mode:
authorIllia <[email protected]>2016-12-06 23:51:42 +0200
committerzeyla <[email protected]>2016-12-06 13:51:42 -0800
commit13de5c2e50410c3a68435dc774537b490bb7115c (patch)
tree798c633e9e06e520083b29fa4417f089f476d0e0 /src/model/id.rs
parentFix changelog header (diff)
downloadserenity-13de5c2e50410c3a68435dc774537b490bb7115c.tar.xz
serenity-13de5c2e50410c3a68435dc774537b490bb7115c.zip
Improve Mentions, fix MessageBuilder
Remove the obsolete Mention struct as well as related methods, improve the way mentioning works, fix the message builder, add a test for all this.
Diffstat (limited to 'src/model/id.rs')
-rw-r--r--src/model/id.rs68
1 files changed, 28 insertions, 40 deletions
diff --git a/src/model/id.rs b/src/model/id.rs
index 5f534ec..032e722 100644
--- a/src/model/id.rs
+++ b/src/model/id.rs
@@ -1,4 +1,5 @@
use super::*;
+use std::fmt;
#[cfg(all(feature = "cache", feature = "methods"))]
use ::client::CACHE;
@@ -27,17 +28,6 @@ impl ChannelId {
rest::get_channel(self.0)
}
- /// Returns a [`Mention`] which will link to the [`Channel`].
- ///
- /// [`Channel`]: enum.Channel.html
- /// [`Mention`]: struct.Mention.html
- pub fn mention(&self) -> Mention {
- Mention {
- id: self.0,
- prefix: "<#",
- }
- }
-
/// Retrieves the channel's webhooks.
///
/// **Note**: Requires the [Manage Webhooks] permission.
@@ -97,16 +87,6 @@ impl GuildId {
rest::get_guild(self.0)
}
- /// Mentions the [`Guild`]'s default channel.
- ///
- /// [`Guild`]: struct.Guild.html
- pub fn mention(&self) -> Mention {
- Mention {
- id: self.0,
- prefix: "<#",
- }
- }
-
/// Returns this Id as a `ChannelId`, which is useful when needing to use
/// the guild Id to send a message to the default channel.
#[cfg(feature = "methods")]
@@ -190,16 +170,6 @@ impl RoleId {
})
.cloned()
}
-
- /// Returns a [`Mention`] which will ping members of the role.
- ///
- /// [`Mention`]: struct.Mention.html
- pub fn mention(&self) -> Mention {
- Mention {
- id: self.0,
- prefix: "<@&",
- }
- }
}
impl From<CurrentUser> for UserId {
@@ -223,15 +193,33 @@ impl From<User> for UserId {
}
}
-impl UserId {
- /// Returns a [`Mention`] which will ping the user.
- ///
- /// [`Mention`]: struct.Mention.html
- pub fn mention(&self) -> Mention {
- Mention {
- id: self.0,
- prefix: "<@",
- }
+impl fmt::Display for UserId {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fmt::Display::fmt(&self.mention(), f)
+ }
+}
+
+impl fmt::Display for RoleId {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fmt::Display::fmt(&self.mention(), f)
+ }
+}
+
+impl fmt::Display for ChannelId {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fmt::Display::fmt(&self.mention(), f)
+ }
+}
+
+impl fmt::Display for GuildId {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fmt::Display::fmt(&self.0, f)
+ }
+}
+
+impl fmt::Display for EmojiId {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fmt::Display::fmt(&self.0, f)
}
}