コード例 #1
0
ファイル: Role.cs プロジェクト: senahf/RickBot
        internal void Update(APIRole model)
        {
            if (model.Name != null)
            {
                Name = model.Name;
            }
            if (model.Hoist != null)
            {
                IsHoisted = model.Hoist.Value;
            }
            if (model.Managed != null)
            {
                IsManaged = model.Managed.Value;
            }
            if (model.Position != null && !IsEveryone)
            {
                Position = model.Position.Value;
            }
            if (model.Color != null)
            {
                Color = new Color(model.Color.Value);
            }
            if (model.Permissions != null)
            {
                Permissions = new ServerPermissions(model.Permissions.Value);
            }

            foreach (var member in Members)
            {
                Server.UpdatePermissions(member);
            }
        }
コード例 #2
0
        private void UpdateRoles(IEnumerable <Role> roles)
        {
            var newRoles = new Dictionary <ulong, Role>();

            if (roles != null)
            {
                foreach (var r in roles)
                {
                    if (r != null)
                    {
                        newRoles[r.Id] = r;
                    }
                }
            }

            if (Server != null)
            {
                var everyone = Server.EveryoneRole;
                newRoles[everyone.Id] = everyone;
            }
            _roles = newRoles;

            if (Server != null)
            {
                Server.UpdatePermissions(this);
            }
        }
コード例 #3
0
        private void UpdateRoles(IEnumerable <Role> roles)
        {
            bool updated  = false;
            var  newRoles = new Dictionary <ulong, Role>();

            var oldRoles = _roles;

            if (roles != null)
            {
                foreach (var r in roles)
                {
                    if (r != null)
                    {
                        newRoles[r.Id] = r;
                        if (!oldRoles.ContainsKey(r.Id))
                        {
                            updated = true; //Check for adds
                        }
                    }
                }
            }

            if (Server != null)
            {
                var everyone = Server.EveryoneRole;
                newRoles[everyone.Id] = everyone;
            }
            if (oldRoles.Count != newRoles.Count)
            {
                updated = true; //Check for removes
            }
            if (updated)
            {
                _roles = newRoles;
                if (Server != null)
                {
                    Server.UpdatePermissions(this);
                }
            }
        }
コード例 #4
0
 internal void Update(APIRole model, bool updatePermissions)
 {
     if (model.Name != null)
     {
         Name = model.Name;
     }
     if (model.Hoist != null)
     {
         IsHoisted = model.Hoist.Value;
     }
     if (model.Managed != null)
     {
         IsManaged = model.Managed.Value;
     }
     if (model.Mentionable != null)
     {
         IsMentionable = model.Mentionable.Value;
     }
     if (model.Position != null && !IsEveryone)
     {
         Position = model.Position.Value;
     }
     if (model.Color != null)
     {
         Color = new Color(model.Color.Value);
     }
     if (model.Permissions != null)
     {
         Permissions = new ServerPermissions(model.Permissions.Value);
         if (updatePermissions) //Dont update these during READY
         {
             foreach (var member in Members)
             {
                 Server.UpdatePermissions(member);
             }
         }
     }
 }