cleanup
This commit is contained in:
parent
d5978a0d66
commit
f06ee47516
@ -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;
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
using NadekoBot.Common;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Modules.Games.Common.Hangman.Exceptions;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user