Skip to content

Commit

Permalink
Merge branch 'master' into docs/sphinx-warns-and-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JustaSqu1d authored Aug 12, 2024
2 parents 44185dc + d8a948b commit 17a59e5
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
10 changes: 10 additions & 0 deletions discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions docs/api/enums.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 17a59e5

Please sign in to comment.