44
44
from typing_extensions import Self
45
45
46
46
from . import utils
47
- from .channel import ThreadChannel
48
47
from .reaction import Reaction
49
48
from .emoji import Emoji
50
49
from .partial_emoji import PartialEmoji
83
82
84
83
__all__ = (
85
84
'Attachment' ,
85
+ 'MessageInteraction' ,
86
86
'Message' ,
87
87
'PartialMessage' ,
88
88
'MessageReference' ,
@@ -641,6 +641,8 @@ class Message(Hashable):
641
641
A list of stickers given to the message.
642
642
643
643
.. versionadded:: 1.6
644
+ interaction: Optional[:class:`MessageInteraction`]
645
+ The interaction associated with this message if any.
644
646
"""
645
647
646
648
__slots__ = ('_edited_timestamp' , 'tts' , 'content' , 'channel' , 'webhook_id' ,
@@ -661,6 +663,8 @@ def __init__(self, *, state: ConnectionState, channel, data: MessagePayload):
661
663
self .components : List [ActionRow ] = [ActionRow .from_dict (d ) for d in data .get ('components' , [])]
662
664
self .application = data .get ('application' ) # TODO: make this a class
663
665
self .activity = data .get ('activity' ) # TODO: make this a class
666
+ interaction = data .get ('interaction' )
667
+ self .interaction : Optional [MessageInteraction ] = MessageInteraction (state = state , data = data ) if interaction else None
664
668
self .channel : Messageable = channel
665
669
self ._edited_timestamp : datetime = utils .parse_time (data ['edited_timestamp' ])
666
670
self .type : MessageType = try_enum (MessageType , data ['type' ])
@@ -693,7 +697,7 @@ def __init__(self, *, state: ConnectionState, channel, data: MessagePayload):
693
697
694
698
ref .resolved = self .__class__ (channel = chan , data = resolved , state = state )
695
699
696
- for handler in ('author' , 'member' , 'mentions' , 'mention_roles' , 'flags' , 'interaction' , ' thread' ):
700
+ for handler in ('author' , 'member' , 'mentions' , 'mention_roles' , 'flags' , 'thread' ):
697
701
try :
698
702
getattr (self , '_handle_%s' % handler )(data [handler ])
699
703
except KeyError :
@@ -816,7 +820,7 @@ def _handle_embeds(self, value):
816
820
self .embeds : List [Embed ] = [Embed .from_dict (data ) for data in value ]
817
821
818
822
def _handle_interaction (self , value ):
819
- self .interaction = value # TODO: implement interaction-model for message
823
+ self .interaction = MessageInteraction ( state = self . _state , data = value )
820
824
821
825
def _handle_thread (self , value ):
822
826
thread = self .guild .get_channel (self .id )
0 commit comments