From 86d188ecb048e809ce5de41c2788d2a587a1ca13 Mon Sep 17 00:00:00 2001 From: Adomix <33987862+Adomix@users.noreply.github.com> Date: Fri, 19 Oct 2018 15:50:29 -0400 Subject: [PATCH] Added "SendDMAsync" This shouldn't throw if the user may not be DMd, however it is probably pointless. --- .../Extensions/UserExtensions.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Discord.Net.Core/Extensions/UserExtensions.cs b/src/Discord.Net.Core/Extensions/UserExtensions.cs index f98bf7227..4c50ca8b8 100644 --- a/src/Discord.Net.Core/Extensions/UserExtensions.cs +++ b/src/Discord.Net.Core/Extensions/UserExtensions.cs @@ -39,6 +39,23 @@ namespace Discord { return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false); } + + public static async Task 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 + } + } + /// /// Sends a file to this message channel with an optional caption.