From 455c91f0ceff58ccefecc2a6fe126e4c1bdca546 Mon Sep 17 00:00:00 2001 From: UK <41271523+NeloBlivion@users.noreply.github.com> Date: Tue, 23 May 2023 04:35:29 +0100 Subject: [PATCH 1/3] Add icon and unicode_emoji to Guild.create_role --- discord/guild.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/discord/guild.py b/discord/guild.py index bd379e8531..d0e2e330a7 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,14 @@ 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`. + Could be ``None`` to denote removal of the icon. + 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 +2909,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) From b668aaeb24d028dfb372cdea7a33da45bd6f3aaa Mon Sep 17 00:00:00 2001 From: UK <41271523+NeloBlivion@users.noreply.github.com> Date: Tue, 23 May 2023 04:53:56 +0100 Subject: [PATCH 2/3] adjust wording --- discord/guild.py | 1 - 1 file changed, 1 deletion(-) diff --git a/discord/guild.py b/discord/guild.py index d0e2e330a7..9f1aae0c2b 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -2869,7 +2869,6 @@ async def create_role( 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`. - Could be ``None`` to denote removal of the icon. 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`. From d384da336a6d7f879002c674026301197979b672 Mon Sep 17 00:00:00 2001 From: UK <41271523+NeloBlivion@users.noreply.github.com> Date: Tue, 23 May 2023 04:55:13 +0100 Subject: [PATCH 3/3] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) 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