Skip to content

Commit 29889fe

Browse files
feat: Adding icon_url property for team.Application (#656)
* feat: Adding icon_url property for team.Application * ci: correct from checks. * Update team.pyi * feat: Adding icon_url property for team.Application Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 5cd9ea5 commit 29889fe

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

interactions/api/models/team.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,19 @@ def __init__(self, **kwargs):
117117
self.owner = User(**self.owner) if self._json.get("owner") else None
118118
self.team = Team(**self.team) if self._json.get("team") else None
119119
self.flags = AppFlags(self.flags) if self._json.get("flags") else None
120+
121+
@property
122+
def icon_url(self) -> str:
123+
"""
124+
Returns the URL of the application's icon
125+
126+
:return: URL of the application's icon.
127+
:rtype: str
128+
"""
129+
url = "https://cdn.discordapp.com/"
130+
if self.icon:
131+
url += f"avatars/{int(self.id)}/{self.icon}"
132+
url += ".gif" if self.icon.startswith("a_") else ".png"
133+
else:
134+
url += f"embed/avatars/{int(self.discriminator) % 5}.png"
135+
return url

interactions/api/models/team.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ class Application(DictSerializerMixin):
4444
type: Optional[Any]
4545
hook: Optional[Any]
4646
def __init__(self, **kwargs): ...
47+
@property
48+
def icon_url(self) -> str: ...

0 commit comments

Comments
 (0)