Beispiel #1
0
        internal void Update(APIChannel model)
        {
            if (!IsPrivate && model.Name != null)
            {
                Name = model.Name;
            }
            if (model.Type != null)
            {
                Type = model.Type;
            }
            if (model.Position != null)
            {
                Position = model.Position.Value;
            }
            if (model.Topic != null)
            {
                Topic = model.Topic;
            }
            if (model.Recipient != null)
            {
                Recipient.Update(model.Recipient);
                Name = $"@{Recipient}";
            }

            if (model.PermissionOverwrites != null)
            {
                _permissionOverwrites = model.PermissionOverwrites
                                        .Select(x => new PermissionOverwrite(PermissionTarget.FromString(x.Type), x.Id, x.Allow, x.Deny))
                                        .ToDictionary(x => x.TargetId);
                UpdatePermissions();
            }
        }
Beispiel #2
0
        internal PublicChannel AddChannel(APIChannel model, bool cachePerms)
        {
            PublicChannel channel;
            ChannelType   type = EnumConverters.ToChannelType(model.Type);

            if (type == ChannelType.Voice)
            {
                channel = new VoiceChannel(model, this);
            }
            else
            {
                channel = new TextChannel(model, this);
            }

            if (cachePerms && Client.Config.UsePermissionsCache)
            {
                foreach (var user in Users)
                {
                    channel.AddUser(user);
                }
            }
            Client.AddChannel(channel);
            return(_channels.GetOrAdd(model.Id, x => channel));
        }
Beispiel #3
0
        internal void Update(APIChannel model)
        {
            Update(model as ChannelReference);

            if (model.Position != null)
                Position = model.Position.Value;
            if (model.Topic != null)
                Topic = model.Topic;
            if (model.Recipient != null)
            {
                Recipient.Update(model.Recipient);
                Name = $"@{Recipient}";
            }

            if (model.PermissionOverwrites != null)
            {
                _permissionOverwrites = model.PermissionOverwrites
                    .Select(x => new PermissionOverwrite(PermissionTarget.FromString(x.Type), x.Id, x.Allow, x.Deny))
                    .ToDictionary(x => x.TargetId);
                UpdatePermissions();
            }
        }