Fixed file being disposed on upload (#1995)

This commit is contained in:
Quin Lynch
2021-12-24 10:38:11 -04:00
committed by GitHub
parent ccc365edfd
commit ad20e03a98
3 changed files with 15 additions and 19 deletions

View File

@@ -344,11 +344,11 @@ namespace Discord.Rest
}
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
public static Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client,
public static async Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client,
Stream stream, string filename, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options, bool isSpoiler, Embed[] embeds)
{
using var file = new FileAttachment(stream, filename, isSpoiler: isSpoiler);
return SendFileAsync(channel, client, file, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds);
using (var file = new FileAttachment(stream, filename, isSpoiler: isSpoiler))
return await SendFileAsync(channel, client, file, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds).ConfigureAwait(false);
}
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>