diff --git a/src/Disqord.Core/Entities/Core/Invite/IInvite.cs b/src/Disqord.Core/Entities/Core/Invite/IInvite.cs index 0432c3851..a11808181 100644 --- a/src/Disqord.Core/Entities/Core/Invite/IInvite.cs +++ b/src/Disqord.Core/Entities/Core/Invite/IInvite.cs @@ -8,6 +8,11 @@ namespace Disqord; /// public interface IInvite : IPossiblyChannelEntity, IClientEntity, IJsonUpdatable { + /// + /// Gets the type of this invite. + /// + InviteType Type { get; } + /// /// Gets the code of this invite. /// diff --git a/src/Disqord.Core/Entities/Transient/Invite/TransientInvite.cs b/src/Disqord.Core/Entities/Transient/Invite/TransientInvite.cs index fa3576063..1cfd893ff 100644 --- a/src/Disqord.Core/Entities/Transient/Invite/TransientInvite.cs +++ b/src/Disqord.Core/Entities/Transient/Invite/TransientInvite.cs @@ -9,6 +9,9 @@ public class TransientInvite : TransientClientEntity, IInvite /// public Snowflake? ChannelId => Model.Channel?.Id; + /// + public InviteType Type => Model.Type; + /// public string Code => Model.Code; @@ -50,7 +53,7 @@ public TransientInvite(IClient client, InviteJsonModel model) public static IInvite Create(IClient client, InviteJsonModel model) { - return model.Guild.HasValue + return model.Type == InviteType.Guild ? new TransientGuildInvite(client, model) : new TransientInvite(client, model); } diff --git a/src/Disqord.Core/Enums/InviteType.cs b/src/Disqord.Core/Enums/InviteType.cs new file mode 100644 index 000000000..96207c8b8 --- /dev/null +++ b/src/Disqord.Core/Enums/InviteType.cs @@ -0,0 +1,22 @@ +namespace Disqord; + +/// +/// Represents the type of an invite. +/// +public enum InviteType +{ + /// + /// An invitation to a guild. + /// + Guild = 0, + + /// + /// An invitation to a group private channel. + /// + Group = 1, + + /// + /// An invitation to add the inviter as a friend. + /// + Friend = 2 +} diff --git a/src/Disqord.Core/Models/Invite/InviteJsonModel.cs b/src/Disqord.Core/Models/Invite/InviteJsonModel.cs index 69e79a055..84ae52af2 100644 --- a/src/Disqord.Core/Models/Invite/InviteJsonModel.cs +++ b/src/Disqord.Core/Models/Invite/InviteJsonModel.cs @@ -6,6 +6,9 @@ namespace Disqord.Models; public class InviteJsonModel : JsonModel { + [JsonProperty("type")] + public InviteType Type; + [JsonProperty("code")] public string Code = null!;