From 6127bb2ee7823008e5bca648ad196df135c9da48 Mon Sep 17 00:00:00 2001 From: Noikoio Date: Wed, 14 Mar 2018 23:59:24 -0700 Subject: [PATCH] Fix race condition between sending notification and removing from server --- Module/ModCommands/Commands/BanKick.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Module/ModCommands/Commands/BanKick.cs b/Module/ModCommands/Commands/BanKick.cs index 28c94e1..0231d31 100644 --- a/Module/ModCommands/Commands/BanKick.cs +++ b/Module/ModCommands/Commands/BanKick.cs @@ -132,6 +132,7 @@ namespace Noikoio.RegexBot.Module.ModCommands.Commands string reasonlog = $"Invoked by {msg.Author.ToString()}."; if (reason != null) reasonlog += $" Reason: {reason}"; reasonlog = Uri.EscapeDataString(reasonlog); + await notifyTask; #warning Remove EscapeDataString call on next Discord.Net update #if !DEBUG if (_mode == CommandMode.Ban) await g.AddBanAsync(targetId, _purgeDays, reasonlog); @@ -140,7 +141,7 @@ namespace Noikoio.RegexBot.Module.ModCommands.Commands #warning "Actual kick/ban action is DISABLED during debug." #endif string resultmsg = BuildSuccessMessage(targetdisp); - if (await notifyTask == false) resultmsg += NotifyFailed; + if (notifyTask.Result == false) resultmsg += NotifyFailed; await msg.Channel.SendMessageAsync(resultmsg); } catch (Discord.Net.HttpException ex)