@@ -20,6 +20,13 @@ namespace Discord | |||||
/// </returns> | /// </returns> | ||||
string Url { get; } | string Url { get; } | ||||
/// <summary> | |||||
/// Gets the user that created this invite. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// A user that created this invite. | |||||
/// </returns> | |||||
IUser Inviter { get; } | |||||
/// <summary> | /// <summary> | ||||
/// Gets the channel this invite is linked to. | /// Gets the channel this invite is linked to. | ||||
/// </summary> | /// </summary> | ||||
@@ -83,5 +90,19 @@ namespace Discord | |||||
/// invite points to; <c>null</c> if one cannot be obtained. | /// invite points to; <c>null</c> if one cannot be obtained. | ||||
/// </returns> | /// </returns> | ||||
int? MemberCount { get; } | int? MemberCount { get; } | ||||
/// <summary> | |||||
/// Gets the user this invite is linked to via <see cref="TargetUserType"/>. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// A user that is linked to this invite. | |||||
/// </returns> | |||||
IUser TargetUser { get; } | |||||
/// <summary> | |||||
/// Gets the type of the linked <see cref="TargetUser"/> for this invite. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// The type of the linked user that is linked to this invite. | |||||
/// </returns> | |||||
TargetUserType TargetUserType { get; } | |||||
} | } | ||||
} | } |
@@ -7,20 +7,6 @@ namespace Discord | |||||
/// </summary> | /// </summary> | ||||
public interface IInviteMetadata : IInvite | public interface IInviteMetadata : IInvite | ||||
{ | { | ||||
/// <summary> | |||||
/// Gets the user that created this invite. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// A user that created this invite. | |||||
/// </returns> | |||||
IUser Inviter { get; } | |||||
/// <summary> | |||||
/// Gets a value that indicates 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> | /// <summary> | ||||
/// Gets a value that indicates whether the invite is a temporary one. | /// Gets a value that indicates whether the invite is a temporary one. | ||||
/// </summary> | /// </summary> | ||||
@@ -36,7 +22,7 @@ namespace Discord | |||||
/// An <see cref="int"/> representing the time in seconds until this invite expires; <c>null</c> if this | /// An <see cref="int"/> representing the time in seconds until this invite expires; <c>null</c> if this | ||||
/// invite never expires. | /// invite never expires. | ||||
/// </returns> | /// </returns> | ||||
int? MaxAge { get; } | |||||
int MaxAge { get; } | |||||
/// <summary> | /// <summary> | ||||
/// Gets the max number of uses this invite may have. | /// Gets the max number of uses this invite may have. | ||||
/// </summary> | /// </summary> | ||||
@@ -44,20 +30,20 @@ namespace Discord | |||||
/// An <see cref="int"/> representing the number of uses this invite may be accepted until it is removed | /// 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. | /// from the guild; <c>null</c> if none is set. | ||||
/// </returns> | /// </returns> | ||||
int? MaxUses { get; } | |||||
int MaxUses { get; } | |||||
/// <summary> | /// <summary> | ||||
/// Gets the number of times this invite has been used. | /// Gets the number of times this invite has been used. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// An <see cref="int"/> representing the number of times this invite has been used. | /// An <see cref="int"/> representing the number of times this invite has been used. | ||||
/// </returns> | /// </returns> | ||||
int? Uses { get; } | |||||
int Uses { get; } | |||||
/// <summary> | /// <summary> | ||||
/// Gets when this invite was created. | /// Gets when this invite was created. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// A <see cref="DateTimeOffset"/> representing the time of which the invite was first created. | /// A <see cref="DateTimeOffset"/> representing the time of which the invite was first created. | ||||
/// </returns> | /// </returns> | ||||
DateTimeOffset? CreatedAt { get; } | |||||
DateTimeOffset CreatedAt { get; } | |||||
} | } | ||||
} | } |
@@ -0,0 +1,14 @@ | |||||
namespace Discord | |||||
{ | |||||
public enum TargetUserType | |||||
{ | |||||
/// <summary> | |||||
/// The invite whose target user type is not defined. | |||||
/// </summary> | |||||
Undefined = 0, | |||||
/// <summary> | |||||
/// The invite is for a Go Live stream. | |||||
/// </summary> | |||||
Stream = 1 | |||||
} | |||||
} |
@@ -11,9 +11,15 @@ namespace Discord.API | |||||
public Optional<InviteGuild> Guild { get; set; } | public Optional<InviteGuild> Guild { get; set; } | ||||
[JsonProperty("channel")] | [JsonProperty("channel")] | ||||
public InviteChannel Channel { get; set; } | public InviteChannel Channel { get; set; } | ||||
[JsonProperty("inviter")] | |||||
public Optional<User> Inviter { get; set; } | |||||
[JsonProperty("approximate_presence_count")] | [JsonProperty("approximate_presence_count")] | ||||
public Optional<int?> PresenceCount { get; set; } | public Optional<int?> PresenceCount { get; set; } | ||||
[JsonProperty("approximate_member_count")] | [JsonProperty("approximate_member_count")] | ||||
public Optional<int?> MemberCount { get; set; } | public Optional<int?> MemberCount { get; set; } | ||||
[JsonProperty("target_user")] | |||||
public Optional<User> TargetUser { get; set; } | |||||
[JsonProperty("target_user_type")] | |||||
public Optional<TargetUserType> TargetUserType { get; set; } | |||||
} | } | ||||
} | } |
@@ -6,19 +6,15 @@ namespace Discord.API | |||||
{ | { | ||||
internal class InviteMetadata : Invite | internal class InviteMetadata : Invite | ||||
{ | { | ||||
[JsonProperty("inviter")] | |||||
public User Inviter { get; set; } | |||||
[JsonProperty("uses")] | [JsonProperty("uses")] | ||||
public Optional<int> Uses { get; set; } | |||||
public int Uses { get; set; } | |||||
[JsonProperty("max_uses")] | [JsonProperty("max_uses")] | ||||
public Optional<int> MaxUses { get; set; } | |||||
public int MaxUses { get; set; } | |||||
[JsonProperty("max_age")] | [JsonProperty("max_age")] | ||||
public Optional<int> MaxAge { get; set; } | |||||
public int MaxAge { get; set; } | |||||
[JsonProperty("temporary")] | [JsonProperty("temporary")] | ||||
public bool Temporary { get; set; } | public bool Temporary { get; set; } | ||||
[JsonProperty("created_at")] | [JsonProperty("created_at")] | ||||
public Optional<DateTimeOffset> CreatedAt { get; set; } | |||||
[JsonProperty("revoked")] | |||||
public bool Revoked { get; set; } | |||||
public DateTimeOffset CreatedAt { get; set; } | |||||
} | } | ||||
} | } |
@@ -21,6 +21,12 @@ namespace Discord.Rest | |||||
public ulong ChannelId { get; private set; } | public ulong ChannelId { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public ulong? GuildId { get; private set; } | public ulong? GuildId { get; private set; } | ||||
/// <inheritdoc /> | |||||
public IUser Inviter { get; private set; } | |||||
/// <inheritdoc /> | |||||
public IUser TargetUser { get; private set; } | |||||
/// <inheritdoc /> | |||||
public TargetUserType TargetUserType { get; private set; } | |||||
internal IChannel Channel { get; } | internal IChannel Channel { get; } | ||||
internal IGuild Guild { get; } | internal IGuild Guild { get; } | ||||
@@ -50,6 +56,9 @@ namespace Discord.Rest | |||||
MemberCount = model.MemberCount.IsSpecified ? model.MemberCount.Value : null; | MemberCount = model.MemberCount.IsSpecified ? model.MemberCount.Value : null; | ||||
PresenceCount = model.PresenceCount.IsSpecified ? model.PresenceCount.Value : null; | PresenceCount = model.PresenceCount.IsSpecified ? model.PresenceCount.Value : null; | ||||
ChannelType = (ChannelType)model.Channel.Type; | ChannelType = (ChannelType)model.Channel.Type; | ||||
Inviter = model.Inviter.IsSpecified ? RestUser.Create(Discord, model.Inviter.Value) : null; | |||||
TargetUser = model.TargetUser.IsSpecified ? RestUser.Create(Discord, model.TargetUser.Value) : null; | |||||
TargetUserType = model.TargetUserType.IsSpecified ? model.TargetUserType.Value : TargetUserType.Undefined; | |||||
} | } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
@@ -6,25 +6,19 @@ namespace Discord.Rest | |||||
/// <summary> Represents additional information regarding the REST-based invite object. </summary> | /// <summary> Represents additional information regarding the REST-based invite object. </summary> | ||||
public class RestInviteMetadata : RestInvite, IInviteMetadata | public class RestInviteMetadata : RestInvite, IInviteMetadata | ||||
{ | { | ||||
private long? _createdAtTicks; | |||||
private long _createdAtTicks; | |||||
/// <inheritdoc /> | |||||
public bool IsRevoked { get; private set; } | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public bool IsTemporary { get; private set; } | public bool IsTemporary { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public int? MaxAge { get; private set; } | |||||
public int MaxAge { get; private set; } | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public int? MaxUses { get; private set; } | |||||
public int MaxUses { get; private set; } | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public int? Uses { get; private set; } | |||||
/// <summary> | |||||
/// Gets the user that created this invite. | |||||
/// </summary> | |||||
public RestUser Inviter { get; private set; } | |||||
public int Uses { get; private set; } | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public DateTimeOffset? CreatedAt => DateTimeUtils.FromTicks(_createdAtTicks); | |||||
public DateTimeOffset CreatedAt => DateTimeUtils.FromTicks(_createdAtTicks); | |||||
internal RestInviteMetadata(BaseDiscordClient discord, IGuild guild, IChannel channel, string id) | internal RestInviteMetadata(BaseDiscordClient discord, IGuild guild, IChannel channel, string id) | ||||
: base(discord, guild, channel, id) | : base(discord, guild, channel, id) | ||||
@@ -39,16 +33,11 @@ namespace Discord.Rest | |||||
internal void Update(Model model) | internal void Update(Model model) | ||||
{ | { | ||||
base.Update(model); | base.Update(model); | ||||
Inviter = model.Inviter != null ? RestUser.Create(Discord, model.Inviter) : null; | |||||
IsRevoked = model.Revoked; | |||||
IsTemporary = model.Temporary; | IsTemporary = model.Temporary; | ||||
MaxAge = model.MaxAge.IsSpecified ? model.MaxAge.Value : (int?)null; | |||||
MaxUses = model.MaxUses.IsSpecified ? model.MaxUses.Value : (int?)null; | |||||
Uses = model.Uses.IsSpecified ? model.Uses.Value : (int?)null; | |||||
_createdAtTicks = model.CreatedAt.IsSpecified ? model.CreatedAt.Value.UtcTicks : (long?)null; | |||||
MaxAge = model.MaxAge; | |||||
MaxUses = model.MaxUses; | |||||
Uses = model.Uses; | |||||
_createdAtTicks = model.CreatedAt.UtcTicks; | |||||
} | } | ||||
/// <inheritdoc /> | |||||
IUser IInviteMetadata.Inviter => Inviter; | |||||
} | } | ||||
} | } |