Skip to content

Commit

Permalink
Undeprecate methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kangalio committed Oct 30, 2023
1 parent bcca906 commit ab4f552
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
13 changes: 8 additions & 5 deletions src/builder/edit_interaction_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,25 @@ impl EditInteractionResponse {
Self(self.0.attachments(attachments))
}

#[deprecated(since = "0.12.0", note = "use `.attachments(...)` for new code")]
/// Adds a new attachment to the message.
///
/// Resets existing attachments. See [`Self::keep_existing_attachment`] or read
/// [`EditAttachments`] for explanation.
pub fn new_attachment(self, attachment: CreateAttachment) -> Self {
#[allow(deprecated)]
Self(self.0.new_attachment(attachment))
}

#[deprecated(since = "0.12.0", note = "use `.attachments(...)` for new code")]
/// Shorthand for [`EditAttachments::keep`]
pub fn keep_existing_attachment(self, id: AttachmentId) -> Self {
#[allow(deprecated)]
Self(self.0.keep_existing_attachment(id))
}

#[deprecated(since = "0.12.0", note = "use `.attachments(...)` for new code")]
pub fn clear_existing_attachments(self) -> Self {
/// Shorthand for [`Self::attachments`] with [`EditAttachments::new`]
pub fn clear_attachments(self) -> Self {
#[allow(deprecated)]
Self(self.0.clear_existing_attachments())
Self(self.0.clear_attachments())
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/builder/edit_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,29 +193,32 @@ impl EditMessage {
self
}

#[deprecated(since = "0.12.0", note = "use `.attachments(...)` for new code")]
/// Adds a new attachment to the message.
///
/// Resets existing attachments. See [`Self::keep_existing_attachment`] or read
/// [`EditAttachments`] for explanation.
pub fn attachment(mut self, attachment: CreateAttachment) -> Self {
let attachments = self.attachments.get_or_insert_with(Default::default);
self.attachments = Some(std::mem::take(attachments).add(attachment));
self
}

#[deprecated(since = "0.12.0", note = "use `.attachments(...)` for new code")]
/// Shorthand for [`EditAttachments::keep`]
pub fn add_existing_attachment(mut self, id: AttachmentId) -> Self {
let attachments = self.attachments.get_or_insert_with(Default::default);
self.attachments = Some(std::mem::take(attachments).keep(id));
self
}

#[deprecated(since = "0.12.0", note = "use `.attachments(...)` for new code")]
/// Shorthand for [`EditAttachments::remove`]
pub fn remove_existing_attachment(mut self, id: AttachmentId) -> Self {
if let Some(attachments) = self.attachments {
self.attachments = Some(attachments.remove(id));
}
self
}

#[deprecated(since = "0.12.0", note = "use `.attachments(...)` for new code")]
/// Shorthand for [`Self::attachments`] with [`EditAttachments::new`]
pub fn remove_all_attachments(mut self) -> Self {
self.attachments = Some(EditAttachments::new());
self
Expand Down
11 changes: 7 additions & 4 deletions src/builder/edit_webhook_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,25 @@ impl EditWebhookMessage {
self
}

#[deprecated(since = "0.12.0", note = "use `.attachments(...)` for new code")]
/// Adds a new attachment to the message.
///
/// Resets existing attachments. See [`Self::keep_existing_attachment`] or read
/// [`EditAttachments`] for explanation.
pub fn new_attachment(mut self, attachment: CreateAttachment) -> Self {
let attachments = self.attachments.get_or_insert_with(Default::default);
self.attachments = Some(std::mem::take(attachments).add(attachment));
self
}

#[deprecated(since = "0.12.0", note = "use `.attachments(...)` for new code")]
/// Shorthand for [`EditAttachments::keep`]
pub fn keep_existing_attachment(mut self, id: AttachmentId) -> Self {
let attachments = self.attachments.get_or_insert_with(Default::default);
self.attachments = Some(std::mem::take(attachments).keep(id));
self
}

#[deprecated(since = "0.12.0", note = "use `.attachments(...)` for new code")]
pub fn clear_existing_attachments(mut self) -> Self {
/// Shorthand for [`Self::attachments`] with [`EditAttachments::new`]
pub fn clear_attachments(mut self) -> Self {
self.attachments = Some(EditAttachments::new());
self
}
Expand Down

0 comments on commit ab4f552

Please sign in to comment.