wrapped async void thing in try catch just in case

This commit is contained in:
Kwoth 2016-07-26 01:32:40 +02:00
parent 531c9821ae
commit a6f3a29be4

View File

@ -91,27 +91,33 @@ namespace NadekoBot.Modules.Gambling.Commands
var fullgame = CheckForFullGameAsync(token); var fullgame = CheckForFullGameAsync(token);
Task.Run(async () => Task.Run(async () =>
{ {
await raceChannel.SendMessage($"🏁`Race is starting in 20 seconds or when the room is full. Type $jr to join the race.`"); try
var t = await Task.WhenAny(Task.Delay(20000, token), fullgame);
Started = true;
cancelSource.Cancel();
if (t == fullgame)
{ {
await raceChannel.SendMessage("🏁`Race full, starting right now!`"); await raceChannel.SendMessage($"🏁`Race is starting in 20 seconds or when the room is full. Type $jr to join the race.`");
} var t = await Task.WhenAny(Task.Delay(20000, token), fullgame);
else if (participants.Count > 1) { Started = true;
await raceChannel.SendMessage("🏁`Game starting with " + participants.Count + " praticipants.`"); cancelSource.Cancel();
} if (t == fullgame)
else { {
await raceChannel.SendMessage("🏁`Race failed to start since there was not enough participants.`"); await raceChannel.SendMessage("🏁`Race full, starting right now!`");
var p = participants.FirstOrDefault(); }
if (p != null) else if (participants.Count > 1)
await FlowersHandler.AddFlowersAsync(p.User, "BetRace", p.AmountBet, true).ConfigureAwait(false); {
await raceChannel.SendMessage("🏁`Game starting with " + participants.Count + " praticipants.`");
}
else
{
await raceChannel.SendMessage("🏁`Race failed to start since there was not enough participants.`");
var p = participants.FirstOrDefault();
if (p != null)
await FlowersHandler.AddFlowersAsync(p.User, "BetRace", p.AmountBet, true).ConfigureAwait(false);
End();
return;
}
await Task.Run(StartRace);
End(); End();
return;
} }
await Task.Run(StartRace); catch { }
End();
}); });
} }