Ejemplo n.º 1
0
        public async Task Status()
        {
            await p.DoAction(Context.User, Context.Guild.Id, Program.Module.Information);

            int          yes   = 0;
            int          no    = 0;
            EmbedBuilder embed = new EmbedBuilder()
            {
                Title = Sentences.ServicesAvailability(Context.Guild.Id)
            };
            string description = "";

            for (Program.Module i = 0; i < Program.Module.Youtube; i++)
            {
                description += "**" + i.ToString() + "**: " + ((Program.p.db.IsAvailable(Context.Guild.Id, i)) ? (Sentences.Enabled(Context.Guild.Id)) : (Sentences.Disabled(Context.Guild.Id))) + Environment.NewLine;
            }
            embed.Description = description;
            if (Program.p.db.IsAvailable(Context.Guild.Id, Program.Module.Radio))
            {
                embed.AddField("Radio Module",
                               "**Opus dll:** " + ((File.Exists("opus.dll") ? ("Yes") : ("No"))) + Environment.NewLine +
                               "**Lib Sodium dll:** " + ((File.Exists("libsodium.dll") ? ("Yes") : ("No"))) + Environment.NewLine +
                               "**Ffmpeg:** " + ((File.Exists("ffmpeg.exe") ? ("Yes") : ("No"))) + Environment.NewLine +
                               "**youtube-dl:** " + ((File.Exists("youtube-dl.exe") ? ("Yes") : ("No"))) + Environment.NewLine +
                               "**YouTube API key:** " + ((p.youtubeService != null ? ("Yes") : ("No"))));
                if (File.Exists("opus.dll") && File.Exists("libsodium.dll") && File.Exists("ffmpeg.exe") && p.youtubeService != null)
                {
                    yes++;
                }
                else
                {
                    no++;
                }
            }
            if (Program.p.db.IsAvailable(Context.Guild.Id, Program.Module.Game))
            {
                embed.AddField("Game Module", ScoreManager.GetInformation(Context.Guild.Id, ref yes, ref no));
            }
            if (Program.p.db.IsAvailable(Context.Guild.Id, Program.Module.Linguistic))
            {
                embed.AddField("Linguistic Module - Translations",
                               "**Google Translate API key:** " + ((p.translationClient != null ? ("Yes") : ("No"))) + Environment.NewLine +
                               "**Google Vision API key:** " + ((p.visionClient != null ? ("Yes") : ("No"))));
                if (p.translationClient != null)
                {
                    yes++;
                    if (p.visionClient != null)
                    {
                        yes++;
                    }
                    else
                    {
                        no++;
                    }
                }
                else
                {
                    no += 2;
                }
            }
            embed.AddField("Information Module - Logs", "**GitHub API key:** " + (p.GitHubKey != null ? "Yes" : "No"));
            if (p.GitHubKey != null)
            {
                yes++;
            }
            else
            {
                no++;
            }
            embed.AddField("Anime/Manga Module - NSFW", "**Kitsu logins:** " + (p.kitsuAuth != null ? "Yes" : "No"));
            embed.AddField("Anime/Manga Module - Subscription", "**Subscription channel:** " + await p.db.GetMyChannelNameAsync(Context.Guild));
            if (p.kitsuAuth != null)
            {
                yes++;
            }
            else
            {
                no++;
            }
            if (Program.p.db.IsAvailable(Context.Guild.Id, Program.Module.Youtube))
            {
                embed.AddField("YouTube Module", "**YouTube API key:** " + ((p.youtubeService != null) ? ("Yes") : ("No")));
                if (p.youtubeService != null)
                {
                    yes++;
                }
                else
                {
                    no++;
                }
            }
            if (yes + no == 0)
            {
                yes++;
            }
            int max = yes + no;

            embed.Color = new Color(no * 255 / max, yes * 255 / max, 0);
            Dictionary <string, int> allTrads = new Dictionary <string, int>();

            foreach (var elem in Program.p.allLanguages)
            {
                allTrads.Add(elem.Key, 0);
            }
            foreach (var s in Program.p.translations)
            {
                if (s.Value.Any(x => x.language == "en"))
                {
                    foreach (var trad in s.Value)
                    {
                        allTrads[trad.language]++;
                    }
                }
            }
            string finalLanguage = "";
            int    enRef         = allTrads["en"];

            foreach (var s in allTrads)
            {
                finalLanguage += CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Program.p.allLanguages[s.Key][0]) + ": " + (s.Value * 100 / enRef) + "%" + Environment.NewLine;
            }
            embed.AddField(Sentences.TranslationsAvailability(Context.Guild.Id), finalLanguage);
            await ReplyAsync("", false, embed.Build());
        }