Beispiel #1
0
        public override void Update(ChannelJsonModel model)
        {
            base.Update(model);

            if (model.Topic.HasValue)
            {
                Topic = model.Topic.Value;
            }

            if (model.Nsfw.HasValue)
            {
                IsNsfw = model.Nsfw.Value;
            }

            if (model.RateLimitPerUser.HasValue)
            {
                Slowmode = model.RateLimitPerUser.Value;
            }

            _type = model.Type;

            if (model.LastMessageId.HasValue)
            {
                LastMessageId = model.LastMessageId.Value;
            }

            if (model.LastPinTimestamp.HasValue)
            {
                LastPinTimestamp = model.LastPinTimestamp.Value;
            }
        }
        protected CachedChannel(IGatewayClient client, ChannelJsonModel model)
            : base(client, model.Id)
        {
            Type = model.Type;

            Update(model);
        }
 public virtual void Update(ChannelJsonModel model)
 {
     if (model.Name.HasValue)
     {
         Name = model.Name.Value;
     }
 }
        public static new TransientGuildChannel Create(IClient client, ChannelJsonModel model)
        {
            switch (model.Type)
            {
            case ChannelType.Text:
            case ChannelType.News:
                return(new TransientTextChannel(client, model));

            case ChannelType.Voice:
                return(new TransientVoiceChannel(client, model));

            case ChannelType.Category:
                return(new TransientCategoryChannel(client, model));

            case ChannelType.Store:
                return(new TransientStoreChannel(client, model));

            case ChannelType.NewsThread:
            case ChannelType.PublicThread:
            case ChannelType.PrivateThread:
                return(new TransientThreadChannel(client, model));

            case ChannelType.Stage:
                return(new TransientStageChannel(client, model));
            }

            return(new TransientUnknownGuildChannel(client, model));
        }
        public override void Update(ChannelJsonModel model)
        {
            base.Update(model);

            if (model.Member.HasValue)
            {
                CurrentMember = new TransientThreadMember(Client, model.Member.Value);
            }

            if (model.MessageCount.HasValue)
            {
                MessageCount = model.MessageCount.Value;
            }

            if (model.MemberCount.HasValue)
            {
                MemberCount = model.MemberCount.Value;
            }

            if (model.ThreadMetadata.HasValue)
            {
                var metadataModel = model.ThreadMetadata.Value;
                IsArchived = metadataModel.Archived;
                AutomaticArchiveDuration = TimeSpan.FromMinutes(metadataModel.AutoArchiveDuration);
                ArchiveStateChangedAt    = metadataModel.ArchiveTimestamp;
                IsLocked         = metadataModel.Locked.GetValueOrDefault();
                AllowsInvitation = metadataModel.Invitable.GetValueOrDefault(true);
            }
        }
Beispiel #6
0
        public static CachedGuildChannel Create(IGatewayClient client, ChannelJsonModel model)
        {
            switch (model.Type)
            {
            case ChannelType.Text:
            case ChannelType.News:
                return(new CachedTextChannel(client, model));

            case ChannelType.Voice:
                return(new CachedVoiceChannel(client, model));

            case ChannelType.Category:
                return(new CachedCategoryChannel(client, model));

            case ChannelType.Store:
                return(new CachedStoreChannel(client, model));

            case ChannelType.NewsThread:
            case ChannelType.PublicThread:
            case ChannelType.PrivateThread:
                return(new CachedThreadChannel(client, model));

            case ChannelType.Stage:
                return(new CachedStageChannel(client, model));
            }

            return(new CachedUnknownGuildChannel(client, model));
        }
