internal void Update(WebSocketGuildModel model) { Update(model as GuildModel); for (var i = 0; i < model.Channels.Length; i++) { var channelModel = model.Channels[i]; _channels.AddOrUpdate(channelModel.Id, _ => CachedGuildChannel.Create(this, channelModel), (_, old) => { old.Update(channelModel); return(old); }); } Update(model.Members); for (var i = 0; i < model.VoiceStates.Length; i++) { var voiceState = model.VoiceStates[i]; _members[voiceState.UserId].Update(voiceState); } if (model.Presences != null) { Update(model.Presences); } MemberCount = model.MemberCount; IsLarge = model.Large; IsUnavailable = !model.Unavailable.HasValue || model.Unavailable.Value; }
internal CachedOverwrite(CachedGuildChannel channel, OverwriteModel model) : base(channel.Client, model.Id) { Channel = channel; TargetId = model.Id; Permissions = (model.Allow, model.Deny); TargetType = model.Type; }
public Task HandleChannelCreateAsync(PayloadModel payload) { var model = payload.D.ToType <ChannelModel>(); CachedChannel channel; if (model.GuildId != null) { var guild = GetGuild(model.GuildId.Value); channel = CachedGuildChannel.Create(guild, model); guild._channels.TryAdd(channel.Id, (CachedGuildChannel)channel); } else { channel = _privateChannels.GetOrAdd(model.Id, _ => CachedPrivateChannel.Create(_client, model)); } return(_client._channelCreated.InvokeAsync(new ChannelCreatedEventArgs(channel))); }