Example #1
0
        private async Task ReportIncursion(JsonClasses.IncursionData incursion, JsonClasses.ConstellationData c, IMessageChannel channel)
        {
            var result = await SQLHelper.IsIncurionExists(incursion.constellation_id);

            //skip existing incursion report
            var isUpdate = result && Settings.IncursionNotificationModule.ReportIncursionStatusAfterDT;

            if (!isUpdate && result)
            {
                return;
            }

            if (!isUpdate)
            {
                await SQLHelper.AddIncursion(incursion.constellation_id);
            }

            c = c ?? await APIHelper.ESIAPI.GetConstellationData(Reason, incursion.constellation_id);

            var r = await APIHelper.ESIAPI.GetRegionData(Reason, c.region_id);

            var sb = new StringBuilder();

            foreach (var system in incursion.infested_solar_systems)
            {
                sb.Append((await APIHelper.ESIAPI.GetSystemData(Reason, system)).name);
                sb.Append(" | ");
            }
            sb.Remove(sb.Length - 3, 2);

            var x = new EmbedBuilder().WithTitle(isUpdate ? LM.Get("incursionUpdateHeader", c.name, r.name) : LM.Get("incursionNewHeader", c.name, r.name))
                    .WithColor(isUpdate ? new Color(0x000045) : new Color(0xdd5353))
                    .WithThumbnailUrl(Settings.Resources.ImgIncursion)
                    .AddField(LM.Get("incursionInfestedSystems"), sb.ToString())
                    .AddField(LM.Get("incursionInfluence"), (incursion.influence).ToString("P"), true)
                    .AddField(LM.Get("incursionBoss"), incursion.has_boss ? LM.Get("Alive") : LM.Get("Defeated"), true)
                    .WithCurrentTimestamp()
                    .Build();
            await APIHelper.DiscordAPI.SendMessageAsync(channel, Settings.IncursionNotificationModule.DefaultMention ?? "", x);
        }