private async Task AnnounceNewMatches() { foreach (var match in Database.Matches.Where(x => !x.Announced)) { var challongeTournament = await ChallongeTournaments.getTournament(match.Tournament.ShortName); var challongeMatch = await ChallongeMatches.GetMatch(match.Tournament.ChallongeIDWithSubdomain, match.ID); if (!challongeMatch.MatchMarkedAsActive) { continue; } var team1 = await Database.Participants.FindAsync(ParticipantIDCache.Instance.GetParticipantID(challongeMatch.player1_id.Value)); var team2 = await Database.Participants.FindAsync(ParticipantIDCache.Instance.GetParticipantID(challongeMatch.player2_id.Value)); var args = new OnNewMatchStartedArgs { Match = challongeMatch, Tournament = challongeTournament, Team1DiscordName = team1?.DiscordMentionName, Team1SeatNum = team1?.SeatNum, Team2DiscordName = team2?.DiscordMentionName, Team2SeatNum = team2?.SeatNum }; OnNewMatchStarted?.Invoke(this, args); match.Announced = true; } await Database.SaveChangesAsync(); }
private ChallongeClient(string apiKey, string subdomain, DateTime createdAfterDate) { var config = new ChallongeConfig(apiKey); Caller = new ChallongeHTTPClientAPICaller(config); ChallongeTournaments = new ChallongeTournaments(Caller, subdomain); ChallongeMatches = new ChallongeMatches(Caller); CreatedAfterDate = createdAfterDate; LoaderTimer = new Timer(e => LoadNewestData()); Database = new DiscordChallongeDatabase(); }