/// <summary> /// Display the top 3 highest ranking members (if available) /// </summary> /// <param name="chatter">User that sent the message</param> private async Task <DateTime> LeaderboardRankAsync(TwitchChatter chatter) { try { IEnumerable <RankFollower> highestRankedFollowers = await _follower.GetFollowersLeaderboardAsync(_broadcasterInstance.DatabaseId); if (highestRankedFollowers.Count() == 0) { _irc.SendPublicChatMessage($"There's no one in your ranks. Start recruiting today! @{chatter.DisplayName}"); return(DateTime.Now); } IEnumerable <Rank> rankList = await _follower.GetRankListAsync(_broadcasterInstance.DatabaseId); string resultMsg = ""; foreach (RankFollower follower in highestRankedFollowers) { Rank currFollowerRank = _follower.GetCurrentRank(rankList, follower.Experience); decimal hoursWatched = _follower.GetHoursWatched(follower.Experience); resultMsg += $"\"{currFollowerRank.Name} {follower.Username}\" with {hoursWatched} hour(s), "; } resultMsg = resultMsg.Remove(resultMsg.Length - 2); // remove extra "," // improve list grammar if (highestRankedFollowers.Count() == 2) { resultMsg = resultMsg.ReplaceLastOccurrence(", ", " and "); } else if (highestRankedFollowers.Count() > 2) { resultMsg = resultMsg.ReplaceLastOccurrence(", ", ", and "); } if (highestRankedFollowers.Count() == 1) { _irc.SendPublicChatMessage($"This leader's highest ranking member is {resultMsg}"); } else { _irc.SendPublicChatMessage($"This leader's highest ranking members are: {resultMsg}"); } } catch (Exception ex) { await _errHndlrInstance.LogError(ex, "FollowerFeature", "LeaderboardRank(TwitchChatter)", false, "!ranktop3"); } return(DateTime.Now); }