From f06ee47516b3f9a1cd7e210d1af2fd26afedc7bd Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Fri, 28 Jul 2017 12:38:08 +0200 Subject: [PATCH] cleanup --- src/NadekoBot/Modules/Games/Common/Hangman/Hangman.cs | 1 + src/NadekoBot/Modules/Games/Common/Hangman/TermPool.cs | 1 - src/NadekoBot/Modules/Games/HangmanCommands.cs | 7 ++++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Modules/Games/Common/Hangman/Hangman.cs b/src/NadekoBot/Modules/Games/Common/Hangman/Hangman.cs index 94f14835..61df5560 100644 --- a/src/NadekoBot/Modules/Games/Common/Hangman/Hangman.cs +++ b/src/NadekoBot/Modules/Games/Common/Hangman/Hangman.cs @@ -53,6 +53,7 @@ namespace NadekoBot.Modules.Games.Common.Hangman public ImmutableArray PreviousGuesses => _previousGuesses.ToImmutableArray(); private readonly TaskCompletionSource _endingCompletionSource = new TaskCompletionSource(); + private bool disposed = false; public Task EndedTask => _endingCompletionSource.Task; diff --git a/src/NadekoBot/Modules/Games/Common/Hangman/TermPool.cs b/src/NadekoBot/Modules/Games/Common/Hangman/TermPool.cs index 4647e740..3074aef7 100644 --- a/src/NadekoBot/Modules/Games/Common/Hangman/TermPool.cs +++ b/src/NadekoBot/Modules/Games/Common/Hangman/TermPool.cs @@ -1,5 +1,4 @@ using NadekoBot.Common; -using NadekoBot.Extensions; using NadekoBot.Modules.Games.Common.Hangman.Exceptions; using Newtonsoft.Json; using System; diff --git a/src/NadekoBot/Modules/Games/HangmanCommands.cs b/src/NadekoBot/Modules/Games/HangmanCommands.cs index 9d28d49a..ce76cc37 100644 --- a/src/NadekoBot/Modules/Games/HangmanCommands.cs +++ b/src/NadekoBot/Modules/Games/HangmanCommands.cs @@ -60,6 +60,9 @@ namespace NadekoBot.Modules.Games await hm.EndedTask.ConfigureAwait(false); + _client.MessageReceived -= _client_MessageReceived; + HangmanGames.TryRemove(Context.Channel.Id, out _); + hm.Dispose(); Task _client_MessageReceived(SocketMessage msg) { @@ -76,8 +79,6 @@ namespace NadekoBot.Modules.Games Task Hm_OnGameEnded(Hangman game, string winner) { - HangmanGames.TryRemove(Context.Channel.Id, out _); - if (winner == null) { var loseEmbed = new EmbedBuilder().WithTitle($"Hangman Game ({game.TermType}) - Ended") @@ -127,7 +128,7 @@ namespace NadekoBot.Modules.Games { if (HangmanGames.TryRemove(Context.Channel.Id, out var removed)) { - removed.Dispose(); + await removed.Stop().ConfigureAwait(false); await ReplyConfirmLocalized("hangman_stopped").ConfigureAwait(false); } }