From 481b27d884f1fda2cc25e9ee29349e243d94ca0d Mon Sep 17 00:00:00 2001
From: Still Hsu <341464@gmail.com>
Date: Sun, 23 Sep 2018 14:04:05 +0800
Subject: [PATCH] Add CreateTextChannel sample
---
.../Entities/Guilds/IGuild.cs | 13 ++++++++++
.../Entities/Guilds/RestGuild.cs | 25 ++++++++++++++-----
.../Entities/Guilds/SocketGuild.cs | 14 ++++++++++-
3 files changed, 45 insertions(+), 7 deletions(-)
diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
index bba400b31..8f9108d95 100644
--- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
+++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
@@ -424,6 +424,19 @@ namespace Discord
///
/// Creates a new text channel in this guild.
///
+ ///
+ /// The following example creates a new text channel under an existing category named Wumpus with a set topic.
+ ///
+ /// 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}.";
+ /// });
+ ///
+ ///
/// The new name for the text channel.
/// The delegate containing the properties to be applied to the channel upon its creation.
/// The options to be used when sending the request.
diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
index 9b535f4cb..fda9b609d 100644
--- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
+++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
@@ -395,14 +395,27 @@ namespace Discord.Rest
return null;
}
///
- /// Creates a text channel with the provided name.
- ///
- /// The name of the new channel.
- /// The options to be used when sending the request.
+ /// Creates a new text channel in this guild.
+ ///
+ ///
+ /// The following example creates a new text channel under an existing category named Wumpus with a set topic.
+ ///
+ /// 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}.";
+ /// });
+ ///
+ ///
+ /// The new name for the text channel.
/// The delegate containing the properties to be applied to the channel upon its creation.
- /// is null.
+ /// The options to be used when sending the request.
///
- /// The created text channel.
+ /// A task that represents the asynchronous creation operation. The task result contains the newly created
+ /// text channel.
///
public Task CreateTextChannelAsync(string name, Action func = null, RequestOptions options = null)
=> GuildHelper.CreateTextChannelAsync(this, Discord, name, options, func);
diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
index 861c1bc38..06b048872 100644
--- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
+++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
@@ -516,10 +516,22 @@ namespace Discord.WebSocket
///
/// Creates a new text channel in this guild.
///
+ ///
+ /// The following example creates a new text channel under an existing category named Wumpus with a set topic.
+ ///
+ /// 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}.";
+ /// });
+ ///
+ ///
/// The new name for the text channel.
/// The delegate containing the properties to be applied to the channel upon its creation.
/// The options to be used when sending the request.
- /// is null.
///
/// A task that represents the asynchronous creation operation. The task result contains the newly created
/// text channel.