<commit_before>use model::{
    guild::Emoji,
    id::{ChannelId, RoleId, UserId},
    misc::Mentionable
};
use std::{
    default::Default,
    fmt::{self, Display, Write},
    ops::Add
};

/// The Message Builder is an ergonomic utility to easily build a message,
/// by adding text and mentioning mentionable structs.
///
/// The finalized value can be accessed via [`build`] or the inner value.
///
/// # Examples
///
/// Build a message, mentioning a [`user`] and an [`emoji`], and retrieving the
/// value:
///
/// ```rust,no_run
/// # use serenity::model::prelude::*;
/// #
/// # let user = UserId(1);
/// # let emoji = Emoji {
/// #     animated: false,
/// #     id: EmojiId(2),
/// #     name: "test".to_string(),
/// #     managed: false,
/// #     require_colons: true,
/// #     roles: vec![],
/// # };
/// #
/// use serenity::utils::MessageBuilder;
///
/// // assuming an `emoji` and `user` have already been bound
///
/// let content = MessageBuilder::new()
///     .push("You sent a message, ")
///     .mention(&user)
///     .push("! ")
///     .mention(&emoji)
///     .build();
/// ```
///
/// [`build`]: #method.build
/// [`emoji`]: #method.emoji
/// [`user`]: #method.user
#[derive(Clone, Debug, Default)]
pub struct MessageBuilder(pub String);

impl MessageBuilder {
    /// Creates a new, empty builder.
    ///
    /// # Examples
    ///
    /// Create a new `MessageBuilder`:
    ///
    /// ```rust
    /// use serenity::utils::MessageBuilder;
    ///
    /// let message = MessageBuilder::new();
    ///
    /// // alternatively:
    /// let message = MessageBuilder::default();
    /// ```
    pub fn new() -> MessageBuilder { MessageBuilder::default() }

    /// Pulls the inner value out of the builder.
    ///
    /// # Examples
    ///
    /// Create a string mentioning a channel by Id, and then suffixing `"!"`,
    /// and finally building it to retrieve the inner String:
    ///
    /// ```rust
    /// use serenity::model::id::ChannelId;
    /// use serenity::utils::MessageBuilder;
    ///
    /// let channel_id = ChannelId(81384788765712384);
    ///
    /// let content = MessageBuilder::new()
    ///     .channel(channel_id)
    ///     .push("!")
    ///     .build();
    ///
    /// assert_eq!(content, "<#81384788765712384>!");
    /// ```
    ///
    /// This is equivalent to simply retrieving the tuple struct's first value:
    ///
    /// ```rust
    /// use serenity::utils::MessageBuilder;
    ///
    /// let content = MessageBuilder::new().push("test").0;
    ///
    /// assert_eq!(content, "test");
    /// ```
    pub fn build(self) -> String { self.0 }

    /// Mentions the [`GuildChannel`] in the built message.
    ///
    /// This accepts anything that converts _into_ a [`ChannelId`]. Refer to
    /// `ChannelId`'s documentation for more information.
    ///
    /// Refer to `ChannelId`'s [Display implementation] for more information on
    /// how this is formatted.
    ///
    /// # Examples
    ///
    /// Mentioning a [`Channel`] by Id:
    ///
    /// ```rust
    /// use serenity::model::id::ChannelId;
    /// use serenity::utils::MessageBuilder;
    ///
    /// let channel_id = ChannelId(81384788765712384);
    ///
    /// let content = MessageBuilder::new()
    ///     .push("The channel is: ")
    ///     .channel(channel_id)
    ///     .build();
    ///
    /// assert_eq!(content, "The channel is: <#81384788765712384>");
    /// ```
    ///
    /// [`Channel`]: ../model/channel/enum.Channel.html
    /// [`ChannelId`]: ../model/id/struct.ChannelId.html
    /// [`GuildChannel`]: ../model/channel/struct.GuildChannel.html
    /// [Display implementation]: ../model/id/struct.ChannelId.html#method.fmt-1
    pub fn channel<C: Into<ChannelId>>(mut self, channel: C) -> Self {
        let _ = write!(self.0, "{}", channel.into().mention());

        self
    }

    /// Displays the given emoji in the built message.
    ///
    /// Refer to `Emoji`s [Display implementation] for more information on how
    /// this is formatted.
    ///
    /// # Examples
    ///
    /// Mention an emoji in a message's content:
    ///
    /// ```rust
    /// use serenity::model::guild::Emoji;
    /// use serenity::model::id::EmojiId;
    /// use serenity::utils::MessageBuilder;
    ///
    /// let emoji = Emoji {
    ///     animated: false,
    ///     id: EmojiId(302516740095606785),
    ///     managed: true,
    ///     name: "smugAnimeFace".to_string(),
    ///     require_colons: true,
    ///     roles: vec![],
    /// };
    ///
    /// let message = MessageBuilder::new()
    ///     .push("foo ")
    ///     .emoji(&emoji)
    ///     .push(".")
    ///     .build();
    ///
    /// assert_eq!(message, "foo <:smugAnimeFace:302516740095606785>.");
    /// ```
    ///
    /// [Display implementation]: ../model/guild/struct.Emoji.html#method.fmt
    pub fn emoji(mut self, emoji: &Emoji) -> Self {
        let _ = write!(self.0, "{}", emoji);

        self
    }

    /// Mentions something that implements the [`Mentionable`] trait.
    ///
    /// [`Mentionable`]: ../model/trait.Mentionable.html<commit_msg>Fix dead link.<commit_after>use model::{
    guild::Emoji,
    id::{ChannelId, RoleId, UserId},
    misc::Mentionable
};
use std::{
    default::Default,
    fmt::{self, Display, Write},
    ops::Add
};

