diff options
| author | NCPlayz <[email protected]> | 2019-03-21 19:59:58 +0000 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-04-06 19:12:50 -0400 |
| commit | be227ebcf0c8bad6b56798339b5414b8da414dc0 (patch) | |
| tree | c7ea93ffc51e9a490b42d36e5c734b6b19ec3909 /discord/client.py | |
| parent | Propagate Cloudflare 429 HTML text. (diff) | |
| download | discord.py-be227ebcf0c8bad6b56798339b5414b8da414dc0.tar.xz discord.py-be227ebcf0c8bad6b56798339b5414b8da414dc0.zip | |
Redesign asset retrieval in the library.
Most assets now return a new class named `Asset`. This allows for the
assets to be consistently saved via a `save` method instead of special
casing for `Attachment`.
`AppInfo` is no longer a namedtuple it is a fully documented dataclass,
as well as having the state attached to it.
Fixes #1997
Diffstat (limited to 'discord/client.py')
| -rw-r--r-- | discord/client.py | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/discord/client.py b/discord/client.py index f8ac3b84..3ad4f7ae 100644 --- a/discord/client.py +++ b/discord/client.py @@ -35,6 +35,7 @@ import aiohttp import websockets from .user import User, Profile +from .asset import Asset from .invite import Invite from .widget import Widget from .guild import Guild @@ -50,21 +51,10 @@ from . import utils from .backoff import ExponentialBackoff from .webhook import Webhook from .iterators import GuildIterator +from .appinfo import AppInfo log = logging.getLogger(__name__) -AppInfo = namedtuple('AppInfo', - 'id name description rpc_origins bot_public bot_require_code_grant icon owner') - -def app_info_icon_url(self): - """Retrieves the application's icon_url if it exists. Empty string otherwise.""" - if not self.icon: - return '' - - return 'https://cdn.discordapp.com/app-icons/{0.id}/{0.icon}.jpg'.format(self) - -AppInfo.icon_url = property(app_info_icon_url) - class Client: r"""Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API. @@ -1060,11 +1050,7 @@ class Client: data = await self.http.application_info() if 'rpc_origins' not in data: data['rpc_origins'] = None - return AppInfo(id=int(data['id']), name=data['name'], - description=data['description'], icon=data['icon'], - rpc_origins=data['rpc_origins'], bot_public=data['bot_public'], - bot_require_code_grant=data['bot_require_code_grant'], - owner=User(state=self._connection, data=data['owner'])) + return AppInfo(self._connection, data) async def fetch_user(self, user_id): """|coro| |