public void Update(APIChannel model)
 {
     _rules = model.PermissionOverwrites
              .Select(x => new Channel.PermissionRule(EnumConverters.ToPermissionTarget(x.Type), x.Id, x.Allow, x.Deny))
              .ToDictionary(x => x.TargetId);
     UpdatePermissions();
 }
        private Task AddOrUpdateOverwrite(ulong id, PermissionTarget type, ChannelTriStatePermissions permissions)
        {
            var request = new AddOrUpdateChannelPermissionsRequest(id)
            {
                TargetId   = id,
                TargetType = EnumConverters.ToString(type),
                Allow      = permissions.AllowValue,
                Deny       = permissions.DenyValue
            };

            return(_channel.Client.ClientAPI.Send(request));
        }
Exemplo n.º 3
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));
        }