@@ -141,11 +141,13 @@ namespace Discord | |||
/// </para> | |||
/// </param> | |||
/// <param name="message">The message which to start the thread from.</param> | |||
/// <param name="invitable">Whether non-moderators can add other non-moderators to a thread; only available when creating a private thread</param> | |||
/// <param name="slowmode">The amount of seconds a user has to wait before sending another message (0-21600)</param> | |||
/// <param name="options">The options to be used when sending the request.</param> | |||
/// <returns> | |||
/// A task that represents the asynchronous create operation. The task result contains a <see cref="IThreadChannel"/> | |||
/// </returns> | |||
Task<IThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, | |||
IMessage message = null, RequestOptions options = null); | |||
IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null); | |||
} | |||
} |
@@ -11,6 +11,12 @@ namespace Discord.API.Rest | |||
public ThreadArchiveDuration Duration { get; set; } | |||
[JsonProperty("type")] | |||
public Optional<ThreadType> Type { get; set; } | |||
public ThreadType Type { get; set; } | |||
[JsonProperty("invitable")] | |||
public Optional<bool> Invitable { get; set; } | |||
[JsonProperty("rate_limit_per_user")] | |||
public Optional<int?> Ratelimit { get; set; } | |||
} | |||
} |
@@ -268,9 +268,9 @@ namespace Discord.Rest | |||
/// A task that represents the asynchronous create operation. The task result contains a <see cref="IThreadChannel"/> | |||
/// </returns> | |||
public async Task<RestThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, | |||
ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, RequestOptions options = null) | |||
ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null) | |||
{ | |||
var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, options); | |||
var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, invitable, slowmode, options); | |||
return RestThreadChannel.Create(Discord, Guild, model); | |||
} | |||
#endregion | |||
@@ -286,8 +286,8 @@ namespace Discord.Rest | |||
async Task<IReadOnlyCollection<IWebhook>> ITextChannel.GetWebhooksAsync(RequestOptions options) | |||
=> await GetWebhooksAsync(options).ConfigureAwait(false); | |||
async Task<IThreadChannel> ITextChannel.CreateThreadAsync(string name, ThreadType type, ThreadArchiveDuration autoArchiveDuration, IMessage message, RequestOptions options) | |||
=> await CreateThreadAsync(name, type, autoArchiveDuration, message, options); | |||
async Task<IThreadChannel> ITextChannel.CreateThreadAsync(string name, ThreadType type, ThreadArchiveDuration autoArchiveDuration, IMessage message, bool? invitable, int? slowmode, RequestOptions options) | |||
=> await CreateThreadAsync(name, type, autoArchiveDuration, message, invitable, slowmode, options); | |||
#endregion | |||
#region IMessageChannel | |||
@@ -387,7 +387,7 @@ namespace Discord.Rest | |||
} | |||
#endregion | |||
#region ITextChannel | |||
#region INestedChannel | |||
/// <inheritdoc /> | |||
async Task<ICategoryChannel> INestedChannel.GetCategoryAsync(CacheMode mode, RequestOptions options) | |||
{ | |||
@@ -9,7 +9,7 @@ namespace Discord.Rest | |||
internal static class ThreadHelper | |||
{ | |||
public static async Task<Model> CreateThreadAsync(BaseDiscordClient client, ITextChannel channel, string name, ThreadType type = ThreadType.PublicThread, | |||
ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, RequestOptions options = null) | |||
ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null) | |||
{ | |||
var features = channel.Guild.Features; | |||
if (autoArchiveDuration == ThreadArchiveDuration.OneWeek && !features.HasFeature(GuildFeature.SevenDayThreadArchive)) | |||
@@ -25,7 +25,9 @@ namespace Discord.Rest | |||
{ | |||
Name = name, | |||
Duration = autoArchiveDuration, | |||
Type = type | |||
Type = type, | |||
Invitable = invitable.HasValue ? invitable.Value : Optional<bool>.Unspecified, | |||
Ratelimit = slowmode.HasValue ? slowmode.Value : Optional<int?>.Unspecified, | |||
}; | |||
Model model; | |||
@@ -113,9 +113,9 @@ namespace Discord.WebSocket | |||
/// A task that represents the asynchronous create operation. The task result contains a <see cref="IThreadChannel"/> | |||
/// </returns> | |||
public async Task<SocketThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, | |||
ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, RequestOptions options = null) | |||
ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null) | |||
{ | |||
var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, options); | |||
var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, invitable, slowmode, options); | |||
var thread = (SocketThreadChannel)Guild.AddOrUpdateChannel(Discord.State, model); | |||
@@ -345,8 +345,8 @@ namespace Discord.WebSocket | |||
async Task<IReadOnlyCollection<IWebhook>> ITextChannel.GetWebhooksAsync(RequestOptions options) | |||
=> await GetWebhooksAsync(options).ConfigureAwait(false); | |||
/// <inheritdoc /> | |||
async Task<IThreadChannel> ITextChannel.CreateThreadAsync(string name, ThreadType type, ThreadArchiveDuration autoArchiveDuration, IMessage message, RequestOptions options) | |||
=> await CreateThreadAsync(name, type, autoArchiveDuration, message, options); | |||
async Task<IThreadChannel> ITextChannel.CreateThreadAsync(string name, ThreadType type, ThreadArchiveDuration autoArchiveDuration, IMessage message, bool? invitable, int? slowmode, RequestOptions options) | |||
=> await CreateThreadAsync(name, type, autoArchiveDuration, message, invitable, slowmode, options); | |||
#endregion | |||
#region IGuildChannel | |||