@@ -1086,13 +1086,32 @@ pub struct MessageActivity {
10861086 pub party_id : Option < String > ,
10871087}
10881088
1089+ enum_number ! {
1090+ /// Message Reference Type information
1091+ ///
1092+ /// [Discord docs](https://discord.com/developers/docs/resources/message#message-reference-types)
1093+ #[ derive( Clone , Copy , Debug , Default , Eq , Hash , Ord , PartialEq , PartialOrd , Deserialize , Serialize ) ]
1094+ #[ cfg_attr( feature = "typesize" , derive( typesize:: derive:: TypeSize ) ) ]
1095+ #[ serde( from = "u8" , into = "u8" ) ]
1096+ #[ non_exhaustive]
1097+ pub enum MessageReferenceKind {
1098+ #[ default ]
1099+ Default = 0 ,
1100+ Forward = 1 ,
1101+ _ => Unknown ( u8 ) ,
1102+ }
1103+ }
1104+
10891105/// Reference data sent with crossposted messages.
10901106///
10911107/// [Discord docs](https://discord.com/developers/docs/resources/channel#message-reference-object-message-reference-structure).
10921108#[ cfg_attr( feature = "typesize" , derive( typesize:: derive:: TypeSize ) ) ]
10931109#[ derive( Clone , Debug , Deserialize , Serialize ) ]
10941110#[ non_exhaustive]
10951111pub struct MessageReference {
1112+ /// The Type of Message Reference
1113+ #[ serde( rename = "type" , default = "MessageReferenceKind::default" ) ]
1114+ pub kind : MessageReferenceKind ,
10961115 /// ID of the originating message.
10971116 pub message_id : Option < MessageId > ,
10981117 /// ID of the originating message's channel.
@@ -1104,9 +1123,41 @@ pub struct MessageReference {
11041123 pub fail_if_not_exists : Option < bool > ,
11051124}
11061125
1126+ impl MessageReference {
1127+ #[ must_use]
1128+ pub fn new ( kind : MessageReferenceKind , channel_id : ChannelId ) -> Self {
1129+ Self {
1130+ kind,
1131+ channel_id,
1132+ message_id : None ,
1133+ guild_id : None ,
1134+ fail_if_not_exists : None ,
1135+ }
1136+ }
1137+
1138+ #[ must_use]
1139+ pub fn message_id ( mut self , message_id : MessageId ) -> Self {
1140+ self . message_id = Some ( message_id) ;
1141+ self
1142+ }
1143+
1144+ #[ must_use]
1145+ pub fn guild_id ( mut self , guild_id : GuildId ) -> Self {
1146+ self . guild_id = Some ( guild_id) ;
1147+ self
1148+ }
1149+
1150+ #[ must_use]
1151+ pub fn fail_if_not_exists ( mut self , fail_if_not_exists : bool ) -> Self {
1152+ self . fail_if_not_exists = Some ( fail_if_not_exists) ;
1153+ self
1154+ }
1155+ }
1156+
11071157impl From < & Message > for MessageReference {
11081158 fn from ( m : & Message ) -> Self {
11091159 Self {
1160+ kind : MessageReferenceKind :: default ( ) ,
11101161 message_id : Some ( m. id ) ,
11111162 channel_id : m. channel_id ,
11121163 guild_id : m. guild_id ,
@@ -1116,8 +1167,10 @@ impl From<&Message> for MessageReference {
11161167}
11171168
11181169impl From < ( ChannelId , MessageId ) > for MessageReference {
1170+ // TODO(next): Remove this
11191171 fn from ( pair : ( ChannelId , MessageId ) ) -> Self {
11201172 Self {
1173+ kind : MessageReferenceKind :: default ( ) ,
11211174 message_id : Some ( pair. 1 ) ,
11221175 channel_id : pair. 0 ,
11231176 guild_id : None ,
0 commit comments