예제 #1
0
        public static async Task <Embed> PrintRecommendedSongs(ISocketMessageChannel ch, Dictionary <string, float[]> songsToRecommend, string name, Stopwatch stopWatch)
        {
            string toPrint = "";
            int    count   = 0;

            foreach (string songKey in songsToRecommend.Keys)
            {
                songsToRecommend.TryGetValue(songKey, out var curr);
                toPrint = toPrint + songKey + $"\n\t Total: {Math.Round(curr[1], 3)}  {name}: {Math.Round(curr[0], 3)} \n\n";
                count++;
                if (count % 10 == 0)
                {
                    await ch.SendMessageAsync(embed : await EmbedHandler.CreateBasicEmbed($"Recommendation for {name}", toPrint, Color.Blue));

                    toPrint = "";
                }
            }
            stopWatch.Stop();
            // Get the elapsed time as a TimeSpan value.
            TimeSpan ts = stopWatch.Elapsed;
            // Format and display the TimeSpan value.
            string elapsedTime = String.Format("{0:00}:{1:00}.{2:00}",
                                               ts.Minutes, ts.Seconds,
                                               ts.Milliseconds / 10);

            Console.WriteLine("Time to calculate: " + elapsedTime);
            return(await EmbedHandler.CreateBasicEmbed("Recommendation", toPrint + $"\n Elapsed Time: {elapsedTime}", Color.Blue));
        }
예제 #2
0
        public static async Task <Embed> ListJsons(string JsonFolder)
        {
            var filenames = from fullFilename
                            in Directory.EnumerateFiles(JsonFolder)
                            select Path.GetFileName(fullFilename);

            string toPrint = "";

            foreach (var item in filenames)
            {
                toPrint = toPrint + item + "\n";
            }

            return(await EmbedHandler.CreateBasicEmbed("Data", toPrint, Color.Blue));
        }
예제 #3
0
 public static async Task<Embed> CalcTotalCorrect(CsharpiEntities _db, PlayersRulesService _service)
 {
     string successRates = "";
     foreach (string player in await _service.GetPlayersTracked())
     {
         float total = 0;
         float correct = 0;
         var Shows = await _db.PlayerStats
             .AsNoTracking()
             .Where(k => k.PlayerName.Equals(player))
             .ToListAsync();
         foreach (PlayerTableObject player1 in Shows)
         {
             total = total + player1.TotalTimesPlayed;
             correct = correct + player1.TimesCorrect;
         }
         successRates = successRates + player + " correct rate: " + Math.Round((double)(correct / total), 3) + "\n";
     }
     return await EmbedHandler.CreateBasicEmbed("Data", successRates, Color.Blue);
 }