Example #1
0
        public static async Task UpdateUserList(DiscordGuild e, bool update)
        {
            var members = await e.GetAllMembersAsync();

            foreach (var user in members)
            {
                if (!RPClass.Users.Any(x => x.UserData.UserID == user.Id))
                {
                    RPClass.Users.Add(new UserObject.RootObject(user.Id));
                }
            }

            if (update)
            {
                await XPClass.UpdateStats();

                await XPClass.UpdatePlayerRanking(e);

                await XPClass.UpdateGuildRanking(e);
            }
        }
Example #2
0
        public static async Task AddOrUpdateUsers(DiscordGuild guild, bool update)
        {
            List <DiscordMember> AllUsers = new List <DiscordMember>(await guild.GetAllMembersAsync());

            AllUsers.RemoveAll(x => x.IsBot);
            List <DiscordChannel> Channels = new List <DiscordChannel>(await guild.GetChannelsAsync());

            foreach (DiscordMember user in AllUsers)
            {
                int role = 0;

                /*312980663638818817 = Pro Hero
                 * 312981984790052866 = Sidekick
                 * 312980292086530048 = Academy Student
                 * 312982325908471808 = Villain
                 * 317915877775245312 = Rogue
                 *
                 */
                if (user.Roles.Any(x => x.Id == 312980663638818817))
                {
                    role = 1;
                }
                else if (user.Roles.Any(x => x.Id == 312982325908471808))
                {
                    role = 2;
                }
                else if (user.Roles.Any(x => x.Id == 317915877775245312))
                {
                    role = 3;
                }
                else if (user.Roles.Any(x => x.Id == 312981984790052866 || x.Id == 312980292086530048))
                {
                    role = 4;
                }
                if (!Users.Any(x => x.UserData.UserID == user.Id))
                {
                    Users.Add(new UserObject.RootObject(new UserObject.UserData(user.Id, user.DisplayName, role), new UserObject.InvData()));
                }
                if (Users.Find(x => x.UserData.UserID == user.Id).UserData.Username != user.DisplayName)
                {
                    Users.Find(x => x.UserData.UserID == user.Id).UserData.Username = user.DisplayName;
                }
                if (Users.Find(x => x.UserData.UserID == user.Id).UserData.Role != role)
                {
                    Users.Find(x => x.UserData.UserID == user.Id).UserData.Role = role;
                }
            }
            if (update)
            {
                await XPClass.UpdateStats(StatsChannel);

                await XPClass.UpdateGuildRanking(guild);

                await XPClass.UpdatePlayerRanking(guild, 1);

                await XPClass.UpdatePlayerRanking(guild, 2);

                await XPClass.UpdatePlayerRanking(guild, 3);

                await XPClass.UpdatePlayerRanking(guild, 4);
            }
            SaveData(-1);
        }