From 946df3b09775a48ca246dea9d4f28ea092e3dcbd Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Wed, 5 Apr 2023 15:15:30 +0200 Subject: [PATCH 1/2] Fix breaking changes from Kord Kotlin/JS support see https://github.com/kordlib/kord/pull/775 --- kord-extensions/build.gradle.kts | 6 +----- .../kord/extensions/builders/ExtensibleBotBuilder.kt | 2 ++ .../extensions/commands/application/ApplicationCommand.kt | 1 + .../commands/application/ApplicationCommandRegistry.kt | 1 + .../com/kotlindiscord/kord/extensions/utils/_ChannelType.kt | 1 - .../com/kotlindiscord/kord/extensions/utils/_Permissions.kt | 4 +++- libs.versions.toml | 3 +-- .../kord/extensions/testbot/extensions/I18nTestExtension.kt | 1 + 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/kord-extensions/build.gradle.kts b/kord-extensions/build.gradle.kts index c3d0b97499..c580c7562e 100644 --- a/kord-extensions/build.gradle.kts +++ b/kord-extensions/build.gradle.kts @@ -27,11 +27,7 @@ dependencies { api(libs.koin.core) api(libs.koin.logger) - api(libs.kord) { - capabilities { - requireCapability(libs.kord.voice.get().toString()) - } - } + api(libs.kord) api(libs.logging) // Basic logging setup api(libs.kx.ser) diff --git a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/builders/ExtensibleBotBuilder.kt b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/builders/ExtensibleBotBuilder.kt index 6eedf69256..f8690d0d7a 100644 --- a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/builders/ExtensibleBotBuilder.kt +++ b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/builders/ExtensibleBotBuilder.kt @@ -31,6 +31,7 @@ import com.kotlindiscord.kord.extensions.utils.getKoin import com.kotlindiscord.kord.extensions.utils.loadModule import dev.kord.cache.api.DataCache import dev.kord.common.Color +import dev.kord.common.asJavaLocale import dev.kord.common.entity.PresenceStatus import dev.kord.common.entity.Snowflake import dev.kord.core.ClientResources @@ -40,6 +41,7 @@ import dev.kord.core.behavior.UserBehavior import dev.kord.core.behavior.channel.ChannelBehavior import dev.kord.core.builder.kord.KordBuilder import dev.kord.core.cache.KordCacheBuilder +import dev.kord.core.cache.lruCache import dev.kord.core.entity.interaction.Interaction import dev.kord.core.event.message.MessageCreateEvent import dev.kord.core.supplier.EntitySupplier diff --git a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/commands/application/ApplicationCommand.kt b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/commands/application/ApplicationCommand.kt index 593cc657d7..ec7a5b9e26 100644 --- a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/commands/application/ApplicationCommand.kt +++ b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/commands/application/ApplicationCommand.kt @@ -17,6 +17,7 @@ import com.kotlindiscord.kord.extensions.extensions.Extension import com.kotlindiscord.kord.extensions.koin.KordExKoinComponent import com.kotlindiscord.kord.extensions.utils.MutableStringKeyedMap import com.kotlindiscord.kord.extensions.utils.getLocale +import dev.kord.common.asJavaLocale import dev.kord.common.entity.ApplicationCommandType import dev.kord.common.entity.Permission import dev.kord.common.entity.Permissions diff --git a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/commands/application/ApplicationCommandRegistry.kt b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/commands/application/ApplicationCommandRegistry.kt index 71ed3ee797..c2d1464416 100644 --- a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/commands/application/ApplicationCommandRegistry.kt +++ b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/commands/application/ApplicationCommandRegistry.kt @@ -28,6 +28,7 @@ import com.kotlindiscord.kord.extensions.i18n.TranslationsProvider import com.kotlindiscord.kord.extensions.koin.KordExKoinComponent import dev.kord.common.annotation.KordExperimental import dev.kord.common.annotation.KordUnsafe +import dev.kord.common.asJavaLocale import dev.kord.common.entity.ApplicationCommandType import dev.kord.common.entity.Choice import dev.kord.common.entity.Snowflake diff --git a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/utils/_ChannelType.kt b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/utils/_ChannelType.kt index 2e8a6b2c00..b55f681fef 100644 --- a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/utils/_ChannelType.kt +++ b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/utils/_ChannelType.kt @@ -12,7 +12,6 @@ import dev.kord.common.entity.ChannelType import java.util.* /** Given a [ChannelType], return a string representing its translation key. **/ -@Suppress("DEPRECATION_ERROR") public fun ChannelType.toTranslationKey(): String = when (this) { ChannelType.DM -> "channelType.dm" ChannelType.GroupDM -> "channelType.groupDm" diff --git a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/utils/_Permissions.kt b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/utils/_Permissions.kt index 560f32c445..eaf4b7370d 100644 --- a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/utils/_Permissions.kt +++ b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/utils/_Permissions.kt @@ -25,7 +25,7 @@ public fun Permission.toTranslationKey(): String? = when (this) { Permission.EmbedLinks -> "permission.embedLinks" Permission.KickMembers -> "permission.kickMembers" Permission.ManageChannels -> "permission.manageChannels" - Permission.ManageEmojisAndStickers -> "permission.manageEmojisAndStickers" + Permission.ManageGuildExpressions, Permission.ManageEmojisAndStickers -> "permission.manageEmojisAndStickers" Permission.ManageEvents -> "permission.manageEvents" Permission.ManageGuild -> "permission.manageGuild" Permission.ManageMessages -> "permission.manageMessages" @@ -57,6 +57,8 @@ public fun Permission.toTranslationKey(): String? = when (this) { Permission.UseExternalStickers -> "permission.useExternalStickers" Permission.UseEmbeddedActivities -> "permission.useEmbeddedActivities" + Permission.ViewCreatorMonetizationAnalytics -> TODO() + Permission.UseSoundboard -> TODO() is Permission.Unknown -> null } diff --git a/libs.versions.toml b/libs.versions.toml index 716db99b3c..d5424a87f5 100644 --- a/libs.versions.toml +++ b/libs.versions.toml @@ -42,8 +42,7 @@ koin-test = { module = "io.insert-koin:koin-test", version.ref = "koin" } konf-core = { module = "com.uchuhimo:konf", version.ref = "konf" } konf-toml = { module = "com.uchuhimo:konf-toml", version.ref = "konf" } -kord = { module = "dev.kord:kord-core", version.ref = "kord" } -kord-voice = { module = "dev.kord:core-voice", version.ref = "kord" } +kord = { module = "dev.kord:kord-core-voice", version.ref = "kord" } kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet" } kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8" } diff --git a/test-bot/src/main/kotlin/com/kotlindiscord/kord/extensions/testbot/extensions/I18nTestExtension.kt b/test-bot/src/main/kotlin/com/kotlindiscord/kord/extensions/testbot/extensions/I18nTestExtension.kt index 0ee0176053..5a84036af0 100644 --- a/test-bot/src/main/kotlin/com/kotlindiscord/kord/extensions/testbot/extensions/I18nTestExtension.kt +++ b/test-bot/src/main/kotlin/com/kotlindiscord/kord/extensions/testbot/extensions/I18nTestExtension.kt @@ -19,6 +19,7 @@ import com.kotlindiscord.kord.extensions.extensions.Extension import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand import com.kotlindiscord.kord.extensions.types.respond +import dev.kord.common.asJavaLocale import dev.kord.core.behavior.interaction.suggestString import dev.kord.core.event.interaction.ChatInputCommandInteractionCreateEvent From 7ef3a1f4a744726ff61fc4e676cb6696fe0e03d3 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Wed, 5 Apr 2023 21:32:12 +0200 Subject: [PATCH 2/2] Add translation keys --- .../com/kotlindiscord/kord/extensions/utils/_Permissions.kt | 4 ++-- .../src/main/resources/translations/kordex/strings.properties | 2 ++ .../resources/translations/kordex/strings_en_GB.properties | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/utils/_Permissions.kt b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/utils/_Permissions.kt index eaf4b7370d..939041cf86 100644 --- a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/utils/_Permissions.kt +++ b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/utils/_Permissions.kt @@ -57,8 +57,8 @@ public fun Permission.toTranslationKey(): String? = when (this) { Permission.UseExternalStickers -> "permission.useExternalStickers" Permission.UseEmbeddedActivities -> "permission.useEmbeddedActivities" - Permission.ViewCreatorMonetizationAnalytics -> TODO() - Permission.UseSoundboard -> TODO() + Permission.ViewCreatorMonetizationAnalytics -> "permission.viewCreatorMonetizationAnalytics" + Permission.UseSoundboard -> "permission.useSoundboard" is Permission.Unknown -> null } diff --git a/kord-extensions/src/main/resources/translations/kordex/strings.properties b/kord-extensions/src/main/resources/translations/kordex/strings.properties index 0b408ebafa..8fe10cff3b 100644 --- a/kord-extensions/src/main/resources/translations/kordex/strings.properties +++ b/kord-extensions/src/main/resources/translations/kordex/strings.properties @@ -205,9 +205,11 @@ permission.useApplicationCommands=Use Application Commands permission.useEmbeddedActivities=Use Activities permission.useExternalEmojis=Use External Emojis permission.useExternalStickers=Use External Stickers +permission.useSoundboard=Use Soundboard permission.useVAD=Use Voice Activity permission.viewAuditLog=View Audit Log permission.viewChannel=View Channel +permission.viewCreatorMonetizationAnalytics=View Creator Monetization Analytics permission.viewGuildInsights=View Server Insights utils.message.useThisChannel=Please use {0} for this command. utils.message.commandNotAvailableInDm=This command is not available via private message. diff --git a/kord-extensions/src/main/resources/translations/kordex/strings_en_GB.properties b/kord-extensions/src/main/resources/translations/kordex/strings_en_GB.properties index 113823035e..45204b15dc 100644 --- a/kord-extensions/src/main/resources/translations/kordex/strings_en_GB.properties +++ b/kord-extensions/src/main/resources/translations/kordex/strings_en_GB.properties @@ -198,9 +198,11 @@ permission.useApplicationCommands=Use Application Commands permission.useEmbeddedActivities=Use Activities permission.useExternalEmojis=Use External Emojis permission.useExternalStickers=Use External Stickers +permission.useSoundboard=Use Soundboard permission.useVAD=Use Voice Activity permission.viewAuditLog=View Audit Log permission.viewChannel=View Channel +permission.viewCreatorMonetizationAnalytics=View Creator Monetization Analytics permission.viewGuildInsights=View Server Insights utils.message.useThisChannel=Please use {0} for this command. utils.message.commandNotAvailableInDm=This command is not available via private message.