/// The Message Builder is an ergonomic utility to easily build a message,
/// by adding text and mentioning mentionable structs.
///
/// The finalized value can be accessed via [`build`] or the inner value.
///
/// # Examples
///
/// Build a message, mentioning a [`user`] and an [`emoji`], and retrieving the
/// value:
///
/// ```rust,no_run
/// # use serenity::model::prelude::*;
/// #
/// # let user = UserId(1);
/// # let emoji = Emoji {
/// #     animated: false,
/// #     id: EmojiId(2),
/// #     name: "test".to_string(),
/// #     managed: false,
/// #     require_colons: true,
/// #     roles: vec![],
/// # };
/// #
/// use serenity::utils::MessageBuilder;
///
/// // assuming an `emoji` and `user` have already been bound
///
/// let content = MessageBuilder::new()
///     .push("You sent a message, ")
///     .mention(&user)
///     .push("! ")
///     .mention(&emoji)
///     .build();
/// ```
///
/// [`build`]: #method.build
/// [`emoji`]: #method.emoji
/// [`user`]: #method.user
#[derive(Clone, Debug, Default)]
pub struct MessageBuilder(pub String);

impl MessageBuilder {
    /// Creates a new, empty builder.
    ///
    /// # Examples
    ///
    /// Create a new `MessageBuilder`:
    ///
    /// ```rust
    /// use serenity::utils::MessageBuilder;
    ///
    /// let message = MessageBuilder::new();
    ///
    /// // alternatively:
    /// let message = MessageBuilder::default();
    /// ```
    pub fn new() -> MessageBuilder { MessageBuilder::default() }

    /// Pulls the inner value out of the builder.
    ///
    /// # Examples
    ///
    /// Create a string mentioning a channel by Id, and then suffixing `"!"`,
    /// and finally building it to retrieve the inner String:
    ///
    /// ```rust
    /// use serenity::model::id::ChannelId;
    /// use serenity::utils::MessageBuilder;
    ///
    /// let channel_id = ChannelId(81384788765712384);
    ///
    /// let content = MessageBuilder::new()
    ///     .channel(channel_id)
    ///     .push("!")
    ///     .build();
    ///
    /// assert_eq!(content, "<#81384788765712384>!");
    /// ```
    ///
    /// This is equivalent to simply retrieving the tuple struct's first value:
    ///
    /// ```rust
    /// use serenity::utils::MessageBuilder;
    ///
    /// let content = MessageBuilder::new().push("test").0;
    ///
    /// assert_eq!(content, "test");
    /// ```
    pub fn build(self) -> String { self.0 }

    /// Mentions the [`GuildChannel`] in the built message.
    ///
    /// This accepts anything that converts _into_ a [`ChannelId`]. Refer to
    /// `ChannelId`'s documentation for more information.
    ///
    /// Refer to `ChannelId`'s [Display implementation] for more information on
    /// how this is formatted.
    ///
    /// # Examples
    ///
    /// Mentioning a [`Channel`] by Id:
    ///
    /// ```rust
    /// use serenity::model::id::ChannelId;
    /// use serenity::utils::MessageBuilder;
    ///
    /// let channel_id = ChannelId(81384788765712384);
    ///
    /// let content = MessageBuilder::new()
    ///     .push("The channel is: ")
    ///     .channel(channel_id)
    ///     .build();
    ///
    /// assert_eq!(content, "The channel is: <#81384788765712384>");
    /// ```
    ///
    /// [`Channel`]: ../model/channel/enum.Channel.html
    /// [`ChannelId`]: ../model/id/struct.ChannelId.html
    /// [`GuildChannel`]: ../model/channel/struct.GuildChannel.html
    /// [Display implementation]: ../model/id/struct.ChannelId.html#method.fmt-1
    pub fn channel<C: Into<ChannelId>>(mut self, channel: C) -> Self {
        let _ = write!(self.0, "{}", channel.into().mention());

        self
    }

    /// Displays the given emoji in the built message.
    ///
    /// Refer to `Emoji`s [Display implementation] for more information on how
    /// this is formatted.
    ///
    /// # Examples
    ///
    /// Mention an emoji in a message's content:
    ///
    /// ```rust
    /// use serenity::model::guild::Emoji;
    /// use serenity::model::id::EmojiId;
    /// use serenity::utils::MessageBuilder;
    ///
    /// let emoji = Emoji {
    ///     animated: false,
    ///     id: EmojiId(302516740095606785),
    ///     managed: true,
    ///     name: "smugAnimeFace".to_string(),
    ///     require_colons: true,
    ///     roles: vec![],
    /// };
    ///
    /// let message = MessageBuilder::new()
    ///     .push("foo ")
    ///     .emoji(&emoji)
    ///     .push(".")
    ///     .build();
    ///
    /// assert_eq!(message, "foo <:smugAnimeFace:302516740095606785>.");
    /// ```
    ///
    /// [Display implementation]: ../model/guild/struct.Emoji.html#method.fmt
    pub fn emoji(mut self, emoji: &Emoji) -> Self {
        let _ = write!(self.0, "{}", emoji);

        self
    }

    /// Mentions something that implements the [`Mentionable`] trait.
    ///
    /// [`Mentionable`]: ../model/misc/trait.Mentionable.html
{'fraction_non_alphanumeric': 0.21021726365237817, 'fraction_numerical': 0.02172636523781562, 'mean_word_length': 1.8924426832720067, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1755750', 'n_tokens_mistral': 3350, 'n_tokens_neox': 3260, 'n_words': 757}