diff --git a/src/Discord.Net.Core/Entities/Invites/IInvite.cs b/src/Discord.Net.Core/Entities/Invites/IInvite.cs index 993f1f047..47ffffacb 100644 --- a/src/Discord.Net.Core/Entities/Invites/IInvite.cs +++ b/src/Discord.Net.Core/Entities/Invites/IInvite.cs @@ -20,6 +20,13 @@ namespace Discord /// string Url { get; } + /// + /// Gets the user that created this invite. + /// + /// + /// A user that created this invite. + /// + IUser Inviter { get; } /// /// Gets the channel this invite is linked to. /// @@ -83,5 +90,19 @@ namespace Discord /// invite points to; null if one cannot be obtained. /// int? MemberCount { get; } + /// + /// Gets the user this invite is linked to via . + /// + /// + /// A user that is linked to this invite. + /// + IUser TargetUser { get; } + /// + /// Gets the type of the linked for this invite. + /// + /// + /// The type of the linked user that is linked to this invite. + /// + TargetUserType TargetUserType { get; } } } diff --git a/src/Discord.Net.Core/Entities/Invites/IInviteMetadata.cs b/src/Discord.Net.Core/Entities/Invites/IInviteMetadata.cs index 471dc377f..c64b3205b 100644 --- a/src/Discord.Net.Core/Entities/Invites/IInviteMetadata.cs +++ b/src/Discord.Net.Core/Entities/Invites/IInviteMetadata.cs @@ -8,28 +8,22 @@ namespace Discord public interface IInviteMetadata : IInvite { /// - /// Gets the user that created this invite. + /// Gets a value that indicates whether the invite is a temporary one. /// /// - /// A user that created this invite. + /// true if users accepting this invite will be removed from the guild when they log off; otherwise + /// false. /// - IUser Inviter { get; } + bool IsTemporary { get; } /// /// Gets a value that indicates whether the invite has been revoked. /// /// /// true if this invite was revoked; otherwise false. /// + [Obsolete("This property doesn't exist anymore and shouldn't be used.")] bool IsRevoked { get; } /// - /// Gets a value that indicates whether the invite is a temporary one. - /// - /// - /// true if users accepting this invite will be removed from the guild when they log off; otherwise - /// false. - /// - bool IsTemporary { get; } - /// /// Gets the time (in seconds) until the invite expires. /// /// diff --git a/src/Discord.Net.Rest/API/Common/Invite.cs b/src/Discord.Net.Rest/API/Common/Invite.cs index 649bc37ec..aba267f34 100644 --- a/src/Discord.Net.Rest/API/Common/Invite.cs +++ b/src/Discord.Net.Rest/API/Common/Invite.cs @@ -11,9 +11,15 @@ namespace Discord.API public Optional Guild { get; set; } [JsonProperty("channel")] public InviteChannel Channel { get; set; } + [JsonProperty("inviter")] + public Optional Inviter { get; set; } [JsonProperty("approximate_presence_count")] public Optional PresenceCount { get; set; } [JsonProperty("approximate_member_count")] public Optional MemberCount { get; set; } + [JsonProperty("target_user")] + public Optional TargetUser { get; set; } + [JsonProperty("target_user_type")] + public Optional TargetUserType { get; set; } } } diff --git a/src/Discord.Net.Rest/API/Common/InviteMetadata.cs b/src/Discord.Net.Rest/API/Common/InviteMetadata.cs index ca019b79b..f818de699 100644 --- a/src/Discord.Net.Rest/API/Common/InviteMetadata.cs +++ b/src/Discord.Net.Rest/API/Common/InviteMetadata.cs @@ -6,19 +6,15 @@ namespace Discord.API { internal class InviteMetadata : Invite { - [JsonProperty("inviter")] - public User Inviter { get; set; } [JsonProperty("uses")] - public Optional Uses { get; set; } + public int Uses { get; set; } [JsonProperty("max_uses")] - public Optional MaxUses { get; set; } + public int MaxUses { get; set; } [JsonProperty("max_age")] - public Optional MaxAge { get; set; } + public int MaxAge { get; set; } [JsonProperty("temporary")] public bool Temporary { get; set; } [JsonProperty("created_at")] - public Optional CreatedAt { get; set; } - [JsonProperty("revoked")] - public bool Revoked { get; set; } + public DateTimeOffset CreatedAt { get; set; } } } diff --git a/src/Discord.Net.Rest/Entities/Invites/RestInvite.cs b/src/Discord.Net.Rest/Entities/Invites/RestInvite.cs index 153eb6c41..95b454c20 100644 --- a/src/Discord.Net.Rest/Entities/Invites/RestInvite.cs +++ b/src/Discord.Net.Rest/Entities/Invites/RestInvite.cs @@ -21,6 +21,12 @@ namespace Discord.Rest public ulong ChannelId { get; private set; } /// public ulong? GuildId { get; private set; } + /// + public IUser Inviter { get; private set; } + /// + public IUser TargetUser { get; private set; } + /// + public TargetUserType TargetUserType { get; private set; } internal IChannel Channel { get; } internal IGuild Guild { get; } @@ -50,6 +56,9 @@ namespace Discord.Rest MemberCount = model.MemberCount.IsSpecified ? model.MemberCount.Value : null; PresenceCount = model.PresenceCount.IsSpecified ? model.PresenceCount.Value : null; 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; } /// diff --git a/src/Discord.Net.Rest/Entities/Invites/RestInviteMetadata.cs b/src/Discord.Net.Rest/Entities/Invites/RestInviteMetadata.cs index 55acd5f45..07ee5851c 100644 --- a/src/Discord.Net.Rest/Entities/Invites/RestInviteMetadata.cs +++ b/src/Discord.Net.Rest/Entities/Invites/RestInviteMetadata.cs @@ -6,9 +6,10 @@ namespace Discord.Rest /// Represents additional information regarding the REST-based invite object. public class RestInviteMetadata : RestInvite, IInviteMetadata { - private long? _createdAtTicks; + private long _createdAtTicks; /// + [Obsolete("This property doesn't exist anymore and shouldn't be used.")] public bool IsRevoked { get; private set; } /// public bool IsTemporary { get; private set; } @@ -18,10 +19,6 @@ namespace Discord.Rest public int? MaxUses { get; private set; } /// public int? Uses { get; private set; } - /// - /// Gets the user that created this invite. - /// - public RestUser Inviter { get; private set; } /// public DateTimeOffset? CreatedAt => DateTimeUtils.FromTicks(_createdAtTicks); @@ -39,16 +36,11 @@ namespace Discord.Rest internal void Update(Model model) { base.Update(model); - Inviter = model.Inviter != null ? RestUser.Create(Discord, model.Inviter) : null; - IsRevoked = model.Revoked; 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; } - - /// - IUser IInviteMetadata.Inviter => Inviter; } } diff --git a/src/Discord.Net.WebSocket/Entities/Invites/SocketInvite.cs b/src/Discord.Net.WebSocket/Entities/Invites/SocketInvite.cs index 902f13935..5dc53a833 100644 --- a/src/Discord.Net.WebSocket/Entities/Invites/SocketInvite.cs +++ b/src/Discord.Net.WebSocket/Entities/Invites/SocketInvite.cs @@ -49,6 +49,7 @@ namespace Discord.WebSocket /// int? IInvite.MemberCount => throw new NotImplementedException(); /// + [Obsolete("This property doesn't exist anymore and shouldn't be used.")] bool IInviteMetadata.IsRevoked => throw new NotImplementedException(); /// public bool IsTemporary { get; private set; } @@ -138,6 +139,8 @@ namespace Discord.WebSocket /// IChannel IInvite.Channel => Channel; /// - IUser IInviteMetadata.Inviter => Inviter; + IUser IInvite.Inviter => Inviter; + /// + IUser IInvite.TargetUser => TargetUser; } }