Example #1
0
        public GuildChannel(Guild guild, Model model)
            : base(model.Id)
        {
            Guild = guild;

            Update(model, UpdateSource.Creation);
        }
Example #2
0
        internal override void Update(ClientState state, Model model)
        {
            base.Update(state, model);

            Topic = model.Topic.Value;
            _nsfw = model.Nsfw.GetValueOrDefault();
        }
        internal override void Update(Model model)
        {
            base.Update(model);

            Topic = model.Topic.Value;
            _nsfw = model.Nsfw.GetValueOrDefault();
        }
Example #4
0
        internal new static RestGroupChannel Create(BaseDiscordClient discord, Model model)
        {
            var entity = new RestGroupChannel(discord, model.Id);

            entity.Update(model);
            return(entity);
        }
Example #5
0
        public GroupChannel(DiscordRestClient discord, Model model)
            : base(model.Id)
        {
            Discord = discord;

            Update(model, UpdateSource.Creation);
        }
Example #6
0
        internal new static RestDMChannel Create(BaseDiscordClient discord, Model model)
        {
            var entity = new RestDMChannel(discord, model.Id, model.Recipients.Value[0].Id);

            entity.Update(model);
            return(entity);
        }
Example #7
0
 /// <inheritdoc />
 internal override void Update(ClientState state, Model model)
 {
     base.Update(state, model);
     CategoryId = model.CategoryId;
     Bitrate    = model.Bitrate.Value;
     UserLimit  = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
 }
Example #8
0
        internal override void Update(Model model)
        {
            base.Update(model);

            Bitrate   = model.Bitrate.Value;
            UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
        }
 /// <inheritdoc />
 internal override void Update(ClientState state, Model model)
 {
     base.Update(state, model);
     Bitrate   = model.Bitrate.Value;
     UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
     RTCRegion = model.RTCRegion.GetValueOrDefault(null);
 }
Example #10
0
        public ISocketGuildChannel AddChannel(ChannelModel model, DataStore dataStore, ConcurrentHashSet <ulong> channels = null)
        {
            var channel = ToChannel(model);

            (channels ?? _channels).TryAdd(model.Id);
            dataStore.AddChannel(channel);
            return(channel);
        }
Example #11
0
 internal override void Update(ClientState state, Model model)
 {
     base.Update(state, model);
     CategoryId       = model.CategoryId;
     Topic            = model.Topic.GetValueOrDefault();
     SlowModeInterval = model.SlowMode.GetValueOrDefault(); // some guilds haven't been patched to include this yet?
     _nsfw            = model.Nsfw.GetValueOrDefault();
 }
Example #12
0
        public DMChannel(DiscordRestClient discord, IUser recipient, Model model)
            : base(model.Id)
        {
            Discord   = discord;
            Recipient = recipient;

            Update(model, UpdateSource.Creation);
        }
Example #13
0
 /// <inheritdoc />
 internal override void Update(Model model)
 {
     base.Update(model);
     CategoryId       = model.CategoryId;
     Topic            = model.Topic.Value;
     SlowModeInterval = model.SlowMode.Value;
     IsNsfw           = model.Nsfw.GetValueOrDefault();
 }
Example #14
0
        internal SocketGuildChannel AddChannel(ClientState state, ChannelModel model)
        {
            var channel = SocketGuildChannel.Create(this, state, model);

            _channels.TryAdd(model.Id);
            state.AddChannel(channel);
            return(channel);
        }
Example #15
0
        public override void Update(Model model, UpdateSource source)
        {
            if (source == UpdateSource.Rest && IsAttached)
            {
                return;
            }

            base.Update(model, source);
        }
Example #16
0
        public void Update(Model model, UpdateSource source)
        {
            if (/*source == UpdateSource.Rest && */ IsAttached)
            {
                return;
            }

            (Recipient as User).Update(model.Recipients.Value[0], source);
        }
Example #17
0
        public override void Update(Model model, UpdateSource source)
        {
            if (source == UpdateSource.Rest && IsAttached)
            {
                return;
            }

            base.Update(model, source);
            Bitrate   = model.Bitrate.Value;
            UserLimit = model.UserLimit.Value;
        }
Example #18
0
        internal override void Update(Model model)
        {
            base.Update(model);
            IsNsfw = model.Nsfw.GetValueOrDefault(false);
            Topic  = model.Topic.GetValueOrDefault();
            DefaultAutoArchiveDuration = model.AutoArchiveDuration.GetValueOrDefault(ThreadArchiveDuration.OneDay);

            Tags = model.ForumTags.GetValueOrDefault(Array.Empty <API.ForumTags>()).Select(
                x => new ForumTag(x.Id, x.Name, x.EmojiId.GetValueOrDefault(null), x.EmojiName.GetValueOrDefault())
                ).ToImmutableArray();
        }
Example #19
0
 public SocketTextChannel(SocketGuild guild, Model model)
     : base(guild, model)
 {
     if (Discord.MessageCacheSize > 0)
     {
         _messages = new MessageCache(Discord, this);
     }
     else
     {
         _messages = new MessageManager(Discord, this);
     }
 }
