mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-04 17:06: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:
@ -244,7 +244,9 @@ class Context(discord.abc.Messageable, Generic[BotT]):
|
||||
if interaction.channel_id is None:
|
||||
raise RuntimeError('interaction channel ID is null, this is probably a Discord bug')
|
||||
|
||||
channel = interaction.channel or PartialMessageable(state=interaction._state, id=interaction.channel_id)
|
||||
channel = interaction.channel or PartialMessageable(
|
||||
state=interaction._state, guild_id=interaction.guild_id, id=interaction.channel_id
|
||||
)
|
||||
message = Message(state=interaction._state, channel=channel, data=synthetic_payload) # type: ignore
|
||||
message.author = interaction.user
|
||||
message.attachments = [a for _, a in interaction.namespace if isinstance(a, Attachment)]
|
||||
|
Reference in New Issue
Block a user