Browse Source

Added "SendDMAsync"

This shouldn't throw if the user may not be DMd, however it is probably pointless.
pull/1178/head
Adomix GitHub 6 years ago
parent
commit
86d188ecb0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions
  1. +17
    -0
      src/Discord.Net.Core/Extensions/UserExtensions.cs

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

@@ -39,6 +39,23 @@ namespace Discord
{
return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false);
}
public static async Task<IUserMessage> SendDMAsync(this IUser user,
string text = null,
bool isTTS = false,
Embed embed = null,
RequestOptions options = null)
{
try
{
return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false);
}
catch(Exception e)
{
// I didn't know what to do here
}
}

/// <summary>
/// Sends a file to this message channel with an optional caption.


Loading…
Cancel
Save