Ejemplo n.º 1
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));
        }