diff --git a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
index 8da7dba79..87dfb3460 100644
--- a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
+++ b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
@@ -129,7 +129,6 @@ namespace Discord
/// Whether the message should be read aloud by Discord or not.
/// The to be sent.
/// The options to be used when sending the request.
- /// Whether the message attachment should be hidden as a spoiler.
///
/// Specifies if notifications are sent for mentioned users and roles in the message .
/// If null, all mentioned roles and users will be notified.
@@ -142,7 +141,7 @@ namespace Discord
/// A task that represents an asynchronous send operation for delivering the message. The task result
/// contains the sent message.
///
- Task SendFileAsync(FileAttachment attachment, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null);
+ Task SendFileAsync(FileAttachment attachment, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null);
///
/// Sends a collection of files to this message channel.
///
@@ -159,7 +158,6 @@ namespace Discord
/// Whether the message should be read aloud by Discord or not.
/// The to be sent.
/// The options to be used when sending the request.
- /// Whether the message attachment should be hidden as a spoiler.
///
/// Specifies if notifications are sent for mentioned users and roles in the message .
/// If null, all mentioned roles and users will be notified.
@@ -172,7 +170,7 @@ namespace Discord
/// A task that represents an asynchronous send operation for delivering the message. The task result
/// contains the sent message.
///
- Task SendFilesAsync(IEnumerable attachments, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null);
+ Task SendFilesAsync(IEnumerable attachments, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null);
///
/// Gets a message from this message channel.
diff --git a/src/Discord.Net.Core/Entities/Messages/FileAttachment.cs b/src/Discord.Net.Core/Entities/Messages/FileAttachment.cs
index d7b7b8155..dc5437861 100644
--- a/src/Discord.Net.Core/Entities/Messages/FileAttachment.cs
+++ b/src/Discord.Net.Core/Entities/Messages/FileAttachment.cs
@@ -11,6 +11,7 @@ namespace Discord
{
public string FileName { get; set; }
public string Description { get; set; }
+ public bool IsSpoiler { get; set; }
#pragma warning disable IDISP008
public Stream Stream { get; }
@@ -24,12 +25,13 @@ namespace Discord
/// The stream to create the attachment from.
/// The name of the attachment.
/// The description of the attachment.
- public FileAttachment(Stream stream, string fileName, string description = null)
+ public FileAttachment(Stream stream, string fileName, string description = null, bool isSpoiler = false)
{
_isDisposed = false;
FileName = fileName;
Description = description;
Stream = stream;
+ IsSpoiler = isSpoiler;
}
///
@@ -60,12 +62,13 @@ namespace Discord
/// The file specified in was not found.
///
/// An I/O error occurred while opening the file.
- public FileAttachment(string path, string description = null)
+ public FileAttachment(string path, string description = null, bool isSpoiler = false)
{
_isDisposed = false;
Stream = File.OpenRead(path);
FileName = Path.GetFileName(path);
Description = description;
+ IsSpoiler = isSpoiler;
}
public void Dispose()
diff --git a/src/Discord.Net.Core/Entities/Messages/MessageProperties.cs b/src/Discord.Net.Core/Entities/Messages/MessageProperties.cs
index abd09d856..1a4eaff2d 100644
--- a/src/Discord.Net.Core/Entities/Messages/MessageProperties.cs
+++ b/src/Discord.Net.Core/Entities/Messages/MessageProperties.cs
@@ -1,3 +1,5 @@
+using System.Collections.Generic;
+
namespace Discord
{
///
@@ -48,5 +50,10 @@ namespace Discord
/// Gets or sets the allowed mentions of the message.
///
public Optional AllowedMentions { get; set; }
+
+ ///
+ /// Gets or sets the attachments for the message.
+ ///
+ public Optional> Attachments { get; set; }
}
}
diff --git a/src/Discord.Net.Rest/API/Common/Attachment.cs b/src/Discord.Net.Rest/API/Common/Attachment.cs
index 0d98fc3a4..7970dc9a5 100644
--- a/src/Discord.Net.Rest/API/Common/Attachment.cs
+++ b/src/Discord.Net.Rest/API/Common/Attachment.cs
@@ -8,6 +8,10 @@ namespace Discord.API
public ulong Id { get; set; }
[JsonProperty("filename")]
public string Filename { get; set; }
+ [JsonProperty("description")]
+ public Optional Description { get; set; }
+ [JsonProperty("content_type")]
+ public Optional ContentType { get; set; }
[JsonProperty("size")]
public int Size { get; set; }
[JsonProperty("url")]
diff --git a/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs b/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs
index 98fb0e7ca..6340c3e38 100644
--- a/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs
+++ b/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs
@@ -3,6 +3,7 @@ using Discord.Net.Rest;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using System.Text;
namespace Discord.API.Rest
@@ -11,9 +12,8 @@ namespace Discord.API.Rest
{
private static JsonSerializer _serializer = new JsonSerializer { ContractResolver = new DiscordContractResolver() };
- public Stream File { get; }
+ public FileAttachment[] Files { get; }
- public Optional Filename { get; set; }
public Optional Content { get; set; }
public Optional Nonce { get; set; }
public Optional IsTTS { get; set; }
@@ -21,22 +21,18 @@ namespace Discord.API.Rest
public Optional AllowedMentions { get; set; }
public Optional MessageReference { get; set; }
public Optional MessageComponent { get; set; }
+ public Optional Flags { get; set; }
public Optional Stickers { get; set; }
- public bool IsSpoiler { get; set; } = false;
- public UploadFileParams(Stream file)
+ public UploadFileParams(params Discord.FileAttachment[] attachments)
{
- File = file;
+ Files = attachments;
}
public IReadOnlyDictionary ToDictionary()
{
var d = new Dictionary();
- var filename = Filename.GetValueOrDefault("unknown.dat");
- if (IsSpoiler && !filename.StartsWith(AttachmentExtensions.SpoilerPrefix))
- filename = filename.Insert(0, AttachmentExtensions.SpoilerPrefix);
- d["file"] = new MultipartFile(File, filename);
-
+
var payload = new Dictionary();
if (Content.IsSpecified)
payload["content"] = Content.Value;
@@ -50,12 +46,33 @@ namespace Discord.API.Rest
payload["allowed_mentions"] = AllowedMentions.Value;
if (MessageComponent.IsSpecified)
payload["components"] = MessageComponent.Value;
- if (IsSpoiler)
- payload["hasSpoiler"] = IsSpoiler.ToString();
if (MessageReference.IsSpecified)
payload["message_reference"] = MessageReference.Value;
if (Stickers.IsSpecified)
payload["sticker_ids"] = Stickers.Value;
+ if (Flags.IsSpecified)
+ payload["flags"] = Flags;
+
+ List