private async Task ExecuteGameInputAsync(IMessagesGame game, SocketUserMessage message) { var gameMessage = await game.GetMessageAsync(); log.Verbose( $"Input {message.Content} by {message.Author.FullName()} in {message.Channel.FullName()}", game.GameName); await game.InputAsync(message.Content, message.Author.Id); if (game is MultiplayerGame mGame) { while (mGame.BotTurn) { await mGame.BotInputAsync(); } } if (game.State != GameState.Active) { games.Remove(game); } if (gameMessage != null && message.Channel.BotCan(ChannelPermission.ManageMessages)) { game.CancelRequests(); try { await gameMessage.ModifyAsync(game.GetMessageUpdate(), game.GetRequestOptions()); } catch (OperationCanceledException) { } await message.DeleteAsync(PmBot.DefaultOptions); } else { game.CancelRequests(); try { var newMsg = await message.Channel.SendMessageAsync(game.GetContent(), false, game.GetEmbed()?.Build(), game.GetRequestOptions()); game.MessageId = newMsg.Id; } catch (OperationCanceledException) { } if (gameMessage != null) { await gameMessage.DeleteAsync(PmBot.DefaultOptions); } } }
private async Task ExecuteGameInputAsync(IMessagesGame game, IUserMessage message) { var gameMessage = await game.GetMessage(); await logger.Log(LogSeverity.Verbose, game.GameName, $"Input {message.Content} by {message.Author.FullName()} in {message.Channel.FullName()}"); game.Input(message.Content, message.Author.Id); if (game is MultiplayerGame mGame) { while (mGame.BotTurn) { mGame.BotInput(); } } if (game.State != State.Active) { games.Remove(game); } game.CancelRequests(); var requestOptions = game.GetRequestOptions(); if (gameMessage != null && message.Channel.BotCan(ChannelPermission.ManageMessages)) { await gameMessage.ModifyAsync(game.GetMessageUpdate(), requestOptions); await message.DeleteAsync(Bot.DefaultOptions); } else { var newMsg = await message.Channel.SendMessageAsync(game.GetContent(), false, game.GetEmbed()?.Build(), requestOptions); game.MessageId = newMsg.Id; if (gameMessage != null) { await gameMessage.DeleteAsync(Bot.DefaultOptions); } } }