diff --git a/src/Discord.Net.Core/Entities/Messages/IAttachment.cs b/src/Discord.Net.Core/Entities/Messages/IAttachment.cs
index 6e9b4df2..591c9586 100644
--- a/src/Discord.Net.Core/Entities/Messages/IAttachment.cs
+++ b/src/Discord.Net.Core/Entities/Messages/IAttachment.cs
@@ -1,18 +1,13 @@
+using System;
+using System.Collections.Generic;
+
namespace Discord
{
///
/// Represents a message attachment found in a .
///
- public interface IAttachment
+ public interface IAttachment : ISnowflakeEntity
{
- ///
- /// Gets the ID of this attachment.
- ///
- ///
- /// A snowflake ID associated with this attachment.
- ///
- ulong Id { get; }
-
///
/// Gets the filename of this attachment.
///
@@ -85,5 +80,20 @@ namespace Discord
/// Gets flags related to this to this attachment.
///
public AttachmentFlags Flags { get; }
+
+ ///
+ /// Gets users who participated in the clip.
+ ///
+ public IReadOnlyCollection ClipParticipants { get; }
+
+ ///
+ /// Gets the title of the clip. if the clip has no title set.
+ ///
+ public string Title { get; }
+
+ ///
+ /// Gets the timestamp of the clip. if the attachment is not a clip.
+ ///
+ public DateTimeOffset? ClipCreatedAt { get; }
}
}
diff --git a/src/Discord.Net.Rest/API/Common/Attachment.cs b/src/Discord.Net.Rest/API/Common/Attachment.cs
index 0cb858af..b8f7783b 100644
--- a/src/Discord.Net.Rest/API/Common/Attachment.cs
+++ b/src/Discord.Net.Rest/API/Common/Attachment.cs
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
+using System;
namespace Discord.API;
@@ -42,4 +43,13 @@ internal class Attachment
[JsonProperty("flags")]
public Optional Flags { get; set; }
+
+ [JsonProperty("title")]
+ public Optional Title { get; set; }
+
+ [JsonProperty("clip_created_at")]
+ public Optional ClipCreatedAt { get; set; }
+
+ [JsonProperty("clip_participants")]
+ public Optional ClipParticipants { get; set; }
}
diff --git a/src/Discord.Net.Rest/Entities/Interactions/CommandBase/RestResolvableData.cs b/src/Discord.Net.Rest/Entities/Interactions/CommandBase/RestResolvableData.cs
index 1be74261..cf2860ed 100644
--- a/src/Discord.Net.Rest/Entities/Interactions/CommandBase/RestResolvableData.cs
+++ b/src/Discord.Net.Rest/Entities/Interactions/CommandBase/RestResolvableData.cs
@@ -113,7 +113,7 @@ namespace Discord.Rest
{
foreach (var attachment in resolved.Attachments.Value)
{
- var discordAttachment = Attachment.Create(attachment.Value);
+ var discordAttachment = Attachment.Create(attachment.Value, discord);
Attachments.Add(ulong.Parse(attachment.Key), discordAttachment);
}
diff --git a/src/Discord.Net.Rest/Entities/Messages/Attachment.cs b/src/Discord.Net.Rest/Entities/Messages/Attachment.cs
index 0c425126..592b2a5f 100644
--- a/src/Discord.Net.Rest/Entities/Messages/Attachment.cs
+++ b/src/Discord.Net.Rest/Entities/Messages/Attachment.cs
@@ -1,4 +1,9 @@
+using Discord.Rest;
+using System;
+using System.Collections.Generic;
+using System.Collections.Immutable;
using System.Diagnostics;
+using System.Linq;
using Model = Discord.API.Attachment;
namespace Discord
@@ -32,11 +37,21 @@ namespace Discord
///
public double? Duration { get; }
+ ///
+ public IReadOnlyCollection ClipParticipants { get; }
+
+ ///
+ public string Title { get; }
+
+ ///
+ public DateTimeOffset? ClipCreatedAt { get; }
+
///
public AttachmentFlags Flags { get; }
internal Attachment(ulong id, string filename, string url, string proxyUrl, int size, int? height, int? width,
- bool? ephemeral, string description, string contentType, double? duration, string waveform, AttachmentFlags flags)
+ bool? ephemeral, string description, string contentType, double? duration, string waveform, AttachmentFlags flags, string title,
+ IReadOnlyCollection clipParticipants, DateTimeOffset? clipCreatedAt)
{
Id = id;
Filename = filename;
@@ -51,19 +66,29 @@ namespace Discord
Duration = duration;
Waveform = waveform;
Flags = flags;
+ Title = title;
+ ClipParticipants = clipParticipants;
+ ClipCreatedAt = clipCreatedAt;
}
- internal static Attachment Create(Model model)
+
+ internal static Attachment Create(Model model, BaseDiscordClient discord)
{
return new Attachment(model.Id, model.Filename, model.Url, model.ProxyUrl, model.Size,
- model.Height.IsSpecified ? model.Height.Value : (int?)null,
- model.Width.IsSpecified ? model.Width.Value : (int?)null,
+ model.Height.IsSpecified ? model.Height.Value : null,
+ model.Width.IsSpecified ? model.Width.Value : null,
model.Ephemeral.ToNullable(), model.Description.GetValueOrDefault(),
model.ContentType.GetValueOrDefault(),
model.DurationSeconds.IsSpecified ? model.DurationSeconds.Value : null,
model.Waveform.GetValueOrDefault(null),
- model.Flags.GetValueOrDefault(AttachmentFlags.None));
+ model.Flags.GetValueOrDefault(AttachmentFlags.None),
+ model.Title.GetValueOrDefault(null),
+ model.ClipParticipants.GetValueOrDefault(Array.Empty()).Select(x => RestUser.Create(discord, x)).ToImmutableArray(),
+ model.ClipCreatedAt.IsSpecified ? model.ClipCreatedAt.Value : null);
}
+ ///
+ public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
+
///
/// Returns the filename of this attachment.
///
@@ -72,5 +97,8 @@ namespace Discord
///
public override string ToString() => Filename;
private string DebuggerDisplay => $"{Filename} ({Size} bytes)";
+
+ ///
+ IReadOnlyCollection IAttachment.ClipParticipants => ClipParticipants;
}
}
diff --git a/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs b/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
index f807c9e1..d9daf5a7 100644
--- a/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
+++ b/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
@@ -84,7 +84,7 @@ namespace Discord.Rest
{
var attachments = ImmutableArray.CreateBuilder(value.Length);
for (int i = 0; i < value.Length; i++)
- attachments.Add(Attachment.Create(value[i]));
+ attachments.Add(Attachment.Create(value[i], Discord));
_attachments = attachments.ToImmutable();
}
else
diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketResolvableData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketResolvableData.cs
index 2167a69a..3baf3db2 100644
--- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketResolvableData.cs
+++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketResolvableData.cs
@@ -130,7 +130,7 @@ namespace Discord.WebSocket
{
foreach (var attachment in resolved.Attachments.Value)
{
- var discordAttachment = Attachment.Create(attachment.Value);
+ var discordAttachment = Attachment.Create(attachment.Value, discord);
Attachments.Add(ulong.Parse(attachment.Key), discordAttachment);
}
diff --git a/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs b/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs
index 4f061b7e..596820e2 100644
--- a/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs
+++ b/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs
@@ -87,7 +87,7 @@ namespace Discord.WebSocket
{
var attachments = ImmutableArray.CreateBuilder(value.Length);
for (int i = 0; i < value.Length; i++)
- attachments.Add(Attachment.Create(value[i]));
+ attachments.Add(Attachment.Create(value[i], Discord));
_attachments = attachments.ToImmutable();
}
else