コード例 #1
0
        internal void Update(ExtendedGuild model)
        {
            Update(model as Guild);

            if (model.Channels != null)
            {
                foreach (var subModel in model.Channels)
                    AddChannel(subModel.Id).Update(subModel);
            }
            if (model.Members != null)
            {
                foreach (var subModel in model.Members)
                    AddUser(subModel.User.Id).Update(subModel);
            }
            if (model.VoiceStates != null)
            {
                foreach (var subModel in model.VoiceStates)
                    GetUser(subModel.UserId)?.Update(subModel);
            }
            if (model.Presences != null)
            {
                foreach (var subModel in model.Presences)
                    GetUser(subModel.User.Id)?.Update(subModel);
            }
        }
コード例 #2
0
ファイル: Server.cs プロジェクト: Carbonitex/Discord.Net
        internal void Update(ExtendedGuild model)
        {
            Update(model as Guild);

            //Only channels or members should have AddXXX(cachePerms: true), not both
            if (model.Channels != null)
            {
                _channels = new ConcurrentDictionary<ulong, Channel>(2, (int)(model.Channels.Length * 1.05));
                foreach (var subModel in model.Channels)
                    AddChannel(subModel.Id, false).Update(subModel);
            }
            if (model.MemberCount != null)
            {
                if (_users == null)
                    _users = new ConcurrentDictionary<ulong, Member>(2, (int)(model.MemberCount * 1.05));
                _userCount = model.MemberCount.Value;
            }
            if (!model.IsLarge)
            {
                if (model.Members != null)
                {
                    foreach (var subModel in model.Members)
                        AddUser(subModel.User.Id, true, false).Update(subModel);
                }
                if (model.VoiceStates != null)
                {
                    foreach (var subModel in model.VoiceStates)
                        GetUser(subModel.UserId)?.Update(subModel);
                }
                if (model.Presences != null)
                {
                    foreach (var subModel in model.Presences)
                        GetUser(subModel.User.Id)?.Update(subModel);
                }
            }
        }