From 2bd7d5a2167e984518ef6de081cdb8f1ec2fa9f3 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 18 Nov 2022 05:34:47 +0100 Subject: [PATCH 1/2] Add new GuildFeatures * InvitesDisabled: https://github.com/discord/discord-api-docs/pull/5269 * DeveloperSupportServer: https://github.com/discord/discord-api-docs/pull/5572 * ApplicationCommandPermissionsV2: https://github.com/discord/discord-api-docs/pull/5649 --- common/api/common.api | 12 ++++++++++ .../dev/kord/common/entity/GuildFeature.kt | 22 +++++++++++++++++++ common/src/main/kotlin/entity/DiscordGuild.kt | 12 ++++++++++ 3 files changed, 46 insertions(+) diff --git a/common/api/common.api b/common/api/common.api index 014734e08980..adce0fd80fde 100644 --- a/common/api/common.api +++ b/common/api/common.api @@ -6212,6 +6212,10 @@ public final class dev/kord/common/entity/GuildFeature$AnimatedIcon : dev/kord/c public static final field INSTANCE Ldev/kord/common/entity/GuildFeature$AnimatedIcon; } +public final class dev/kord/common/entity/GuildFeature$ApplicationCommandPermissionsV2 : dev/kord/common/entity/GuildFeature { + public static final field INSTANCE Ldev/kord/common/entity/GuildFeature$ApplicationCommandPermissionsV2; +} + public final class dev/kord/common/entity/GuildFeature$AutoModeration : dev/kord/common/entity/GuildFeature { public static final field INSTANCE Ldev/kord/common/entity/GuildFeature$AutoModeration; } @@ -6233,6 +6237,10 @@ public final class dev/kord/common/entity/GuildFeature$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class dev/kord/common/entity/GuildFeature$DeveloperSupportServer : dev/kord/common/entity/GuildFeature { + public static final field INSTANCE Ldev/kord/common/entity/GuildFeature$DeveloperSupportServer; +} + public final class dev/kord/common/entity/GuildFeature$Discoverable : dev/kord/common/entity/GuildFeature { public static final field INSTANCE Ldev/kord/common/entity/GuildFeature$Discoverable; } @@ -6245,6 +6253,10 @@ public final class dev/kord/common/entity/GuildFeature$InviteSplash : dev/kord/c public static final field INSTANCE Ldev/kord/common/entity/GuildFeature$InviteSplash; } +public final class dev/kord/common/entity/GuildFeature$InvitesDisabled : dev/kord/common/entity/GuildFeature { + public static final field INSTANCE Ldev/kord/common/entity/GuildFeature$InvitesDisabled; +} + public final class dev/kord/common/entity/GuildFeature$MemberVerificationGateEnabled : dev/kord/common/entity/GuildFeature { public static final field INSTANCE Ldev/kord/common/entity/GuildFeature$MemberVerificationGateEnabled; } diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildFeature.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildFeature.kt index fc82c9276b87..49b26863e899 100644 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildFeature.kt +++ b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildFeature.kt @@ -59,6 +59,12 @@ public sealed class GuildFeature( */ public object AnimatedIcon : GuildFeature("ANIMATED_ICON") + /** + * Guild is using the old permissions configuration behavior. + */ + public object ApplicationCommandPermissionsV2 : + GuildFeature("APPLICATION_COMMAND_PERMISSIONS_V2") + /** * Guild has set up auto moderation rules. */ @@ -75,6 +81,11 @@ public sealed class GuildFeature( */ public object Community : GuildFeature("COMMUNITY") + /** + * Guild has been set as a support server on the App Directory. + */ + public object DeveloperSupportServer : GuildFeature("DEVELOPER_SUPPORT_SERVER") + /** * Guild is able to be discovered in the directory. */ @@ -85,6 +96,11 @@ public sealed class GuildFeature( */ public object Featurable : GuildFeature("FEATURABLE") + /** + * Guild has paused invites, preventing new users from joining. + */ + public object InvitesDisabled : GuildFeature("INVITES_DISABLED") + /** * Guild has access to set an invite splash background. */ @@ -201,12 +217,15 @@ public sealed class GuildFeature( when (val value = decoder.decodeString()) { "ANIMATED_BANNER" -> AnimatedBanner "ANIMATED_ICON" -> AnimatedIcon + "APPLICATION_COMMAND_PERMISSIONS_V2" -> ApplicationCommandPermissionsV2 "AUTO_MODERATION" -> AutoModeration "BANNER" -> Banner "COMMERCE" -> @Suppress("DEPRECATION_ERROR") Commerce "COMMUNITY" -> Community + "DEVELOPER_SUPPORT_SERVER" -> DeveloperSupportServer "DISCOVERABLE" -> Discoverable "FEATURABLE" -> Featurable + "INVITES_DISABLED" -> InvitesDisabled "INVITE_SPLASH" -> InviteSplash "MEMBER_VERIFICATION_GATE_ENABLED" -> MemberVerificationGateEnabled "MONETIZATION_ENABLED" -> MonetizationEnabled @@ -235,12 +254,15 @@ public sealed class GuildFeature( listOf( AnimatedBanner, AnimatedIcon, + ApplicationCommandPermissionsV2, AutoModeration, Banner, @Suppress("DEPRECATION_ERROR") Commerce, Community, + DeveloperSupportServer, Discoverable, Featurable, + InvitesDisabled, InviteSplash, MemberVerificationGateEnabled, MonetizationEnabled, diff --git a/common/src/main/kotlin/entity/DiscordGuild.kt b/common/src/main/kotlin/entity/DiscordGuild.kt index e5071389a52e..7f2adbca94ce 100644 --- a/common/src/main/kotlin/entity/DiscordGuild.kt +++ b/common/src/main/kotlin/entity/DiscordGuild.kt @@ -75,6 +75,10 @@ kDoc = "Guild has access to set an animated guild banner image.", ), Entry("AnimatedIcon", stringValue = "ANIMATED_ICON", kDoc = "Guild has access to set an animated guild icon."), + Entry( + "ApplicationCommandPermissionsV2", stringValue = "APPLICATION_COMMAND_PERMISSIONS_V2", + kDoc = "Guild is using the old permissions configuration behavior.", + ), Entry("AutoModeration", stringValue = "AUTO_MODERATION", kDoc = "Guild has set up auto moderation rules."), Entry("Banner", stringValue = "BANNER", kDoc = "Guild has access to set a guild banner image."), Entry( @@ -82,11 +86,19 @@ kDoc = "Guild can enable welcome screen, Membership Screening, stage channels and discovery, and " + "receives community updates.", ), + Entry( + "DeveloperSupportServer", stringValue = "DEVELOPER_SUPPORT_SERVER", + kDoc = "Guild has been set as a support server on the App Directory.", + ), Entry("Discoverable", stringValue = "DISCOVERABLE", kDoc = "Guild is able to be discovered in the directory."), Entry( "Featurable", stringValue = "FEATURABLE", kDoc = "Guild is able to be featured in the directory.", ), + Entry( + "InvitesDisabled", stringValue = "INVITES_DISABLED", + kDoc = "Guild has paused invites, preventing new users from joining.", + ), Entry( "InviteSplash", stringValue = "INVITE_SPLASH", kDoc = "Guild has access to set an invite splash background.", From 5ca8e1499a14ad08e91dd35e7c35600e3696fe1c Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 18 Nov 2022 06:37:29 +0100 Subject: [PATCH 2/2] Allow editing Guild Features This can for example be used to pause invites: guild.edit { features = guild.features + GuildFeature.InvitesDisabled } --- rest/api/rest.api | 14 +++++++++----- .../kotlin/builder/guild/GuildModifyBuilder.kt | 13 ++++++++----- rest/src/main/kotlin/json/request/GuildRequests.kt | 1 + 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/rest/api/rest.api b/rest/api/rest.api index 489096df54cd..6fb668ac1cfe 100644 --- a/rest/api/rest.api +++ b/rest/api/rest.api @@ -926,6 +926,7 @@ public final class dev/kord/rest/builder/guild/GuildModifyBuilder : dev/kord/res public final fun getAfkTimeout-FghU774 ()Lkotlin/time/Duration; public final fun getBanner ()Ldev/kord/rest/Image; public final fun getExplicitContentFilter ()Ldev/kord/common/entity/ExplicitContentFilter; + public final fun getFeatures ()Ljava/util/Set; public final fun getIcon ()Ldev/kord/rest/Image; public final fun getName ()Ljava/lang/String; public final fun getNotificationLevel ()Ldev/kord/common/entity/DefaultMessageNotificationLevel; @@ -942,6 +943,7 @@ public final class dev/kord/rest/builder/guild/GuildModifyBuilder : dev/kord/res public final fun setAfkTimeout-BwNAW2A (Lkotlin/time/Duration;)V public final fun setBanner (Ldev/kord/rest/Image;)V public final fun setExplicitContentFilter (Ldev/kord/common/entity/ExplicitContentFilter;)V + public final fun setFeatures (Ljava/util/Set;)V public final fun setIcon (Ldev/kord/rest/Image;)V public final fun setName (Ljava/lang/String;)V public final fun setNotificationLevel (Ldev/kord/common/entity/DefaultMessageNotificationLevel;)V @@ -3732,9 +3734,9 @@ public final class dev/kord/rest/json/request/GuildMemberModifyRequest$Companion public final class dev/kord/rest/json/request/GuildModifyRequest { public static final field Companion Ldev/kord/rest/json/request/GuildModifyRequest$Companion; public fun ()V - public synthetic fun (ILdev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (ILdev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V + public synthetic fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/common/entity/optional/Optional; public final fun component10 ()Ldev/kord/common/entity/optional/Optional; public final fun component11 ()Ldev/kord/common/entity/optional/Optional; @@ -3742,6 +3744,7 @@ public final class dev/kord/rest/json/request/GuildModifyRequest { public final fun component13 ()Ldev/kord/common/entity/optional/OptionalSnowflake; public final fun component14 ()Ldev/kord/common/entity/optional/OptionalSnowflake; public final fun component15 ()Ldev/kord/common/entity/optional/Optional; + public final fun component16 ()Ldev/kord/common/entity/optional/Optional; public final fun component2 ()Ldev/kord/common/entity/optional/Optional; public final fun component3 ()Ldev/kord/common/entity/optional/Optional; public final fun component4 ()Ldev/kord/common/entity/optional/Optional; @@ -3750,14 +3753,15 @@ public final class dev/kord/rest/json/request/GuildModifyRequest { public final fun component7 ()Ldev/kord/common/entity/optional/Optional; public final fun component8 ()Ldev/kord/common/entity/optional/Optional; public final fun component9 ()Ldev/kord/common/entity/optional/OptionalSnowflake; - public final fun copy (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/GuildModifyRequest; - public static synthetic fun copy$default (Ldev/kord/rest/json/request/GuildModifyRequest;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/GuildModifyRequest; + public final fun copy (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/GuildModifyRequest; + public static synthetic fun copy$default (Ldev/kord/rest/json/request/GuildModifyRequest;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/GuildModifyRequest; public fun equals (Ljava/lang/Object;)Z public final fun getAfkChannelId ()Ldev/kord/common/entity/optional/OptionalSnowflake; public final fun getAfkTimeout ()Ldev/kord/common/entity/optional/Optional; public final fun getBanner ()Ldev/kord/common/entity/optional/Optional; public final fun getContentFilter ()Ldev/kord/common/entity/optional/Optional; public final fun getDefaultMessageNotificationLevel ()Ldev/kord/common/entity/optional/Optional; + public final fun getFeatures ()Ldev/kord/common/entity/optional/Optional; public final fun getIcon ()Ldev/kord/common/entity/optional/Optional; public final fun getName ()Ldev/kord/common/entity/optional/Optional; public final fun getOwnerId ()Ldev/kord/common/entity/optional/OptionalSnowflake; diff --git a/rest/src/main/kotlin/builder/guild/GuildModifyBuilder.kt b/rest/src/main/kotlin/builder/guild/GuildModifyBuilder.kt index 1ac624dffaab..ad3c81c10fc3 100644 --- a/rest/src/main/kotlin/builder/guild/GuildModifyBuilder.kt +++ b/rest/src/main/kotlin/builder/guild/GuildModifyBuilder.kt @@ -1,10 +1,7 @@ package dev.kord.rest.builder.guild import dev.kord.common.annotation.KordDsl -import dev.kord.common.entity.DefaultMessageNotificationLevel -import dev.kord.common.entity.ExplicitContentFilter -import dev.kord.common.entity.Snowflake -import dev.kord.common.entity.VerificationLevel +import dev.kord.common.entity.* import dev.kord.common.entity.optional.Optional import dev.kord.common.entity.optional.OptionalSnowflake import dev.kord.common.entity.optional.delegate.delegate @@ -77,6 +74,11 @@ public class GuildModifyBuilder : AuditRequestBuilder { */ public var preferredLocale: Locale? by ::_preferredLocale.delegate() + private var _features: Optional> = Optional.Missing() + + /** The enabled [GuildFeature]s. */ + public var features: Set? by ::_features.delegate() + override fun toRequest(): GuildModifyRequest = GuildModifyRequest( _name, _region, @@ -92,6 +94,7 @@ public class GuildModifyBuilder : AuditRequestBuilder { _systemChannelId, _rulesChannelId, _publicUpdatesChannelId, - _preferredLocale.map { "${it.language}-${it.country}" } + _preferredLocale.map { "${it.language}-${it.country}" }, + features = _features, ) } diff --git a/rest/src/main/kotlin/json/request/GuildRequests.kt b/rest/src/main/kotlin/json/request/GuildRequests.kt index 94445e392ddf..0a0d9b3f5a1c 100644 --- a/rest/src/main/kotlin/json/request/GuildRequests.kt +++ b/rest/src/main/kotlin/json/request/GuildRequests.kt @@ -252,6 +252,7 @@ public data class GuildModifyRequest( val publicUpdatesChannelId: OptionalSnowflake? = OptionalSnowflake.Missing, @SerialName("preferred_locale") val preferredLocale: Optional = Optional.Missing(), + val features: Optional> = Optional.Missing(), ) @Serializable