Browse Source

Add documentation for some REST-based objects

pull/1161/head
Still Hsu 7 years ago
parent
commit
afda0cd172
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
11 changed files with 196 additions and 15 deletions
  1. +1
    -1
      src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs
  2. +7
    -1
      src/Discord.Net.Core/Entities/Guilds/IBan.cs
  3. +33
    -3
      src/Discord.Net.Core/Entities/Invites/IInvite.cs
  4. +33
    -7
      src/Discord.Net.Core/Entities/Invites/IInviteMetadata.cs
  5. +3
    -0
      src/Discord.Net.Rest/Entities/Channels/RestChannel.cs
  6. +29
    -1
      src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs
  7. +2
    -0
      src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
  8. +1
    -1
      src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs
  9. +63
    -1
      src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
  10. +9
    -0
      src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs
  11. +15
    -0
      src/Discord.Net.Rest/Entities/Guilds/RestBan.cs

+ 1
- 1
src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs View File

@@ -4,7 +4,7 @@ using System.Threading.Tasks;
namespace Discord namespace Discord
{ {
/// <summary> /// <summary>
/// Represents a voice channel in a guild.
/// Represents a generic voice channel in a guild.
/// </summary> /// </summary>
public interface IVoiceChannel : IGuildChannel, IAudioChannel public interface IVoiceChannel : IGuildChannel, IAudioChannel
{ {


+ 7
- 1
src/Discord.Net.Core/Entities/Guilds/IBan.cs View File

@@ -8,10 +8,16 @@ namespace Discord
/// <summary> /// <summary>
/// Gets the banned user. /// Gets the banned user.
/// </summary> /// </summary>
/// <returns>
/// A generic <see cref="IUser"/> object that was banned.
/// </returns>
IUser User { get; } IUser User { get; }
/// <summary> /// <summary>
/// Gets the reason why the user is banned.
/// Gets the reason why the user is banned if specified.
/// </summary> /// </summary>
/// <returns>
/// A string containing the reason behind the ban; <c>null</c> if none is specified.
/// </returns>
string Reason { get; } string Reason { get; }
} }
} }

+ 33
- 3
src/Discord.Net.Core/Entities/Invites/IInvite.cs View File

@@ -1,5 +1,3 @@
using System.Threading.Tasks;

namespace Discord namespace Discord
{ {
/// <summary> /// <summary>
@@ -10,44 +8,76 @@ namespace Discord
/// <summary> /// <summary>
/// Gets the unique identifier for this invite. /// Gets the unique identifier for this invite.
/// </summary> /// </summary>
/// <returns>
/// A string containing the invite code (e.g. <c>FTqNnyS</c>).
/// </returns>
string Code { get; } string Code { get; }
/// <summary> /// <summary>
/// Gets the URL used to accept this invite, using Code.
/// Gets the URL used to accept this invite using <see cref="Code"/>.
/// </summary> /// </summary>
/// <returns>
/// A string containing the full invite URL (e.g. <c>https://discord.gg/FTqNnyS</c>).
/// </returns>
string Url { get; } string Url { get; }


/// <summary> /// <summary>
/// Gets the channel this invite is linked to. /// Gets the channel this invite is linked to.
/// </summary> /// </summary>
/// <returns>
/// A generic channel that the invite points to.
/// </returns>
IChannel Channel { get; } IChannel Channel { get; }
/// <summary> /// <summary>
/// Gets the ID of the channel this invite is linked to. /// Gets the ID of the channel this invite is linked to.
/// </summary> /// </summary>
/// <returns>
/// An <see cref="ulong"/> representing the channel snowflake identifier that the invite points to.
/// </returns>
ulong ChannelId { get; } ulong ChannelId { get; }
/// <summary> /// <summary>
/// Gets the name of the channel this invite is linked to. /// Gets the name of the channel this invite is linked to.
/// </summary> /// </summary>
/// <returns>
/// A string containing the name of the channel that the invite points to.
/// </returns>
string ChannelName { get; } string ChannelName { get; }


/// <summary> /// <summary>
/// Gets the guild this invite is linked to. /// Gets the guild this invite is linked to.
/// </summary> /// </summary>
/// <returns>
/// A generic <see cref="IGuild"/> representing the guild that the invite points to.
/// </returns>
IGuild Guild { get; } IGuild Guild { get; }
/// <summary> /// <summary>
/// Gets the ID of the guild this invite is linked to. /// Gets the ID of the guild this invite is linked to.
/// </summary> /// </summary>
/// <returns>
/// An <see cref="ulong"/> representing the guild snowflake identifier that the invite points to.
/// </returns>
ulong GuildId { get; } ulong GuildId { get; }
/// <summary> /// <summary>
/// Gets the name of the guild this invite is linked to. /// Gets the name of the guild this invite is linked to.
/// </summary> /// </summary>
/// <returns>
/// A string containing the name of the guild that the invite points to.
/// </returns>
string GuildName { get; } string GuildName { get; }
/// <summary> /// <summary>
/// Gets the approximated count of online members in the guild. /// Gets the approximated count of online members in the guild.
/// </summary> /// </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; } int? PresenceCount { get; }
/// <summary> /// <summary>
/// Gets the approximated count of total members in the guild. /// Gets the approximated count of total members in the guild.
/// </summary> /// </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; } int? MemberCount { get; }
} }
} }

