From ac20ce73cd59658a9b9fa67923dae1e449bee79b Mon Sep 17 00:00:00 2001 From: Ivin Date: Tue, 27 Aug 2024 16:06:12 +0530 Subject: [PATCH] Add support for get_sticker_pack_by_id endpoint --- src/http/client.rs | 15 +++++++++++++++ src/http/routing.rs | 4 ++++ src/model/sticker.rs | 13 +++++++++++++ 3 files changed, 32 insertions(+) diff --git a/src/http/client.rs b/src/http/client.rs index 04a9eb0c47a..e01139fcd4e 100644 --- a/src/http/client.rs +++ b/src/http/client.rs @@ -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 { + 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> { #[derive(Deserialize)] diff --git a/src/http/routing.rs b/src/http/routing.rs index b3a04b02b44..516bd3eea92 100644 --- a/src/http/routing.rs +++ b/src/http/routing.rs @@ -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); diff --git a/src/model/sticker.rs b/src/model/sticker.rs index 5134f61cac7..7aee60ba0db 100644 --- a/src/model/sticker.rs +++ b/src/model/sticker.rs @@ -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) -> Result { + http.as_ref().get_sticker_pack(self).await + } +} + #[cfg(feature = "model")] impl StickerId { /// Delete a guild sticker.