commitpull/1923/head88c15787f8
Author: quin lynch <lynchquin@gmail.com> Date: Wed Aug 4 23:17:43 2021 -0300 Fix full stop commit50aedfb7c3
Author: quin lynch <lynchquin@gmail.com> Date: Wed Aug 4 23:13:22 2021 -0300 Threads pre 3 commitf507091a79
Author: quin lynch <lynchquin@gmail.com> Date: Wed Aug 4 21:17:44 2021 -0300 Update docs commitc2003031ce
Author: Quin Lynch <49576606+quinchs@users.noreply.github.com> Date: Tue Aug 3 20:43:34 2021 -0300 Update README.md commitef77e45c75
Author: Quin Lynch <49576606+quinchs@users.noreply.github.com> Date: Tue Aug 3 20:28:41 2021 -0300 Update README.md commit09bb562d06
Author: quin lynch <lynchquin@gmail.com> Date: Sat Jul 31 21:28:15 2021 -0300 Fix rest guild channel not creating threads. fix private thread feature check
@@ -3410,6 +3410,28 @@ | |||
admins and moderators of Community guilds receive notices from Discord; <see langword="null" /> if none is set. | |||
</returns> | |||
</member> | |||
<member name="M:Discord.IGuild.GetThreadChannelAsync(System.UInt64,Discord.CacheMode,Discord.RequestOptions)"> | |||
<summary> | |||
Gets a thread channel within this guild. | |||
</summary> | |||
<param name="id">The id of the thread channel.</param> | |||
<param name="mode">The <see cref="T:Discord.CacheMode"/> that determines whether the object should be fetched from cache.</param> | |||
<param name="options">The options to be used when sending the request.</param> | |||
<returns> | |||
A task that represents the asynchronous get operation. The task result contains the thread channel. | |||
</returns> | |||
</member> | |||
<member name="M:Discord.IGuild.GetThreadChannelsAsync(Discord.CacheMode,Discord.RequestOptions)"> | |||
<summary> | |||
Gets a collection of all thread channels in this guild. | |||
</summary> | |||
<param name="mode">The <see cref="T:Discord.CacheMode" /> that determines whether the object should be fetched from cache.</param> | |||
<param name="options">The options to be used when sending the request.</param> | |||
<returns> | |||
A task that represents the asynchronous get operation. The task result contains a read-only collection of | |||
thread channels found within this guild. | |||
</returns> | |||
</member> | |||
<member name="M:Discord.IGuild.CreateTextChannelAsync(System.String,System.Action{Discord.TextChannelProperties},Discord.RequestOptions)"> | |||
<summary> | |||
Creates a new text channel in this guild. | |||
@@ -589,6 +589,26 @@ namespace Discord | |||
/// admins and moderators of Community guilds receive notices from Discord; <see langword="null" /> if none is set. | |||
/// </returns> | |||
Task<ITextChannel> GetPublicUpdatesChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||
/// <summary> | |||
/// Gets a thread channel within this guild. | |||
/// </summary> | |||
/// <param name="id">The id of the thread channel.</param> | |||
/// <param name="mode">The <see cref="CacheMode"/> that determines whether the object should be fetched from cache.</param> | |||
/// <param name="options">The options to be used when sending the request.</param> | |||
/// <returns> | |||
/// A task that represents the asynchronous get operation. The task result contains the thread channel. | |||
/// </returns> | |||
Task<IThreadChannel> GetThreadChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||
/// <summary> | |||
/// Gets a collection of all thread channels in this guild. | |||
/// </summary> | |||
/// <param name="mode">The <see cref="CacheMode" /> that determines whether the object should be fetched from cache.</param> | |||
/// <param name="options">The options to be used when sending the request.</param> | |||
/// <returns> | |||
/// A task that represents the asynchronous get operation. The task result contains a read-only collection of | |||
/// thread channels found within this guild. | |||
/// </returns> | |||
Task<IReadOnlyCollection<IThreadChannel>> GetThreadChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||
/// <summary> | |||
/// Creates a new text channel in this guild. | |||
@@ -3088,6 +3088,27 @@ | |||
message channels found within this guild. | |||
</returns> | |||
</member> | |||
<member name="M:Discord.Rest.RestGuild.GetThreadChannelAsync(System.UInt64,Discord.RequestOptions)"> | |||
<summary> | |||
Gets a thread channel in this guild. | |||
</summary> | |||
<param name="id">The snowflake identifier for the thread channel.</param> | |||
<param name="options">The options to be used when sending the request.</param> | |||
<returns> | |||
A task that represents the asynchronous get operation. The task result contains the thread channel associated | |||
with the specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||
</returns> | |||
</member> | |||
<member name="M:Discord.Rest.RestGuild.GetThreadChannelsAsync(Discord.RequestOptions)"> | |||
<summary> | |||
Gets a collection of all thread in this guild. | |||
</summary> | |||
<param name="options">The options to be used when sending the request.</param> | |||
<returns> | |||
A task that represents the asynchronous get operation. The task result contains a read-only collection of | |||
threads found within this guild. | |||
</returns> | |||
</member> | |||
<member name="M:Discord.Rest.RestGuild.GetVoiceChannelAsync(System.UInt64,Discord.RequestOptions)"> | |||
<summary> | |||
Gets a voice channel in this guild. | |||
@@ -3463,6 +3484,12 @@ | |||
<member name="M:Discord.Rest.RestGuild.Discord#IGuild#GetTextChannelAsync(System.UInt64,Discord.CacheMode,Discord.RequestOptions)"> | |||
<inheritdoc /> | |||
</member> | |||
<member name="M:Discord.Rest.RestGuild.Discord#IGuild#GetThreadChannelAsync(System.UInt64,Discord.CacheMode,Discord.RequestOptions)"> | |||
<inheritdoc /> | |||
</member> | |||
<member name="M:Discord.Rest.RestGuild.Discord#IGuild#GetThreadChannelsAsync(Discord.CacheMode,Discord.RequestOptions)"> | |||
<inheritdoc /> | |||
</member> | |||
<member name="M:Discord.Rest.RestGuild.Discord#IGuild#GetVoiceChannelsAsync(Discord.CacheMode,Discord.RequestOptions)"> | |||
<inheritdoc /> | |||
</member> | |||
@@ -42,6 +42,8 @@ namespace Discord.Rest | |||
return RestVoiceChannel.Create(discord, guild, model); | |||
case ChannelType.Category: | |||
return RestCategoryChannel.Create(discord, guild, model); | |||
case ChannelType.PublicThread or ChannelType.PrivateThread or ChannelType.NewsThread: | |||
return RestThreadChannel.Create(discord, guild, model); | |||
default: | |||
return new RestGuildChannel(discord, guild, model.Id); | |||
} | |||
@@ -19,6 +19,9 @@ namespace Discord.Rest | |||
if (autoArchiveDuration == ThreadArchiveDuration.ThreeDays && !channel.Guild.Features.Contains("THREE_DAY_THREAD_ARCHIVE")) | |||
throw new ArgumentException($"The guild {channel.Guild.Name} does not have the THREE_DAY_THREAD_ARCHIVE feature!"); | |||
if (type == ThreadType.PrivateThread && !channel.Guild.Features.Contains("PRIVATE_THREADS")) | |||
throw new ArgumentException($"The guild {channel.Guild.Name} does not have the PRIVATE_THREADS feature!"); | |||
var args = new StartThreadParams() | |||
{ | |||
Name = name, | |||
@@ -394,6 +394,35 @@ namespace Discord.Rest | |||
return channels.OfType<RestTextChannel>().ToImmutableArray(); | |||
} | |||
/// <summary> | |||
/// Gets a thread channel in this guild. | |||
/// </summary> | |||
/// <param name="id">The snowflake identifier for the thread channel.</param> | |||
/// <param name="options">The options to be used when sending the request.</param> | |||
/// <returns> | |||
/// A task that represents the asynchronous get operation. The task result contains the thread channel associated | |||
/// with the specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||
/// </returns> | |||
public async Task<RestThreadChannel> GetThreadChannelAsync(ulong id, RequestOptions options = null) | |||
{ | |||
var channel = await GuildHelper.GetChannelAsync(this, Discord, id, options).ConfigureAwait(false); | |||
return channel as RestThreadChannel; | |||
} | |||
/// <summary> | |||
/// Gets a collection of all thread in this guild. | |||
/// </summary> | |||
/// <param name="options">The options to be used when sending the request.</param> | |||
/// <returns> | |||
/// A task that represents the asynchronous get operation. The task result contains a read-only collection of | |||
/// threads found within this guild. | |||
/// </returns> | |||
public async Task<IReadOnlyCollection<RestThreadChannel>> GetThreadChannelsAsync(RequestOptions options = null) | |||
{ | |||
var channels = await GuildHelper.GetChannelsAsync(this, Discord, options).ConfigureAwait(false); | |||
return channels.OfType<RestThreadChannel>().ToImmutableArray(); | |||
} | |||
/// <summary> | |||
/// Gets a voice channel in this guild. | |||
/// </summary> | |||
@@ -891,6 +920,22 @@ namespace Discord.Rest | |||
return null; | |||
} | |||
/// <inheritdoc /> | |||
async Task<IThreadChannel> IGuild.GetThreadChannelAsync(ulong id, CacheMode mode, RequestOptions options) | |||
{ | |||
if (mode == CacheMode.AllowDownload) | |||
return await GetThreadChannelAsync(id, options).ConfigureAwait(false); | |||
else | |||
return null; | |||
} | |||
/// <inheritdoc /> | |||
async Task<IReadOnlyCollection<IThreadChannel>> IGuild.GetThreadChannelsAsync(CacheMode mode, RequestOptions options) | |||
{ | |||
if (mode == CacheMode.AllowDownload) | |||
return await GetThreadChannelsAsync(options).ConfigureAwait(false); | |||
else | |||
return null; | |||
} | |||
/// <inheritdoc /> | |||
async Task<IReadOnlyCollection<IVoiceChannel>> IGuild.GetVoiceChannelsAsync(CacheMode mode, RequestOptions options) | |||
{ | |||
if (mode == CacheMode.AllowDownload) | |||
@@ -542,7 +542,7 @@ namespace Discord.WebSocket | |||
internal readonly AsyncEvent<Func<SocketApplicationCommand, Task>> _applicationCommandDeleted = new AsyncEvent<Func<SocketApplicationCommand, Task>>(); | |||
/// <summary> | |||
/// Fired when a thread is created within a guild. | |||
/// Fired when a thread is created within a guild, or when the current user is added to a thread. | |||
/// </summary> | |||
public event Func<SocketThreadChannel, Task> ThreadCreated | |||
{ | |||
@@ -758,7 +758,7 @@ | |||
</member> | |||
<member name="E:Discord.WebSocket.BaseSocketClient.ThreadCreated"> | |||
<summary> | |||
Fired when a thread is created within a guild. | |||
Fired when a thread is created within a guild. or when the current user is added to a thread. | |||
</summary> | |||
</member> | |||
<member name="E:Discord.WebSocket.BaseSocketClient.ThreadUpdated"> | |||
@@ -3058,6 +3058,15 @@ | |||
A text channel associated with the specified <paramref name="id" />; <see langword="null"/> if none is found. | |||
</returns> | |||
</member> | |||
<member name="M:Discord.WebSocket.SocketGuild.GetThreadChannel(System.UInt64)"> | |||
<summary> | |||
Gets a thread in this guild. | |||
</summary> | |||
<param name="id">The snowflake identifier for the thread.</param> | |||
<returns> | |||
A thread channel associated with the specified <paramref name="id" />; <see langword="null"/> if none is found. | |||
</returns> | |||
</member> | |||
<member name="M:Discord.WebSocket.SocketGuild.GetVoiceChannel(System.UInt64)"> | |||
<summary> | |||
Gets a voice channel in this guild. | |||
@@ -3393,6 +3402,12 @@ | |||
<member name="M:Discord.WebSocket.SocketGuild.Discord#IGuild#GetTextChannelAsync(System.UInt64,Discord.CacheMode,Discord.RequestOptions)"> | |||
<inheritdoc /> | |||
</member> | |||
<member name="M:Discord.WebSocket.SocketGuild.Discord#IGuild#GetThreadChannelAsync(System.UInt64,Discord.CacheMode,Discord.RequestOptions)"> | |||
<inheritdoc /> | |||
</member> | |||
<member name="M:Discord.WebSocket.SocketGuild.Discord#IGuild#GetThreadChannelsAsync(Discord.CacheMode,Discord.RequestOptions)"> | |||
<inheritdoc /> | |||
</member> | |||
<member name="M:Discord.WebSocket.SocketGuild.Discord#IGuild#GetVoiceChannelsAsync(Discord.CacheMode,Discord.RequestOptions)"> | |||
<inheritdoc /> | |||
</member> | |||
@@ -379,6 +379,13 @@ namespace Discord.WebSocket | |||
client.InviteDeleted += (channel, invite) => _inviteDeletedEvent.InvokeAsync(channel, invite); | |||
client.InteractionCreated += (interaction) => _interactionCreatedEvent.InvokeAsync(interaction); | |||
client.ThreadUpdated += (thread1, thread2) => _threadUpdated.InvokeAsync(thread1, thread2); | |||
client.ThreadCreated += (thread) => _threadCreated.InvokeAsync(thread); | |||
client.ThreadDeleted += (thread) => _threadDeleted.InvokeAsync(thread); | |||
client.ThreadMemberJoined += (user) => _threadMemberJoined.InvokeAsync(user); | |||
client.ThreadMemberLeft += (user) => _threadMemberLeft.InvokeAsync(user); | |||
} | |||
//IDiscordClient | |||
@@ -2001,8 +2001,9 @@ namespace Discord.WebSocket | |||
threadChannel = (SocketThreadChannel)guild.AddChannel(this.State, data); | |||
if (data.ThreadMember.IsSpecified) | |||
threadChannel.AddOrUpdateThreadMember(data.ThreadMember.Value, guild.CurrentUser); | |||
await TimedInvokeAsync(_threadCreated, nameof(ThreadCreated), threadChannel).ConfigureAwait(false); | |||
} | |||
await TimedInvokeAsync(_threadCreated, nameof(ThreadCreated), threadChannel).ConfigureAwait(false); | |||
} | |||
break; | |||
@@ -281,14 +281,14 @@ namespace Discord.WebSocket | |||
/// <b>This method is not supported in threads.</b> | |||
/// </remarks> | |||
public override OverwritePermissions? GetPermissionOverwrite(IRole role) | |||
=> throw new NotImplementedException(); | |||
=> ParentChannel.GetPermissionOverwrite(role); | |||
/// <inheritdoc/> | |||
/// <remarks> | |||
/// <b>This method is not supported in threads.</b> | |||
/// </remarks> | |||
public override OverwritePermissions? GetPermissionOverwrite(IUser user) | |||
=> throw new NotImplementedException(); | |||
=> ParentChannel.GetPermissionOverwrite(user); | |||
/// <inheritdoc/> | |||
/// <remarks> | |||
@@ -633,6 +633,16 @@ namespace Discord.WebSocket | |||
public SocketTextChannel GetTextChannel(ulong id) | |||
=> GetChannel(id) as SocketTextChannel; | |||
/// <summary> | |||
/// Gets a thread in this guild. | |||
/// </summary> | |||
/// <param name="id">The snowflake identifier for the thread.</param> | |||
/// <returns> | |||
/// A thread channel associated with the specified <paramref name="id" />; <see langword="null"/> if none is found. | |||
/// </returns> | |||
public SocketThreadChannel GetThreadChannel(ulong id) | |||
=> GetChannel(id) as SocketThreadChannel; | |||
/// <summary> | |||
/// Gets a voice channel in this guild. | |||
/// </summary> | |||
/// <param name="id">The snowflake identifier for the voice channel.</param> | |||
@@ -1329,6 +1339,12 @@ namespace Discord.WebSocket | |||
Task<ITextChannel> IGuild.GetTextChannelAsync(ulong id, CacheMode mode, RequestOptions options) | |||
=> Task.FromResult<ITextChannel>(GetTextChannel(id)); | |||
/// <inheritdoc /> | |||
Task<IThreadChannel> IGuild.GetThreadChannelAsync(ulong id, CacheMode mode, RequestOptions options) | |||
=> Task.FromResult<IThreadChannel>(GetThreadChannel(id)); | |||
/// <inheritdoc /> | |||
Task<IReadOnlyCollection<IThreadChannel>> IGuild.GetThreadChannelsAsync(CacheMode mode, RequestOptions options) | |||
=> Task.FromResult<IReadOnlyCollection<IThreadChannel>>(ThreadChannels); | |||
/// <inheritdoc /> | |||
Task<IReadOnlyCollection<IVoiceChannel>> IGuild.GetVoiceChannelsAsync(CacheMode mode, RequestOptions options) | |||
=> Task.FromResult<IReadOnlyCollection<IVoiceChannel>>(VoiceChannels); | |||
/// <inheritdoc /> | |||