From 0e6082c57d9139dbba6e998c147b34cae5018e78 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 19 Jul 2018 17:12:24 -0400 Subject: Implement roles kwarg for guild.create_custom_emoji and emoji.edit --- discord/guild.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'discord/guild.py') diff --git a/discord/guild.py b/discord/guild.py index 8f770b19..46621e83 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -986,7 +986,7 @@ class Guild(Hashable): return result - async def create_custom_emoji(self, *, name, image, reason=None): + async def create_custom_emoji(self, *, name, image, roles=None, reason=None): """|coro| Creates a custom :class:`Emoji` for the guild. @@ -1005,6 +1005,8 @@ class Guild(Hashable): image: bytes The *bytes-like* object representing the image data to use. Only JPG and PNG images are supported. + roles: Optional[list[:class:`Role`]] + A :class:`list` of :class:`Role`s that can use this emoji. Leave empty to make it available to everyone. reason: Optional[str] The reason for creating this emoji. Shows up on the audit log. @@ -1022,7 +1024,9 @@ class Guild(Hashable): """ img = utils._bytes_to_base64_data(image) - data = await self._state.http.create_custom_emoji(self.id, name, img, reason=reason) + if roles: + roles = [role.id for role in roles] + data = await self._state.http.create_custom_emoji(self.id, name, img, roles=roles, reason=reason) return self._state.store_emoji(self, data) async def create_role(self, *, reason=None, **fields): -- cgit v1.2.3