Fix race condition between sending notification and removing from server
This commit is contained in:
parent
18cd562993
commit
6127bb2ee7
1 changed files with 2 additions and 1 deletions
|
@ -132,6 +132,7 @@ namespace Noikoio.RegexBot.Module.ModCommands.Commands
|
||||||
string reasonlog = $"Invoked by {msg.Author.ToString()}.";
|
string reasonlog = $"Invoked by {msg.Author.ToString()}.";
|
||||||
if (reason != null) reasonlog += $" Reason: {reason}";
|
if (reason != null) reasonlog += $" Reason: {reason}";
|
||||||
reasonlog = Uri.EscapeDataString(reasonlog);
|
reasonlog = Uri.EscapeDataString(reasonlog);
|
||||||
|
await notifyTask;
|
||||||
#warning Remove EscapeDataString call on next Discord.Net update
|
#warning Remove EscapeDataString call on next Discord.Net update
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
if (_mode == CommandMode.Ban) await g.AddBanAsync(targetId, _purgeDays, reasonlog);
|
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."
|
#warning "Actual kick/ban action is DISABLED during debug."
|
||||||
#endif
|
#endif
|
||||||
string resultmsg = BuildSuccessMessage(targetdisp);
|
string resultmsg = BuildSuccessMessage(targetdisp);
|
||||||
if (await notifyTask == false) resultmsg += NotifyFailed;
|
if (notifyTask.Result == false) resultmsg += NotifyFailed;
|
||||||
await msg.Channel.SendMessageAsync(resultmsg);
|
await msg.Channel.SendMessageAsync(resultmsg);
|
||||||
}
|
}
|
||||||
catch (Discord.Net.HttpException ex)
|
catch (Discord.Net.HttpException ex)
|
||||||
|
|
Loading…
Reference in a new issue