Skip to content

Commit

Permalink
feat: Adding url property for getting emoji's url from the emoji'…
Browse files Browse the repository at this point in the history
…s icon (#783)

* feat: Adding ``icon_url`` property for getting the guild's icon URL

* feat: Adding ``url`` property for ``Emoji`` for getting the emoji's URL

* ci: correct from checks.

* file: Update interactions/api/models/message.py

Co-authored-by: Max <maxyolo01.ytb@gmail.com>

* file: Update interactions/api/models/message.pyi

Co-authored-by: Max <maxyolo01.ytb@gmail.com>

* file: Update interactions/api/models/message.py

Co-authored-by: Max <maxyolo01.ytb@gmail.com>

* file: Update ./api/models/message.py to meet the review

* file: Update interactions/api/models/message.py

Co-authored-by: Toricane <73972068+Toricane@users.noreply.github.com>

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Max <maxyolo01.ytb@gmail.com>
Co-authored-by: Toricane <73972068+Toricane@users.noreply.github.com>
  • Loading branch information
4 people authored May 19, 2022
1 parent c0d6661 commit 1de7844
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions interactions/api/models/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,18 @@ async def delete(
guild_id=guild_id, emoji_id=int(self.id), reason=reason
)

@property
def url(self) -> str:
"""
Returns the emoji's URL.
:return: URL of the emoji
:rtype: str
"""
url = f"https://cdn.discordapp.com/emojis/{self.id}"
url += ".gif" if self.animated else ".png"
return url


class ReactionObject(DictSerializerMixin):
"""The reaction object.
Expand Down
2 changes: 2 additions & 0 deletions interactions/api/models/message.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ class Emoji(DictSerializerMixin):
guild_id: int,
reason: Optional[str] = None,
) -> None: ...
@property
def url(self) -> str: ...

class ReactionObject(DictSerializerMixin):
_json: dict
Expand Down

0 comments on commit 1de7844

Please sign in to comment.