public async Task <DiscordEmbed> BuildRaidMessage(RaidData raid, ulong userId) { var pkmn = _db.Pokemon[raid.PokemonId.ToString()]; if (pkmn == null) { _logger.Error($"Failed to lookup Raid Pokemon '{raid.PokemonId}' in database."); return(null); } var user = await _client.GetMemberFromUserId(userId); if (user == null) { _logger.Error($"Failed to get discord member object from user id {userId}."); return(null); } //var loc = Utils.GetGoogleAddress(raid.Latitude, raid.Longitude, _config.GmapsKey); var loc = _geofenceSvc.GetGeofence(new Location(raid.Latitude, raid.Longitude)); if (loc == null) { _logger.Error($"Failed to lookup city for coordinates {raid.Latitude},{raid.Longitude}, skipping..."); return(null); } if (!_config.CityRoles.Exists(x => string.Compare(x, loc.Name, true) == 0)) { File.AppendAllText("cities.txt", $"City: {loc.Name}\r\n"); } if (!_client.HasRole(user, loc.Name)) { _logger.Debug($"Skipping notification for user {user.DisplayName} ({user.Id}) for Pokemon {pkmn.Name} because they do not have the city role '{loc.Name}'."); return(null); } var eb = new DiscordEmbedBuilder { Title = loc == null || string.IsNullOrEmpty(loc.Name) ? "DIRECTIONS" : loc.Name, //Description = $"{pkmn.Name} raid available until {raid.EndTime.ToLongTimeString()}!", Url = string.Format(Strings.GoogleMaps, raid.Latitude, raid.Longitude), ImageUrl = string.Format(Strings.GoogleMapsStaticImage, raid.Latitude, raid.Longitude), ThumbnailUrl = string.Format(Strings.PokemonImage, raid.PokemonId, 0), Color = DiscordHelpers.BuildRaidColor(Convert.ToInt32(raid.Level)) }; var fixedEndTime = DateTime.Parse(raid.EndTime.ToLongTimeString()); var remaining = GetTimeRemaining(fixedEndTime); eb.Description = $"{pkmn.Name} Raid Ends: {raid.EndTime.ToLongTimeString()}\r\n\r\n"; eb.Description += $"**Starts:** {raid.StartTime.ToLongTimeString()}\r\n"; eb.Description += $"**Ends:** {raid.EndTime.ToLongTimeString()} ({remaining.ToReadableStringNoSeconds()} left)\r\n"; var perfectRange = _db.GetPokemonCpRange(raid.PokemonId, 20); var boostedRange = _db.GetPokemonCpRange(raid.PokemonId, 25); eb.Description += $"**Perfect CP:** {perfectRange.Best} / :white_sun_rain_cloud: {boostedRange.Best}\r\n"; if (pkmn.Types.Count > 0) { var types = new List <string>(); pkmn.Types.ForEach(x => { if (Strings.TypeEmojis.ContainsKey(x.Type.ToLower())) { types.Add(Strings.TypeEmojis[x.Type.ToLower()] + " " + x.Type); } }); eb.Description += $"**Types:** {string.Join("/", types)}\r\n"; } var fastMove = _db.Movesets.ContainsKey(raid.FastMove) ? _db.Movesets[raid.FastMove] : null; if (fastMove != null) { eb.Description += $"**Fast Move:** {Strings.TypeEmojis[fastMove.Type.ToLower()]} {fastMove.Name}\r\n"; } var chargeMove = _db.Movesets.ContainsKey(raid.ChargeMove) ? _db.Movesets[raid.ChargeMove] : null; if (chargeMove != null) { eb.Description += $"**Charge Move:** {Strings.TypeEmojis[chargeMove.Type.ToLower()]} {chargeMove.Name}\r\n"; } var strengths = new List <string>(); var weaknesses = new List <string>(); foreach (var type in pkmn.Types) { foreach (var strength in PokemonExtensions.GetStrengths(type.Type)) { if (!strengths.Contains(strength)) { strengths.Add(strength); } } foreach (var weakness in PokemonExtensions.GetWeaknesses(type.Type)) { if (!weaknesses.Contains(weakness)) { weaknesses.Add(weakness); } } } if (strengths.Count > 0) { eb.Description += $"**Strong Against:** {string.Join(", ", strengths)}\r\n"; } if (weaknesses.Count > 0) { eb.Description += $"**Weaknesses:** {string.Join(", ", weaknesses)}\r\n"; } eb.Description += $"**Location:** {Math.Round(raid.Latitude, 5)},{Math.Round(raid.Longitude, 5)}"; eb.ImageUrl = string.Format(Strings.GoogleMapsStaticImage, raid.Latitude, raid.Longitude) + $"&key={_config.GmapsKey}"; eb.Footer = new DiscordEmbedBuilder.EmbedFooter { Text = $"versx | {DateTime.Now}" }; var embed = eb.Build(); return(embed); }