Add Message.jump_url helper (#68)
Some checks failed
Deploy MkDocs / deploy (push) Has been cancelled
Some checks failed
Deploy MkDocs / deploy (push) Has been cancelled
This commit is contained in:
parent
7c7bebc95a
commit
def2ff0183
@ -11,6 +11,7 @@ A Python library for interacting with the Discord API, with a focus on bot devel
|
||||
- Gateway and HTTP API clients
|
||||
- Slash command framework
|
||||
- Message component helpers
|
||||
- `Message.jump_url` property for quick links to messages
|
||||
- Built-in caching layer
|
||||
- Experimental voice support
|
||||
- Helpful error handling utilities
|
||||
|
@ -115,6 +115,13 @@ class Message:
|
||||
# self.mention_roles: List[str] = data.get("mention_roles", [])
|
||||
# self.mention_everyone: bool = data.get("mention_everyone", False)
|
||||
|
||||
@property
|
||||
def jump_url(self) -> str:
|
||||
"""Return a URL that jumps to this message in the Discord client."""
|
||||
|
||||
guild_or_dm = self.guild_id or "@me"
|
||||
return f"https://discord.com/channels/{guild_or_dm}/{self.channel_id}/{self.id}"
|
||||
|
||||
@property
|
||||
def clean_content(self) -> str:
|
||||
"""Returns message content without user, role, or channel mentions."""
|
||||
|
@ -8,6 +8,9 @@ async for message in channel.history(limit=200):
|
||||
print(message.content)
|
||||
```
|
||||
|
||||
Each returned `Message` has a ``jump_url`` property that links directly to the
|
||||
message in the Discord client.
|
||||
|
||||
Pass `before` or `after` to control the range of messages returned. The paginator fetches messages in batches of up to 100 until the limit is reached or Discord returns no more messages.
|
||||
|
||||
## Next Steps
|
||||
|
Loading…
x
Reference in New Issue
Block a user