private Executable GetSafariExe(EmbedBuilder embed, IUserMessage msg, Card newCard, SafariImage pokeImage, ICharacterInfo character, ITextChannel trashChannel, IUser winner) { return(new Executable("safari", new Task(() => { using (var db = new Database.UserContext(_config)) { var botUser = db.GetUserOrCreateAsync(winner.Id).Result; newCard.FirstIdOwner = winner.Id; newCard.Affection += botUser.GameDeck.AffectionFromKarma(); botUser.GameDeck.RemoveCharacterFromWishList(newCard.Character); botUser.GameDeck.Cards.Add(newCard); db.SaveChanges(); QueryCacheManager.ExpireTag(new string[] { $"user-{botUser.Id}", "users" }); using (var dba = new Database.AnalyticsContext(_config)) { dba.UsersData.Add(new Database.Models.Analytics.UserAnalytics { Value = 1, UserId = winner.Id, MeasureDate = DateTime.Now, GuildId = trashChannel?.Guild?.Id ?? 0, Type = Database.Models.Analytics.UserAnalyticsEventType.Card }); dba.SaveChanges(); } } _ = Task.Run(async() => { try { embed.ImageUrl = await _waifu.GetSafariViewAsync(pokeImage, newCard, trashChannel); embed.Description = $"{winner.Mention} zdobył na polowaniu i wsadził do klatki:\n" + $"{newCard.GetString(false, false, true)}\n({newCard.Title})"; await msg.ModifyAsync(x => x.Embed = embed.Build()); var privEmb = new EmbedBuilder() { Color = EMType.Info.Color(), Description = $"Na [polowaniu]({msg.GetJumpUrl()}) zdobyłeś: {newCard.GetString(false, false, true)}" }; var priv = await winner.GetOrCreateDMChannelAsync(); if (priv != null) { await priv.SendMessageAsync("", false, privEmb.Build()); } } catch (Exception ex) { _logger.Log($"In Safari: {ex}"); } }); }))); }
private Executable GetSafariExe(EmbedBuilder embed, IUserMessage msg, Card newCard, SafariImage pokeImage, ICharacterInfo character, ITextChannel trashChannel, IUser winner) { return(new Executable("safari", new Task(() => { using (var db = new Database.UserContext(_config)) { var botUser = db.GetUserOrCreateAsync(winner.Id).Result; botUser.GameDeck.Cards.Add(newCard); db.SaveChanges(); QueryCacheManager.ExpireTag(new string[] { $"user-{botUser.Id}", "users" }); } _ = Task.Run(async() => { try { embed.ImageUrl = await _waifu.GetSafariViewAsync(pokeImage, character, newCard, trashChannel); embed.Description = $"{winner.Mention} zdobył na polowaniu i wsadził do klatki:\n" + $"{newCard.GetString(false, false, true)}\n({newCard.Title})"; await msg.ModifyAsync(x => x.Embed = embed.Build()); var privEmb = new EmbedBuilder() { Color = EMType.Info.Color(), Description = $"Na [polowaniu]({msg.GetJumpUrl()}) zdobyłeś: {newCard.GetString(false, false, true)}" }; var priv = await winner.GetOrCreateDMChannelAsync(); if (priv != null) { await priv.SendMessageAsync("", false, privEmb.Build()); } } catch (Exception ex) { _logger.Log($"In Safari: {ex}"); } }); }))); }