diff --git a/CHANGELOG.md b/CHANGELOG.md index 89af5c015f..9bc0bccc58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#1867](https://github.com/Pycord-Development/pycord/pull/1867)) - Added support for usernames and modified multiple methods accordingly. ([#2042](https://github.com/Pycord-Development/pycord/pull/2042)) +- Added `icon` and `unicode_emoji` to `Guild.create_role`. + ([#2086](https://github.com/Pycord-Development/pycord/pull/2086)) ### Changed diff --git a/discord/guild.py b/discord/guild.py index bd379e8531..9f1aae0c2b 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -2803,6 +2803,8 @@ async def create_role( colour: Colour | int = ..., hoist: bool = ..., mentionable: bool = ..., + icon: bytes | None = MISSING, + unicode_emoji: str | None = MISSING, ) -> Role: ... @@ -2816,6 +2818,8 @@ async def create_role( color: Colour | int = ..., hoist: bool = ..., mentionable: bool = ..., + icon: bytes | None = ..., + unicode_emoji: str | None = ..., ) -> Role: ... @@ -2829,6 +2833,8 @@ async def create_role( hoist: bool = MISSING, mentionable: bool = MISSING, reason: str | None = None, + icon: bytes | None = MISSING, + unicode_emoji: str | None = MISSING, ) -> Role: """|coro| @@ -2859,6 +2865,13 @@ async def create_role( Defaults to ``False``. reason: Optional[:class:`str`] The reason for creating this role. Shows up on the audit log. + icon: Optional[:class:`bytes`] + A :term:`py:bytes-like object` representing the icon. Only PNG/JPEG/WebP is supported. + If this argument is passed, ``unicode_emoji`` is set to None. + Only available to guilds that contain ``ROLE_ICONS`` in :attr:`Guild.features`. + unicode_emoji: Optional[:class:`str`] + The role's unicode emoji. If this argument is passed, ``icon`` is set to None. + Only available to guilds that contain ``ROLE_ICONS`` in :attr:`Guild.features`. Returns ------- @@ -2895,6 +2908,17 @@ async def create_role( if name is not MISSING: fields["name"] = name + if icon is not MISSING: + if icon is None: + fields["icon"] = None + else: + fields["icon"] = _bytes_to_base64_data(icon) + fields["unicode_emoji"] = None + + if unicode_emoji is not MISSING: + fields["unicode_emoji"] = unicode_emoji + fields["icon"] = None + data = await self._state.http.create_role(self.id, reason=reason, **fields) role = Role(guild=self, data=data, state=self._state)