This commit is contained in:
Master Kwoth 2017-07-28 12:38:08 +02:00
parent d5978a0d66
commit f06ee47516
3 changed files with 5 additions and 4 deletions

View File

@ -53,6 +53,7 @@ namespace NadekoBot.Modules.Games.Common.Hangman
public ImmutableArray<char> PreviousGuesses => _previousGuesses.ToImmutableArray();
private readonly TaskCompletionSource<bool> _endingCompletionSource = new TaskCompletionSource<bool>();
private bool disposed = false;
public Task EndedTask => _endingCompletionSource.Task;

View File

@ -1,5 +1,4 @@
using NadekoBot.Common;
using NadekoBot.Extensions;
using NadekoBot.Modules.Games.Common.Hangman.Exceptions;
using Newtonsoft.Json;
using System;

View File

@ -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);
}
}