implement guild stickers
This commit is contained in:
@ -60,6 +60,7 @@ from .appinfo import AppInfo
|
||||
from .ui.view import View
|
||||
from .stage_instance import StageInstance
|
||||
from .threads import Thread
|
||||
from .sticker import GuildSticker, StandardSticker, StickerPack, _sticker_factory
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .abc import SnowflakeTime, PrivateChannel, GuildChannel, Snowflake
|
||||
@ -277,6 +278,14 @@ class Client:
|
||||
"""List[:class:`.Emoji`]: The emojis that the connected client has."""
|
||||
return self._connection.emojis
|
||||
|
||||
@property
|
||||
def stickers(self) -> List[GuildSticker]:
|
||||
"""List[:class:`GuildSticker`]: The stickers that the connected client has.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
"""
|
||||
return self._connection.stickers
|
||||
|
||||
@property
|
||||
def cached_messages(self) -> Sequence[Message]:
|
||||
"""Sequence[:class:`.Message`]: Read-only list of messages the connected client has cached.
|
||||
@ -777,6 +786,23 @@ class Client:
|
||||
"""
|
||||
return self._connection.get_emoji(id)
|
||||
|
||||
def get_sticker(self, id: int) -> Optional[GuildSticker]:
|
||||
"""Returns a guild sticker with the given ID.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
.. note::
|
||||
|
||||
To retrieve standard stickers, use :meth:`.fetch_sticker`.
|
||||
or :meth:`.fetch_nitro_sticker_packs`.
|
||||
|
||||
Returns
|
||||
--------
|
||||
Optional[:class:`.GuildSticker`]
|
||||
The sticker or ``None`` if not found.
|
||||
"""
|
||||
return self._connection.get_sticker(id)
|
||||
|
||||
def get_all_channels(self) -> Generator[GuildChannel, None, None]:
|
||||
"""A generator that retrieves every :class:`.abc.GuildChannel` the client can 'access'.
|
||||
|
||||
@ -1443,6 +1469,49 @@ class Client:
|
||||
data = await self.http.get_webhook(webhook_id)
|
||||
return Webhook.from_state(data, state=self._connection)
|
||||
|
||||
async def fetch_sticker(self, sticker_id: int) -> Union[StandardSticker, GuildSticker]:
|
||||
"""|coro|
|
||||
|
||||
Retrieves a :class:`.Sticker` with the specified ID.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
Raises
|
||||
--------
|
||||
:exc:`.HTTPException`
|
||||
Retrieving the sticker failed.
|
||||
:exc:`.NotFound`
|
||||
Invalid sticker ID.
|
||||
|
||||
Returns
|
||||
--------
|
||||
Union[:class:`.StandardSticker`, :class:`.GuildSticker`]
|
||||
The sticker you requested.
|
||||
"""
|
||||
data = await self.http.get_sticker(sticker_id)
|
||||
cls, _ = _sticker_factory(data['type']) # type: ignore
|
||||
return cls(state=self._connection, data=data) # type: ignore
|
||||
|
||||
async def fetch_nitro_sticker_packs(self) -> List[StickerPack]:
|
||||
"""|coro|
|
||||
|
||||
Retrieves all available nitro sticker packs.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
Raises
|
||||
-------
|
||||
:exc:`.HTTPException`
|
||||
Retrieving the sticker packs failed.
|
||||
|
||||
Returns
|
||||
---------
|
||||
List[:class:`.StickerPack`]
|
||||
All available nitro sticker packs.
|
||||
"""
|
||||
data = await self.http.list_nitro_sticker_packs()
|
||||
return [StickerPack(state=self._connection, data=pack) for pack in data['sticker_packs']]
|
||||
|
||||
async def create_dm(self, user: Snowflake) -> DMChannel:
|
||||
"""|coro|
|
||||
|
||||
|
Reference in New Issue
Block a user