[Feature] Text-In-Stage support & missing IVoiceChannel properties (#2610)

* initial commit

* add a check for voice/stage channels in `PinAsync`

* moar refactoring

* Update IStageChannel.cs

* forgot about mocked. again.
This commit is contained in:
Misha133
2023-02-26 22:55:23 +03:00
committed by GitHub
parent e69e27aa44
commit 76bb9018c4
11 changed files with 59 additions and 435 deletions

View File

@@ -8,14 +8,6 @@ namespace Discord
/// </summary> /// </summary>
public interface IStageChannel : IVoiceChannel public interface IStageChannel : IVoiceChannel
{ {
/// <summary>
/// Gets the topic of the Stage instance.
/// </summary>
/// <remarks>
/// If the stage isn't live then this property will be set to <see langword="null"/>.
/// </remarks>
string Topic { get; }
/// <summary> /// <summary>
/// Gets the <see cref="StagePrivacyLevel"/> of the current stage. /// Gets the <see cref="StagePrivacyLevel"/> of the current stage.
/// </summary> /// </summary>

View File

@@ -7,7 +7,7 @@ namespace Discord
/// <summary> /// <summary>
/// Represents a generic voice channel in a guild. /// Represents a generic voice channel in a guild.
/// </summary> /// </summary>
public interface IVoiceChannel : IMessageChannel, INestedChannel, IAudioChannel, IMentionable public interface IVoiceChannel : ITextChannel, IAudioChannel
{ {
/// <summary> /// <summary>
/// Gets the bit-rate that the clients in this voice channel are requested to use. /// Gets the bit-rate that the clients in this voice channel are requested to use.
@@ -31,44 +31,6 @@ namespace Discord
/// </summary> /// </summary>
VideoQualityMode VideoQualityMode { get; } VideoQualityMode VideoQualityMode { get; }
/// <summary>
/// Bulk-deletes multiple messages.
/// </summary>
/// <example>
/// <para>The following example gets 250 messages from the channel and deletes them.</para>
/// <code language="cs">
/// var messages = await voiceChannel.GetMessagesAsync(250).FlattenAsync();
/// await voiceChannel.DeleteMessagesAsync(messages);
/// </code>
/// </example>
/// <remarks>
/// This method attempts to remove the messages specified in bulk.
/// <note type="important">
/// Due to the limitation set by Discord, this method can only remove messages that are posted within 14 days!
/// </note>
/// </remarks>
/// <param name="messages">The messages to be bulk-deleted.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous bulk-removal operation.
/// </returns>
Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null);
/// <summary>
/// Bulk-deletes multiple messages.
/// </summary>
/// <remarks>
/// This method attempts to remove the messages specified in bulk.
/// <note type="important">
/// Due to the limitation set by Discord, this method can only remove messages that are posted within 14 days!
/// </note>
/// </remarks>
/// <param name="messageIds">The snowflake identifier of the messages to be bulk-deleted.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous bulk-removal operation.
/// </returns>
Task DeleteMessagesAsync(IEnumerable<ulong> messageIds, RequestOptions options = null);
/// <summary> /// <summary>
/// Modifies this voice channel. /// Modifies this voice channel.
/// </summary> /// </summary>

View File

@@ -1,10 +1,12 @@
namespace Discord using System;
namespace Discord;
/// <summary>
/// Provides properties that are used to modify an <see cref="IVoiceChannel" /> with the specified changes.
/// </summary>
public class VoiceChannelProperties : TextChannelProperties
{ {
/// <summary>
/// Provides properties that are used to modify an <see cref="IVoiceChannel" /> with the specified changes.
/// </summary>
public class VoiceChannelProperties : GuildChannelProperties
{
/// <summary> /// <summary>
/// Gets or sets the bitrate of the voice connections in this channel. Must be greater than 8000. /// Gets or sets the bitrate of the voice connections in this channel. Must be greater than 8000.
/// </summary> /// </summary>
@@ -22,5 +24,10 @@ namespace Discord
/// Get or sets the video quality mode for this channel. /// Get or sets the video quality mode for this channel.
/// </summary> /// </summary>
public Optional<VideoQualityMode> VideoQualityMode { get; set; } public Optional<VideoQualityMode> VideoQualityMode { get; set; }
}
/// <remarks>
/// Not supported in voice channels
/// </remarks>
/// <inheritdoc cref="TextChannelProperties.Topic"/>
public new Optional<string> Topic { get; }
} }

View File

@@ -3,7 +3,7 @@ using Newtonsoft.Json;
namespace Discord.API.Rest namespace Discord.API.Rest
{ {
[JsonObject(MemberSerialization = MemberSerialization.OptIn)] [JsonObject(MemberSerialization = MemberSerialization.OptIn)]
internal class ModifyVoiceChannelParams : ModifyGuildChannelParams internal class ModifyVoiceChannelParams : ModifyTextChannelParams
{ {
[JsonProperty("bitrate")] [JsonProperty("bitrate")]
public Optional<int> Bitrate { get; set; } public Optional<int> Bitrate { get; set; }

View File

@@ -91,6 +91,8 @@ namespace Discord.Rest
Deny = overwrite.Permissions.DenyValue.ToString() Deny = overwrite.Permissions.DenyValue.ToString()
}).ToArray() }).ToArray()
: Optional.Create<API.Overwrite[]>(), : Optional.Create<API.Overwrite[]>(),
SlowModeInterval = args.SlowModeInterval,
IsNsfw = args.IsNsfw,
}; };
return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
} }

