Browse Source

Added SendFileAsync (#774)

pull/794/merge
Hsu Still Christopher F 7 years ago
parent
commit
0de5d5b02b
1 changed files with 32 additions and 0 deletions
  1. +32
    -0
      src/Discord.Net.Core/Extensions/UserExtensions.cs

+ 32
- 0
src/Discord.Net.Core/Extensions/UserExtensions.cs View File

@@ -1,9 +1,13 @@
using System.Threading.Tasks;
using System.IO;

namespace Discord
{
public static class UserExtensions
{
/// <summary>
/// Sends a message to the user via DM.
/// </summary>
public static async Task<IUserMessage> 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);
}

/// <summary>
/// Sends a file to the user via DM.
/// </summary>
public static async Task<IUserMessage> 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
/// <summary>
/// Sends a file to the user via DM.
/// </summary>
public static async Task<IUserMessage> 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
}
}

Loading…
Cancel
Save