Mark guild optional in invite & general invite improvement (#1094)

* Mark guild as optional for invite

* Mark partial InviteMetadata members as Optional<T>

* Some of them aren't sent when requesting through the general GET invite endpoint

* Remove GetInviteParams

* It was kinda stupid in the first place, might as well always get the count instead of having to ask the user whether they want the two fields filled or not.

* Add ChannelType property

* Add vanity invite support
This commit is contained in:
Still Hsu
2018-07-03 05:02:38 +08:00
committed by Christopher F
parent 4bc06a0a54
commit ffe994a9df
17 changed files with 84 additions and 52 deletions

View File

@@ -0,0 +1,11 @@
namespace Discord
{
public enum ChannelType
{
Text = 0,
DM = 1,
Voice = 2,
Group = 3,
Category = 4
}
}

View File

@@ -120,6 +120,15 @@ namespace Discord
/// <summary> Gets a collection of all invites to this guild. </summary>
Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null);
/// <summary>
/// Gets the vanity invite URL of this guild.
/// </summary>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// An awaitable <see cref="Task"/> containing the partial metadata of the vanity invite found within
/// this guild.
/// </returns>
Task<IInviteMetadata> GetVanityInviteAsync(RequestOptions options = null);
/// <summary> Gets the role in this guild with the provided id, or null if not found. </summary>
IRole GetRole(ulong id);

View File

@@ -1,5 +1,3 @@
using System.Threading.Tasks;
namespace Discord
{
public interface IInvite : IEntity<string>, IDeletable
@@ -11,6 +9,8 @@ namespace Discord
/// <summary> Gets the channel this invite is linked to. </summary>
IChannel Channel { get; }
/// <summary> Gets the type of the channel this invite is linked to. </summary>
ChannelType ChannelType { get; }
/// <summary> Gets the id of the channel this invite is linked to. </summary>
ulong ChannelId { get; }
/// <summary> Gets the name of the channel this invite is linked to. </summary>
@@ -19,7 +19,7 @@ namespace Discord
/// <summary> Gets the guild this invite is linked to. </summary>
IGuild Guild { get; }
/// <summary> Gets the id of the guild this invite is linked to. </summary>
ulong GuildId { get; }
ulong? GuildId { get; }
/// <summary> Gets the name of the guild this invite is linked to. </summary>
string GuildName { get; }
/// <summary> Gets the approximated count of online members in the guild. </summary>

View File

@@ -1,4 +1,4 @@
using System;
using System;
namespace Discord
{
@@ -15,8 +15,8 @@ namespace Discord
/// <summary> Gets the max amount of times this invite may be used, or null if there is no limit. </summary>
int? MaxUses { get; }
/// <summary> Gets the amount of times this invite has been used. </summary>
int Uses { get; }
int? Uses { get; }
/// <summary> Gets when this invite was created. </summary>
DateTimeOffset CreatedAt { get; }
DateTimeOffset? CreatedAt { get; }
}
}
}