コード例 #1
0
        public async Task NextMatch()
        {
            using (var c = new FootballDataDatabaseConnection())
            {
                var scheduledMatchesList = c.GetScheduledMatchesList();

                if (!scheduledMatchesList.Any())
                {
                    await Context.Channel.SendMessageAsync(":warning: Season ended. Come back later");
                }
                else
                {
                    var match           = scheduledMatchesList[0];
                    var builder         = new EmbedBuilder();
                    var date            = DateConverter.ConvertToDateTime(match.MatchDate);
                    var dateString      = DateConverter.ConvertToString(match.MatchDate);
                    var timeUntil       = (date - DateTime.Now);
                    var timeUntilString = $"{timeUntil.Days} days, {timeUntil.Hours} hours, {timeUntil.Minutes} minutes";

                    builder.WithTitle("Next match");
                    builder.WithThumbnailUrl("https://upload.wikimedia.org/wikipedia/en/thumb/4/47/FC_Barcelona_%28crest%29.svg/1200px-FC_Barcelona_%28crest%29.svg.png");
                    builder.WithColor(Color.Purple);
                    builder.AddField($"{match.MatchHomeTeam} - {match.MatchAwayTeam}", $"{match.MatchCompetition} \n {match.MatchStadium}");
                    builder.AddField("Time", $"Kick-off time: {dateString} UTC\nTime until kick-off: {timeUntilString}");
                    builder.AddField("Head to Head - Recent games", $"Matches: {match.MatchTotalMatches} \n Wins: {match.MatchWins} \n Draws: {match.MatchDraws} \n Losses: {match.MatchLosses}");

                    await Context.Channel.SendMessageAsync("", false, builder.Build());
                }
            }
        }