Skip to content

Commit

Permalink
Add a method to retrieve a link to a message (#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
arqunis authored Jun 18, 2020
1 parent e7eb52d commit a92ca08
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/model/channel/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,16 @@ impl Message {
self.guild_id.as_ref().and_then(|guild_id| self.author.nick_in(cache_http, *guild_id))
}

/// Returns a link referencing this message. When clicked, users will jump to the message.
/// The link will be valid for messages in either private channels or guilds.
#[inline]
pub fn link(&self) -> String {
match self.guild_id {
Some(guild_id) => format!("https://discord.com/channels/{}/{}/{}", guild_id.0, self.channel_id.0, self.id.0),
None => format!("https://discord.com/channels/@me/{}/{}", self.channel_id.0, self.id.0),
}
}

pub(crate) fn check_content_length(map: &JsonMap) -> Result<()> {
if let Some(content) = map.get("content") {
if let Value::String(ref content) = *content {
Expand Down

0 comments on commit a92ca08

Please sign in to comment.