Repository: serenity-rs/serenity (language: rust)

Issue:
New get_guild_role endpoint
The new endpoint is:
GET `/guilds/{1}/roles/{2}` where `{1}` is a `GuildId` instance and `{2}` is a `RoleId` instance.

As well as the Http implementation, a helper method in the `GuildId` object could end up being useful (similar to the existing `roles` method). I can't imagine a reason to have a helper method in `RoleId`.

[Discord API docs change commit](https://github.com/discord/discord-api-docs/commit/722480036365d610539ac92f37279d028a247563)


Discussion / hints:

Fix patch:
diff --git a/src/http/client.rs b/src/http/client.rs
index b8a18cd08e3..04a9eb0c47a 100644
--- a/src/http/client.rs
+++ b/src/http/client.rs
@@ -3772,6 +3772,29 @@ impl Http {
         .await
     }
 
+    /// Retrieves a specific role in a [`Guild`].
+    pub async fn get_guild_role(&self, guild_id: GuildId, role_id: RoleId) -> Result<Role> {
+        let mut value: Value = self
+            .fire(Request {
+                body: None,
+                multipart: None,
+                headers: None,
+                method: LightMethod::Get,
+                route: Route::GuildRole {
+                    guild_id,
+                    role_id,
+                },
+                params: None,
+            })
+            .await?;
+
+        if let Some(map) = value.as_object_mut() {
+            map.insert("guild_id".to_string(), guild_id.get().into());
+        }
+
+        from_value(value).map_err(From::from)
+    }
+
     /// Retrieves a list of roles in a [`Guild`].
     pub async fn get_guild_roles(&self, guild_id: GuildId) -> Result<Vec<Role>> {
         let mut value: Value = self
diff --git a/src/model/guild/guild_id.rs b/src/model/guild/guild_id.rs
index a810c4ef243..3b4b67c5dd6 100644
--- a/src/model/guild/guild_id.rs
+++ b/src/model/guild/guild_id.rs
@@ -899,6 +899,16 @@ impl GuildId {
         builder.execute(cache_http, self).await
     }
 
+    /// Gets a specific role in the guild, by Id.
+    ///
+    /// # Errors
+    ///
+    /// Returns [`Error::Http`] if the current user is not in the guild, or if the role does not
+    /// exist.
+    pub async fn role(self, http: impl AsRef<Http>, role_id: RoleId) -> Result<Role> {
+        http.as_ref().get_guild_role(self, role_id).await
+    }
+
     /// Gets all of the guild's roles over the REST API.
     ///
     /// # Errors


Test patch: