Implement roles kwarg for guild.create_custom_emoji and emoji.edit
This commit is contained in:
parent
e825762807
commit
0e6082c57d
@ -228,7 +228,7 @@ class Emoji(Hashable):
|
|||||||
|
|
||||||
await self._state.http.delete_custom_emoji(self.guild.id, self.id, reason=reason)
|
await self._state.http.delete_custom_emoji(self.guild.id, self.id, reason=reason)
|
||||||
|
|
||||||
async def edit(self, *, name, reason=None):
|
async def edit(self, *, name, roles=None, reason=None):
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
Edits the custom emoji.
|
Edits the custom emoji.
|
||||||
@ -242,6 +242,8 @@ class Emoji(Hashable):
|
|||||||
-----------
|
-----------
|
||||||
name: str
|
name: str
|
||||||
The new emoji name.
|
The new emoji name.
|
||||||
|
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]
|
reason: Optional[str]
|
||||||
The reason for editing this emoji. Shows up on the audit log.
|
The reason for editing this emoji. Shows up on the audit log.
|
||||||
|
|
||||||
@ -253,4 +255,6 @@ class Emoji(Hashable):
|
|||||||
An error occurred editing the emoji.
|
An error occurred editing the emoji.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
await self._state.http.edit_custom_emoji(self.guild.id, self.id, name=name, reason=reason)
|
if roles:
|
||||||
|
roles = [role.id for role in roles]
|
||||||
|
await self._state.http.edit_custom_emoji(self.guild.id, self.id, name=name, roles=roles, reason=reason)
|
||||||
|
@ -986,7 +986,7 @@ class Guild(Hashable):
|
|||||||
|
|
||||||
return result
|
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|
|
"""|coro|
|
||||||
|
|
||||||
Creates a custom :class:`Emoji` for the guild.
|
Creates a custom :class:`Emoji` for the guild.
|
||||||
@ -1005,6 +1005,8 @@ class Guild(Hashable):
|
|||||||
image: bytes
|
image: bytes
|
||||||
The *bytes-like* object representing the image data to use.
|
The *bytes-like* object representing the image data to use.
|
||||||
Only JPG and PNG images are supported.
|
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]
|
reason: Optional[str]
|
||||||
The reason for creating this emoji. Shows up on the audit log.
|
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)
|
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)
|
return self._state.store_emoji(self, data)
|
||||||
|
|
||||||
async def create_role(self, *, reason=None, **fields):
|
async def create_role(self, *, reason=None, **fields):
|
||||||
|
@ -600,10 +600,11 @@ class HTTPClient:
|
|||||||
}
|
}
|
||||||
return self.request(Route('GET', '/guilds/{guild_id}/prune', guild_id=guild_id), params=params)
|
return self.request(Route('GET', '/guilds/{guild_id}/prune', guild_id=guild_id), params=params)
|
||||||
|
|
||||||
def create_custom_emoji(self, guild_id, name, image, *, reason=None):
|
def create_custom_emoji(self, guild_id, name, image, *, roles=None, reason=None):
|
||||||
payload = {
|
payload = {
|
||||||
'name': name,
|
'name': name,
|
||||||
'image': image
|
'image': image,
|
||||||
|
'roles': roles or []
|
||||||
}
|
}
|
||||||
|
|
||||||
r = Route('POST', '/guilds/{guild_id}/emojis', guild_id=guild_id)
|
r = Route('POST', '/guilds/{guild_id}/emojis', guild_id=guild_id)
|
||||||
@ -613,9 +614,10 @@ class HTTPClient:
|
|||||||
r = Route('DELETE', '/guilds/{guild_id}/emojis/{emoji_id}', guild_id=guild_id, emoji_id=emoji_id)
|
r = Route('DELETE', '/guilds/{guild_id}/emojis/{emoji_id}', guild_id=guild_id, emoji_id=emoji_id)
|
||||||
return self.request(r, reason=reason)
|
return self.request(r, reason=reason)
|
||||||
|
|
||||||
def edit_custom_emoji(self, guild_id, emoji_id, *, name, reason=None):
|
def edit_custom_emoji(self, guild_id, emoji_id, *, name, roles=None, reason=None):
|
||||||
payload = {
|
payload = {
|
||||||
'name': name
|
'name': name,
|
||||||
|
'roles': roles or []
|
||||||
}
|
}
|
||||||
r = Route('PATCH', '/guilds/{guild_id}/emojis/{emoji_id}', guild_id=guild_id, emoji_id=emoji_id)
|
r = Route('PATCH', '/guilds/{guild_id}/emojis/{emoji_id}', guild_id=guild_id, emoji_id=emoji_id)
|
||||||
return self.request(r, json=payload, reason=reason)
|
return self.request(r, json=payload, reason=reason)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user