+ 33
- 7
src/Discord.Net.Core/Entities/Invites/IInviteMetadata.cs View File

@@ -2,37 +2,63 @@ using System;


namespace Discord 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 public interface IInviteMetadata : IInvite
{ {
/// <summary> /// <summary>
/// Gets the user that created this invite. /// Gets the user that created this invite.
/// </summary> /// </summary>
/// <returns>
/// A generic <see cref="IUser"/> that created this invite.
/// </returns>
IUser Inviter { get; } IUser Inviter { get; }
/// <summary> /// <summary>
/// Returns <c>true</c> if this invite was revoked.
/// Determines whether the invite has been revoked.
/// </summary> /// </summary>
/// <returns>
/// <c>true</c> if this invite was revoked; otherwise <c>false</c>.
/// </returns>
bool IsRevoked { get; } bool IsRevoked { get; }
/// <summary> /// <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> /// </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; } bool IsTemporary { get; }
/// <summary> /// <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> /// </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; } int? MaxAge { get; }
/// <summary> /// <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> /// </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; } int? MaxUses { get; }
/// <summary> /// <summary>
/// Gets the amount of times this invite has been used.
/// Gets the number of times this invite has been used.
/// </summary> /// </summary>
/// <returns>
/// An <see cref="int"/> representing the number of times this invite has been used.
/// </returns>
int Uses { get; } int Uses { get; }
/// <summary> /// <summary>
/// Gets when this invite was created. /// Gets when this invite was created.
/// </summary> /// </summary>
/// <returns>
/// A <see cref="DateTimeOffset"/> representing the time of which the invite was first created.
/// </returns>
DateTimeOffset CreatedAt { get; } DateTimeOffset CreatedAt { get; }
} }
} }

+ 3
- 0
src/Discord.Net.Rest/Entities/Channels/RestChannel.cs View File

@@ -6,6 +6,9 @@ using Model = Discord.API.Channel;


namespace Discord.Rest namespace Discord.Rest
{ {
/// <summary>
/// Represents a generic REST-based channel.
/// </summary>
public class RestChannel : RestEntity<ulong>, IChannel, IUpdateable public class RestChannel : RestEntity<ulong>, IChannel, IUpdateable
{ {
/// <inheritdoc /> /// <inheritdoc />


+ 29
- 1
src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs View File

@@ -10,7 +10,7 @@ using Model = Discord.API.Channel;
namespace Discord.Rest namespace Discord.Rest
{ {
/// <summary> /// <summary>
/// Represents a REST-based DM channel.
/// Represents a REST-based direct-message channel.
/// </summary> /// </summary>
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] [DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestDMChannel : RestChannel, IDMChannel, IRestPrivateChannel, IRestMessageChannel public class RestDMChannel : RestChannel, IDMChannel, IRestPrivateChannel, IRestMessageChannel
@@ -74,18 +74,46 @@ namespace Discord.Rest
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); => ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);


/// <inheritdoc /> /// <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) public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);


/// <inheritdoc /> /// <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) 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); => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, options);
/// <inheritdoc /> /// <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) 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); => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, options);


/// <inheritdoc />
public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
=> ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options); => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options);
/// <inheritdoc />
public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
=> ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options); => ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options);




+ 2
- 0
src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs View File

@@ -83,8 +83,10 @@ namespace Discord.Rest
public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); => ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);


/// <inheritdoc />
public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
=> ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options); => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options);
/// <inheritdoc />
public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
=> ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options); => ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options);




+ 1
- 1
src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs View File

