From 765c0c554475efb332a6c28d935dbd9951158e73 Mon Sep 17 00:00:00 2001
From: Quin Lynch <49576606+quinchs@users.noreply.github.com>
Date: Wed, 9 Mar 2022 17:28:56 -0400
Subject: [PATCH] Feature: attachment description and content type (#2180)
---
.../Entities/Messages/FileAttachment.cs | 16 ++++++++++++++++
.../Entities/Messages/IAttachment.cs | 8 ++++++++
.../Entities/Messages/Attachment.cs | 12 ++++++++++--
3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/src/Discord.Net.Core/Entities/Messages/FileAttachment.cs b/src/Discord.Net.Core/Entities/Messages/FileAttachment.cs
index 35252693b..7470a72cd 100644
--- a/src/Discord.Net.Core/Entities/Messages/FileAttachment.cs
+++ b/src/Discord.Net.Core/Entities/Messages/FileAttachment.cs
@@ -7,13 +7,29 @@ using System.Threading.Tasks;
namespace Discord
{
+ ///
+ /// Represents an outgoing file attachment used to send a file to discord.
+ ///
public struct FileAttachment : IDisposable
{
+ ///
+ /// Gets or sets the filename.
+ ///
public string FileName { get; set; }
+ ///
+ /// Gets or sets the description of the file.
+ ///
public string Description { get; set; }
+
+ ///
+ /// Gets or sets whether this file should be marked as a spoiler.
+ ///
public bool IsSpoiler { get; set; }
#pragma warning disable IDISP008
+ ///
+ /// Gets the stream containing the file content.
+ ///
public Stream Stream { get; }
#pragma warning restore IDISP008
diff --git a/src/Discord.Net.Core/Entities/Messages/IAttachment.cs b/src/Discord.Net.Core/Entities/Messages/IAttachment.cs
index e94e9f97c..277c06291 100644
--- a/src/Discord.Net.Core/Entities/Messages/IAttachment.cs
+++ b/src/Discord.Net.Core/Entities/Messages/IAttachment.cs
@@ -62,5 +62,13 @@ namespace Discord
/// if the attachment is ephemeral; otherwise .
///
bool Ephemeral { get; }
+ ///
+ /// Gets the description of the attachment; or if there is none set.
+ ///
+ string Description { get; }
+ ///
+ /// Gets the media's MIME type if present; otherwise .
+ ///
+ string ContentType { get; }
}
}
diff --git a/src/Discord.Net.Rest/Entities/Messages/Attachment.cs b/src/Discord.Net.Rest/Entities/Messages/Attachment.cs
index 4e4849c51..a5b83fb7b 100644
--- a/src/Discord.Net.Rest/Entities/Messages/Attachment.cs
+++ b/src/Discord.Net.Rest/Entities/Messages/Attachment.cs
@@ -23,8 +23,13 @@ namespace Discord
public int? Width { get; }
///
public bool Ephemeral { get; }
+ ///
+ public string Description { get; }
+ ///
+ public string ContentType { get; }
- internal Attachment(ulong id, string filename, string url, string proxyUrl, int size, int? height, int? width, bool? ephemeral)
+ internal Attachment(ulong id, string filename, string url, string proxyUrl, int size, int? height, int? width,
+ bool? ephemeral, string description, string contentType)
{
Id = id;
Filename = filename;
@@ -34,13 +39,16 @@ namespace Discord
Height = height;
Width = width;
Ephemeral = ephemeral.GetValueOrDefault(false);
+ Description = description;
+ ContentType = contentType;
}
internal static Attachment Create(Model model)
{
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.Ephemeral.ToNullable());
+ model.Ephemeral.ToNullable(), model.Description.GetValueOrDefault(),
+ model.ContentType.GetValueOrDefault());
}
///