@@ -100,5 +100,25 @@ namespace Discord | |||||
/// A read-only collection of user IDs. | /// A read-only collection of user IDs. | ||||
/// </returns> | /// </returns> | ||||
IReadOnlyCollection<ulong> MentionedUserIds { get; } | IReadOnlyCollection<ulong> MentionedUserIds { get; } | ||||
/// <summary> | |||||
/// Returns the Activity associated with a message. | |||||
/// </summary> | |||||
/// <remarks> | |||||
/// Sent with Rich Presence-related chat embeds. | |||||
/// </remarks> | |||||
/// <returns> | |||||
/// A message's activity, if any is associated. | |||||
/// </returns> | |||||
MessageActivity Activity { get; } | |||||
/// <summary> | |||||
/// Returns the Application associated with a messsage. | |||||
/// </summary> | |||||
/// <remarks> | |||||
/// Sent with Rich-Presence-related chat embeds. | |||||
/// </remarks> | |||||
/// <returns> | |||||
/// A message's application, if any is associated. | |||||
/// </returns> | |||||
MessageApplication Application { get; } | |||||
} | } | ||||
} | } |
@@ -0,0 +1,27 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Diagnostics; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace Discord | |||||
{ | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | |||||
public class MessageActivity | |||||
{ | |||||
/// <summary> | |||||
/// Gets the type of activity of this message. | |||||
/// </summary> | |||||
public MessageActivityType Type { get; set; } | |||||
/// <summary> | |||||
/// Gets the party ID of this activity, if any. | |||||
/// </summary> | |||||
public string PartyId { get; set; } | |||||
private string DebuggerDisplay | |||||
=> $"{Type}{(string.IsNullOrWhiteSpace(PartyId) ? "" : $" {PartyId}")}"; | |||||
public override string ToString() => DebuggerDisplay; | |||||
} | |||||
} |
@@ -0,0 +1,16 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace Discord | |||||
{ | |||||
public enum MessageActivityType | |||||
{ | |||||
Join = 1, | |||||
Spectate = 2, | |||||
Listen = 3, | |||||
JoinRequest = 5 | |||||
} | |||||
} |
@@ -0,0 +1,37 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Diagnostics; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace Discord | |||||
{ | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | |||||
public class MessageApplication | |||||
{ | |||||
/// <summary> | |||||
/// Gets the snowflake ID of the application. | |||||
/// </summary> | |||||
public ulong Id { get; set; } | |||||
/// <summary> | |||||
/// Gets the ID of the embed's image asset. | |||||
/// </summary> | |||||
public string CoverImage { get; set; } | |||||
/// <summary> | |||||
/// Gets the application's description. | |||||
/// </summary> | |||||
public string Description { get; set; } | |||||
/// <summary> | |||||
/// Gets the ID of the application's icon. | |||||
/// </summary> | |||||
public string Icon { get; set; } | |||||
/// <summary> | |||||
/// Gets the name of the application. | |||||
/// </summary> | |||||
public string Name { get; set; } | |||||
private string DebuggerDisplay | |||||
=> $"{Name} ({Id}): {Description}"; | |||||
} | |||||
} |
@@ -44,5 +44,11 @@ namespace Discord.API | |||||
public Optional<bool> Pinned { get; set; } | public Optional<bool> Pinned { get; set; } | ||||
[JsonProperty("reactions")] | [JsonProperty("reactions")] | ||||
public Optional<Reaction[]> Reactions { get; set; } | public Optional<Reaction[]> Reactions { get; set; } | ||||
// sent with Rich Presence-related chat embeds | |||||
[JsonProperty("activity")] | |||||
public Optional<MessageActivity> Activity { get; set; } | |||||
// sent with Rich Presence-related chat embeds | |||||
[JsonProperty("application")] | |||||
public Optional<MessageApplication> Application { get; set; } | |||||
} | } | ||||
} | } |
@@ -0,0 +1,17 @@ | |||||
using Newtonsoft.Json; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace Discord.API | |||||
{ | |||||
public class MessageActivity | |||||
{ | |||||
[JsonProperty("type")] | |||||
public Optional<MessageActivityType> Type { get; set; } | |||||
[JsonProperty("party_id")] | |||||
public Optional<string> PartyId { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,38 @@ | |||||
using Newtonsoft.Json; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace Discord.API | |||||
{ | |||||
public class MessageApplication | |||||
{ | |||||
/// <summary> | |||||
/// Gets the snowflake ID of the application. | |||||
/// </summary> | |||||
[JsonProperty("id")] | |||||
public ulong Id { get; set; } | |||||
/// <summary> | |||||
/// Gets the ID of the embed's image asset. | |||||
/// </summary> | |||||
[JsonProperty("cover_image")] | |||||
public string CoverImage { get; set; } | |||||
/// <summary> | |||||
/// Gets the application's description. | |||||
/// </summary> | |||||
[JsonProperty("description")] | |||||
public string Description { get; set; } | |||||
/// <summary> | |||||
/// Gets the ID of the application's icon. | |||||
/// </summary> | |||||
[JsonProperty("icon")] | |||||
public string Icon { get; set; } | |||||
/// <summary> | |||||
/// Gets the name of the application. | |||||
/// </summary> | |||||
[JsonProperty("name")] | |||||
public string Name { get; set; } | |||||
} | |||||
} |
@@ -55,6 +55,9 @@ namespace Discord.Rest | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public DateTimeOffset Timestamp => DateTimeUtils.FromTicks(_timestampTicks); | public DateTimeOffset Timestamp => DateTimeUtils.FromTicks(_timestampTicks); | ||||
//todo Rest impl | |||||
public MessageActivity Activity => null; | |||||
public MessageApplication Application => null; | |||||
internal RestMessage(BaseDiscordClient discord, ulong id, IMessageChannel channel, IUser author, MessageSource source) | internal RestMessage(BaseDiscordClient discord, ulong id, IMessageChannel channel, IUser author, MessageSource source) | ||||
: base(discord, id) | : base(discord, id) | ||||
@@ -43,6 +43,14 @@ namespace Discord.WebSocket | |||||
public virtual bool IsPinned => false; | public virtual bool IsPinned => false; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public virtual DateTimeOffset? EditedTimestamp => null; | public virtual DateTimeOffset? EditedTimestamp => null; | ||||
/// <inheritdoc /> | |||||
public MessageActivity Activity { get; private set; } | |||||
/// <inheritdoc /> | |||||
public MessageApplication Application { get; private set; } | |||||
/// <summary> | /// <summary> | ||||
/// Returns all attachments included in this message. | /// Returns all attachments included in this message. | ||||
/// </summary> | /// </summary> | ||||
@@ -105,6 +113,29 @@ namespace Discord.WebSocket | |||||
if (model.Content.IsSpecified) | if (model.Content.IsSpecified) | ||||
Content = model.Content.Value; | Content = model.Content.Value; | ||||
if (model.Application.IsSpecified) | |||||
{ | |||||
// create a new Application from the API model | |||||
Application = new MessageApplication() | |||||
{ | |||||
Id = model.Application.Value.Id, | |||||
CoverImage = model.Application.Value.CoverImage, | |||||
Description = model.Application.Value.Description, | |||||
Icon = model.Application.Value.Icon, | |||||
Name = model.Application.Value.Name | |||||
}; | |||||
} | |||||
if (model.Activity.IsSpecified) | |||||
{ | |||||
// create a new Activity from the API model | |||||
Activity = new MessageActivity() | |||||
{ | |||||
Type = model.Activity.Value.Type.Value, | |||||
PartyId = model.Activity.Value.PartyId.Value | |||||
}; | |||||
} | |||||
} | } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||