@@ -4,7 +4,7 @@ using System.Threading.Tasks; | |||
namespace Discord | |||
{ | |||
/// <summary> | |||
/// Represents a voice channel in a guild. | |||
/// Represents a generic voice channel in a guild. | |||
/// </summary> | |||
public interface IVoiceChannel : IGuildChannel, IAudioChannel | |||
{ | |||
@@ -8,10 +8,16 @@ namespace Discord | |||
/// <summary> | |||
/// Gets the banned user. | |||
/// </summary> | |||
/// <returns> | |||
/// A generic <see cref="IUser"/> object that was banned. | |||
/// </returns> | |||
IUser User { get; } | |||
/// <summary> | |||
/// Gets the reason why the user is banned. | |||
/// Gets the reason why the user is banned if specified. | |||
/// </summary> | |||
/// <returns> | |||
/// A string containing the reason behind the ban; <c>null</c> if none is specified. | |||
/// </returns> | |||
string Reason { get; } | |||
} | |||
} |
@@ -1,5 +1,3 @@ | |||
using System.Threading.Tasks; | |||
namespace Discord | |||
{ | |||
/// <summary> | |||
@@ -10,44 +8,76 @@ namespace Discord | |||
/// <summary> | |||
/// Gets the unique identifier for this invite. | |||
/// </summary> | |||
/// <returns> | |||
/// A string containing the invite code (e.g. <c>FTqNnyS</c>). | |||
/// </returns> | |||
string Code { get; } | |||
/// <summary> | |||
/// Gets the URL used to accept this invite, using Code. | |||
/// Gets the URL used to accept this invite using <see cref="Code"/>. | |||
/// </summary> | |||
/// <returns> | |||
/// A string containing the full invite URL (e.g. <c>https://discord.gg/FTqNnyS</c>). | |||
/// </returns> | |||
string Url { get; } | |||
/// <summary> | |||
/// Gets the channel this invite is linked to. | |||
/// </summary> | |||
/// <returns> | |||
/// A generic channel that the invite points to. | |||
/// </returns> | |||
IChannel Channel { get; } | |||
/// <summary> | |||
/// Gets the ID of the channel this invite is linked to. | |||
/// </summary> | |||
/// <returns> | |||
/// An <see cref="ulong"/> representing the channel snowflake identifier that the invite points to. | |||
/// </returns> | |||
ulong ChannelId { get; } | |||
/// <summary> | |||
/// Gets the name of the channel this invite is linked to. | |||
/// </summary> | |||
/// <returns> | |||
/// A string containing the name of the channel that the invite points to. | |||
/// </returns> | |||
string ChannelName { get; } | |||
/// <summary> | |||
/// Gets the guild this invite is linked to. | |||
/// </summary> | |||
/// <returns> | |||
/// A generic <see cref="IGuild"/> representing the guild that the invite points to. | |||
/// </returns> | |||
IGuild Guild { get; } | |||
/// <summary> | |||
/// Gets the ID of the guild this invite is linked to. | |||
/// </summary> | |||
/// <returns> | |||
/// An <see cref="ulong"/> representing the guild snowflake identifier that the invite points to. | |||
/// </returns> | |||
ulong GuildId { get; } | |||
/// <summary> | |||
/// Gets the name of the guild this invite is linked to. | |||
/// </summary> | |||
/// <returns> | |||
/// A string containing the name of the guild that the invite points to. | |||
/// </returns> | |||
string GuildName { get; } | |||
/// <summary> | |||
/// Gets the approximated count of online members in the guild. | |||
/// </summary> | |||
/// <returns> | |||
/// An <see cref="System.Int32" /> representing the approximated online member count of the guild that the | |||
/// invite points to; <c>null</c> if one cannot be obtained. | |||
/// </returns> | |||
int? PresenceCount { get; } | |||
/// <summary> | |||
/// Gets the approximated count of total members in the guild. | |||
/// </summary> | |||
/// <returns> | |||
/// An <see cref="System.Int32" /> representing the approximated total member count of the guild that the | |||
/// invite points to; <c>null</c> if one cannot be obtained. | |||
/// </returns> | |||
int? MemberCount { get; } | |||
} | |||
} |
@@ -2,37 +2,63 @@ using System; | |||
namespace Discord | |||
{ | |||
/// <summary> Represents additional information regarding the generic invite object. </summary> | |||
/// <summary> | |||
/// Represents additional information regarding the generic invite object. | |||
/// </summary> | |||
public interface IInviteMetadata : IInvite | |||
{ | |||
/// <summary> | |||
/// Gets the user that created this invite. | |||
/// </summary> | |||
/// <returns> | |||
/// A generic <see cref="IUser"/> that created this invite. | |||
/// </returns> | |||
IUser Inviter { get; } | |||
/// <summary> | |||
/// Returns <c>true</c> if this invite was revoked. | |||
/// Determines whether the invite has been revoked. | |||
/// </summary> | |||
/// <returns> | |||
/// <c>true</c> if this invite was revoked; otherwise <c>false</c>. | |||
/// </returns> | |||
bool IsRevoked { get; } | |||
/// <summary> | |||
/// Returns <c>true</c> if users accepting this invite will be removed from the guild when they | |||
/// log off. | |||
/// Determines whether the invite is a temporary one (i.e. whether the invite will be removed from the guild | |||
/// when the user logs off). | |||
/// </summary> | |||
/// <returns> | |||
/// <c>true</c> if users accepting this invite will be removed from the guild when they log off; otherwise | |||
/// <c>false</c>. | |||
/// </returns> | |||
bool IsTemporary { get; } | |||
/// <summary> | |||
/// Gets the time (in seconds) until the invite expires, or <c>null</c> if it never expires. | |||
/// Gets the time (in seconds) until the invite expires. | |||
/// </summary> | |||
/// <returns> | |||
/// An <see cref="int"/> representing the time in seconds until this invite expires; <c>null</c> if this | |||
/// invite never expires. | |||
/// </returns> | |||
int? MaxAge { get; } | |||
/// <summary> | |||
/// Gets the max amount of times this invite may be used, or <c>null</c> if there is no limit. | |||
/// Gets the max number of uses this invite may have. | |||
/// </summary> | |||
/// <returns> | |||
/// An <see cref="int"/> representing the number of uses this invite may be accepted until it is removed | |||
/// from the guild; <c>null</c> if none is set. | |||
/// </returns> | |||
int? MaxUses { get; } | |||
/// <summary> | |||
/// Gets the amount of times this invite has been used. | |||
/// Gets the number of times this invite has been used. | |||
/// </summary> | |||
/// <returns> | |||
/// An <see cref="int"/> representing the number of times this invite has been used. | |||
/// </returns> | |||
int Uses { get; } | |||
/// <summary> | |||
/// Gets when this invite was created. | |||
/// </summary> | |||
/// <returns> | |||
/// A <see cref="DateTimeOffset"/> representing the time of which the invite was first created. | |||
/// </returns> | |||
DateTimeOffset CreatedAt { get; } | |||
} | |||
} |
@@ -6,6 +6,9 @@ using Model = Discord.API.Channel; | |||
namespace Discord.Rest | |||
{ | |||
/// <summary> | |||
/// Represents a generic REST-based channel. | |||
/// </summary> | |||
public class RestChannel : RestEntity<ulong>, IChannel, IUpdateable | |||
{ | |||
/// <inheritdoc /> | |||
@@ -10,7 +10,7 @@ using Model = Discord.API.Channel; | |||
namespace Discord.Rest | |||
{ | |||
/// <summary> | |||
/// Represents a REST-based DM channel. | |||
/// Represents a REST-based direct-message channel. | |||
/// </summary> | |||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | |||
public class RestDMChannel : RestChannel, IDMChannel, IRestPrivateChannel, IRestMessageChannel | |||
@@ -74,18 +74,46 @@ namespace Discord.Rest | |||
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); | |||
/// <inheritdoc /> | |||
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | |||
public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null) | |||
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); | |||
/// <inheritdoc /> | |||
/// <exception cref="ArgumentException"> | |||
/// <paramref name="filePath" /> is a zero-length string, contains only white space, or contains one or more | |||
/// invalid characters as defined by <see cref="System.IO.Path.InvalidPathChars" />. | |||
/// </exception> | |||
/// <exception cref="ArgumentNullException"> | |||
/// <paramref name="filePath" /> is <c>null</c>. | |||
/// </exception> | |||
/// <exception cref="PathTooLongException"> | |||
/// The specified path, file name, or both exceed the system-defined maximum length. For example, on | |||
/// Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 | |||
/// characters. | |||
/// </exception> | |||
/// <exception cref="DirectoryNotFoundException"> | |||
/// The specified path is invalid, (for example, it is on an unmapped drive). | |||
/// </exception> | |||
/// <exception cref="UnauthorizedAccessException"> | |||
/// <paramref name="filePath" /> specified a directory.-or- The caller does not have the required permission. | |||
/// </exception> | |||
/// <exception cref="FileNotFoundException"> | |||
/// The file specified in <paramref name="filePath" /> was not found. | |||
/// </exception> | |||
/// <exception cref="NotSupportedException"><paramref name="filePath" /> is in an invalid format.</exception> | |||
/// <exception cref="IOException">An I/O error occurred while opening the file.</exception> | |||
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | |||
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | |||
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, options); | |||
/// <inheritdoc /> | |||
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | |||
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | |||
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, options); | |||
/// <inheritdoc /> | |||
public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) | |||
=> ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options); | |||
/// <inheritdoc /> | |||
public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) | |||
=> ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options); | |||
@@ -83,8 +83,10 @@ namespace Discord.Rest | |||
public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | |||
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); | |||
/// <inheritdoc /> | |||
public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) | |||
=> ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options); | |||
/// <inheritdoc /> | |||
public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) | |||
=> ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options); | |||
@@ -8,7 +8,7 @@ using Model = Discord.API.Channel; | |||
namespace Discord.Rest | |||
{ | |||
/// <summary> | |||
/// Represents a private REST group channel. | |||
/// Represents a private REST-based group channel. | |||
/// </summary> | |||
public class RestGuildChannel : RestChannel, IGuildChannel | |||
{ | |||
@@ -8,14 +8,20 @@ using Model = Discord.API.Channel; | |||
namespace Discord.Rest | |||
{ | |||
/// <summary> | |||
/// Represents a REST-based channel in a guild that can send and receive messages. | |||
/// </summary> | |||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | |||
public class RestTextChannel : RestGuildChannel, IRestMessageChannel, ITextChannel | |||
{ | |||
/// <inheritdoc /> | |||
public string Topic { get; private set; } | |||
/// <inheritdoc /> | |||
public string Mention => MentionUtils.MentionChannel(Id); | |||
private bool _nsfw; | |||
/// <inheritdoc /> | |||
public bool IsNsfw => _nsfw || ChannelHelper.IsNsfw(this); | |||
internal RestTextChannel(BaseDiscordClient discord, IGuild guild, ulong id) | |||
@@ -36,6 +42,7 @@ namespace Discord.Rest | |||
_nsfw = model.Nsfw.GetValueOrDefault(); | |||
} | |||
/// <inheritdoc /> | |||
public async Task ModifyAsync(Action<TextChannelProperties> func, RequestOptions options = null) | |||
{ | |||
var model = await ChannelHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false); | |||
@@ -47,41 +54,80 @@ namespace Discord.Rest | |||
public IAsyncEnumerable<IReadOnlyCollection<RestGuildUser>> GetUsersAsync(RequestOptions options = null) | |||
=> ChannelHelper.GetUsersAsync(this, Guild, Discord, null, null, options); | |||
/// <inheritdoc /> | |||
public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null) | |||
=> ChannelHelper.GetMessageAsync(this, Discord, id, options); | |||
/// <inheritdoc /> | |||
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
=> ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, options); | |||
/// <inheritdoc /> | |||
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, options); | |||
/// <inheritdoc /> | |||
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | |||
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options); | |||
/// <inheritdoc /> | |||
public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | |||
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); | |||
/// <inheritdoc /> | |||
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | |||
public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null) | |||
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); | |||
/// <inheritdoc /> | |||
/// <exception cref="ArgumentException"> | |||
/// <paramref name="filePath" /> is a zero-length string, contains only white space, or contains one or more | |||
/// invalid characters as defined by <see cref="System.IO.Path.InvalidPathChars" />. | |||
/// </exception> | |||
/// <exception cref="ArgumentNullException"> | |||
/// <paramref name="filePath" /> is <c>null</c>. | |||
/// </exception> | |||
/// <exception cref="PathTooLongException"> | |||
/// The specified path, file name, or both exceed the system-defined maximum length. For example, on | |||
/// Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 | |||
/// characters. | |||
/// </exception> | |||
/// <exception cref="DirectoryNotFoundException"> | |||
/// The specified path is invalid, (for example, it is on an unmapped drive). | |||
/// </exception> | |||
/// <exception cref="UnauthorizedAccessException"> | |||
/// <paramref name="filePath" /> specified a directory.-or- The caller does not have the required permission. | |||
/// </exception> | |||
/// <exception cref="FileNotFoundException"> | |||
/// The file specified in <paramref name="filePath" /> was not found. | |||
/// </exception> | |||
/// <exception cref="NotSupportedException"><paramref name="filePath" /> is in an invalid format.</exception> | |||
/// <exception cref="IOException">An I/O error occurred while opening the file.</exception> | |||
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | |||
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | |||
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, options); | |||
/// <inheritdoc /> | |||
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | |||
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | |||
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, options); | |||
/// <inheritdoc /> | |||
public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) | |||
=> ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options); | |||
/// <inheritdoc /> | |||
public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) | |||
=> ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options); | |||
/// <inheritdoc /> | |||
public Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null) | |||
=> ChannelHelper.DeleteMessagesAsync(this, Discord, messages.Select(x => x.Id), options); | |||
/// <inheritdoc /> | |||
public Task DeleteMessagesAsync(IEnumerable<ulong> messageIds, RequestOptions options = null) | |||
=> ChannelHelper.DeleteMessagesAsync(this, Discord, messageIds, options); | |||
/// <inheritdoc /> | |||
public Task TriggerTypingAsync(RequestOptions options = null) | |||
=> ChannelHelper.TriggerTypingAsync(this, Discord, options); | |||
public IDisposable EnterTypingState(RequestOptions options = null) | |||
=> ChannelHelper.EnterTypingState(this, Discord, options); | |||
public Task<RestWebhook> CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null) | |||
=> ChannelHelper.CreateWebhookAsync(this, Discord, name, avatar, options); | |||
public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null) | |||
@@ -92,14 +138,18 @@ namespace Discord.Rest | |||
private string DebuggerDisplay => $"{Name} ({Id}, Text)"; | |||
//ITextChannel | |||
/// <inheritdoc /> | |||
async Task<IWebhook> ITextChannel.CreateWebhookAsync(string name, Stream avatar, RequestOptions options) | |||
=> await CreateWebhookAsync(name, avatar, options).ConfigureAwait(false); | |||
/// <inheritdoc /> | |||
async Task<IWebhook> ITextChannel.GetWebhookAsync(ulong id, RequestOptions options) | |||
=> await GetWebhookAsync(id, options).ConfigureAwait(false); | |||
/// <inheritdoc /> | |||
async Task<IReadOnlyCollection<IWebhook>> ITextChannel.GetWebhooksAsync(RequestOptions options) | |||
=> await GetWebhooksAsync(options).ConfigureAwait(false); | |||
//IMessageChannel | |||
/// <inheritdoc /> | |||
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) | |||
{ | |||
if (mode == CacheMode.AllowDownload) | |||
@@ -107,6 +157,7 @@ namespace Discord.Rest | |||
else | |||
return null; | |||
} | |||
/// <inheritdoc /> | |||
IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
{ | |||
if (mode == CacheMode.AllowDownload) | |||
@@ -114,6 +165,7 @@ namespace Discord.Rest | |||
else | |||
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
} | |||
/// <inheritdoc /> | |||
IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
{ | |||
if (mode == CacheMode.AllowDownload) | |||
@@ -121,6 +173,7 @@ namespace Discord.Rest | |||
else | |||
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
} | |||
/// <inheritdoc /> | |||
IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | |||
{ | |||
if (mode == CacheMode.AllowDownload) | |||
@@ -128,20 +181,26 @@ namespace Discord.Rest | |||
else | |||
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
} | |||
/// <inheritdoc /> | |||
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | |||
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false); | |||
/// <inheritdoc /> | |||
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options) | |||
=> await SendFileAsync(filePath, text, isTTS, embed, options).ConfigureAwait(false); | |||
/// <inheritdoc /> | |||
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options) | |||
=> await SendFileAsync(stream, filename, text, isTTS, embed, options).ConfigureAwait(false); | |||
/// <inheritdoc /> | |||
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options) | |||
=> await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false); | |||
/// <inheritdoc /> | |||
IDisposable IMessageChannel.EnterTypingState(RequestOptions options) | |||
=> EnterTypingState(options); | |||
//IGuildChannel | |||
/// <inheritdoc /> | |||
async Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
{ | |||
if (mode == CacheMode.AllowDownload) | |||
@@ -149,6 +208,7 @@ namespace Discord.Rest | |||
else | |||
return null; | |||
} | |||
/// <inheritdoc /> | |||
IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
{ | |||
if (mode == CacheMode.AllowDownload) | |||
@@ -158,6 +218,7 @@ namespace Discord.Rest | |||
} | |||
//IChannel | |||
/// <inheritdoc /> | |||
async Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
{ | |||
if (mode == CacheMode.AllowDownload) | |||
@@ -165,6 +226,7 @@ namespace Discord.Rest | |||
else | |||
return null; | |||
} | |||
/// <inheritdoc /> | |||
IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
{ | |||
if (mode == CacheMode.AllowDownload) | |||
@@ -8,10 +8,15 @@ using Model = Discord.API.Channel; | |||
namespace Discord.Rest | |||
{ | |||
/// <summary> | |||
/// Represents a REST-based voice channel in a guild. | |||
/// </summary> | |||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | |||
public class RestVoiceChannel : RestGuildChannel, IVoiceChannel, IRestAudioChannel | |||
{ | |||
/// <inheritdoc /> | |||
public int Bitrate { get; private set; } | |||
/// <inheritdoc /> | |||
public int? UserLimit { get; private set; } | |||
internal RestVoiceChannel(BaseDiscordClient discord, IGuild guild, ulong id) | |||
@@ -24,6 +29,7 @@ namespace Discord.Rest | |||
entity.Update(model); | |||
return entity; | |||
} | |||
/// <inheritdoc /> | |||
internal override void Update(Model model) | |||
{ | |||
base.Update(model); | |||
@@ -32,6 +38,7 @@ namespace Discord.Rest | |||
UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null; | |||
} | |||
/// <inheritdoc /> | |||
public async Task ModifyAsync(Action<VoiceChannelProperties> func, RequestOptions options = null) | |||
{ | |||
var model = await ChannelHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false); | |||
@@ -46,8 +53,10 @@ namespace Discord.Rest | |||
Task<IAudioClient> IAudioChannel.ConnectAsync(Action<IAudioClient> configAction) => throw new NotSupportedException(); | |||
//IGuildChannel | |||
/// <inheritdoc /> | |||
Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
=> Task.FromResult<IGuildUser>(null); | |||
/// <inheritdoc /> | |||
IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
=> AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>(); | |||
} | |||
@@ -3,9 +3,18 @@ using Model = Discord.API.Ban; | |||
namespace Discord.Rest | |||
{ | |||
/// <summary> | |||
/// Represents a REST-based ban object. | |||
/// </summary> | |||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | |||
public class RestBan : IBan | |||
{ | |||
/// <summary> | |||
/// Gets the banned user. | |||
/// </summary> | |||
/// <returns> | |||
/// A generic <see cref="RestUser"/> object that was banned. | |||
/// </returns> | |||
public RestUser User { get; } | |||
/// <inheritdoc /> | |||
public string Reason { get; } | |||
@@ -20,6 +29,12 @@ namespace Discord.Rest | |||
return new RestBan(RestUser.Create(client, model.User), model.Reason); | |||
} | |||
/// <summary> | |||
/// Gets the name of the banned user. | |||
/// </summary> | |||
/// <returns> | |||
/// A string containing the name of the user that was banned. | |||
/// </returns> | |||
public override string ToString() => User.ToString(); | |||
private string DebuggerDisplay => $"{User}: {Reason}"; | |||