Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for get_sticker_pack_by_id endpoint #2960

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4228,6 +4228,21 @@ impl Http {
.await
}

/// Retrieves a specific [`StickerPack`] from it's [`StickerPackId`]
pub async fn get_sticker_pack(&self, sticker_pack_id: StickerPackId) -> Result<StickerPack> {
self.fire(Request {
body: None,
multipart: None,
headers: None,
method: LightMethod::Get,
route: Route::StickerPack {
sticker_pack_id,
},
params: None,
})
.await
}

/// Retrieves a list of all nitro sticker packs.
pub async fn get_nitro_stickers(&self) -> Result<Vec<StickerPack>> {
#[derive(Deserialize)]
Expand Down
4 changes: 4 additions & 0 deletions src/http/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ routes! ('a, {
api!("/sticker-packs"),
Some(RatelimitingKind::Path);

StickerPack { sticker_pack_id: StickerPackId },
api!("/sticker-packs/{}", sticker_pack_id),
Some(RatelimitingKind::Path);

User { user_id: UserId },
api!("/users/{}", user_id),
Some(RatelimitingKind::Path);
Expand Down
13 changes: 13 additions & 0 deletions src/model/sticker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ use crate::internal::prelude::*;
use crate::model::prelude::*;
use crate::model::utils::comma_separated_string;

#[cfg(feature = "model")]
impl StickerPackId {
/// Gets the [`StickerPack`] object.
///
/// # Errors
///
/// Returns [`Error::Http`] if a [`StickerPack`] with that [`StickerPackId`] does not exist, or
/// is otherwise unavailable.
pub async fn to_sticker_pack(self, http: impl AsRef<Http>) -> Result<StickerPack> {
http.as_ref().get_sticker_pack(self).await
}
}

#[cfg(feature = "model")]
impl StickerId {
/// Delete a guild sticker.
Expand Down
Loading