View File

@@ -13,10 +13,12 @@ namespace Discord.Rest
{ {
/// <inheritdoc/> /// <inheritdoc/>
/// <remarks> /// <remarks>
/// This field is always false for stage channels. /// This field is always true for stage channels.
/// </remarks> /// </remarks>
///
[Obsolete("This property is no longer used because Discord enabled text-in-voice and text-in-stage for all channels.")]
public override bool IsTextInVoice public override bool IsTextInVoice
=> false; => true;
/// <inheritdoc/> /// <inheritdoc/>
public StagePrivacyLevel? PrivacyLevel { get; private set; } public StagePrivacyLevel? PrivacyLevel { get; private set; }

View File

@@ -19,7 +19,9 @@ namespace Discord.Rest
/// <summary> /// <summary>
/// Gets whether or not the guild has Text-In-Voice enabled and the voice channel is a TiV channel. /// Gets whether or not the guild has Text-In-Voice enabled and the voice channel is a TiV channel.
/// </summary> /// </summary>
[Obsolete("This property is no longer used because Discord enabled text-in-voice for all channels.")]
public virtual bool IsTextInVoice => true; public virtual bool IsTextInVoice => true;
/// <inheritdoc /> /// <inheritdoc />
public int Bitrate { get; private set; } public int Bitrate { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
@@ -62,11 +64,6 @@ namespace Discord.Rest
Update(model); Update(model);
} }
/// <inheritdoc/>
/// <exception cref="InvalidOperationException">Cannot modify text channel properties of a voice channel.</exception>
public override Task ModifyAsync(Action<TextChannelProperties> func, RequestOptions options = null)
=> throw new InvalidOperationException("Cannot modify text channel properties of a voice channel");
/// <inheritdoc/> /// <inheritdoc/>
/// <exception cref="InvalidOperationException">Cannot create a thread within a voice channel.</exception> /// <exception cref="InvalidOperationException">Cannot create a thread within a voice channel.</exception>
public override Task<RestThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null) public override Task<RestThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null)
@@ -78,166 +75,6 @@ namespace Discord.Rest
#region TextOverrides #region TextOverrides
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetMessageAsync(id, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.DeleteMessageAsync(message, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.DeleteMessageAsync(messageId, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.DeleteMessagesAsync(messages, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task DeleteMessagesAsync(IEnumerable<ulong> messageIds, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.DeleteMessagesAsync(messageIds, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override IDisposable EnterTypingState(RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.EnterTypingState(options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = 100, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetMessagesAsync(fromMessage, dir, limit, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = 100, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetMessagesAsync(limit, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = 100, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetMessagesAsync(fromMessageId, dir, limit, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetPinnedMessagesAsync(options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetWebhookAsync(id, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<IReadOnlyCollection<RestWebhook>> GetWebhooksAsync(RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetWebhooksAsync(options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestWebhook> CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.CreateWebhookAsync(name, avatar, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<IUserMessage> ModifyMessageAsync(ulong messageId, Action<MessageProperties> func, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.ModifyMessageAsync(messageId, func, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestUserMessage> SendFileAsync(FileAttachment attachment, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.SendFileAsync(attachment, text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, components, stickers, embeds, flags);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, components, stickers, embeds, flags);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.SendFilesAsync(attachments, text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task TriggerTypingAsync(RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.TriggerTypingAsync(options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">Threads are not supported in voice channels</exception> /// <inheritdoc/> <exception cref="NotSupportedException">Threads are not supported in voice channels</exception>
public override Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null) public override Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null)
=> throw new NotSupportedException("Threads are not supported in voice channels"); => throw new NotSupportedException("Threads are not supported in voice channels");

View File

@@ -212,6 +212,8 @@ namespace Discord.Rest
public static async Task PinAsync(IMessage msg, BaseDiscordClient client, public static async Task PinAsync(IMessage msg, BaseDiscordClient client,
RequestOptions options) RequestOptions options)
{ {
if (msg.Channel is IVoiceChannel)
throw new NotSupportedException("Pinned messages are not supported in text-in-voice channels.");
await client.ApiClient.AddPinAsync(msg.Channel.Id, msg.Id, options).ConfigureAwait(false); await client.ApiClient.AddPinAsync(msg.Channel.Id, msg.Id, options).ConfigureAwait(false);
} }

View File

@@ -16,10 +16,11 @@ namespace Discord.WebSocket
{ {
/// <inheritdoc/> /// <inheritdoc/>
/// <remarks> /// <remarks>
/// This field is always false for stage channels. /// This field is always true for stage channels.
/// </remarks> /// </remarks>
[Obsolete("This property is no longer used because Discord enabled text-in-stage for all channels.")]
public override bool IsTextInVoice public override bool IsTextInVoice
=> false; => true;
/// <inheritdoc/> /// <inheritdoc/>
public StagePrivacyLevel? PrivacyLevel { get; private set; } public StagePrivacyLevel? PrivacyLevel { get; private set; }

View File

@@ -23,9 +23,10 @@ namespace Discord.WebSocket
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Discord currently doesn't have a way to disable Text-In-Voice yet so this field is always /// Discord currently doesn't have a way to disable Text-In-Voice yet so this field is always
/// <see langword="true"/> on <see cref="SocketVoiceChannel"/>s and <see langword="false"/> on /// <see langword="true"/> on <see cref="SocketVoiceChannel"/>s and <see langword="true"/> on
/// <see cref="SocketStageChannel"/>s. /// <see cref="SocketStageChannel"/>s.
/// </remarks> /// </remarks>
[Obsolete("This property is no longer used because Discord enabled text-in-voice for all channels.")]
public virtual bool IsTextInVoice => true; public virtual bool IsTextInVoice => true;
/// <inheritdoc /> /// <inheritdoc />
@@ -99,206 +100,10 @@ namespace Discord.WebSocket
public override Task<SocketThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null) public override Task<SocketThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null)
=> throw new InvalidOperationException("Voice channels cannot contain threads."); => throw new InvalidOperationException("Voice channels cannot contain threads.");
/// <inheritdoc/> <exception cref="InvalidOperationException">Cannot modify text channel properties for voice channels.</exception>
public override Task ModifyAsync(Action<TextChannelProperties> func, RequestOptions options = null)
=> throw new InvalidOperationException("Cannot modify text channel properties for voice channels.");
#endregion #endregion
#region TextOverrides #region TextOverrides
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<IMessage> GetMessageAsync(ulong id, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetMessageAsync(id, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.DeleteMessageAsync(message, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.DeleteMessageAsync(messageId, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.DeleteMessagesAsync(messages, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task DeleteMessagesAsync(IEnumerable<ulong> messageIds, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.DeleteMessagesAsync(messageIds, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override IDisposable EnterTypingState(RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.EnterTypingState(options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override SocketMessage GetCachedMessage(ulong id)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetCachedMessage(id);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override IReadOnlyCollection<SocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = 100)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetCachedMessages(fromMessage, dir, limit);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override IReadOnlyCollection<SocketMessage> GetCachedMessages(int limit = 100)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetCachedMessages(limit);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override IReadOnlyCollection<SocketMessage> GetCachedMessages(ulong fromMessageId, Direction dir, int limit = 100)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetCachedMessages(fromMessageId, dir, limit);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = 100, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetMessagesAsync(fromMessage, dir, limit, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = 100, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetMessagesAsync(limit, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = 100, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetMessagesAsync(fromMessageId, dir, limit, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetPinnedMessagesAsync(options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetWebhookAsync(id, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<IReadOnlyCollection<RestWebhook>> GetWebhooksAsync(RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetWebhooksAsync(options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestWebhook> CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.CreateWebhookAsync(name, avatar, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<IUserMessage> ModifyMessageAsync(ulong messageId, Action<MessageProperties> func, RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.ModifyMessageAsync(messageId, func, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestUserMessage> SendFileAsync(FileAttachment attachment, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.SendFileAsync(attachment, text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, components, stickers, embeds, flags);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, components, stickers, embeds, flags);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.SendFilesAsync(attachments, text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
public override Task TriggerTypingAsync(RequestOptions options = null)
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.TriggerTypingAsync(options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">Threads are not supported in voice channels</exception> /// <inheritdoc/> <exception cref="NotSupportedException">Threads are not supported in voice channels</exception>
public override Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null) public override Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null)
=> throw new NotSupportedException("Threads are not supported in voice channels"); => throw new NotSupportedException("Threads are not supported in voice channels");

View File

@@ -12,9 +12,17 @@ namespace Discord
public int Bitrate => throw new NotImplementedException(); public int Bitrate => throw new NotImplementedException();
public int? UserLimit => throw new NotImplementedException(); public int? UserLimit => throw new NotImplementedException();
public string Topic { get; }
public int SlowModeInterval { get; }
public ThreadArchiveDuration DefaultArchiveDuration { get; }
public Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null) => throw new NotImplementedException(); public Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null) => throw new NotImplementedException();
public Task DeleteMessagesAsync(IEnumerable<ulong> messageIds, RequestOptions options = null) => throw new NotImplementedException(); public Task DeleteMessagesAsync(IEnumerable<ulong> messageIds, RequestOptions options = null) => throw new NotImplementedException();
public Task ModifyAsync(Action<TextChannelProperties> func, RequestOptions options = null) => throw new NotImplementedException();
public Task<IThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null) => throw new NotImplementedException();
public Task<IReadOnlyCollection<IThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null) => throw new NotImplementedException();
public ulong? CategoryId => throw new NotImplementedException(); public ulong? CategoryId => throw new NotImplementedException();
@@ -39,6 +47,7 @@ namespace Discord
public ChannelFlags Flags => throw new NotImplementedException(); public ChannelFlags Flags => throw new NotImplementedException();
public VideoQualityMode VideoQualityMode => throw new NotImplementedException(); public VideoQualityMode VideoQualityMode => throw new NotImplementedException();
public bool IsNsfw { get; }
public Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null) => throw new NotImplementedException(); public Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null) => throw new NotImplementedException();
public Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options = null) => throw new NotImplementedException(); public Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options = null) => throw new NotImplementedException();
@@ -78,5 +87,10 @@ namespace Discord
public Task TriggerTypingAsync(RequestOptions options = null) => throw new NotImplementedException(); public Task TriggerTypingAsync(RequestOptions options = null) => throw new NotImplementedException();
Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) => throw new NotImplementedException(); Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) => throw new NotImplementedException();
IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) => throw new NotImplementedException(); IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) => throw new NotImplementedException();
public Task<IWebhook> CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null) => throw new NotImplementedException();
public Task<IWebhook> GetWebhookAsync(ulong id, RequestOptions options = null) => throw new NotImplementedException();
public Task<IReadOnlyCollection<IWebhook>> GetWebhooksAsync(RequestOptions options = null) => throw new NotImplementedException();
} }
} }