Beispiel #7
0
        public override void Update(ChannelJsonModel model)
        {
            base.Update(model);

            if (model.Nsfw.HasValue)
            {
                IsNsfw = model.Nsfw.Value;
            }
        }
        public override void Update(ChannelJsonModel model)
        {
            base.Update(model);

            if (model.ParentId.HasValue)
            {
                CategoryId = model.ParentId.Value;
            }
        }
        public override void Update(ChannelJsonModel model)
        {
            base.Update(model);

            if (model.UserLimit.HasValue)
            {
                MemberLimit = model.UserLimit.Value;
            }
        }
        public CachedThreadChannel(IGatewayClient client, ChannelJsonModel model)
            : base(client, model)
        {
            ChannelId = model.ParentId.Value.Value;
            CreatorId = model.OwnerId.Value;

            if (model.ThreadMetadata.HasValue)
            {
                CreatedAt = model.ThreadMetadata.Value.CreateTimestamp.GetValueOrDefault();
            }
        }
            static ChannelJsonModel MatchMemberToThread(ChannelJsonModel threadModel, ThreadMemberJsonModel[] memberModels)
            {
                var memberModel = Array.Find(memberModels, x => x.Id == threadModel.Id);

                if (memberModel != null)
                {
                    threadModel.Member = memberModel;
                }

                return(threadModel);
            }
Beispiel #12
0
        public override void Update(ChannelJsonModel model)
        {
            base.Update(model);

            if (model.Position.HasValue)
            {
                Position = model.Position.Value;
            }

            if (model.PermissionOverwrites.HasValue)
            {
                Overwrites = model.PermissionOverwrites.Value.ToReadOnlyList(this, (x, @this) => new TransientOverwrite(@this.Client, @this.Id, x));
            }
        }
        public override void Update(ChannelJsonModel model)
        {
            base.Update(model);

            if (model.Bitrate.HasValue)
            {
                Bitrate = model.Bitrate.Value;
            }

            if (model.RtcRegion.HasValue)
            {
                Region = model.RtcRegion.Value;
            }
        }
Beispiel #14
0
        public override void Update(ChannelJsonModel model)
        {
            base.Update(model);

            if (model.Topic.HasValue)
            {
                Topic = model.Topic.Value;
            }

            if (model.Nsfw.HasValue)
            {
                IsNsfw = model.Nsfw.Value;
            }

            if (model.DefaultAutoArchiveDuration.HasValue)
            {
                DefaultAutomaticArchiveDuration = TimeSpan.FromMinutes(model.DefaultAutoArchiveDuration.Value);
            }
        }
Beispiel #15
0
        public override void Update(ChannelJsonModel model)
        {
            base.Update(model);

            if (model.RateLimitPerUser.HasValue)
            {
                Slowmode = TimeSpan.FromSeconds(model.RateLimitPerUser.Value);
            }

            if (model.LastMessageId.HasValue)
            {
                LastMessageId = model.LastMessageId.Value;
            }

            if (model.LastPinTimestamp.HasValue)
            {
                LastPinTimestamp = model.LastPinTimestamp.Value;
            }
        }
Beispiel #16
0
        public static CachedChannel Create(IGatewayClient client, ChannelJsonModel model)
        {
            switch (model.Type)
            {
            case ChannelType.Direct:
            case ChannelType.Group:
                // TODO: cached private channels?
                break;

            case ChannelType.Text:
            case ChannelType.Voice:
            case ChannelType.Category:
            case ChannelType.News:
            case ChannelType.Store:
            case ChannelType.Thread:
                return(CachedGuildChannel.Create(client, model));
            }

            return(null /*TransientUnknownChannel(client, model)*/);
        }
 public CachedNestableChannel(IGatewayClient client, Snowflake guildId, ChannelJsonModel model)
     : base(client, guildId, model)
 {
 }
Beispiel #18
0
 public CachedCategoryChannel(IGatewayClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
Beispiel #19
0
 public CachedStoreChannel(IGatewayClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
Beispiel #20
0
 protected TransientVocalGuildChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
Beispiel #21
0
 protected CachedCategorizableGuildChannel(IGatewayClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
 public TransientDirectChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
 public TransientCategoryChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
Beispiel #24
0
 public TransientThreadChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
Beispiel #25
0
 protected CachedGuildChannel(IGatewayClient client, ChannelJsonModel model)
     : base(client, model)
 {
     GuildId = model.GuildId.Value;
 }
Beispiel #26
0
 protected TransientMessageGuildChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
Beispiel #27
0
 protected TransientPrivateChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
 protected TransientCategorizableGuildChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
Beispiel #29
0
 public TransientStoreChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
 public CachedThreadChannel(IGatewayClient client, ChannelJsonModel model)
     : base(client, model)
 {
     ChannelId = model.ParentId.Value.Value;
     CreatorId = model.OwnerId.Value;
 }