Exemple #1
0
        public async Task MoveGame(CommandContext ctx)
        {
            var game = Game(ctx);

            if (game is null)
            {
                await ctx.ReplyAsync("There is no active game in this channel!");

                return;
            }

            if (DateTime.Now - game.LastBumped > TimeSpan.FromSeconds(2))
            {
                game.LastBumped = DateTime.Now;
                await DeleteGameMessageAsync(ctx);

                game.LastBumped = DateTime.Now;
                var msg = await RespondGameAsync(ctx);

                game.LastBumped = DateTime.Now;

                if (game is PacManGame pacmanGame)
                {
                    await PacManModule.AddControls(pacmanGame, msg);
                }
            }
        }
        private async Task MoveGame()
        {
            var game = Games.GetForChannel(Context.Channel.Id);

            if (game == null)
            {
                await ReplyAsync("There is no active game in this channel!");

                return;
            }

            try
            {
                var gameMessage = await game.GetMessage();

                if (gameMessage != null)
                {
                    await gameMessage.DeleteAsync(DefaultOptions);                      // Old message
                }
            }
            catch (HttpException) { } // Something happened to the message, can ignore it

            var message = await ReplyAsync(game.GetContent(), game.GetEmbed());

            game.MessageId = message.Id;

            if (game is PacManGame pacmanGame)
            {
                await PacManModule.AddControls(pacmanGame, message);
            }
        }