/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> public static async Task <RestTextChannel> CreateTextChannelAsync(IGuild guild, BaseDiscordClient client, string name, RequestOptions options, Action <TextChannelProperties> func = null) { if (name == null) { throw new ArgumentNullException(paramName: nameof(name)); } var props = new TextChannelProperties(); func?.Invoke(props); var args = new CreateGuildChannelParams(name, ChannelType.Text) { CategoryId = props.CategoryId, Topic = props.Topic, IsNsfw = props.IsNsfw, Position = props.Position, SlowModeInterval = props.SlowModeInterval, Overwrites = props.PermissionOverwrites.IsSpecified ? props.PermissionOverwrites.Value.Select(overwrite => new API.Overwrite { TargetId = overwrite.TargetId, TargetType = overwrite.TargetType, Allow = overwrite.Permissions.AllowValue.ToString(), Deny = overwrite.Permissions.DenyValue.ToString() }).ToArray() : Optional.Create <API.Overwrite[]>(), }; var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); return(RestTextChannel.Create(client, guild, model)); }
public static async Task <Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client, Action <TextChannelProperties> func, RequestOptions options) { var args = new TextChannelProperties(); func(args); var apiArgs = new API.Rest.ModifyTextChannelParams { Name = args.Name, Position = args.Position, CategoryId = args.CategoryId, Topic = args.Topic, IsNsfw = args.IsNsfw, SlowModeInterval = args.SlowModeInterval, Overwrites = args.PermissionOverwrites.IsSpecified ? args.PermissionOverwrites.Value.Select(overwrite => new API.Overwrite { TargetId = overwrite.TargetId, TargetType = overwrite.TargetType, Allow = overwrite.Permissions.AllowValue.ToString(), Deny = overwrite.Permissions.DenyValue.ToString() }).ToArray() : Optional.Create <API.Overwrite[]>(), }; return(await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false)); }
protected void DiscordGetNewChannelProperies(TextChannelProperties C, string channelname, string channeltopic, string catname) { if (catname != null) { if (catmap.ContainsKey(catname) == true) { C.CategoryId = catmap[catname].Id; } } C.Name = channelname; C.Topic = channeltopic; }
public static async Task <Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client, Action <TextChannelProperties> func, RequestOptions options) { var args = new TextChannelProperties(); func(args); var apiArgs = new API.Rest.ModifyTextChannelParams { Name = args.Name, Position = args.Position, Topic = args.Topic }; return(await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false)); }
public static async Task <Model> ModifyAsync(IThreadChannel channel, BaseDiscordClient client, Action <TextChannelProperties> func, RequestOptions options) { var args = new TextChannelProperties(); func(args); var apiArgs = new ModifyThreadParams { Name = args.Name, Archived = args.Archived, AutoArchiveDuration = args.AutoArchiveDuration, Locked = args.Locked, Slowmode = args.SlowModeInterval }; return(await client.ApiClient.ModifyThreadAsync(channel.Id, apiArgs, options).ConfigureAwait(false)); }
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> public static async Task <RestTextChannel> CreateTextChannelAsync(IGuild guild, BaseDiscordClient client, string name, RequestOptions options, Action <TextChannelProperties> func = null) { if (name == null) { throw new ArgumentNullException(paramName: nameof(name)); } var props = new TextChannelProperties(); func?.Invoke(props); var args = new CreateGuildChannelParams(name, ChannelType.Text) { CategoryId = props.CategoryId, Topic = props.Topic, IsNsfw = props.IsNsfw, }; var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); return(RestTextChannel.Create(client, guild, model)); }