Fixed file uploading, Cleaned up DiscordAPIClient helper methods
This commit is contained in:
@@ -250,64 +250,58 @@ namespace Discord.API
|
|||||||
ConnectionState = ConnectionState.Disconnected;
|
ConnectionState = ConnectionState.Disconnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Core
|
//REST
|
||||||
public Task SendAsync(string method, string endpoint,
|
public Task SendAsync(string method, string endpoint,
|
||||||
GlobalBucket bucket = GlobalBucket.GeneralRest, RequestOptions options = null)
|
GlobalBucket bucket = GlobalBucket.GeneralRest, RequestOptions options = null)
|
||||||
=> SendInternalAsync(method, endpoint, null, true, bucket, options);
|
=> SendInternalAsync(method, endpoint, null, true, BucketGroup.Global, (int)bucket, 0, options);
|
||||||
public Task SendAsync(string method, string endpoint, object payload,
|
public Task SendAsync(string method, string endpoint, object payload,
|
||||||
GlobalBucket bucket = GlobalBucket.GeneralRest, RequestOptions options = null)
|
GlobalBucket bucket = GlobalBucket.GeneralRest, RequestOptions options = null)
|
||||||
=> SendInternalAsync(method, endpoint, payload, true, bucket, options);
|
=> SendInternalAsync(method, endpoint, payload, true, BucketGroup.Global, (int)bucket, 0, options);
|
||||||
public Task SendAsync(string method, string endpoint, Stream file, IReadOnlyDictionary<string, string> multipartArgs,
|
|
||||||
GlobalBucket bucket = GlobalBucket.GeneralRest, RequestOptions options = null)
|
|
||||||
=> SendInternalAsync(method, endpoint, multipartArgs, true, bucket, options);
|
|
||||||
public async Task<TResponse> SendAsync<TResponse>(string method, string endpoint,
|
public async Task<TResponse> SendAsync<TResponse>(string method, string endpoint,
|
||||||
GlobalBucket bucket = GlobalBucket.GeneralRest, RequestOptions options = null)
|
GlobalBucket bucket = GlobalBucket.GeneralRest, RequestOptions options = null) where TResponse : class
|
||||||
where TResponse : class
|
=> DeserializeJson<TResponse>(await SendInternalAsync(method, endpoint, null, false, BucketGroup.Global, (int)bucket, 0, options).ConfigureAwait(false));
|
||||||
=> DeserializeJson<TResponse>(await SendInternalAsync(method, endpoint, null, false, bucket, options).ConfigureAwait(false));
|
|
||||||
public async Task<TResponse> SendAsync<TResponse>(string method, string endpoint, object payload, GlobalBucket bucket =
|
public async Task<TResponse> SendAsync<TResponse>(string method, string endpoint, object payload, GlobalBucket bucket =
|
||||||
GlobalBucket.GeneralRest, RequestOptions options = null)
|
GlobalBucket.GeneralRest, RequestOptions options = null) where TResponse : class
|
||||||
where TResponse : class
|
=> DeserializeJson<TResponse>(await SendInternalAsync(method, endpoint, payload, false, BucketGroup.Global, (int)bucket, 0, options).ConfigureAwait(false));
|
||||||
=> DeserializeJson<TResponse>(await SendInternalAsync(method, endpoint, payload, false, bucket, options).ConfigureAwait(false));
|
|
||||||
public async Task<TResponse> SendAsync<TResponse>(string method, string endpoint, Stream file, IReadOnlyDictionary<string, string> multipartArgs,
|
|
||||||
GlobalBucket bucket = GlobalBucket.GeneralRest, RequestOptions options = null)
|
|
||||||
where TResponse : class
|
|
||||||
=> DeserializeJson<TResponse>(await SendInternalAsync(method, endpoint, multipartArgs, false, bucket, options).ConfigureAwait(false));
|
|
||||||
|
|
||||||
public Task SendAsync(string method, string endpoint,
|
public Task SendAsync(string method, string endpoint,
|
||||||
GuildBucket bucket, ulong guildId, RequestOptions options = null)
|
GuildBucket bucket, ulong guildId, RequestOptions options = null)
|
||||||
=> SendInternalAsync(method, endpoint, null, true, bucket, guildId, options);
|
=> SendInternalAsync(method, endpoint, null, true, BucketGroup.Guild, (int)bucket, guildId, options);
|
||||||
public Task SendAsync(string method, string endpoint, object payload,
|
public Task SendAsync(string method, string endpoint, object payload,
|
||||||
GuildBucket bucket, ulong guildId, RequestOptions options = null)
|
GuildBucket bucket, ulong guildId, RequestOptions options = null)
|
||||||
=> SendInternalAsync(method, endpoint, payload, true, bucket, guildId, options);
|
=> SendInternalAsync(method, endpoint, payload, true, BucketGroup.Guild, (int)bucket, guildId, options);
|
||||||
public Task SendAsync(string method, string endpoint, Stream file, IReadOnlyDictionary<string, string> multipartArgs,
|
|
||||||
GuildBucket bucket, ulong guildId, RequestOptions options = null)
|
|
||||||
=> SendInternalAsync(method, endpoint, multipartArgs, true, bucket, guildId, options);
|
|
||||||
public async Task<TResponse> SendAsync<TResponse>(string method, string endpoint,
|
public async Task<TResponse> SendAsync<TResponse>(string method, string endpoint,
|
||||||
GuildBucket bucket, ulong guildId, RequestOptions options = null)
|
GuildBucket bucket, ulong guildId, RequestOptions options = null) where TResponse : class
|
||||||
where TResponse : class
|
=> DeserializeJson<TResponse>(await SendInternalAsync(method, endpoint, null, false, BucketGroup.Guild, (int)bucket, guildId, options).ConfigureAwait(false));
|
||||||
=> DeserializeJson<TResponse>(await SendInternalAsync(method, endpoint, null, false, bucket, guildId, options).ConfigureAwait(false));
|
|
||||||
public async Task<TResponse> SendAsync<TResponse>(string method, string endpoint, object payload,
|
public async Task<TResponse> SendAsync<TResponse>(string method, string endpoint, object payload,
|
||||||
GuildBucket bucket, ulong guildId, RequestOptions options = null)
|
GuildBucket bucket, ulong guildId, RequestOptions options = null) where TResponse : class
|
||||||
where TResponse : class
|
=> DeserializeJson<TResponse>(await SendInternalAsync(method, endpoint, payload, false, BucketGroup.Guild, (int)bucket, guildId, options).ConfigureAwait(false));
|
||||||
=> DeserializeJson<TResponse>(await SendInternalAsync(method, endpoint, payload, false, bucket, guildId, options).ConfigureAwait(false));
|
|
||||||
public async Task<TResponse> SendAsync<TResponse>(string method, string endpoint, Stream file, IReadOnlyDictionary<string, string> multipartArgs,
|
|
||||||
GuildBucket bucket, ulong guildId, RequestOptions options = null)
|
|
||||||
where TResponse : class
|
|
||||||
=> DeserializeJson<TResponse>(await SendInternalAsync(method, endpoint, multipartArgs, false, bucket, guildId, options).ConfigureAwait(false));
|
|
||||||
|
|
||||||
private Task<Stream> SendInternalAsync(string method, string endpoint, object payload, bool headerOnly,
|
|
||||||
GlobalBucket bucket, RequestOptions options)
|
|
||||||
=> SendInternalAsync(method, endpoint, payload, headerOnly, BucketGroup.Global, (int)bucket, 0, options);
|
|
||||||
private Task<Stream> SendInternalAsync(string method, string endpoint, object payload, bool headerOnly,
|
|
||||||
GuildBucket bucket, ulong guildId, RequestOptions options)
|
|
||||||
=> SendInternalAsync(method, endpoint, payload, headerOnly, BucketGroup.Guild, (int)bucket, guildId, options);
|
|
||||||
private Task<Stream> SendInternalAsync(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs, bool headerOnly,
|
|
||||||
GlobalBucket bucket, RequestOptions options)
|
|
||||||
=> SendInternalAsync(method, endpoint, multipartArgs, headerOnly, BucketGroup.Global, (int)bucket, 0, options);
|
|
||||||
private Task<Stream> SendInternalAsync(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs, bool headerOnly,
|
|
||||||
GuildBucket bucket, ulong guildId, RequestOptions options)
|
|
||||||
=> SendInternalAsync(method, endpoint, multipartArgs, headerOnly, BucketGroup.Guild, (int)bucket, guildId, options);
|
|
||||||
|
|
||||||
|
//REST - Multipart
|
||||||
|
public Task SendMultipartAsync(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs,
|
||||||
|
GlobalBucket bucket = GlobalBucket.GeneralRest, RequestOptions options = null)
|
||||||
|
=> SendMultipartInternalAsync(method, endpoint, multipartArgs, true, BucketGroup.Global, (int)bucket, 0, options);
|
||||||
|
public async Task<TResponse> SendMultipartAsync<TResponse>(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs,
|
||||||
|
GlobalBucket bucket = GlobalBucket.GeneralRest, RequestOptions options = null) where TResponse : class
|
||||||
|
=> DeserializeJson<TResponse>(await SendMultipartInternalAsync(method, endpoint, multipartArgs, false, BucketGroup.Global, (int)bucket, 0, options).ConfigureAwait(false));
|
||||||
|
|
||||||
|
public Task SendMultipartAsync(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs,
|
||||||
|
GuildBucket bucket, ulong guildId, RequestOptions options = null)
|
||||||
|
=> SendMultipartInternalAsync(method, endpoint, multipartArgs, true, BucketGroup.Guild, (int)bucket, guildId, options);
|
||||||
|
public async Task<TResponse> SendMultipartAsync<TResponse>(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs,
|
||||||
|
GuildBucket bucket, ulong guildId, RequestOptions options = null) where TResponse : class
|
||||||
|
=> DeserializeJson<TResponse>(await SendMultipartInternalAsync(method, endpoint, multipartArgs, false, BucketGroup.Guild, (int)bucket, guildId, options).ConfigureAwait(false));
|
||||||
|
|
||||||
|
//Gateway
|
||||||
|
public Task SendGatewayAsync(GatewayOpCode opCode, object payload,
|
||||||
|
GlobalBucket bucket = GlobalBucket.GeneralGateway, RequestOptions options = null)
|
||||||
|
=> SendGatewayInternalAsync(opCode, payload, BucketGroup.Global, (int)bucket, 0, options);
|
||||||
|
|
||||||
|
public Task SendGatewayAsync(GatewayOpCode opCode, object payload,
|
||||||
|
GuildBucket bucket, ulong guildId, RequestOptions options = null)
|
||||||
|
=> SendGatewayInternalAsync(opCode, payload, BucketGroup.Guild, (int)bucket, guildId, options);
|
||||||
|
|
||||||
|
//Core
|
||||||
private async Task<Stream> SendInternalAsync(string method, string endpoint, object payload, bool headerOnly,
|
private async Task<Stream> SendInternalAsync(string method, string endpoint, object payload, bool headerOnly,
|
||||||
BucketGroup group, int bucketId, ulong guildId, RequestOptions options = null)
|
BucketGroup group, int bucketId, ulong guildId, RequestOptions options = null)
|
||||||
{
|
{
|
||||||
@@ -323,7 +317,7 @@ namespace Discord.API
|
|||||||
|
|
||||||
return responseStream;
|
return responseStream;
|
||||||
}
|
}
|
||||||
private async Task<Stream> SendInternalAsync(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs, bool headerOnly,
|
private async Task<Stream> SendMultipartInternalAsync(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs, bool headerOnly,
|
||||||
BucketGroup group, int bucketId, ulong guildId, RequestOptions options = null)
|
BucketGroup group, int bucketId, ulong guildId, RequestOptions options = null)
|
||||||
{
|
{
|
||||||
var stopwatch = Stopwatch.StartNew();
|
var stopwatch = Stopwatch.StartNew();
|
||||||
@@ -336,14 +330,7 @@ namespace Discord.API
|
|||||||
|
|
||||||
return responseStream;
|
return responseStream;
|
||||||
}
|
}
|
||||||
|
private async Task SendGatewayInternalAsync(GatewayOpCode opCode, object payload,
|
||||||
public Task SendGatewayAsync(GatewayOpCode opCode, object payload,
|
|
||||||
GlobalBucket bucket = GlobalBucket.GeneralGateway, RequestOptions options = null)
|
|
||||||
=> SendGatewayAsync(opCode, payload, BucketGroup.Global, (int)bucket, 0, options);
|
|
||||||
public Task SendGatewayAsync(GatewayOpCode opCode, object payload,
|
|
||||||
GuildBucket bucket, ulong guildId, RequestOptions options = null)
|
|
||||||
=> SendGatewayAsync(opCode, payload, BucketGroup.Guild, (int)bucket, guildId, options);
|
|
||||||
private async Task SendGatewayAsync(GatewayOpCode opCode, object payload,
|
|
||||||
BucketGroup group, int bucketId, ulong guildId, RequestOptions options)
|
BucketGroup group, int bucketId, ulong guildId, RequestOptions options)
|
||||||
{
|
{
|
||||||
//TODO: Add ETF
|
//TODO: Add ETF
|
||||||
@@ -1016,31 +1003,35 @@ namespace Discord.API
|
|||||||
else
|
else
|
||||||
return await SendAsync<Message>("POST", $"channels/{channelId}/messages", args, GlobalBucket.DirectMessage, options: options).ConfigureAwait(false);
|
return await SendAsync<Message>("POST", $"channels/{channelId}/messages", args, GlobalBucket.DirectMessage, options: options).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
public Task<Message> UploadFileAsync(ulong guildId, ulong channelId, Stream file, UploadFileParams args, RequestOptions options = null)
|
public Task<Message> UploadFileAsync(ulong guildId, ulong channelId, UploadFileParams args, RequestOptions options = null)
|
||||||
{
|
{
|
||||||
Preconditions.NotEqual(guildId, 0, nameof(guildId));
|
Preconditions.NotEqual(guildId, 0, nameof(guildId));
|
||||||
|
|
||||||
return UploadFileInternalAsync(guildId, channelId, file, args);
|
return UploadFileInternalAsync(guildId, channelId, args);
|
||||||
}
|
}
|
||||||
public Task<Message> UploadDMFileAsync(ulong channelId, Stream file, UploadFileParams args, RequestOptions options = null)
|
public Task<Message> UploadDMFileAsync(ulong channelId, UploadFileParams args, RequestOptions options = null)
|
||||||
{
|
{
|
||||||
return UploadFileInternalAsync(0, channelId, file, args);
|
return UploadFileInternalAsync(0, channelId, args);
|
||||||
}
|
}
|
||||||
private async Task<Message> UploadFileInternalAsync(ulong guildId, ulong channelId, Stream file, UploadFileParams args, RequestOptions options = null)
|
private async Task<Message> UploadFileInternalAsync(ulong guildId, ulong channelId, UploadFileParams args, RequestOptions options = null)
|
||||||
{
|
{
|
||||||
Preconditions.NotNull(args, nameof(args));
|
Preconditions.NotNull(args, nameof(args));
|
||||||
Preconditions.NotEqual(channelId, 0, nameof(channelId));
|
Preconditions.NotEqual(channelId, 0, nameof(channelId));
|
||||||
if (args.Content.IsSpecified)
|
|
||||||
|
if (args.Content.GetValueOrDefault(null) == null)
|
||||||
|
args.Content = "";
|
||||||
|
else if (args.Content.IsSpecified)
|
||||||
{
|
{
|
||||||
Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content));
|
if (args.Content.Value == null)
|
||||||
if (args.Content.Value.Length > DiscordConfig.MaxMessageSize)
|
args.Content = "";
|
||||||
|
if (args.Content.Value?.Length > DiscordConfig.MaxMessageSize)
|
||||||
throw new ArgumentOutOfRangeException($"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", nameof(args.Content));
|
throw new ArgumentOutOfRangeException($"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", nameof(args.Content));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (guildId != 0)
|
if (guildId != 0)
|
||||||
return await SendAsync<Message>("POST", $"channels/{channelId}/messages", file, args.ToDictionary(), GuildBucket.SendEditMessage, guildId, options: options).ConfigureAwait(false);
|
return await SendMultipartAsync<Message>("POST", $"channels/{channelId}/messages", args.ToDictionary(), GuildBucket.SendEditMessage, guildId, options: options).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
return await SendAsync<Message>("POST", $"channels/{channelId}/messages", file, args.ToDictionary(), GlobalBucket.DirectMessage, options: options).ConfigureAwait(false);
|
return await SendMultipartAsync<Message>("POST", $"channels/{channelId}/messages", args.ToDictionary(), GlobalBucket.DirectMessage, options: options).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
public Task DeleteMessageAsync(ulong guildId, ulong channelId, ulong messageId, RequestOptions options = null)
|
public Task DeleteMessageAsync(ulong guildId, ulong channelId, ulong messageId, RequestOptions options = null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,18 +1,27 @@
|
|||||||
using System.Collections.Generic;
|
using Discord.Net.Rest;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Discord.API.Rest
|
namespace Discord.API.Rest
|
||||||
{
|
{
|
||||||
public class UploadFileParams
|
public class UploadFileParams
|
||||||
{
|
{
|
||||||
|
public Stream File { get; set; }
|
||||||
public string Filename { get; set; } = "unknown.dat";
|
public string Filename { get; set; } = "unknown.dat";
|
||||||
|
|
||||||
public Optional<string> Content { get; set; }
|
public Optional<string> Content { get; set; }
|
||||||
public Optional<string> Nonce { get; set; }
|
public Optional<string> Nonce { get; set; }
|
||||||
public Optional<bool> IsTTS { get; set; }
|
public Optional<bool> IsTTS { get; set; }
|
||||||
|
|
||||||
public IReadOnlyDictionary<string, string> ToDictionary()
|
public UploadFileParams(Stream file)
|
||||||
{
|
{
|
||||||
var d = new Dictionary<string, string>();
|
File = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IReadOnlyDictionary<string, object> ToDictionary()
|
||||||
|
{
|
||||||
|
var d = new Dictionary<string, object>();
|
||||||
|
d["file"] = new MultipartFile(File, Filename);
|
||||||
if (Content.IsSpecified)
|
if (Content.IsSpecified)
|
||||||
d["content"] = Content.Value;
|
d["content"] = Content.Value;
|
||||||
if (IsTTS.IsSpecified)
|
if (IsTTS.IsSpecified)
|
||||||
|
|||||||
@@ -73,15 +73,15 @@ namespace Discord
|
|||||||
string filename = Path.GetFileName(filePath);
|
string filename = Path.GetFileName(filePath);
|
||||||
using (var file = File.OpenRead(filePath))
|
using (var file = File.OpenRead(filePath))
|
||||||
{
|
{
|
||||||
var args = new UploadFileParams { Filename = filename, Content = text, IsTTS = isTTS };
|
var args = new UploadFileParams(file) { Filename = filename, Content = text, IsTTS = isTTS };
|
||||||
var model = await Discord.ApiClient.UploadDMFileAsync(Id, file, args).ConfigureAwait(false);
|
var model = await Discord.ApiClient.UploadDMFileAsync(Id, args).ConfigureAwait(false);
|
||||||
return new Message(this, new User(model.Author.Value), model);
|
return new Message(this, new User(model.Author.Value), model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<IMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS)
|
public async Task<IMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS)
|
||||||
{
|
{
|
||||||
var args = new UploadFileParams { Filename = filename, Content = text, IsTTS = isTTS };
|
var args = new UploadFileParams(stream) { Filename = filename, Content = text, IsTTS = isTTS };
|
||||||
var model = await Discord.ApiClient.UploadDMFileAsync(Id, stream, args).ConfigureAwait(false);
|
var model = await Discord.ApiClient.UploadDMFileAsync(Id, args).ConfigureAwait(false);
|
||||||
return new Message(this, new User(model.Author.Value), model);
|
return new Message(this, new User(model.Author.Value), model);
|
||||||
}
|
}
|
||||||
public virtual async Task<IMessage> GetMessageAsync(ulong id)
|
public virtual async Task<IMessage> GetMessageAsync(ulong id)
|
||||||
|
|||||||
@@ -99,15 +99,15 @@ namespace Discord
|
|||||||
string filename = Path.GetFileName(filePath);
|
string filename = Path.GetFileName(filePath);
|
||||||
using (var file = File.OpenRead(filePath))
|
using (var file = File.OpenRead(filePath))
|
||||||
{
|
{
|
||||||
var args = new UploadFileParams { Filename = filename, Content = text, IsTTS = isTTS };
|
var args = new UploadFileParams(file) { Filename = filename, Content = text, IsTTS = isTTS };
|
||||||
var model = await Discord.ApiClient.UploadDMFileAsync(Id, file, args).ConfigureAwait(false);
|
var model = await Discord.ApiClient.UploadDMFileAsync(Id, args).ConfigureAwait(false);
|
||||||
return new Message(this, new User(model.Author.Value), model);
|
return new Message(this, new User(model.Author.Value), model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<IMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS)
|
public async Task<IMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS)
|
||||||
{
|
{
|
||||||
var args = new UploadFileParams { Filename = filename, Content = text, IsTTS = isTTS };
|
var args = new UploadFileParams(stream) { Filename = filename, Content = text, IsTTS = isTTS };
|
||||||
var model = await Discord.ApiClient.UploadDMFileAsync(Id, stream, args).ConfigureAwait(false);
|
var model = await Discord.ApiClient.UploadDMFileAsync(Id, args).ConfigureAwait(false);
|
||||||
return new Message(this, new User(model.Author.Value), model);
|
return new Message(this, new User(model.Author.Value), model);
|
||||||
}
|
}
|
||||||
public virtual async Task<IMessage> GetMessageAsync(ulong id)
|
public virtual async Task<IMessage> GetMessageAsync(ulong id)
|
||||||
|
|||||||
@@ -68,15 +68,15 @@ namespace Discord
|
|||||||
string filename = Path.GetFileName(filePath);
|
string filename = Path.GetFileName(filePath);
|
||||||
using (var file = File.OpenRead(filePath))
|
using (var file = File.OpenRead(filePath))
|
||||||
{
|
{
|
||||||
var args = new UploadFileParams { Filename = filename, Content = text, IsTTS = isTTS };
|
var args = new UploadFileParams(file) { Filename = filename, Content = text, IsTTS = isTTS };
|
||||||
var model = await Discord.ApiClient.UploadFileAsync(Guild.Id, Id, file, args).ConfigureAwait(false);
|
var model = await Discord.ApiClient.UploadFileAsync(Guild.Id, Id, args).ConfigureAwait(false);
|
||||||
return new Message(this, new User(model.Author.Value), model);
|
return new Message(this, new User(model.Author.Value), model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<IMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS)
|
public async Task<IMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS)
|
||||||
{
|
{
|
||||||
var args = new UploadFileParams { Filename = filename, Content = text, IsTTS = isTTS };
|
var args = new UploadFileParams(stream) { Filename = filename, Content = text, IsTTS = isTTS };
|
||||||
var model = await Discord.ApiClient.UploadFileAsync(Guild.Id, Id, stream, args).ConfigureAwait(false);
|
var model = await Discord.ApiClient.UploadFileAsync(Guild.Id, Id, args).ConfigureAwait(false);
|
||||||
return new Message(this, new User(model.Author.Value), model);
|
return new Message(this, new User(model.Author.Value), model);
|
||||||
}
|
}
|
||||||
public virtual async Task<IMessage> GetMessageAsync(ulong id)
|
public virtual async Task<IMessage> GetMessageAsync(ulong id)
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ namespace Discord.Net.Rest
|
|||||||
if (p.Value is MultipartFile)
|
if (p.Value is MultipartFile)
|
||||||
{
|
{
|
||||||
var fileValue = (MultipartFile)p.Value;
|
var fileValue = (MultipartFile)p.Value;
|
||||||
content.Add(new StreamContent(fileValue.Stream), fileValue.Filename, p.Key);
|
content.Add(new StreamContent(fileValue.Stream), p.Key, fileValue.Filename);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user