mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-12-04 22:42:21 +00:00
Improve generic duck type programming with PartialMessageable
This adds jump_url, permissions_for, and created_at. Luckily, most cases of this type being constructed already have the guild_id at creation time.
This commit is contained in:
@@ -807,7 +807,9 @@ class Client:
|
||||
"""
|
||||
return self._connection.get_channel(id) # type: ignore # The cache contains all channel types
|
||||
|
||||
def get_partial_messageable(self, id: int, *, type: Optional[ChannelType] = None) -> PartialMessageable:
|
||||
def get_partial_messageable(
|
||||
self, id: int, *, guild_id: Optional[int] = None, type: Optional[ChannelType] = None
|
||||
) -> PartialMessageable:
|
||||
"""Returns a partial messageable with the given channel ID.
|
||||
|
||||
This is useful if you have a channel_id but don't want to do an API call
|
||||
@@ -819,6 +821,11 @@ class Client:
|
||||
-----------
|
||||
id: :class:`int`
|
||||
The channel ID to create a partial messageable for.
|
||||
guild_id: Optional[:class:`int`]
|
||||
The optional guild ID to create a partial messageable for.
|
||||
|
||||
This is not required to actually send messages, but it does allow the
|
||||
:meth:`PartialMessageable.jump_url` property to form a well formed URL.
|
||||
type: Optional[:class:`.ChannelType`]
|
||||
The underlying channel type for the partial messageable.
|
||||
|
||||
@@ -827,7 +834,7 @@ class Client:
|
||||
:class:`.PartialMessageable`
|
||||
The partial messageable
|
||||
"""
|
||||
return PartialMessageable(state=self._connection, id=id, type=type)
|
||||
return PartialMessageable(state=self._connection, id=id, guild_id=guild_id, type=type)
|
||||
|
||||
def get_stage_instance(self, id: int, /) -> Optional[StageInstance]:
|
||||
"""Returns a stage instance with the given stage channel ID.
|
||||
|
||||
Reference in New Issue
Block a user