Example #20
0
 public SocketDMChannel(DiscordSocketClient discord, SocketDMUser recipient, Model model)
     : base(discord, recipient, model)
 {
     if (Discord.MessageCacheSize > 0)
     {
         _messages = new MessageCache(Discord, this);
     }
     else
     {
         _messages = new MessageManager(Discord, this);
     }
 }
Example #21
0
 public SocketGroupChannel(DiscordSocketClient discord, Model model)
     : base(discord, model)
 {
     if (Discord.MessageCacheSize > 0)
     {
         _messages = new MessageCache(Discord, this);
     }
     else
     {
         _messages = new MessageManager(Discord, this);
     }
     _voiceStates = new ConcurrentDictionary <ulong, VoiceState>(1, 5);
 }
        internal override void Update(ClientState state, Model model)
        {
            Name     = model.Name.Value;
            Position = model.Position.Value;

            var overwrites    = model.PermissionOverwrites.Value;
            var newOverwrites = ImmutableArray.CreateBuilder <Overwrite>(overwrites.Length);

            for (int i = 0; i < overwrites.Length; i++)
            {
                newOverwrites.Add(overwrites[i].ToEntity());
            }
            _overwrites = newOverwrites.ToImmutable();
        }
Example #23
0
        new internal ISocketGuildChannel ToChannel(ChannelModel model)
        {
            switch (model.Type)
            {
            case ChannelType.Text:
                return(new SocketTextChannel(this, model));

            case ChannelType.Voice:
                return(new SocketVoiceChannel(this, model));

            default:
                throw new InvalidOperationException($"Unexpected channel type: {model.Type}");
            }
        }
Example #24
0
        /// <exception cref="InvalidOperationException">Unexpected channel type.</exception>
        internal static IRestPrivateChannel CreatePrivate(BaseDiscordClient discord, Model model)
        {
            switch (model.Type)
            {
            case ChannelType.DM:
                return(RestDMChannel.Create(discord, model));

            case ChannelType.Group:
                return(RestGroupChannel.Create(discord, model));

            default:
                throw new InvalidOperationException($"Unexpected channel type: {model.Type}");
            }
        }
Example #25
0
        internal static RestChannel Create(BaseDiscordClient discord, Model model)
        {
            switch (model.Type)
            {
            case ChannelType.Text:
            case ChannelType.Voice:
                return(RestGuildChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model));

            case ChannelType.DM:
            case ChannelType.Group:
                return(CreatePrivate(discord, model) as RestChannel);

            default:
                throw new InvalidOperationException($"Unexpected channel type: {model.Type}");
            }
        }
Example #26
0
        internal override void Update(Model model)
        {
            if (model.Name.IsSpecified)
            {
                Name = model.Name.Value;
            }
            if (model.Icon.IsSpecified)
            {
                _iconId = model.Icon.Value;
            }

            if (model.Recipients.IsSpecified)
            {
                UpdateUsers(model.Recipients.Value);
            }
        }
Example #27
0
        /// <inheritdoc />
        internal override void Update(Model model)
        {
            base.Update(model);

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

            if (model.UserLimit.IsSpecified)
            {
                UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
            }

            RTCRegion = model.RTCRegion.GetValueOrDefault(null);
        }
Example #28
0
 /// <exception cref="InvalidOperationException">Unexpected channel type.</exception>
 internal static RestChannel Create(BaseDiscordClient discord, Model model)
 {
     return(model.Type switch
     {
         ChannelType.News or
         ChannelType.Text or
         ChannelType.Voice or
         ChannelType.Stage or
         ChannelType.NewsThread or
         ChannelType.PrivateThread or
         ChannelType.PublicThread
         => RestGuildChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model),
         ChannelType.DM or ChannelType.Group => CreatePrivate(discord, model) as RestChannel,
         ChannelType.Category => RestCategoryChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model),
         _ => new RestChannel(discord, model.Id),
     });
Example #29
0
        internal static RestChannel Create(BaseDiscordClient discord, Model model)
        {
            switch (model.Type)
            {
            case ChannelType.Text:
            case ChannelType.Voice:
                return(RestGuildChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model));

            case ChannelType.DM:
            case ChannelType.Group:
                return(CreatePrivate(discord, model) as RestChannel);

            default:
                return(new RestChannel(discord, model.Id));
            }
        }
Example #30
0
 internal override void Update(ClientState state, Model model)
 {
     base.Update(state, model);
     CategoryId       = model.CategoryId;
     Topic            = model.Topic.GetValueOrDefault();
     SlowModeInterval = model.SlowMode.GetValueOrDefault(); // some guilds haven't been patched to include this yet?
     _nsfw            = model.Nsfw.GetValueOrDefault();
     if (model.AutoArchiveDuration.IsSpecified)
     {
         DefaultArchiveDuration = model.AutoArchiveDuration.Value;
     }
     else
     {
         DefaultArchiveDuration = ThreadArchiveDuration.OneDay;
     }
     // basic value at channel creation. Shouldn't be called since guild text channels always have this property
 }