From a51f69e104fd1ec82c8e3bf5b665f1a8575bda13 Mon Sep 17 00:00:00 2001 From: Sacul0457Deve <183588943+Sacul0457@users.noreply.github.com.> Date: Fri, 5 Jun 2026 14:51:56 +0800 Subject: [PATCH] add channel_type attr --- discord/message.py | 7 +++++++ discord/types/message.py | 1 + 2 files changed, 8 insertions(+) diff --git a/discord/message.py b/discord/message.py index 5192a54d2..6bc889375 100644 --- a/discord/message.py +++ b/discord/message.py @@ -2138,6 +2138,11 @@ class Message(PartialMessage, Hashable): The message snapshots attached to this message. .. versionadded:: 2.5 + channel_type: Optional[:class:`ChannelType`] + The message channel's Discord type. + This is only present when received in :func:`on_message`. + + .. versionadded:: 2.8 """ __slots__ = ( @@ -2177,6 +2182,7 @@ class Message(PartialMessage, Hashable): 'call', 'purchase_notification', 'message_snapshots', + 'channel_type', '_pinned_at', ) @@ -2218,6 +2224,7 @@ class Message(PartialMessage, Hashable): self.stickers: List[StickerItem] = [StickerItem(data=d, state=state) for d in data.get('sticker_items', [])] self.message_snapshots: List[MessageSnapshot] = MessageSnapshot._from_value(state, data.get('message_snapshots')) self.call: Optional[CallMessage] = None + self.channel_type: Optional[ChannelType] = try_enum(ChannelType, data['channel_type']) if 'channel_type' in data else None # Set by Messageable.pins self._pinned_at: Optional[datetime.datetime] = None diff --git a/discord/types/message.py b/discord/types/message.py index c7631ffc3..7533ba2f4 100644 --- a/discord/types/message.py +++ b/discord/types/message.py @@ -228,6 +228,7 @@ class Message(PartialMessage): thread: NotRequired[Thread] call: NotRequired[CallMessage] purchase_notification: NotRequired[PurchaseNotificationResponse] + channel_type: NotRequired[int] AllowedMentionType = Literal['roles', 'users', 'everyone']