diff --git a/src/Discord.Net.Core/Entities/Messages/IMessage.cs b/src/Discord.Net.Core/Entities/Messages/IMessage.cs
index b74e333c1..35458d87d 100644
--- a/src/Discord.Net.Core/Entities/Messages/IMessage.cs
+++ b/src/Discord.Net.Core/Entities/Messages/IMessage.cs
@@ -148,11 +148,11 @@ namespace Discord
MessageApplication Application { get; }
///
- /// Gets the reference to the original message if it was crossposted.
+ /// Gets the reference to the original message if it is a crosspost, channel follow add, pin, or reply message.
///
///
- /// Sent with Cross-posted messages, meaning they were published from news channels
- /// and received by subscriber channels.
+ /// Sent with cross-posted messages, meaning they were published from news channels
+ /// and received by subscriber channels, channel follow adds, pins, and message replies.
///
///
/// A message's reference, if any is associated.
diff --git a/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs b/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs
index e2fb25aae..1589e2ae5 100644
--- a/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs
+++ b/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.Threading.Tasks;
namespace Discord
@@ -9,6 +8,14 @@ namespace Discord
///
public interface IUserMessage : IMessage
{
+ ///
+ /// Gets the referenced message if it is a crosspost, channel follow add, pin, or reply message.
+ ///
+ ///
+ /// The referenced message, if any is associated and still exists.
+ ///
+ IUserMessage ReferencedMessage { get; }
+
///
/// Modifies this message.
///
diff --git a/src/Discord.Net.Core/Entities/Messages/MessageReference.cs b/src/Discord.Net.Core/Entities/Messages/MessageReference.cs
index 533239f4a..029910e56 100644
--- a/src/Discord.Net.Core/Entities/Messages/MessageReference.cs
+++ b/src/Discord.Net.Core/Entities/Messages/MessageReference.cs
@@ -17,9 +17,10 @@ namespace Discord
/// Gets the Channel ID of the original message.
///
///
- /// If there is no referenced channel id, it will be the default value (zero).
+ /// It only will be the default value (zero) if it was instantiated with a in the constructor.
///
- public ulong ChannelId { get; internal set; }
+ public ulong ChannelId { get => InternalChannelId.GetValueOrDefault(); }
+ internal Optional InternalChannelId;
///
/// Gets the Guild ID of the original message.
@@ -41,7 +42,7 @@ namespace Discord
public MessageReference(ulong? messageId = null, ulong? channelId = null, ulong? guildId = null)
{
MessageId = messageId ?? Optional.Create();
- ChannelId = channelId ?? default(ulong);
+ InternalChannelId = channelId ?? Optional.Create();
GuildId = guildId ?? Optional.Create();
}
diff --git a/src/Discord.Net.Core/Entities/Messages/MessageType.cs b/src/Discord.Net.Core/Entities/Messages/MessageType.cs
index bdbd8e534..ad1f3a3cd 100644
--- a/src/Discord.Net.Core/Entities/Messages/MessageType.cs
+++ b/src/Discord.Net.Core/Entities/Messages/MessageType.cs
@@ -63,6 +63,6 @@ namespace Discord
///
/// Only available in API v8.
///
- InlineReply = 19,
+ Reply = 19,
}
}
diff --git a/src/Discord.Net.Core/Extensions/MessageExtensions.cs b/src/Discord.Net.Core/Extensions/MessageExtensions.cs
index e44e397fa..b043d7b77 100644
--- a/src/Discord.Net.Core/Extensions/MessageExtensions.cs
+++ b/src/Discord.Net.Core/Extensions/MessageExtensions.cs
@@ -71,5 +71,25 @@ namespace Discord
foreach (var rxn in reactions)
await msg.RemoveReactionAsync(rxn, user, options).ConfigureAwait(false);
}
+
+ ///
+ /// Sends an inline reply that references a message.
+ ///
+ /// The message to be sent.
+ /// Determines whether the message should be read aloud by Discord or not.
+ /// The to be sent.
+ ///
+ /// Specifies if notifications are sent for mentioned users and roles in the message .
+ /// If null, all mentioned roles and users will be notified.
+ ///
+ /// The options to be used when sending the request.
+ ///
+ /// A task that represents an asynchronous send operation for delivering the message. The task result
+ /// contains the sent message.
+ ///
+ public static async Task ReplyAsync(this IUserMessage msg, string text = null, bool isTTS = false, Embed embed = null, AllowedMentions allowedMentions = null, RequestOptions options = null)
+ {
+ return await msg.Channel.SendMessageAsync(text, isTTS, embed, options, allowedMentions, new MessageReference(messageId: msg.Id)).ConfigureAwait(false);
+ }
}
}
diff --git a/src/Discord.Net.Rest/API/Common/MessageReference.cs b/src/Discord.Net.Rest/API/Common/MessageReference.cs
index c21f0158a..6cc7603e0 100644
--- a/src/Discord.Net.Rest/API/Common/MessageReference.cs
+++ b/src/Discord.Net.Rest/API/Common/MessageReference.cs
@@ -8,7 +8,7 @@ namespace Discord.API
public Optional MessageId { get; set; }
[JsonProperty("channel_id")]
- public Optional ChannelId { get; set; }
+ public Optional ChannelId { get; set; } // Optional when sending, always present when receiving
[JsonProperty("guild_id")]
public Optional GuildId { get; set; }
diff --git a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs
index d6a718b3a..30aa71959 100644
--- a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs
@@ -282,7 +282,7 @@ namespace Discord.Rest
public static MessageSource GetSource(Model msg)
{
- if (msg.Type != MessageType.Default)
+ if (msg.Type != MessageType.Default && msg.Type != MessageType.Reply)
return MessageSource.System;
else if (msg.WebhookId.IsSpecified)
return MessageSource.Webhook;
diff --git a/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs b/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs
index 1cb9d1aef..0169c9b8b 100644
--- a/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs
+++ b/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs
@@ -77,7 +77,7 @@ namespace Discord.Rest
}
internal static RestMessage Create(BaseDiscordClient discord, IMessageChannel channel, IUser author, Model model)
{
- if (model.Type == MessageType.Default)
+ if (model.Type == MessageType.Default || model.Type == MessageType.Reply)
return RestUserMessage.Create(discord, channel, author, model);
else
return RestSystemMessage.Create(discord, channel, author, model);
@@ -119,7 +119,7 @@ namespace Discord.Rest
Reference = new MessageReference
{
GuildId = model.Reference.Value.GuildId,
- ChannelId = model.Reference.Value.ChannelId.GetValueOrDefault(),
+ InternalChannelId = model.Reference.Value.ChannelId,
MessageId = model.Reference.Value.MessageId
};
}
diff --git a/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs b/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
index be955b13d..e8bdb9508 100644
--- a/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
+++ b/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
@@ -15,6 +15,7 @@ namespace Discord.Rest
{
private bool _isMentioningEveryone, _isTTS, _isPinned, _isSuppressed;
private long? _editedTimestampTicks;
+ private IUserMessage _referencedMessage;
private ImmutableArray _attachments = ImmutableArray.Create();
private ImmutableArray