|
|
@ -84,7 +84,7 @@ if TYPE_CHECKING: |
|
|
|
from typing_extensions import Self |
|
|
|
|
|
|
|
from .abc import Messageable, PrivateChannel, Snowflake, SnowflakeTime |
|
|
|
from .app_commands import Command, ContextMenu, MissingApplicationID |
|
|
|
from .app_commands import Command, ContextMenu |
|
|
|
from .automod import AutoModAction, AutoModRule |
|
|
|
from .channel import DMChannel, GroupChannel |
|
|
|
from .ext.commands import AutoShardedBot, Bot, Context, CommandError |
|
|
@ -249,6 +249,11 @@ class Client: |
|
|
|
set to is ``30.0`` seconds. |
|
|
|
|
|
|
|
.. versionadded:: 2.0 |
|
|
|
connector: Optional[:class:`aiohttp.BaseConnector`] |
|
|
|
The aiohhtp connector to use for this client. This can be used to control underlying aiohttp |
|
|
|
behavior, such as setting a dns resolver or sslcontext. |
|
|
|
|
|
|
|
.. versionadded:: 2.5 |
|
|
|
|
|
|
|
Attributes |
|
|
|
----------- |
|
|
@ -264,6 +269,7 @@ class Client: |
|
|
|
self.shard_id: Optional[int] = options.get('shard_id') |
|
|
|
self.shard_count: Optional[int] = options.get('shard_count') |
|
|
|
|
|
|
|
connector: Optional[aiohttp.BaseConnector] = options.get('connector', None) |
|
|
|
proxy: Optional[str] = options.pop('proxy', None) |
|
|
|
proxy_auth: Optional[aiohttp.BasicAuth] = options.pop('proxy_auth', None) |
|
|
|
unsync_clock: bool = options.pop('assume_unsync_clock', True) |
|
|
@ -271,6 +277,7 @@ class Client: |
|
|
|
max_ratelimit_timeout: Optional[float] = options.pop('max_ratelimit_timeout', None) |
|
|
|
self.http: HTTPClient = HTTPClient( |
|
|
|
self.loop, |
|
|
|
connector, |
|
|
|
proxy=proxy, |
|
|
|
proxy_auth=proxy_auth, |
|
|
|
unsync_clock=unsync_clock, |
|
|
@ -359,7 +366,13 @@ class Client: |
|
|
|
|
|
|
|
@property |
|
|
|
def emojis(self) -> Sequence[Emoji]: |
|
|
|
"""Sequence[:class:`.Emoji`]: The emojis that the connected client has.""" |
|
|
|
"""Sequence[:class:`.Emoji`]: The emojis that the connected client has. |
|
|
|
|
|
|
|
.. note:: |
|
|
|
|
|
|
|
This not include the emojis that are owned by the application. |
|
|
|
Use :meth:`.fetch_application_emoji` to get those. |
|
|
|
""" |
|
|
|
return self._connection.emojis |
|
|
|
|
|
|
|
@property |
|
|
@ -623,6 +636,11 @@ class Client: |
|
|
|
if self._connection.application_id is None: |
|
|
|
self._connection.application_id = self._application.id |
|
|
|
|
|
|
|
if self._application.interactions_endpoint_url is not None: |
|
|
|
_log.warning( |
|
|
|
'Application has an interaction endpoint URL set, this means registered components and app commands will not be received by the library.' |
|
|
|
) |
|
|
|
|
|
|
|
if not self._connection.application_flags: |
|
|
|
self._connection.application_flags = self._application.flags |
|
|
|
|
|
|
@ -2919,6 +2937,33 @@ class Client: |
|
|
|
data = await self.http.list_premium_sticker_packs() |
|
|
|
return [StickerPack(state=self._connection, data=pack) for pack in data['sticker_packs']] |
|
|
|
|
|
|
|
async def fetch_premium_sticker_pack(self, sticker_pack_id: int, /) -> StickerPack: |
|
|
|
"""|coro| |
|
|
|
|
|
|
|
Retrieves a premium sticker pack with the specified ID. |
|
|
|
|
|
|
|
.. versionadded:: 2.5 |
|
|
|
|
|
|
|
Parameters |
|
|
|
---------- |
|
|
|
sticker_pack_id: :class:`int` |
|
|
|
The sticker pack's ID to fetch from. |
|
|
|
|
|
|
|
Raises |
|
|
|
------- |
|
|
|
NotFound |
|
|
|
A sticker pack with this ID does not exist. |
|
|
|
HTTPException |
|
|
|
Retrieving the sticker pack failed. |
|
|
|
|
|
|
|
Returns |
|
|
|
------- |
|
|
|
:class:`.StickerPack` |
|
|
|
The retrieved premium sticker pack. |
|
|
|
""" |
|
|
|
data = await self.http.get_sticker_pack(sticker_pack_id) |
|
|
|
return StickerPack(state=self._connection, data=data) |
|
|
|
|
|
|
|
async def create_dm(self, user: Snowflake) -> DMChannel: |
|
|
|
"""|coro| |
|
|
|
|
|
|
@ -3039,3 +3084,97 @@ class Client: |
|
|
|
.. versionadded:: 2.0 |
|
|
|
""" |
|
|
|
return self._connection.persistent_views |
|
|
|
|
|
|
|
async def create_application_emoji( |
|
|
|
self, |
|
|
|
*, |
|
|
|
name: str, |
|
|
|
image: bytes, |
|
|
|
) -> Emoji: |
|
|
|
"""|coro| |
|
|
|
|
|
|
|
Create an emoji for the current application. |
|
|
|
|
|
|
|
.. versionadded:: 2.5 |
|
|
|
|
|
|
|
Parameters |
|
|
|
---------- |
|
|
|
name: :class:`str` |
|
|
|
The emoji name. Must be at least 2 characters. |
|
|
|
image: :class:`bytes` |
|
|
|
The :term:`py:bytes-like object` representing the image data to use. |
|
|
|
Only JPG, PNG and GIF images are supported. |
|
|
|
|
|
|
|
Raises |
|
|
|
------ |
|
|
|
MissingApplicationID |
|
|
|
The application ID could not be found. |
|
|
|
HTTPException |
|
|
|
Creating the emoji failed. |
|
|
|
|
|
|
|
Returns |
|
|
|
------- |
|
|
|
:class:`.Emoji` |
|
|
|
The emoji that was created. |
|
|
|
""" |
|
|
|
if self.application_id is None: |
|
|
|
raise MissingApplicationID |
|
|
|
|
|
|
|
img = utils._bytes_to_base64_data(image) |
|
|
|
data = await self.http.create_application_emoji(self.application_id, name, img) |
|
|
|
return Emoji(guild=Object(0), state=self._connection, data=data) |
|
|
|
|
|
|
|
async def fetch_application_emoji(self, emoji_id: int, /) -> Emoji: |
|
|
|
"""|coro| |
|
|
|
|
|
|
|
Retrieves an emoji for the current application. |
|
|
|
|
|
|
|
.. versionadded:: 2.5 |
|
|
|
|
|
|
|
Parameters |
|
|
|
---------- |
|
|
|
emoji_id: :class:`int` |
|
|
|
The emoji ID to retrieve. |
|
|
|
|
|
|
|
Raises |
|
|
|
------ |
|
|
|
MissingApplicationID |
|
|
|
The application ID could not be found. |
|
|
|
HTTPException |
|
|
|
Retrieving the emoji failed. |
|
|
|
|
|
|
|
Returns |
|
|
|
------- |
|
|
|
:class:`.Emoji` |
|
|
|
The emoji requested. |
|
|
|
""" |
|
|
|
if self.application_id is None: |
|
|
|
raise MissingApplicationID |
|
|
|
|
|
|
|
data = await self.http.get_application_emoji(self.application_id, emoji_id) |
|
|
|
return Emoji(guild=Object(0), state=self._connection, data=data) |
|
|
|
|
|
|
|
async def fetch_application_emojis(self) -> List[Emoji]: |
|
|
|
"""|coro| |
|
|
|
|
|
|
|
Retrieves all emojis for the current application. |
|
|
|
|
|
|
|
.. versionadded:: 2.5 |
|
|
|
|
|
|
|
Raises |
|
|
|
------- |
|
|
|
MissingApplicationID |
|
|
|
The application ID could not be found. |
|
|
|
HTTPException |
|
|
|
Retrieving the emojis failed. |
|
|
|
|
|
|
|
Returns |
|
|
|
------- |
|
|
|
List[:class:`.Emoji`] |
|
|
|
The list of emojis for the current application. |
|
|
|
""" |
|
|
|
if self.application_id is None: |
|
|
|
raise MissingApplicationID |
|
|
|
|
|
|
|
data = await self.http.get_application_emojis(self.application_id) |
|
|
|
return [Emoji(guild=Object(0), state=self._connection, data=emoji) for emoji in data['items']] |
|
|
|