Repository: serenity-rs/serenity (language: rust)

Issue:
Update `MessageReference` Struct
the [`MessageReference`](https://github.com/serenity-rs/serenity/blob/current/src/model/channel/message.rs#L1095) struct is missing the type field (see here: https://discord.com/developers/docs/resources/message#message-reference-object)

I am happy to implement this myself, the question is do you want this added as a struct field, or make a union enum from this? 


Discussion / hints:
This looks to be part of fowarding, which should have it's issue opened to track, but you can add this as a field as part of the forwarding work if you want. Use our `enum_number!` macro to make `MessageReferenceType`/`Kind` (depending what everything else is) and add it as a field.

Fix patch:
diff --git a/src/builder/create_message.rs b/src/builder/create_message.rs
index 874ba3682ea..ebe56ef4014 100644
--- a/src/builder/create_message.rs
+++ b/src/builder/create_message.rs
@@ -208,7 +208,7 @@ impl CreateMessage {
         self
     }
 
-    /// Set the reference message this message is a reply to.
+    /// Set the message this reply or forward is referring to.
     pub fn reference_message(mut self, reference: impl Into<MessageReference>) -> Self {
         self.message_reference = Some(reference.into());
         self
diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs
index c8dc8495510..6ede655d74e 100644
--- a/src/model/channel/message.rs
+++ b/src/model/channel/message.rs
@@ -1086,6 +1086,22 @@ pub struct MessageActivity {
     pub party_id: Option<String>,
 }
 
+enum_number! {
+    /// Message Reference Type information
+    ///
+    /// [Discord docs](https://discord.com/developers/docs/resources/message#message-reference-types)
+    #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
+    #[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
+    #[serde(from = "u8", into = "u8")]
+    #[non_exhaustive]
+    pub enum MessageReferenceKind {
+        #[default]
+        Default = 0,
+        Forward = 1,
+        _ => Unknown(u8),
+    }
+}
+
 /// Reference data sent with crossposted messages.
 ///
 /// [Discord docs](https://discord.com/developers/docs/resources/channel#message-reference-object-message-reference-structure).
@@ -1093,6 +1109,9 @@ pub struct MessageActivity {
 #[derive(Clone, Debug, Deserialize, Serialize)]
 #[non_exhaustive]
 pub struct MessageReference {
+    /// The Type of Message Reference
+    #[serde(rename = "type", default = "MessageReferenceKind::default")]
+    pub kind: MessageReferenceKind,
     /// ID of the originating message.
     pub message_id: Option<MessageId>,
     /// ID of the originating message's channel.
@@ -1104,9 +1123,41 @@ pub struct MessageReference {
     pub fail_if_not_exists: Option<bool>,
 }
 
+impl MessageReference {
+    #[must_use]
+    pub fn new(kind: MessageReferenceKind, channel_id: ChannelId) -> Self {
+        Self {
+            kind,
+            channel_id,
+            message_id: None,
+            guild_id: None,
+            fail_if_not_exists: None,
+        }
+    }
+
+    #[must_use]
+    pub fn message_id(mut self, message_id: MessageId) -> Self {
+        self.message_id = Some(message_id);
+        self
+    }
+
+    #[must_use]
+    pub fn guild_id(mut self, guild_id: GuildId) -> Self {
+        self.guild_id = Some(guild_id);
+        self
+    }
+
+    #[must_use]
+    pub fn fail_if_not_exists(mut self, fail_if_not_exists: bool) -> Self {
+        self.fail_if_not_exists = Some(fail_if_not_exists);
+        self
+    }
+}
+
 impl From<&Message> for MessageReference {
     fn from(m: &Message) -> Self {
         Self {
+            kind: MessageReferenceKind::default(),
             message_id: Some(m.id),
             channel_id: m.channel_id,
             guild_id: m.guild_id,
@@ -1116,8 +1167,10 @@ impl From<&Message> for MessageReference {
 }
 
 impl From<(ChannelId, MessageId)> for MessageReference {
+    // TODO(next): Remove this
     fn from(pair: (ChannelId, MessageId)) -> Self {
         Self {
+            kind: MessageReferenceKind::default(),
             message_id: Some(pair.1),
             channel_id: pair.0,
             guild_id: None,


Test patch: