示例#1
0
        public async Task Schedule()
        {
            using (var c = new FootballDataDatabaseConnection())
            {
                var scheduledMatchesList = c.GetScheduledMatchesList().Take(5).ToList();

                if (!scheduledMatchesList.Any())
                {
                    await Context.Channel.SendMessageAsync(":warning: Season ended. Come back later");
                }
                else
                {
                    var builder = new EmbedBuilder();
                    builder.WithTitle("Schedule");
                    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);

                    foreach (var match in scheduledMatchesList)
                    {
                        var date = DateConverter.ConvertToString(match.MatchDate);

                        builder.AddField($"{match.MatchHomeTeam} - {match.MatchAwayTeam}", $"{match.MatchCompetition}, {date} UTC");
                    }

                    builder.WithFooter("To see info with more detail about next match do -nextmatch");

                    await Context.Channel.SendMessageAsync("", false, builder.Build());
                }
            }
        }
示例#2
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());
                }
            }
        }