Skip to content

Commit 0a0d5c9

Browse files
Nanrechpre-commit-ci[bot]EepyElvyra
authored
feat: Add url property for message objects (#695)
* feat: Add url property for message objects * ci: correct from checks. * Update interactions/api/models/message.py Co-authored-by: EdVraz <88881326+EdVraz@users.noreply.github.com> * Update message.pyi Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: EdVraz <88881326+EdVraz@users.noreply.github.com>
1 parent 1d5685c commit 0a0d5c9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

interactions/api/models/message.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,17 @@ async def get_from_url(cls, url: str, client: "HTTPClient") -> "Message": # noq
672672
)
673673
return cls(**_message, _client=client)
674674

675+
@property
676+
def url(self) -> str:
677+
"""
678+
Returns the URL of the message.
679+
680+
:return: The URL of said message
681+
:rtype: str
682+
"""
683+
guild = self.guild_id if self.guild_id else "@me"
684+
return f"https://discord.com/channels/{guild}/{self.channel_id}/{self.id}"
685+
675686

676687
class Emoji(DictSerializerMixin):
677688
"""

interactions/api/models/message.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ class Message(DictSerializerMixin):
170170
url: str,
171171
client: HTTPClient,
172172
) -> "Message": ...
173+
@property
174+
def url(self) -> str: ...
173175

174176
class Emoji(DictSerializerMixin):
175177
_client: HTTPClient

0 commit comments

Comments
 (0)