diff options
| author | SebbyLaw <[email protected]> | 2020-10-04 05:41:29 -0700 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2020-11-21 21:11:47 -0500 |
| commit | 2e2560126fb924d558c9df3f92162eda4de46323 (patch) | |
| tree | fffc3eee715cf2296b35f903aa3ba3e9e8ecb1c5 /discord/channel.py | |
| parent | Translation sync with crowdin (diff) | |
| download | discord.py-2e2560126fb924d558c9df3f92162eda4de46323.tar.xz discord.py-2e2560126fb924d558c9df3f92162eda4de46323.zip | |
Implement icon_rl_as and cover_image_url_as for AppInfo
Diffstat (limited to 'discord/channel.py')
| -rw-r--r-- | discord/channel.py | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/discord/channel.py b/discord/channel.py index c3ccbe0f..7568b404 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -1154,8 +1154,39 @@ class GroupChannel(discord.abc.Messageable, Hashable): @property def icon_url(self): - """:class:`Asset`: Returns the channel's icon asset if available.""" - return Asset._from_icon(self._state, self, 'channel') + """:class:`Asset`: Returns the channel's icon asset if available. + + This is equivalent to calling :meth:`icon_url_as` with + the default parameters ('webp' format and a size of 1024). + """ + return self.icon_url_as() + + def icon_url_as(self, *, format='webp', size=1024): + """Returns an :class:`Asset` for the icon the channel has. + + The format must be one of 'webp', 'jpeg', 'jpg' or 'png'. + The size must be a power of 2 between 16 and 4096. + + .. versionadded:: 2.0 + + Parameters + ----------- + format: :class:`str` + The format to attempt to convert the icon to. Defaults to 'webp'. + size: :class:`int` + The size of the image to display. + + Raises + ------ + InvalidArgument + Bad image format passed to ``format`` or invalid ``size``. + + Returns + -------- + :class:`Asset` + The resulting CDN asset. + """ + return Asset._from_icon(self._state, self, 'channel', format=format, size=size) @property def created_at(self): |