public async Task Hangman([Remainder] string type = "All") { var hm = new HangmanGame(Context.Channel, type); if (!HangmanGames.TryAdd(Context.Channel.Id, hm)) { await Context.Channel.SendErrorAsync("Hangman game already running on this channel.").ConfigureAwait(false); return; } hm.OnEnded += (g) => { HangmanGame throwaway; HangmanGames.TryRemove(g.GameChannel.Id, out throwaway); }; try { hm.Start(); } catch (Exception ex) { try { await Context.Channel.SendErrorAsync($"Starting errored: {ex.Message}").ConfigureAwait(false); } catch { } HangmanGame throwaway; HangmanGames.TryRemove(Context.Channel.Id, out throwaway); throwaway.Dispose(); return; } await Context.Channel.SendConfirmAsync("Hangman game started", hm.ScrambledWord + "\n" + hm.GetHangman() + "\n" + hm.ScrambledWord); }
public async Task Hangman(HangmanTermPool.HangmanTermType type = HangmanTermPool.HangmanTermType.All) { var hm = new HangmanGame(Context.Channel, type); if (!HangmanGames.TryAdd(Context.Channel.Id, hm)) { await Context.Channel.SendErrorAsync("Hangman game already running on this channel.").ConfigureAwait(false); return; } hm.OnEnded += (g) => { HangmanGame throwaway; HangmanGames.TryRemove(g.GameChannel.Id, out throwaway); }; hm.Start(); await Context.Channel.SendConfirmAsync("Hangman game started", hm.ScrambledWord + "\n" + hm.GetHangman() + "\n" + hm.ScrambledWord); }