@@ -8,7 +8,7 @@ using Model = Discord.API.Channel;
namespace Discord.Rest namespace Discord.Rest
{ {
/// <summary> /// <summary>
/// Represents a private REST group channel.
/// Represents a private REST-based group channel.
/// </summary> /// </summary>
public class RestGuildChannel : RestChannel, IGuildChannel public class RestGuildChannel : RestChannel, IGuildChannel
{ {


+ 63
- 1
src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs View File

@@ -8,14 +8,20 @@ using Model = Discord.API.Channel;


namespace Discord.Rest namespace Discord.Rest
{ {
/// <summary>
/// Represents a REST-based channel in a guild that can send and receive messages.
/// </summary>
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] [DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestTextChannel : RestGuildChannel, IRestMessageChannel, ITextChannel public class RestTextChannel : RestGuildChannel, IRestMessageChannel, ITextChannel
{ {
/// <inheritdoc />
public string Topic { get; private set; } public string Topic { get; private set; }


/// <inheritdoc />
public string Mention => MentionUtils.MentionChannel(Id); public string Mention => MentionUtils.MentionChannel(Id);


private bool _nsfw; private bool _nsfw;
/// <inheritdoc />
public bool IsNsfw => _nsfw || ChannelHelper.IsNsfw(this); public bool IsNsfw => _nsfw || ChannelHelper.IsNsfw(this);


internal RestTextChannel(BaseDiscordClient discord, IGuild guild, ulong id) internal RestTextChannel(BaseDiscordClient discord, IGuild guild, ulong id)
@@ -36,6 +42,7 @@ namespace Discord.Rest
_nsfw = model.Nsfw.GetValueOrDefault(); _nsfw = model.Nsfw.GetValueOrDefault();
} }


/// <inheritdoc />
public async Task ModifyAsync(Action<TextChannelProperties> func, RequestOptions options = null) public async Task ModifyAsync(Action<TextChannelProperties> func, RequestOptions options = null)
{ {
var model = await ChannelHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false); 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) public IAsyncEnumerable<IReadOnlyCollection<RestGuildUser>> GetUsersAsync(RequestOptions options = null)
=> ChannelHelper.GetUsersAsync(this, Guild, Discord, null, null, options); => ChannelHelper.GetUsersAsync(this, Guild, Discord, null, null, options);


/// <inheritdoc />
public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null) public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null)
=> ChannelHelper.GetMessageAsync(this, Discord, id, options); => ChannelHelper.GetMessageAsync(this, Discord, id, options);
/// <inheritdoc />
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
=> ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, options); => 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) public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, options); => 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) 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); => ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options);
/// <inheritdoc />
public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); => 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) public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); => 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) 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); => 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) 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); => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, options);


/// <inheritdoc />
public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
=> ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options); => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options);
/// <inheritdoc />
public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
=> ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options); => ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options);


/// <inheritdoc />
public Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null) public Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null)
=> ChannelHelper.DeleteMessagesAsync(this, Discord, messages.Select(x => x.Id), options); => ChannelHelper.DeleteMessagesAsync(this, Discord, messages.Select(x => x.Id), options);
/// <inheritdoc />
public Task DeleteMessagesAsync(IEnumerable<ulong> messageIds, RequestOptions options = null) public Task DeleteMessagesAsync(IEnumerable<ulong> messageIds, RequestOptions options = null)
=> ChannelHelper.DeleteMessagesAsync(this, Discord, messageIds, options); => ChannelHelper.DeleteMessagesAsync(this, Discord, messageIds, options);


/// <inheritdoc />
public Task TriggerTypingAsync(RequestOptions options = null) public Task TriggerTypingAsync(RequestOptions options = null)
=> ChannelHelper.TriggerTypingAsync(this, Discord, options); => ChannelHelper.TriggerTypingAsync(this, Discord, options);
public IDisposable EnterTypingState(RequestOptions options = null) public IDisposable EnterTypingState(RequestOptions options = null)
=> ChannelHelper.EnterTypingState(this, Discord, options); => ChannelHelper.EnterTypingState(this, Discord, options);

public Task<RestWebhook> CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null) public Task<RestWebhook> CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null)
=> ChannelHelper.CreateWebhookAsync(this, Discord, name, avatar, options); => ChannelHelper.CreateWebhookAsync(this, Discord, name, avatar, options);
public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null) public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null)
@@ -92,14 +138,18 @@ namespace Discord.Rest
private string DebuggerDisplay => $"{Name} ({Id}, Text)"; private string DebuggerDisplay => $"{Name} ({Id}, Text)";


//ITextChannel //ITextChannel
/// <inheritdoc />
async Task<IWebhook> ITextChannel.CreateWebhookAsync(string name, Stream avatar, RequestOptions options) async Task<IWebhook> ITextChannel.CreateWebhookAsync(string name, Stream avatar, RequestOptions options)
=> await CreateWebhookAsync(name, avatar, options).ConfigureAwait(false); => await CreateWebhookAsync(name, avatar, options).ConfigureAwait(false);
/// <inheritdoc />
async Task<IWebhook> ITextChannel.GetWebhookAsync(ulong id, RequestOptions options) async Task<IWebhook> ITextChannel.GetWebhookAsync(ulong id, RequestOptions options)
=> await GetWebhookAsync(id, options).ConfigureAwait(false); => await GetWebhookAsync(id, options).ConfigureAwait(false);
/// <inheritdoc />
async Task<IReadOnlyCollection<IWebhook>> ITextChannel.GetWebhooksAsync(RequestOptions options) async Task<IReadOnlyCollection<IWebhook>> ITextChannel.GetWebhooksAsync(RequestOptions options)
=> await GetWebhooksAsync(options).ConfigureAwait(false); => await GetWebhooksAsync(options).ConfigureAwait(false);


