private async Task HandleCupsSaved(int nrOfCups, Message message)
        {
            _savedCups += nrOfCups;

            if (nrOfCups > 0)
            {
                var achievement = _achievementService.GetAchievement(_savedCups);
                if (achievement != null)
                {
                    await bot.Send(message, $"Unlocked achievement: {achievement}");
                }

                await bot.Send(message,
                               $"Thanks for saving {nrOfCups} {(nrOfCups > 1 ? "cups" : "cup")} " +
                               $"({Constants.PlasticPerCupInGram * nrOfCups} grams of plastic) \n\n" +
                               $"{Helpers.TotalSavedText(_savedCups)}");
            }
            else if (nrOfCups < 0)
            {
                await bot.Send(message, $"{nrOfCups} undo done.\n\n" +
                               $"{Helpers.TotalSavedText(_savedCups)}");
            }

            _coffeeCupRepository.UpdateCoffeeCupsSaved(_savedCups);
            _userRepository.UpdateCount(message.Chat.Id, nrOfCups);
            _userRepository.UpdateCount(message.Chat.Id, nrOfCups);

            if (_postUrl != null)
            {
                PostHelper.PostCount(_postUrl, _savedCups);
            }
        }
Beispiel #2
0
        private async Task OnMessageCreateAsync(IDiscordMessage arg)
        {
            if (!(app is MikiBotApp botApp))
            {
                return;
            }

            switch (arg.Content.ToLowerInvariant())
            {
            case "here come dat boi":
            {
                var a = achievementService.GetAchievement(AchievementIds.FrogId);
                await botApp.CreateFromMessageAsync(
                    arg,
                    async ctx => await achievementService.UnlockAsync(ctx, a, arg.Author.Id));
            }
            break;

            case "( ͡° ͜ʖ ͡°)":
            {
                var a = achievementService.GetAchievement(AchievementIds.LennyId);
                await botApp.CreateFromMessageAsync(
                    arg,
                    async ctx => await achievementService.UnlockAsync(ctx, a, arg.Author.Id));
            }
            break;

            case "poi":
            {
                var a = achievementService.GetAchievement(AchievementIds.ShipId);
                await botApp.CreateFromMessageAsync(
                    arg,
                    async ctx => await achievementService.UnlockAsync(ctx, a, arg.Author.Id));
            }
            break;
            }

            if (MikiRandom.Next(0, 10000000000) == 5234210)
            {
                var a = achievementService.GetAchievement(AchievementIds.LuckId);
                await botApp.CreateFromMessageAsync(
                    arg,
                    async ctx => await achievementService.UnlockAsync(ctx, a, arg.Author.Id));
            }
        }