From 11da7c89b6715cde6344539459c6b11fbf6f05f3 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 11 Jan 2017 13:54:25 +0100 Subject: [PATCH] hangman fix? closes #956 --- .../Modules/Games/Commands/Hangman/HangmanGame.cs | 8 +++++++- src/NadekoBot/Modules/Games/Commands/HangmanCommands.cs | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs b/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs index 58071453..23b76e9b 100644 --- a/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs +++ b/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs @@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Games.Commands.Hangman } } - public class HangmanGame + public class HangmanGame: IDisposable { private readonly Logger _log; @@ -196,5 +196,11 @@ namespace NadekoBot.Modules.Games.Commands.Hangman {(Errors > 1 ? "/" : " ")} {(Errors > 2 ? "|" : " ")} {(Errors > 3 ? "\\" : " ")} | {(Errors > 4 ? "/" : " ")} {(Errors > 5 ? "\\" : " ")} | /-\"; + + public void Dispose() + { + NadekoBot.Client.MessageReceived -= PotentialGuess; + OnEnded = null; + } } } \ No newline at end of file diff --git a/src/NadekoBot/Modules/Games/Commands/HangmanCommands.cs b/src/NadekoBot/Modules/Games/Commands/HangmanCommands.cs index 0827ab94..50596e4c 100644 --- a/src/NadekoBot/Modules/Games/Commands/HangmanCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/HangmanCommands.cs @@ -52,8 +52,12 @@ namespace NadekoBot.Modules.Games { hm.Start(); } - catch (Exception ex) { + 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; }