Esempio n. 1
0
        internal new static RestGroupChannel Create(BaseDiscordClient discord, Model model)
        {
            RestGroupChannel entity = new RestGroupChannel(discord, model.Id);

            entity.Update(model);
            return(entity);
        }
Esempio n. 2
0
        internal new static RestDMChannel Create(BaseDiscordClient discord, Model model)
        {
            RestDMChannel entity = new RestDMChannel(discord, model.Id, model.Recipients.Value[0].Id);

            entity.Update(model);
            return(entity);
        }
Esempio n. 3
0
 /// <inheritdoc />
 internal override void Update(Model model)
 {
     base.Update(model);
     CategoryId = model.CategoryId;
     Bitrate    = model.Bitrate.Value;
     UserLimit  = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
 }
Esempio n. 4
0
 internal override void Update(ClientState state, Model model)
 {
     base.Update(state, model);
     CategoryId       = model.CategoryId;
     Topic            = model.Topic.Value;
     SlowModeInterval = model.SlowMode.GetValueOrDefault(); // some guilds haven't been patched to include this yet?
     _nsfw            = model.Nsfw.GetValueOrDefault();
 }
Esempio n. 5
0
 /// <inheritdoc />
 internal override void Update(Model model)
 {
     base.Update(model);
     CategoryId = model.CategoryId;
     Topic      = model.Topic.Value;
     if (model.SlowMode.IsSpecified)
     {
         SlowModeInterval = model.SlowMode.Value;
     }
     IsNsfw = model.Nsfw.GetValueOrDefault();
 }
Esempio n. 6
0
        // Categories
        public static async Task <ICategoryChannel> GetCategoryAsync(INestedChannel channel, BaseDiscordClient client, RequestOptions options)
        {
            // if no category id specified, return null
            if (!channel.CategoryId.HasValue)
            {
                return(null);
            }
            // CategoryId will contain a value here
            Model model = await client.ApiClient.GetChannelAsync(channel.CategoryId.Value, options).ConfigureAwait(false);

            return(RestCategoryChannel.Create(client, model) as ICategoryChannel);
        }
Esempio n. 7
0
        internal override void Update(Model model)
        {
            Name     = model.Name.Value;
            Position = model.Position.Value;

            API.OverwriteJson[] overwrites = model.PermissionOverwrites.Value;
            ImmutableArray <Overwrite> .Builder newOverwrites = ImmutableArray.CreateBuilder <Overwrite>(overwrites.Length);
            for (int i = 0; i < overwrites.Length; i++)
            {
                newOverwrites.Add(overwrites[i].ToEntity());
            }
            _overwrites = newOverwrites.ToImmutable();
        }
Esempio n. 8
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}");
            }
        }
        internal override void Update(ClientState state, Model model)
        {
            if (model.Name.IsSpecified)
            {
                Name = model.Name.Value;
            }
            if (model.Icon.IsSpecified)
            {
                _iconId = model.Icon.Value;
            }

            if (model.Recipients.IsSpecified)
            {
                UpdateUsers(state, model.Recipients.Value);
            }
        }
Esempio n. 10
0
        /// <exception cref="InvalidOperationException">Unexpected channel type.</exception>
        internal static RestChannel Create(BaseDiscordClient discord, Model model)
        {
            switch (model.Type)
            {
            case ChannelType.News:
            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);

            case ChannelType.Category:
                return(RestCategoryChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model));

            default:
                return(new RestChannel(discord, model.Id));
            }
        }
Esempio n. 11
0
        internal static SocketGroupChannel Create(DiscordSocketClient discord, ClientState state, Model model)
        {
            SocketGroupChannel entity = new SocketGroupChannel(discord, model.Id);

            entity.Update(state, model);
            return(entity);
        }
Esempio n. 12
0
 internal abstract void Update(ClientState state, Model model);
Esempio n. 13
0
        internal new static RestCategoryChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
        {
            RestCategoryChannel entity = new RestCategoryChannel(discord, guild, model.Id);

            entity.Update(model);
            return(entity);
        }
Esempio n. 14
0
 internal virtual void Update(Model model)
 {
 }
Esempio n. 15
0
        /// <inheritdoc />
        public override async Task UpdateAsync(RequestOptions options = null)
        {
            Model model = await Discord.ApiClient.GetChannelAsync(GuildId, Id, options).ConfigureAwait(false);

            Update(model);
        }
Esempio n. 16
0
        internal static RestGuildChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
        {
            switch (model.Type)
            {
            case ChannelType.News:
                return(RestNewsChannel.Create(discord, guild, model));

            case ChannelType.Text:
                return(RestTextChannel.Create(discord, guild, model));

            case ChannelType.Voice:
                return(RestVoiceChannel.Create(discord, guild, model));

            case ChannelType.Category:
                return(RestCategoryChannel.Create(discord, guild, model));

            default:
                return(new RestGuildChannel(discord, guild, model.Id));
            }
        }
Esempio n. 17
0
        internal static SocketGuildChannel Create(SocketGuild guild, ClientState state, Model model)
        {
            switch (model.Type)
            {
            case ChannelType.News:
                return(SocketNewsChannel.Create(guild, state, model));

            case ChannelType.Text:
                return(SocketTextChannel.Create(guild, state, model));

            case ChannelType.Voice:
                return(SocketVoiceChannel.Create(guild, state, model));

            case ChannelType.Category:
                return(SocketCategoryChannel.Create(guild, state, model));

            default:
                return(new SocketGuildChannel(guild.Discord, model.Id, guild));
            }
        }
Esempio n. 18
0
        internal static SocketDMChannel Create(DiscordSocketClient discord, ClientState state, Model model)
        {
            SocketDMChannel entity = new SocketDMChannel(discord, model.Id, discord.GetOrCreateUser(state, model.Recipients.Value[0]));

            entity.Update(state, model);
            return(entity);
        }
Esempio n. 19
0
 internal override void Update(ClientState state, Model model)
 {
     Recipient.Update(state, model.Recipients.Value[0]);
 }
Esempio n. 20
0
 internal override void Update(Model model)
 {
     Recipient.Update(model.Recipients.Value[0]);
 }
Esempio n. 21
0
        /// <inheritdoc />
        public async Task ModifyAsync(Action <VoiceChannelProperties> func, RequestOptions options = null)
        {
            Model model = await ChannelHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);

            Update(model);
        }
Esempio n. 22
0
        internal new static SocketVoiceChannel Create(SocketGuild guild, ClientState state, Model model)
        {
            SocketVoiceChannel entity = new SocketVoiceChannel(guild.Discord, model.Id, guild);

            entity.Update(state, model);
            return(entity);
        }