Fix GetActiveThreadsAsync & add it to ITextChannel (#2526)

* fix `GetActiveThreadsAsync` being sadge

* ah, forgot about mocked channel
This commit is contained in:
Misha133
2022-12-14 09:56:06 +03:00
committed by GitHub
parent 55280a569e
commit bd2f719774
11 changed files with 51 additions and 8 deletions

View File

@@ -135,9 +135,9 @@ namespace Discord.WebSocket
MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, ForumTag[] tags = null)
=> ThreadHelper.CreatePostAsync(this, Discord, title, attachments, archiveDuration, slowmode, text, embed, options, allowedMentions, components, stickers, embeds, flags, tags?.Select(tag => tag.Id).ToArray());
/// <inheritdoc cref="IForumChannel.GetActiveThreadsAsync(RequestOptions)"/>
/// <inheritdoc cref="ITextChannel.GetActiveThreadsAsync(RequestOptions)"/>
public Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null)
=> ThreadHelper.GetActiveThreadsAsync(Guild, Discord, options);
=> ThreadHelper.GetActiveThreadsAsync(Guild, Id, Discord, options);
/// <inheritdoc cref="IForumChannel.GetJoinedPrivateArchivedThreadsAsync(int?, DateTimeOffset?, RequestOptions)"/>
public Task<IReadOnlyCollection<RestThreadChannel>> GetJoinedPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null)

View File

@@ -130,7 +130,12 @@ namespace Discord.WebSocket
return thread;
}
#endregion
/// <inheritdoc cref="ITextChannel.GetActiveThreadsAsync(RequestOptions)"/>
public virtual Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null)
=> ThreadHelper.GetActiveThreadsAsync(Guild, Id, Discord, options);
#endregion
#region Messages
/// <inheritdoc />
@@ -378,6 +383,9 @@ namespace Discord.WebSocket
/// <inheritdoc />
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);
/// <inheritdoc />
async Task<IReadOnlyCollection<IThreadChannel>> ITextChannel.GetActiveThreadsAsync(RequestOptions options)
=> await GetActiveThreadsAsync(options);
#endregion
#region IGuildChannel

View File

@@ -374,6 +374,10 @@ namespace Discord.WebSocket
public override Task SyncPermissionsAsync(RequestOptions options = null)
=> throw new NotSupportedException("This method is not supported in threads.");
/// <inheritdoc/> <exception cref="NotSupportedException">This method is not supported in threads.</exception>
public override Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null)
=> throw new NotSupportedException("This method is not supported in threads.");
string IChannel.Name => Name;
}
}

View File

@@ -296,6 +296,10 @@ namespace Discord.WebSocket
return base.TriggerTypingAsync(options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">Threads are not supported in voice channels</exception>
public override Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null)
=> throw new NotSupportedException("Threads are not supported in voice channels");
#endregion
private string DebuggerDisplay => $"{Name} ({Id}, Voice)";