Example #1
0
        public async Task EventRsvpCheck(int eventId, string house = null, string division = null, string team = null, string roster = null, bool mention = false)
        {
            var client = DIHttpClient.CreateWithAuthCookies(ConfigUtil.Config.AuthConfig.Cookies);

            var evt = _calendar.Calendars.SelectMany(x => x.Events).FirstOrDefault(x => x.EventID == eventId);

            if (evt == null)
            {
                await ReplyAsync("No event with that ID could be found!");

                return;
            }

            var rsvpMembers = await client.GetEventRsvpAsync(evt.TitleUrl);

            DIUnit unit = _mdr.GetUnit(house, division, team, roster);

            var members = unit.Members.Where(x => x.Rank != DIRank.Associate && x.Rank != DIRank.AwayST && x.Rank != DIRank.AwayLT);

            var memberCount     = members.Count();
            var memberRsvpCount = members.Select(x => x.Name).Intersect(rsvpMembers).Count();

            var response = $"RSVP Rate: {memberRsvpCount}/{memberCount} ({((memberRsvpCount / (float)memberCount) * 100).ToString("0.00")}%). People missing:\n\n" +
                           members
                           .Select(x => x.Name)
                           .Except(rsvpMembers)
                           .Select(x => mention && members.First(y => y.Name == x)?.DiscordId > 0 ? Context.Guild.GetUser(members.First(y => y.Name == x).DiscordId)?.Mention ?? x : x)
                           .Aggregate((a, b) => a + "\n" + b);

            await ReplyAsync("", false, evt.GetEmbed());

            await ReplyMultiMessageAsync(response);
        }
Example #2
0
        public async Task MDRApply(string house = null, string division = null, string team = null, string roster = null)
        {
            DIUnit unit = _mdr.GetUnit(house, division, team, roster);

            try
            {
                var response = "Following members were found:\n\n" + unit.Members
                               .Select(x => x.Name + (x.DiscordId > 0 ? $" - ({Context.Guild.GetUser(x.DiscordId)?.Mention ?? ""})" : ""))
                               .Aggregate((a, b) => a + "\n" + b);

                await ReplyMultiMessageAsync(response);
            }
            catch (Exception e)
            {
                e.ToString();
            }
        }