From dfbe23d014d5c001cf865a8e8778fa866dbf4125 Mon Sep 17 00:00:00 2001 From: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com> Date: Mon, 12 Aug 2024 14:40:09 -0700 Subject: [PATCH 1/2] docs: fix hyphen-related grammar (#2527) !crowdin upload --- docs/api/enums.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/enums.rst b/docs/api/enums.rst index bd319f86eb..c734e2fd1e 100644 --- a/docs/api/enums.rst +++ b/docs/api/enums.rst @@ -418,13 +418,13 @@ of :class:`enum.Enum`. Represents a slash command interaction. .. attribute:: component - Represents a component based interaction, i.e. using the Discord Bot UI Kit. + Represents a component-based interaction, i.e. using the Discord Bot UI Kit. .. attribute:: auto_complete Represents a autocomplete interaction for slash commands. .. attribute:: modal_submit - Represents a modal based interaction. + Represents a modal-based interaction. .. class:: InteractionResponseType From d8a948bace75ff60ba3361bfcfdc6f9509250a08 Mon Sep 17 00:00:00 2001 From: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:10:34 -0700 Subject: [PATCH 2/2] feat: implement `Guild.fetch_role` (#2528) * feat: implement `Guild.fetch_role` * style(pre-commit): auto fixes from pre-commit.com hooks * docs: add changelog entry --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> !crowdin update --- CHANGELOG.md | 5 +++++ discord/guild.py | 24 ++++++++++++++++++++++++ discord/http.py | 10 ++++++++++ 3 files changed, 39 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ebb0f0528..2e71e51acc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,11 @@ These changes are available on the `master` branch, but have not yet been releas - ⚠️ **This Version Removes Support For Python 3.8** ⚠️ ([#2521](https://github.com/Pycord-Development/pycord/pull/2521)) +### Added + +- Added `Guild.fetch_role` method. + ([#2528](https://github.com/Pycord-Development/pycord/pull/2528)) + ## [2.6.0] - 2024-07-09 ### Added diff --git a/discord/guild.py b/discord/guild.py index eda67a2e13..52d2acd783 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -2815,6 +2815,30 @@ async def fetch_roles(self) -> list[Role]: data = await self._state.http.get_roles(self.id) return [Role(guild=self, state=self._state, data=d) for d in data] + async def fetch_role(self, role_id: int) -> Role: + """|coro| + + Retrieves a :class:`Role` that the guild has. + + .. note:: + + This method is an API call. For general usage, consider using :attr:`get_role` instead. + + .. versionadded:: 2.7 + + Returns + ------- + :class:`Role` + The role in the guild with the specified ID. + + Raises + ------ + HTTPException + Retrieving the role failed. + """ + data = await self._state.http.get_role(self.id, role_id) + return Role(guild=self, state=self._state, data=data) + async def _fetch_role(self, role_id: int) -> Role: """|coro| diff --git a/discord/http.py b/discord/http.py index 8b3db319e7..7813d20a23 100644 --- a/discord/http.py +++ b/discord/http.py @@ -2048,6 +2048,16 @@ def delete_invite( def get_roles(self, guild_id: Snowflake) -> Response[list[role.Role]]: return self.request(Route("GET", "/guilds/{guild_id}/roles", guild_id=guild_id)) + def get_role(self, guild_id: Snowflake, role_id: Snowflake) -> Response[role.Role]: + return self.request( + Route( + "GET", + "/guilds/{guild_id}/roles/{role_id}", + guild_id=guild_id, + role_id=role_id, + ) + ) + def edit_role( self, guild_id: Snowflake,