Browse Source

Add CreateTextChannel sample

pull/1161/head
Still Hsu 7 years ago
parent
commit
481b27d884
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
3 changed files with 45 additions and 7 deletions
  1. +13
    -0
      src/Discord.Net.Core/Entities/Guilds/IGuild.cs
  2. +19
    -6
      src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
  3. +13
    -1
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs

+ 13
- 0
src/Discord.Net.Core/Entities/Guilds/IGuild.cs View File

@@ -424,6 +424,19 @@ namespace Discord
/// <summary>
/// Creates a new text channel in this guild.
/// </summary>
/// <example>
/// The following example creates a new text channel under an existing category named <c>Wumpus</c> with a set topic.
/// <code lang="cs">
/// var categories = await guild.GetCategoriesAsync();
/// var targetCategory = categories.FirstOrDefault(x => x.Name == "wumpus");
/// if (targetCategory == null) return;
/// await Context.Guild.CreateTextChannelAsync(name, x =>
/// {
/// x.CategoryId = targetCategory.Id;
/// x.Topic = $"This channel was created at {DateTimeOffset.UtcNow} by {user}.";
/// });
/// </code>
/// </example>
/// <param name="name">The new name for the text channel.</param>
/// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param>
/// <param name="options">The options to be used when sending the request.</param>


+ 19
- 6
src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs View File

@@ -395,14 +395,27 @@ namespace Discord.Rest
return null;
}
/// <summary>
/// Creates a text channel with the provided name.
/// </summary>
/// <param name="name">The name of the new channel.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// Creates a new text channel in this guild.
/// </summary>
/// <example>
/// The following example creates a new text channel under an existing category named <c>Wumpus</c> with a set topic.
/// <code lang="cs">
/// var categories = await guild.GetCategoriesAsync();
/// var targetCategory = categories.FirstOrDefault(x => x.Name == "wumpus");
/// if (targetCategory == null) return;
/// await Context.Guild.CreateTextChannelAsync(name, x =>
/// {
/// x.CategoryId = targetCategory.Id;
/// x.Topic = $"This channel was created at {DateTimeOffset.UtcNow} by {user}.";
/// });
/// </code>
/// </example>
/// <param name="name">The new name for the text channel.</param>
/// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param>
/// <exception cref="ArgumentNullException"><paramref name="name" /> is <c>null</c>.</exception>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// The created text channel.
/// A task that represents the asynchronous creation operation. The task result contains the newly created
/// text channel.
/// </returns>
public Task<RestTextChannel> CreateTextChannelAsync(string name, Action<TextChannelProperties> func = null, RequestOptions options = null)
=> GuildHelper.CreateTextChannelAsync(this, Discord, name, options, func);


+ 13
- 1
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -516,10 +516,22 @@ namespace Discord.WebSocket
/// <summary>
/// Creates a new text channel in this guild.
/// </summary>
/// <example>
/// The following example creates a new text channel under an existing category named <c>Wumpus</c> with a set topic.
/// <code lang="cs">
/// var categories = await guild.GetCategoriesAsync();
/// var targetCategory = categories.FirstOrDefault(x => x.Name == "wumpus");
/// if (targetCategory == null) return;
/// await Context.Guild.CreateTextChannelAsync(name, x =>
/// {
/// x.CategoryId = targetCategory.Id;
/// x.Topic = $"This channel was created at {DateTimeOffset.UtcNow} by {user}.";
/// });
/// </code>
/// </example>
/// <param name="name">The new name for the text channel.</param>
/// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception>
/// <returns>
/// A task that represents the asynchronous creation operation. The task result contains the newly created
/// text channel.


Loading…
Cancel
Save