diff --git a/src/Discord.Net.Core/Entities/Invites/IInvite.cs b/src/Discord.Net.Core/Entities/Invites/IInvite.cs
index 53b483d21..eb1f6a243 100644
--- a/src/Discord.Net.Core/Entities/Invites/IInvite.cs
+++ b/src/Discord.Net.Core/Entities/Invites/IInvite.cs
@@ -56,13 +56,11 @@ namespace Discord
///
/// Gets the guild this invite is linked to.
///
- ///
- /// The guild may be partially populated.
- ///
///
/// A guild object representing the guild that the invite points to.
///
IGuild Guild { get; }
+
///
/// Gets the ID of the guild this invite is linked to.
///
diff --git a/src/Discord.Net.Core/Entities/Invites/InviteGuild.cs b/src/Discord.Net.Core/Entities/Invites/InviteGuild.cs
new file mode 100644
index 000000000..a8559215c
--- /dev/null
+++ b/src/Discord.Net.Core/Entities/Invites/InviteGuild.cs
@@ -0,0 +1,143 @@
+using System;
+
+namespace Discord;
+
+public class InviteGuild : ISnowflakeEntity
+{
+ ///
+ public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
+
+ ///
+ public ulong Id { get; private set; }
+
+ ///
+ /// Gets the name of this guild.
+ ///
+ ///
+ /// A string containing the name of this guild.
+ ///
+ public string Name { get; private set; }
+
+ ///
+ /// Gets the description for the guild.
+ ///
+ ///
+ /// The description for the guild; if none is set.
+ ///
+ public string Description { get; private set; }
+
+ ///
+ /// Gets the ID of this guild's splash image.
+ ///
+ ///
+ /// An identifier for the splash image; if none is set.
+ ///
+ public string SplashId { get; private set; }
+
+ ///
+ /// Gets the URL of this guild's splash image.
+ ///
+ ///
+ /// A URL pointing to the guild's splash image; if none is set.
+ ///
+ public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId);
+
+ ///
+ /// Gets the identifier for this guilds banner image.
+ ///
+ ///
+ /// An identifier for the banner image; if none is set.
+ ///
+ public string BannerId { get; private set; }
+
+ ///
+ /// Gets the URL of this guild's banner image.
+ ///
+ ///
+ /// A URL pointing to the guild's banner image; if none is set.
+ ///
+ public string BannerUrl => CDN.GetGuildBannerUrl(Id, BannerId, ImageFormat.Auto);
+
+ ///
+ /// Gets the features for this guild.
+ ///
+ ///
+ /// A flags enum containing all the features for the guild.
+ ///
+ public GuildFeatures Features { get; private set; }
+
+ ///
+ /// Gets the ID of this guild's icon.
+ ///
+ ///
+ /// An identifier for the splash image; if none is set.
+ ///
+ public string IconId { get; private set; }
+
+ ///
+ /// Gets the URL of this guild's icon.
+ ///
+ ///
+ /// A URL pointing to the guild's icon; if none is set.
+ ///
+ public string IconUrl => CDN.GetGuildIconUrl(Id, IconId);///
+ ///
+ /// Gets the level of requirements a user must fulfill before being allowed to post messages in this guild.
+ ///
+ ///
+ /// The level of requirements.
+ ///
+ public VerificationLevel VerificationLevel { get; private set; }
+
+ ///
+ /// Gets the code for this guild's vanity invite URL.
+ ///
+ ///
+ /// A string containing the vanity invite code for this guild; if none is set.
+ ///
+ public string VanityURLCode { get; private set; }
+
+ ///
+ /// Gets the number of premium subscribers of this guild.
+ ///
+ ///
+ /// This is the number of users who have boosted this guild.
+ ///
+ ///
+ /// The number of premium subscribers of this guild;
+ ///
+ public int PremiumSubscriptionCount { get; private set; }
+
+ ///
+ /// Gets the NSFW level of this guild.
+ ///
+ ///
+ /// The NSFW level of this guild.
+ ///
+ public NsfwLevel NsfwLevel { get; private set; }
+
+ ///
+ /// Gets the Welcome Screen of this guild
+ ///
+ ///
+ /// The welcome screen of this guild. if none is set.
+ /// The welcome screen of this guild. if none is set.
+ ///
+ public WelcomeScreen WelcomeScreen { get; private set; }
+
+ internal InviteGuild(ulong id, string name, string description, string splashId, string bannerId, GuildFeatures features, string iconId, VerificationLevel verificationLevel, string vanityURLCode, int premiumSubscriptionCount, NsfwLevel nsfwLevel, WelcomeScreen welcomeScreen)
+ {
+ Id = id;
+ Name = name;
+ Description = description;
+ SplashId = splashId;
+ BannerId = bannerId;
+ Features = features;
+ IconId = iconId;
+ VerificationLevel = verificationLevel;
+ VanityURLCode = vanityURLCode;
+ PremiumSubscriptionCount = premiumSubscriptionCount;
+ NsfwLevel = nsfwLevel;
+ WelcomeScreen = welcomeScreen;
+ }
+}
diff --git a/src/Discord.Net.Rest/API/Common/Invite.cs b/src/Discord.Net.Rest/API/Common/Invite.cs
index 7b797a97d..f9d53bad6 100644
--- a/src/Discord.Net.Rest/API/Common/Invite.cs
+++ b/src/Discord.Net.Rest/API/Common/Invite.cs
@@ -7,7 +7,7 @@ namespace Discord.API
[JsonProperty("code")]
public string Code { get; set; }
[JsonProperty("guild")]
- public Optional Guild { get; set; }
+ public Optional Guild { get; set; }
[JsonProperty("channel")]
public InviteChannel Channel { get; set; }
[JsonProperty("inviter")]
diff --git a/src/Discord.Net.Rest/API/Common/InviteGuild.cs b/src/Discord.Net.Rest/API/Common/InviteGuild.cs
new file mode 100644
index 000000000..8d63de60d
--- /dev/null
+++ b/src/Discord.Net.Rest/API/Common/InviteGuild.cs
@@ -0,0 +1,47 @@
+using Newtonsoft.Json;
+using System.Collections.Generic;
+
+namespace Discord.API
+{
+ internal class InviteGuild
+ {
+ [JsonProperty("id")]
+ public ulong Id { get; set; }
+
+ [JsonProperty("name")]
+ public string Name { get; set; }
+
+ [JsonProperty("splash")]
+ public Optional Splash { get; set; }
+
+ [JsonProperty("banner")]
+ public Optional BannerHash { get; set; }
+
+ [JsonProperty("description")]
+ public Optional Description { get; set; }
+
+ [JsonProperty("icon")]
+ public Optional IconHash { get; set; }
+
+ [JsonProperty("features")]
+ public GuildFeatures Features { get; set; }
+
+ [JsonProperty("verification_level")]
+ public VerificationLevel VerificationLevel { get; set; }
+
+ [JsonProperty("vanity_url_code")]
+ public Optional VanityUrlCode { get; set; }
+
+ [JsonProperty("premium_subscription_count")]
+ public Optional PremiumSubscriptionCount { get; set; }
+
+ [JsonProperty("nsfw")]
+ public Optional Nsfw { get; set; }
+
+ [JsonProperty("nsfw_level")]
+ public NsfwLevel NsfwLevel { get; set; }
+
+ [JsonProperty("welcome_screen")]
+ public Optional WelcomeScreen { get; set; }
+ }
+}
diff --git a/src/Discord.Net.Rest/ClientHelper.cs b/src/Discord.Net.Rest/ClientHelper.cs
index ceed8420e..0c8f8c42f 100644
--- a/src/Discord.Net.Rest/ClientHelper.cs
+++ b/src/Discord.Net.Rest/ClientHelper.cs
@@ -57,7 +57,7 @@ namespace Discord.Rest
{
var model = await client.ApiClient.GetInviteAsync(inviteId, options).ConfigureAwait(false);
if (model != null)
- return RestInviteMetadata.Create(client, RestGuild.Create(client, model.Guild.IsSpecified ? model.Guild.Value : null), null, model);
+ return RestInviteMetadata.Create(client, null, null, model);
return null;
}
diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
index 77c6d0e90..e0e96a104 100644
--- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
+++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
@@ -182,7 +182,7 @@ namespace Discord.Rest
if (model.MaxVideoChannelUsers.IsSpecified)
MaxVideoChannelUsers = model.MaxVideoChannelUsers.Value;
PreferredLocale = model.PreferredLocale;
- PreferredCulture = model.PreferredLocale is null ? null : new CultureInfo(PreferredLocale);
+ PreferredCulture = new CultureInfo(PreferredLocale);
if (model.ApproximateMemberCount.IsSpecified)
ApproximateMemberCount = model.ApproximateMemberCount.Value;
if (model.ApproximatePresenceCount.IsSpecified)
diff --git a/src/Discord.Net.Rest/Entities/Invites/RestInvite.cs b/src/Discord.Net.Rest/Entities/Invites/RestInvite.cs
index 60f109d39..93f79ad29 100644
--- a/src/Discord.Net.Rest/Entities/Invites/RestInvite.cs
+++ b/src/Discord.Net.Rest/Entities/Invites/RestInvite.cs
@@ -1,5 +1,7 @@
using System;
+using System.Collections.Immutable;
using System.Diagnostics;
+using System.Linq;
using System.Threading.Tasks;
using Model = Discord.API.Invite;
@@ -27,10 +29,18 @@ namespace Discord.Rest
public IUser TargetUser { get; private set; }
///
public TargetUserType TargetUserType { get; private set; }
- internal IChannel Channel { get; }
- ///
- public IGuild Guild { get; }
+ ///
+ /// Gets the guild this invite is linked to.
+ ///
+ ///
+ /// A partial guild object representing the guild that the invite points to.
+ ///
+ public InviteGuild InviteGuild { get; private set; }
+
+ internal IChannel Channel { get; }
+
+ internal IGuild Guild { get; }
///
public string Code => Id;
@@ -61,6 +71,32 @@ namespace Discord.Rest
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;
+
+ if (model.Guild.IsSpecified)
+ {
+ InviteGuild = new InviteGuild
+ (model.Guild.Value.Id,
+ model.Guild.Value.Name,
+ model.Guild.Value.Description.IsSpecified ? model.Guild.Value.Description.Value : null,
+ model.Guild.Value.Splash.IsSpecified ? model.Guild.Value.Splash.Value : null,
+ model.Guild.Value.BannerHash.IsSpecified ? model.Guild.Value.BannerHash.Value : null,
+ model.Guild.Value.Features,
+ model.Guild.Value.IconHash.IsSpecified ? model.Guild.Value.IconHash.Value : null,
+ model.Guild.Value.VerificationLevel,
+ model.Guild.Value.VanityUrlCode.IsSpecified ? model.Guild.Value.VanityUrlCode.Value : null,
+ model.Guild.Value.PremiumSubscriptionCount.GetValueOrDefault(0),
+ model.Guild.Value.NsfwLevel,
+ model.Guild.Value.WelcomeScreen.IsSpecified
+ ? new WelcomeScreen(
+ model.Guild.Value.WelcomeScreen.Value.Description.IsSpecified ? model.Guild.Value.WelcomeScreen.Value.Description.Value : null,
+ model.Guild.Value.WelcomeScreen.Value.WelcomeChannels.Select(ch =>
+ new WelcomeScreenChannel(
+ ch.ChannelId,
+ ch.Description,
+ ch.EmojiName.IsSpecified ? ch.EmojiName.Value : null,
+ ch.EmojiId.IsSpecified ? ch.EmojiId.Value : null)).ToImmutableArray())
+ : null);
+ }
}
///