示例#1
0
        internal void Update(GuildSyncModel model)
        {
            Update(model.Members);

            if (_members.Count != model.Members.Length)
            {
                foreach (var key in _members.Keys.Except(model.Members.Select(x => new Snowflake(x.User.Id))))
                {
                    _members.TryRemove(key, out _);
                }
            }

            Update(model.Presences);
        }
示例#2
0
        internal void Update(GuildSyncModel model)
        {
            for (var i = 0; i < model.Members.Length; i++)
            {
                var memberModel = model.Members[i];
                _members.AddOrUpdate(memberModel.User.Id,
                    _ => Client.GetOrCreateMember(this, memberModel, memberModel.User, true),
                    (_, x) =>
                    {
                        x.Update(memberModel);
                        return x;
                    });
            }

            if (_members.Count != model.Members.Length)
            {
                foreach (var key in _members.Keys.Except(model.Members.Select(x => new Snowflake(x.User.Id))))
                    _members.TryRemove(key, out _);
            }

            Update(model.Presences);
        }