From 0de5d5b02ba5bccd92109ea76fb8e76c522415a2 Mon Sep 17 00:00:00 2001
From: Hsu Still <341464@gmail.com>
Date: Wed, 30 Aug 2017 04:57:47 +0800
Subject: [PATCH] Added SendFileAsync (#774)
---
src/Discord.Net.Core/Extensions/UserExtensions.cs | 32 +++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/src/Discord.Net.Core/Extensions/UserExtensions.cs b/src/Discord.Net.Core/Extensions/UserExtensions.cs
index 0861ed33e..eac25391e 100644
--- a/src/Discord.Net.Core/Extensions/UserExtensions.cs
+++ b/src/Discord.Net.Core/Extensions/UserExtensions.cs
@@ -1,9 +1,13 @@
using System.Threading.Tasks;
+using System.IO;
namespace Discord
{
public static class UserExtensions
{
+ ///
+ /// Sends a message to the user via DM.
+ ///
public static async Task SendMessageAsync(this IUser user,
string text,
bool isTTS = false,
@@ -12,5 +16,33 @@ namespace Discord
{
return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false);
}
+
+ ///
+ /// Sends a file to the user via DM.
+ ///
+ public static async Task SendFileAsync(this IUser user,
+ Stream stream,
+ string filename,
+ string text = null,
+ bool isTTS = false,
+ RequestOptions options = null
+ )
+ {
+ return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
+ }
+
+#if FILESYSTEM
+ ///
+ /// Sends a file to the user via DM.
+ ///
+ public static async Task SendFileAsync(this IUser user,
+ string filePath,
+ string text = null,
+ bool isTTS = false,
+ RequestOptions options = null)
+ {
+ return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
+ }
+#endif
}
}