public async Task RemoveParticipant(string discordId) { using (Context.Channel.EnterTypingState()) { try { var participant = _participantService.GetParticipantOrDefault(Context.Guild.Id.ToString(), discordId); if (participant == null) { await ReplyAsync($"Participant with id {discordId} wasn't found."); return; } var credentials = await _stravaCredentialService.GetByStravaId(participant.StravaId); await _participantService.Remove(participant, credentials); await ReplyAsync($"Participant with id {discordId} was removed."); } catch (Exception e) { _logger.LogError(e, "list failed"); } } }
public async Task ShowParticipantStats() { using (Context.Channel.EnterTypingState()) { try { var participant = await _participantService .GetParticipantOrDefault(Context.Guild.Id.ToString(), Context.User.Id.ToString()); if (participant == null) { await ReplyAsync("It seems like you're not part of the leaderboard. Try joining it."); } var start = DateTime.Now.AddDays(-7); var activities = await _stravaService.FetchActivitiesForParticipant(participant, start); await ReplyAsync(embed : _embedBuilderService.BuildParticipantStatsForCategoryEmbed(participant, activities, Constants.LeaderboardRideType.RealRide, start, DateTime.Now)); await ReplyAsync(embed : _embedBuilderService.BuildParticipantStatsForCategoryEmbed(participant, activities, Constants.LeaderboardRideType.VirtualRide, start, DateTime.Now)); } catch (Exception e) { _logger.LogError(e, "stats failed"); } } }
public async Task GetDetailedParticipant(string discordId) { using (Context.Channel.EnterTypingState()) { try { _logger.LogInformation($"Executing get {discordId}"); var participant = await _participantService.GetParticipantOrDefault(Context.Guild.Id.ToString(), discordId); if (participant == null) { await ReplyAsync(embed : _embedBuilderService.BuildSimpleEmbed( "Not Found", "Couldn't find participant with this discord id") ); return; } var athlete = await _stravaService.GetAthlete(participant); foreach (var embed in _embedBuilderService.BuildDetailedAthleteEmbeds(participant, athlete)) { await ReplyAsync(embed : embed); } } catch (Exception e) { _logger.LogError(e, "list failed"); } } }
public async Task ShowParticipantStats() { using (Context.Channel.EnterTypingState()) { try { var participant = _participantService.GetParticipantOrDefault(Context.Guild.Id.ToString(), Context.User.Id.ToString()); if (participant == null) { await ReplyAsync("It seems like you're not part of the leaderboard. Try joining it."); return; } var start = DateTime.Now.AddDays(-7); var(policy, context) = _stravaAuthenticationService.GetUnauthorizedPolicy(participant.StravaId); var activities = await policy.ExecuteAsync(x => _activityService.GetForStravaUser(participant.StravaId, start), context); var participantWithActivities = new ParticipantWithActivities { Participant = participant, Activities = activities }; var realRideCategoryResult = _leaderboardService.GetTopResultsForCategory( new List <ParticipantWithActivities> { participantWithActivities }, new RealRideCategory()); await ReplyAsync(embed : _embedBuilderService.BuildParticipantStatsForCategoryEmbed(realRideCategoryResult, $"'{new RealRideCategory().Name}' leaderboard for '{start:yyyy MMMM dd} - {DateTime.Now:yyyy MMMM dd}'")); var virtualRideCategoryResult = _leaderboardService.GetTopResultsForCategory( new List <ParticipantWithActivities> { participantWithActivities }, new VirtualRideCategory()); await ReplyAsync(embed : _embedBuilderService.BuildParticipantStatsForCategoryEmbed(virtualRideCategoryResult, $"'{new VirtualRideCategory().Name}' leaderboard for '{start:yyyy MMMM dd} - {DateTime.Now:yyyy MMMM dd}'")); } catch (Exception e) { _logger.LogError(e, "stats failed"); } } }