コード例 #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;
            }
        }
コード例 #2
0
        protected CachedChannel(IGatewayClient client, ChannelJsonModel model)
            : base(client, model.Id)
        {
            Type = model.Type;

            Update(model);
        }
コード例 #3
0
 public virtual void Update(ChannelJsonModel model)
 {
     if (model.Name.HasValue)
     {
         Name = model.Name.Value;
     }
 }
コード例 #4
0
        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));
        }
コード例 #5
0
        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);
            }
        }
コード例 #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));
        }
コード例 #7
0
        public override void Update(ChannelJsonModel model)
        {
            base.Update(model);

            if (model.Nsfw.HasValue)
            {
                IsNsfw = model.Nsfw.Value;
            }
        }
コード例 #8
0
        public override void Update(ChannelJsonModel model)
        {
            base.Update(model);

            if (model.ParentId.HasValue)
            {
                CategoryId = model.ParentId.Value;
            }
        }
コード例 #9
0
        public override void Update(ChannelJsonModel model)
        {
            base.Update(model);

            if (model.UserLimit.HasValue)
            {
                MemberLimit = model.UserLimit.Value;
            }
        }
コード例 #10
0
        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();
            }
        }
コード例 #11
0
            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);
            }
コード例 #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));
            }
        }
コード例 #13
0
        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;
            }
        }
コード例 #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);
            }
        }
コード例 #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;
            }
        }
コード例 #16
0
ファイル: CachedChannel.cs プロジェクト: Pyhoma69/Disqord
        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)*/);
        }
コード例 #17
0
 public CachedNestableChannel(IGatewayClient client, Snowflake guildId, ChannelJsonModel model)
     : base(client, guildId, model)
 {
 }
コード例 #18
0
 public CachedCategoryChannel(IGatewayClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
コード例 #19
0
 public CachedStoreChannel(IGatewayClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
コード例 #20
0
 protected TransientVocalGuildChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
コード例 #21
0
 protected CachedCategorizableGuildChannel(IGatewayClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
コード例 #22
0
 public TransientDirectChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
コード例 #23
0
 public TransientCategoryChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
コード例 #24
0
 public TransientThreadChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
コード例 #25
0
 protected CachedGuildChannel(IGatewayClient client, ChannelJsonModel model)
     : base(client, model)
 {
     GuildId = model.GuildId.Value;
 }
コード例 #26
0
 protected TransientMessageGuildChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
コード例 #27
0
 protected TransientPrivateChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
コード例 #28
0
 protected TransientCategorizableGuildChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
コード例 #29
0
 public TransientStoreChannel(IClient client, ChannelJsonModel model)
     : base(client, model)
 {
 }
コード例 #30
0
 public CachedThreadChannel(IGatewayClient client, ChannelJsonModel model)
     : base(client, model)
 {
     ChannelId = model.ParentId.Value.Value;
     CreatorId = model.OwnerId.Value;
 }