Browse Source

Move invites-related methods from IGuildChannel to INestedChannel

pull/1172/head
Still Hsu 7 years ago
parent
commit
a7ec6c9c74
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
4 changed files with 40 additions and 57 deletions
  1. +0
    -39
      src/Discord.Net.Core/Entities/Channels/IGuildChannel.cs
  2. +40
    -0
      src/Discord.Net.Core/Entities/Channels/INestedChannel.cs
  3. +0
    -10
      src/Discord.Net.Rest/Entities/Channels/RestCategoryChannel.cs
  4. +0
    -8
      src/Discord.Net.WebSocket/Entities/Channels/SocketCategoryChannel.cs

+ 0
- 39
src/Discord.Net.Core/Entities/Channels/IGuildChannel.cs View File

@@ -44,45 +44,6 @@ namespace Discord
/// </returns>
IReadOnlyCollection<Overwrite> PermissionOverwrites { get; }

/// <summary>
/// Creates a new invite to this channel.
/// </summary>
/// <example>
/// The following example creates a new invite to this channel; the invite lasts for 12 hours and can only
/// be used 3 times throughout its lifespan.
/// <code language="cs">
/// await guildChannel.CreateInviteAsync(maxAge: 43200, maxUses: 3);
/// </code>
/// </example>
/// <param name="maxAge">The time (in seconds) until the invite expires. Set to <c>null</c> to never expire.</param>
/// <param name="maxUses">The max amount of times this invite may be used. Set to <c>null</c> to have unlimited uses.</param>
/// <param name="isTemporary">If <c>true</c>, the user accepting this invite will be kicked from the guild after closing their client.</param>
/// <param name="isUnique">If <c>true</c>, don't try to reuse a similar invite (useful for creating many unique one time use invites).</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous invite creation operation. The task result contains an invite
/// metadata object containing information for the created invite.
/// </returns>
Task<IInviteMetadata> CreateInviteAsync(int? maxAge = 86400, int? maxUses = default(int?), bool isTemporary = false, bool isUnique = false, RequestOptions options = null);
/// <summary>
/// Gets a collection of all invites to this channel.
/// </summary>
/// <example>
/// The following example gets all of the invites that have been created in this channel and selects the
/// most used invite.
/// <code language="cs">
/// var invites = await channel.GetInvitesAsync();
/// if (invites.Count == 0) return;
/// var invite = invites.OrderByDescending(x => x.Uses).FirstOrDefault();
/// </code>
/// </example>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous get operation. The task result contains a read-only collection
/// of invite metadata that are created for this channel.
/// </returns>
Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null);

/// <summary>
/// Modifies this guild channel.
/// </summary>


+ 40
- 0
src/Discord.Net.Core/Entities/Channels/INestedChannel.cs View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Discord
@@ -25,5 +26,44 @@ namespace Discord
/// representing the parent of this channel; <c>null</c> if none is set.
/// </returns>
Task<ICategoryChannel> GetCategoryAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);

/// <summary>
/// Creates a new invite to this channel.
/// </summary>
/// <example>
/// The following example creates a new invite to this channel; the invite lasts for 12 hours and can only
/// be used 3 times throughout its lifespan.
/// <code language="cs">
/// await guildChannel.CreateInviteAsync(maxAge: 43200, maxUses: 3);
/// </code>
/// </example>
/// <param name="maxAge">The time (in seconds) until the invite expires. Set to <c>null</c> to never expire.</param>
/// <param name="maxUses">The max amount of times this invite may be used. Set to <c>null</c> to have unlimited uses.</param>
/// <param name="isTemporary">If <c>true</c>, the user accepting this invite will be kicked from the guild after closing their client.</param>
/// <param name="isUnique">If <c>true</c>, don't try to reuse a similar invite (useful for creating many unique one time use invites).</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous invite creation operation. The task result contains an invite
/// metadata object containing information for the created invite.
/// </returns>
Task<IInviteMetadata> CreateInviteAsync(int? maxAge = 86400, int? maxUses = default(int?), bool isTemporary = false, bool isUnique = false, RequestOptions options = null);
/// <summary>
/// Gets a collection of all invites to this channel.
/// </summary>B
/// <example>
/// The following example gets all of the invites that have been created in this channel and selects the
/// most used invite.
/// <code language="cs">
/// var invites = await channel.GetInvitesAsync();
/// if (invites.Count == 0) return;
/// var invite = invites.OrderByDescending(x => x.Uses).FirstOrDefault();
/// </code>
/// </example>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous get operation. The task result contains a read-only collection
/// of invite metadata that are created for this channel.
/// </returns>
Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null);
}
}

+ 0
- 10
src/Discord.Net.Rest/Entities/Channels/RestCategoryChannel.cs View File

@@ -25,16 +25,6 @@ namespace Discord.Rest

private string DebuggerDisplay => $"{Name} ({Id}, Category)";

// IGuildChannel
/// <inheritdoc />
/// <exception cref="NotSupportedException">This method is not supported with category channels.</exception>
Task<IInviteMetadata> IGuildChannel.CreateInviteAsync(int? maxAge, int? maxUses, bool isTemporary, bool isUnique, RequestOptions options)
=> throw new NotSupportedException();
/// <inheritdoc />
/// <exception cref="NotSupportedException">This method is not supported with category channels.</exception>
Task<IReadOnlyCollection<IInviteMetadata>> IGuildChannel.GetInvitesAsync(RequestOptions options)
=> throw new NotSupportedException();

//IChannel
/// <inheritdoc />
/// <exception cref="NotSupportedException">This method is not supported with category channels.</exception>


+ 0
- 8
src/Discord.Net.WebSocket/Entities/Channels/SocketCategoryChannel.cs View File

@@ -67,14 +67,6 @@ namespace Discord.WebSocket
/// <inheritdoc />
Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
=> Task.FromResult<IGuildUser>(GetUser(id));
/// <inheritdoc />
/// <exception cref="NotSupportedException">This method is not supported with category channels.</exception>
Task<IInviteMetadata> IGuildChannel.CreateInviteAsync(int? maxAge, int? maxUses, bool isTemporary, bool isUnique, RequestOptions options)
=> throw new NotSupportedException();
/// <inheritdoc />
/// <exception cref="NotSupportedException">This method is not supported with category channels.</exception>
Task<IReadOnlyCollection<IInviteMetadata>> IGuildChannel.GetInvitesAsync(RequestOptions options)
=> throw new NotSupportedException();

//IChannel
/// <inheritdoc />


Loading…
Cancel
Save