diff --git a/common/src/main/kotlin/entity/DiscordGuild.kt b/common/src/main/kotlin/entity/DiscordGuild.kt index 914c584b7429..d063bdd162d5 100644 --- a/common/src/main/kotlin/entity/DiscordGuild.kt +++ b/common/src/main/kotlin/entity/DiscordGuild.kt @@ -74,6 +74,7 @@ data class DiscordUnavailableGuild( * @param approximateMemberCount The approximate number of members in this guild, returned from the `GET /guild/` endpoint when `with_counts` is `true`. * @param approximatePresenceCount The approximate number of non-offline members in this guild, returned from the `GET /guild/` endpoint when `with_counts` is `true`. * @param welcomeScreen The welcome screen of a Community guild, shown to new members. + * @param nsfw true if this guild is [designated as NSFW](https://support.discord.com/hc/en-us/articles/1500005389362-NSFW-Server-Designation) */ @Serializable data class DiscordGuild( @@ -150,7 +151,9 @@ data class DiscordGuild( val approximateMemberCount: OptionalInt = OptionalInt.Missing, @SerialName("approximate_presence_count") val approximatePresenceCount: OptionalInt = OptionalInt.Missing, - + @SerialName("welcome_screen") + val welcomeScreen: Optional = Optional.Missing(), + val nsfw: Boolean ) /** diff --git a/common/src/test/kotlin/json/GuildTest.kt b/common/src/test/kotlin/json/GuildTest.kt index 23b901274980..8880dcd394b9 100644 --- a/common/src/test/kotlin/json/GuildTest.kt +++ b/common/src/test/kotlin/json/GuildTest.kt @@ -59,6 +59,7 @@ class GuildTest { preferredLocale shouldBe "en-US" rulesChannelId shouldBe "441688182833020939" publicUpdatesChannelId shouldBe "281283303326089216" + nsfw shouldBe true } } diff --git a/common/src/test/resources/json/guild/guild.json b/common/src/test/resources/json/guild/guild.json index 0c7995a220dd..a9f61a3f2588 100644 --- a/common/src/test/resources/json/guild/guild.json +++ b/common/src/test/resources/json/guild/guild.json @@ -38,5 +38,6 @@ "system_channel_flags": 0, "preferred_locale": "en-US", "rules_channel_id": "441688182833020939", - "public_updates_channel_id": "281283303326089216" + "public_updates_channel_id": "281283303326089216", + "nsfw": true } \ No newline at end of file diff --git a/core/src/main/kotlin/cache/data/GuildData.kt b/core/src/main/kotlin/cache/data/GuildData.kt index 2da5a2aa2d5b..32e92ede9b95 100644 --- a/core/src/main/kotlin/cache/data/GuildData.kt +++ b/core/src/main/kotlin/cache/data/GuildData.kt @@ -54,6 +54,8 @@ data class GuildData( val maxVideoChannelUsers: OptionalInt = OptionalInt.Missing, val approximateMemberCount: OptionalInt = OptionalInt.Missing, val approximatePresenceCount: OptionalInt = OptionalInt.Missing, + val welcomeScreen: Optional = Optional.Missing(), + val nsfw: Boolean ) { companion object { @@ -113,6 +115,8 @@ data class GuildData( maxVideoChannelUsers = maxVideoChannelUsers, approximateMemberCount = approximateMemberCount, approximatePresenceCount = approximatePresenceCount, + welcomeScreen = welcomeScreen.map { WelcomeScreenData.from(it) }, + nsfw = nsfw ) } } diff --git a/core/src/main/kotlin/entity/Guild.kt b/core/src/main/kotlin/entity/Guild.kt index 0c0ec59c56e6..294fc57e93c1 100644 --- a/core/src/main/kotlin/entity/Guild.kt +++ b/core/src/main/kotlin/entity/Guild.kt @@ -332,6 +332,16 @@ class Guild( */ val maxVideoChannelUsers: Int? get() = data.maxVideoChannelUsers.value + /** + * The welcome screen of a Community guild, shown to new members, returned in an [Invite]'s guild object + */ + val welcomeScreen: WelcomeScreen? get() = data.welcomeScreen.unwrap { WelcomeScreen(it, kord) } + + /** + * True if this guild is [designated as NSFW](https://support.discord.com/hc/en-us/articles/1500005389362-NSFW-Server-Designation) + */ + val nsfw: Boolean get() = data.nsfw + /** * Requests to get the [VoiceChannel] represented by the [afkChannelId], * returns null if the [afkChannelId] isn't present or the channel itself isn't present. diff --git a/core/src/test/kotlin/performance/KordEventDropTest.kt b/core/src/test/kotlin/performance/KordEventDropTest.kt index 39542aa3970d..ecc60599727c 100644 --- a/core/src/test/kotlin/performance/KordEventDropTest.kt +++ b/core/src/test/kotlin/performance/KordEventDropTest.kt @@ -85,7 +85,8 @@ class KordEventDropTest { rulesChannelId = null, vanityUrlCode = null, banner = null, - publicUpdatesChannelId = null + publicUpdatesChannelId = null, + nsfw = false ), 0) val counter = AtomicInteger(0)