internal new static RestGroupChannel Create(BaseDiscordClient discord, Model model) { RestGroupChannel entity = new RestGroupChannel(discord, model.Id); entity.Update(model); return(entity); }
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); }
/// <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; }
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(); }
/// <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(); }
// 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); }
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(); }
/// <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); } }
/// <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)); } }
internal static SocketGroupChannel Create(DiscordSocketClient discord, ClientState state, Model model) { SocketGroupChannel entity = new SocketGroupChannel(discord, model.Id); entity.Update(state, model); return(entity); }
internal abstract void Update(ClientState state, Model model);
internal new static RestCategoryChannel Create(BaseDiscordClient discord, IGuild guild, Model model) { RestCategoryChannel entity = new RestCategoryChannel(discord, guild, model.Id); entity.Update(model); return(entity); }
internal virtual void Update(Model model) { }
/// <inheritdoc /> public override async Task UpdateAsync(RequestOptions options = null) { Model model = await Discord.ApiClient.GetChannelAsync(GuildId, Id, options).ConfigureAwait(false); Update(model); }
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)); } }
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)); } }
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); }
internal override void Update(ClientState state, Model model) { Recipient.Update(state, model.Recipients.Value[0]); }
internal override void Update(Model model) { Recipient.Update(model.Recipients.Value[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); }
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); }