feature: Implemented Message Reference Property (#1413)
* Added support for Message References * Removed unused usings, added debugger display, updated ToString override * Changed snowflakes to be wrapped in an optional instead of a nullable.
This commit is contained in:
@@ -140,6 +140,18 @@ namespace Discord
|
||||
/// </returns>
|
||||
MessageApplication Application { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the reference to the original message if it was crossposted.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Sent with Cross-posted messages, meaning they were published from news channels
|
||||
/// and received by subscriber channels.
|
||||
/// </remarks>
|
||||
/// <returns>
|
||||
/// A message's reference, if any is associated.
|
||||
/// </returns>
|
||||
MessageReference Reference { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets all reactions included in this message.
|
||||
/// </summary>
|
||||
|
||||
33
src/Discord.Net.Core/Entities/Messages/MessageReference.cs
Normal file
33
src/Discord.Net.Core/Entities/Messages/MessageReference.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the IDs sent from a crossposted message.
|
||||
/// </summary>
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public class MessageReference
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Message ID of the original message.
|
||||
/// </summary>
|
||||
public Optional<ulong> MessageId { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Channel ID of the original message.
|
||||
/// </summary>
|
||||
public ulong ChannelId { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Guild ID of the original message.
|
||||
/// </summary>
|
||||
public Optional<ulong> GuildId { get; internal set; }
|
||||
|
||||
private string DebuggerDisplay
|
||||
=> $"Channel ID: ({ChannelId}){(GuildId.IsSpecified ? $", Guild ID: ({GuildId.Value})" : "")}" +
|
||||
$"{(MessageId.IsSpecified ? $", Message ID: ({MessageId.Value})" : "")}";
|
||||
|
||||
public override string ToString()
|
||||
=> DebuggerDisplay;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user