//IMessageChannel //IMessageChannel
/// <inheritdoc />
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
@@ -107,6 +157,7 @@ namespace Discord.Rest
else else
return null; return null;
} }
/// <inheritdoc />
IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
@@ -114,6 +165,7 @@ namespace Discord.Rest
else else
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
} }
/// <inheritdoc />
IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
@@ -121,6 +173,7 @@ namespace Discord.Rest
else else
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
} }
/// <inheritdoc />
IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
@@ -128,20 +181,26 @@ namespace Discord.Rest
else else
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
} }
/// <inheritdoc />
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);


/// <inheritdoc />
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, embed, options).ConfigureAwait(false); => 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) 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); => await SendFileAsync(stream, filename, text, isTTS, embed, options).ConfigureAwait(false);
/// <inheritdoc />
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options)
=> await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false); => await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false);
/// <inheritdoc />
IDisposable IMessageChannel.EnterTypingState(RequestOptions options) IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
=> EnterTypingState(options); => EnterTypingState(options);


//IGuildChannel //IGuildChannel
/// <inheritdoc />
async Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
@@ -149,6 +208,7 @@ namespace Discord.Rest
else else
return null; return null;
} }
/// <inheritdoc />
IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
@@ -158,6 +218,7 @@ namespace Discord.Rest
} }


//IChannel //IChannel
/// <inheritdoc />
async Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
@@ -165,6 +226,7 @@ namespace Discord.Rest
else else
return null; return null;
} }
/// <inheritdoc />
IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)


+ 9
- 0
src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs View File

@@ -8,10 +8,15 @@ using Model = Discord.API.Channel;


namespace Discord.Rest namespace Discord.Rest
{ {
/// <summary>
/// Represents a REST-based voice channel in a guild.
/// </summary>
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] [DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestVoiceChannel : RestGuildChannel, IVoiceChannel, IRestAudioChannel public class RestVoiceChannel : RestGuildChannel, IVoiceChannel, IRestAudioChannel
{ {
/// <inheritdoc />
public int Bitrate { get; private set; } public int Bitrate { get; private set; }
/// <inheritdoc />
public int? UserLimit { get; private set; } public int? UserLimit { get; private set; }


internal RestVoiceChannel(BaseDiscordClient discord, IGuild guild, ulong id) internal RestVoiceChannel(BaseDiscordClient discord, IGuild guild, ulong id)
@@ -24,6 +29,7 @@ namespace Discord.Rest
entity.Update(model); entity.Update(model);
return entity; return entity;
} }
/// <inheritdoc />
internal override void Update(Model model) internal override void Update(Model model)
{ {
base.Update(model); base.Update(model);
@@ -32,6 +38,7 @@ namespace Discord.Rest
UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null; UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
} }


/// <inheritdoc />
public async Task ModifyAsync(Action<VoiceChannelProperties> func, RequestOptions options = null) public async Task ModifyAsync(Action<VoiceChannelProperties> func, RequestOptions options = null)
{ {
var model = await ChannelHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false); 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(); Task<IAudioClient> IAudioChannel.ConnectAsync(Action<IAudioClient> configAction) => throw new NotSupportedException();


//IGuildChannel //IGuildChannel
/// <inheritdoc />
Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
=> Task.FromResult<IGuildUser>(null); => Task.FromResult<IGuildUser>(null);
/// <inheritdoc />
IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
=> AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>(); => AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>();
} }


+ 15
- 0
src/Discord.Net.Rest/Entities/Guilds/RestBan.cs View File

@@ -3,9 +3,18 @@ using Model = Discord.API.Ban;


namespace Discord.Rest namespace Discord.Rest
{ {
/// <summary>
/// Represents a REST-based ban object.
/// </summary>
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] [DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestBan : IBan 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; } public RestUser User { get; }
/// <inheritdoc /> /// <inheritdoc />
public string Reason { get; } public string Reason { get; }
@@ -20,6 +29,12 @@ namespace Discord.Rest
return new RestBan(RestUser.Create(client, model.User), model.Reason); 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(); public override string ToString() => User.ToString();
private string DebuggerDisplay => $"{User}: {Reason}"; private string DebuggerDisplay => $"{User}: {Reason}";




Loading…
Cancel
Save