Skip to content

Commit

Permalink
Adjust docs and fix clippy warnings
Browse files Browse the repository at this point in the history
Of note:
 - Renamed `CreateMessage::set_sticker_ids` -> `CreateMessage::sticker_ids`
  • Loading branch information
mkrasnitski committed Jun 25, 2022
1 parent 90608c1 commit 3912a2f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/builder/create_interaction_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,6 @@ impl<'a> CreateAutocompleteResponse<'a> {
/// Returns an [`Error::Http`] if the API returns an error.
#[cfg(feature = "http")]
pub async fn execute(self, http: impl AsRef<Http>) -> Result<()> {
http.as_ref().create_interaction_response(self.id.into(), &self.token, &self).await
http.as_ref().create_interaction_response(self.id.into(), self.token, &self).await
}
}
8 changes: 4 additions & 4 deletions src/builder/create_interaction_response_followup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,17 @@ impl<'a> CreateInteractionResponseFollowup<'a> {
match self.id {
Some(id) => {
if files.is_empty() {
http.edit_followup_message(&self.token, id.into(), &self).await
http.edit_followup_message(self.token, id.into(), &self).await
} else {
http.edit_followup_message_and_attachments(&self.token, id.into(), &self, files)
http.edit_followup_message_and_attachments(self.token, id.into(), &self, files)
.await
}
},
None => {
if files.is_empty() {
http.create_followup_message(&self.token, &self).await
http.create_followup_message(self.token, &self).await
} else {
http.create_followup_message_with_files(&self.token, &self, files).await
http.create_followup_message_with_files(self.token, &self, files).await
}
},
}
Expand Down
52 changes: 25 additions & 27 deletions src/builder/create_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ use crate::http::{CacheHttp, Http};
use crate::internal::prelude::*;
use crate::model::prelude::*;

/// A builder to specify the contents of an [`Http::send_message`] request,
/// primarily meant for use through [`ChannelId::send_message`].
/// A builder to specify the contents of an [`Http::send_message`] request, primarily meant for use
/// through [`ChannelId::send_message`].
///
/// There are three situations where different field requirements are present:
///
/// 1. When sending a message without embeds or stickers, [`Self::content`] is
/// the only required field that is required to be set.
/// 1. When sending a message without embeds or stickers, [`Self::content`] is the only required
/// field that is required to be set.
/// 2. When sending an [`Self::embed`], no other field is required.
/// 3. When sending stickers with [`Self::sticker_id`] or other sticker methods,
/// no other field is required.
/// 3. When sending stickers with [`Self::sticker_id`] or other sticker methods, no other field is
/// required.
///
/// Note that if you only need to send the content of a message, without
/// specifying other fields, then [`ChannelId::say`] may be a more preferable
/// option.
/// Note that if you only need to send the content of a message, without specifying other fields,
/// then [`ChannelId::say`] may be a more preferable option.
///
/// # Examples
///
Expand Down Expand Up @@ -186,8 +185,8 @@ impl<'a> CreateMessage<'a> {

/// Sets a list of files to include in the message.
///
/// Calling this multiple times will overwrite the file list.
/// To append files, call [`Self::add_file`] or [`Self::add_files`] instead.
/// Calling this multiple times will overwrite the file list. To append files, call
/// [`Self::add_file`] or [`Self::add_files`] instead.
///
/// **Note**: Requres the [Attach Files] permission.
///
Expand Down Expand Up @@ -242,20 +241,12 @@ impl<'a> CreateMessage<'a> {
self
}

/// Sets a single sticker ID to include in the message.
///
/// **Note**: This will replace all existing stickers. Use
/// [`Self::add_sticker_id()`] to add an additional sticker.
pub fn sticker_id(self, sticker_id: impl Into<StickerId>) -> Self {
self.set_sticker_ids(vec![sticker_id.into()])
}

/// Add a sticker ID for the message.
///
/// **Note**: There can be a maximum of 3 stickers in a message.
///
/// **Note**: This will keep all existing stickers. Use
/// [`Self::set_sticker_ids()`] to replace existing stickers.
/// **Note**: This will keep all existing stickers. Use [`Self::sticker_ids()`] to replace
/// existing stickers.
pub fn add_sticker_id(mut self, sticker_id: impl Into<StickerId>) -> Self {
self.sticker_ids.push(sticker_id.into());
self
Expand All @@ -265,8 +256,8 @@ impl<'a> CreateMessage<'a> {
///
/// **Note**: There can be a maximum of 3 stickers in a message.
///
/// **Note**: This will keep all existing stickers. Use
/// [`Self::set_sticker_ids()`] to replace existing stickers.
/// **Note**: This will keep all existing stickers. Use [`Self::sticker_ids()`] to replace
/// existing stickers.
pub fn add_sticker_ids<T: Into<StickerId>, It: IntoIterator<Item = T>>(
mut self,
sticker_ids: It,
Expand All @@ -277,14 +268,21 @@ impl<'a> CreateMessage<'a> {
self
}

/// Sets a single sticker ID to include in the message.
///
/// **Note**: This will replace all existing stickers. Use [`Self::add_sticker_id()`] to add an
/// additional sticker.
pub fn sticker_id(self, sticker_id: impl Into<StickerId>) -> Self {
self.sticker_ids(vec![sticker_id.into()])
}

/// Sets a list of sticker IDs to include in the message.
///
/// **Note**: There can be a maximum of 3 stickers in a message.
///
/// **Note**: This will replace all existing stickers. Use
/// [`Self::add_sticker_id()`] or [`Self::add_sticker_ids()`] to keep
/// existing stickers.
pub fn set_sticker_ids<T: Into<StickerId>, It: IntoIterator<Item = T>>(
/// **Note**: This will replace all existing stickers. Use [`Self::add_sticker_ids()`] or
/// [`Self::add_sticker_ids()`] to keep existing stickers.
pub fn sticker_ids<T: Into<StickerId>, It: IntoIterator<Item = T>>(
mut self,
sticker_ids: It,
) -> Self {
Expand Down
15 changes: 7 additions & 8 deletions src/model/channel/embed.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#[cfg(feature = "utils")]
use crate::utils::Colour;

/// Represents a rich embed which allows using richer markdown, multiple fields
/// and more. This was heavily inspired by [slack's attachments].
/// Represents a rich embed which allows using richer markdown, multiple fields and more. This was
/// heavily inspired by [slack's attachments].
///
/// You can include an attachment in your own message by a user or a bot, or in
/// a webhook.
/// You can include an attachment in your own message by a user or a bot, or in a webhook.
///
/// **Note**: Maximum amount of characters you can put is 256 in a field name,
/// 1024 in a field value, and 2048 in a description.
/// **Note**: Maximum amount of characters you can put is 256 in a field name, 1024 in a field
/// value, and 2048 in a description.
///
/// [slack's attachments]: https://api.slack.com/docs/message-attachments
#[derive(Clone, Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -43,8 +42,8 @@ pub struct Embed {
pub kind: Option<String>,
/// Provider information for the embed.
///
/// For example, if the embed [`Self::kind`] is `"video"`, the provider might
/// contain information about YouTube.
/// For example, if the embed [`Self::kind`] is `"video"`, the provider might contain
/// information about YouTube.
pub provider: Option<EmbedProvider>,
/// Thumbnail information of the embed.
pub thumbnail: Option<EmbedThumbnail>,
Expand Down
2 changes: 1 addition & 1 deletion src/model/channel/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ impl Message {
.parse(crate::builder::ParseValue::Everyone)
.parse(crate::builder::ParseValue::Users)
.parse(crate::builder::ParseValue::Roles)
})
});
}
builder.execute(cache_http.http()).await
}
Expand Down

0 comments on commit 3912a2f

Please sign in to comment.