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 35252693b2..7470a72cd5 100644 --- a/src/Discord.Net.Core/Entities/Messages/FileAttachment.cs +++ b/src/Discord.Net.Core/Entities/Messages/FileAttachment.cs @@ -7,13 +7,29 @@ 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 e94e9f97c4..277c062915 100644 --- a/src/Discord.Net.Core/Entities/Messages/IAttachment.cs +++ b/src/Discord.Net.Core/Entities/Messages/IAttachment.cs @@ -62,5 +62,13 @@ public interface IAttachment /// 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 4e4849c512..a5b83fb7b9 100644 --- a/src/Discord.Net.Rest/Entities/Messages/Attachment.cs +++ b/src/Discord.Net.Rest/Entities/Messages/Attachment.cs @@ -23,8 +23,13 @@ public class Attachment : IAttachment 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 @@ internal Attachment(ulong id, string filename, string url, string proxyUrl, int 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()); } ///