Skip to content

Commit

Permalink
Remove bundles, begin porting everything else
Browse files Browse the repository at this point in the history
  • Loading branch information
gdude2002 committed Sep 17, 2024
1 parent 599c896 commit 17ec3c4
Show file tree
Hide file tree
Showing 130 changed files with 1,066 additions and 997 deletions.
1 change: 1 addition & 0 deletions annotations/annotation-processor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ metadata {

dependencies {
implementation(libs.kotlin.stdlib)
implementation(libs.kotlin.reflect)

implementation(libs.koin.core)
implementation(libs.ksp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public class ConverterBuilderClassBuilder : KoinComponent {
builder.append(" {\n")

if (ConverterType.CHOICE in types) {
builder.append(" override var choices: MutableMap<String, $argumentType> = mutableMapOf()\n\n")
builder.append(" override var choices: MutableMap<Key, $argumentType> = mutableMapOf()\n\n")
}

builder.append(" /** @inject: builderFields **/\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public class ConverterBuilderFunctionBuilder : KoinComponent {

builder.append(".() -> Unit\n")

// TODO: Arbitrary function arguments

builder.append("): $converterType<$argumentType>")

if (whereSuffix != null) {
Expand Down

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ koin-test = { module = "io.insert-koin:koin-test", version.ref = "koin" }
kord = { module = "dev.kord:kord-core-voice", version.ref = "kord" }

kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8" }
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect" }
ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }

ktor-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import dev.kordex.core.commands.chat.ChatCommand
import dev.kordex.core.commands.converters.builders.ConverterBuilder
import dev.kordex.core.events.EventHandler
import dev.kordex.core.extensions.Extension
import dev.kordex.core.i18n.types.Bundle
import dev.kordex.core.i18n.types.Key
import dev.kordex.parser.StringParser
import java.util.*
Expand Down Expand Up @@ -148,7 +147,6 @@ public open class ArgumentParsingException(
public override val reason: String,
public override val translationKey: Key?,
public val locale: Locale,
public val bundle: Bundle?,
public val argument: Argument<*>?,
public val arguments: Arguments,
public val parser: StringParser?,
Expand All @@ -158,7 +156,7 @@ public open class ArgumentParsingException(
public constructor(other: ArgumentParsingException) :
this(
other.reason,
other.translationKey, other.locale, other.bundle,
other.translationKey, other.locale,
other.argument, other.arguments,
other.parser
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyrighted (Kord Extensions, 2024). Licensed under the EUPL-1.2
* with the specific provision (EUPL articles 14 & 15) that the
* applicable law is the (Republic of) Irish law and the Jurisdiction
* Dublin.
* Any redistribution must include the specific provision above.
*/

package dev.kordex.core.annotations

@RequiresOptIn(
level = RequiresOptIn.Level.WARNING,
message = "A String provided here will not be translated. " +
"If you intended to translate it, please switch to using a Key object."
)
@Target(
AnnotationTarget.CLASS,
AnnotationTarget.TYPEALIAS,
AnnotationTarget.FUNCTION,
AnnotationTarget.PROPERTY,
AnnotationTarget.FIELD,
AnnotationTarget.CONSTRUCTOR,
AnnotationTarget.PROPERTY_SETTER,
AnnotationTarget.PROPERTY_SETTER
)
public annotation class NotTranslated
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import dev.kordex.core.annotations.BotBuilderDSL
import dev.kordex.core.builders.about.Copyright
import dev.kordex.core.builders.about.CopyrightType
import dev.kordex.core.builders.about.Section
import dev.kordex.core.i18n.types.Bundle
import dev.kordex.core.koin.KordExKoinComponent

/**
Expand All @@ -25,7 +24,6 @@ public class AboutBuilder : KordExKoinComponent {

public var ephemeral: Boolean = true

public val translationBundle: Bundle? = null
public val sections: MutableMap<String, Section> = mutableMapOf()

init {
Expand Down Expand Up @@ -94,9 +92,6 @@ public class AboutBuilder : KordExKoinComponent {

builder(section)

section.translationBundle = section.translationBundle
?: translationBundle

if (name == "extensions.about.copyright.commandName" || name == "copyright") {
error("You may not replace the copyright section.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public open class ExtensibleBotBuilder {
* If all the above values are missing, this setting defaults to "standard".
*
* For more information on what data KordEx collects, how to get at it, and how it's stored, please see here:
* TODO: LINK HERE
* https://docs.kordex.dev/data-collection.html
*/
@OptIn(InternalAPI::class)
public var dataCollectionMode: DataCollection = DATA_COLLECTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import dev.kord.common.asJavaLocale
import dev.kord.common.kLocale
import dev.kord.core.entity.interaction.Interaction
import dev.kordex.core.annotations.BotBuilderDSL
import dev.kordex.core.annotations.tooling.Translatable
import dev.kordex.core.annotations.tooling.TranslatableType
import dev.kordex.core.i18n.ResourceBundleTranslations
import dev.kordex.core.i18n.SupportedLocales
import dev.kordex.core.i18n.TranslationsProvider
Expand All @@ -23,8 +21,7 @@ import dev.kord.common.Locale as KLocale
/** Builder used to configure i18n options. **/
@BotBuilderDSL
public class I18nBuilder {
/** Locale that should be used by default. **/
@Translatable(TranslatableType.LOCALE)

public var defaultLocale: Locale = SupportedLocales.ENGLISH

/**
Expand Down Expand Up @@ -59,7 +56,6 @@ public class I18nBuilder {
*/
@JvmName("applicationCommandLocale_v1")
public fun applicationCommandLocale(
@Translatable(TranslatableType.LOCALE)
vararg locales: KLocale,
) {
applicationCommandLocales.addAll(locales.toList())
Expand All @@ -72,7 +68,6 @@ public class I18nBuilder {
*/
@JvmName("applicationCommandLocale_v2")
public fun applicationCommandLocale(
@Translatable(TranslatableType.LOCALE)
vararg locales: Locale,
) {
applicationCommandLocales.addAll(locales.map { it.kLocale })
Expand All @@ -85,7 +80,6 @@ public class I18nBuilder {
*/
@JvmName("applicationCommandLocale_c1")
public fun applicationCommandLocale(
@Translatable(TranslatableType.LOCALE)
locales: Collection<KLocale>,
) {
applicationCommandLocales.addAll(locales)
Expand All @@ -98,7 +92,6 @@ public class I18nBuilder {
*/
@JvmName("applicationCommandLocale_c2")
public fun applicationCommandLocale(
@Translatable(TranslatableType.LOCALE)
locales: Collection<Locale>,
) {
applicationCommandLocales.addAll(locales.map { it.kLocale })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package dev.kordex.core.builders.about
import dev.kord.rest.builder.message.MessageBuilder
import dev.kordex.core.i18n.TranslationsProvider
import dev.kordex.core.i18n.toKey
import dev.kordex.core.i18n.types.Bundle
import dev.kordex.core.i18n.types.Key
import dev.kordex.core.koin.KordExKoinComponent
import org.koin.core.component.inject
Expand All @@ -27,7 +26,6 @@ public class Section(public val name: Key, public val description: Key) : KordEx
public val translations: TranslationsProvider by inject()

public var ephemeral: Boolean? = null
public var translationBundle: Bundle? = null

public lateinit var builder: SectionBuilder

Expand All @@ -36,7 +34,7 @@ public class Section(public val name: Key, public val description: Key) : KordEx
}

public fun translate(key: Key, locale: Locale, replacements: Array<Any?> = arrayOf()): String =
key.withBundle(translationBundle)
key
.withLocale(locale)
.translateArray(replacements)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Any redistribution must include the specific provision above.
*/

@file:OptIn(NotTranslated::class)

package dev.kordex.core.checks

import dev.kord.common.entity.Snowflake
Expand All @@ -16,6 +18,7 @@ import dev.kord.core.behavior.channel.asChannelOfOrNull
import dev.kord.core.entity.channel.Category
import dev.kord.core.entity.channel.GuildChannel
import dev.kord.core.event.Event
import dev.kordex.core.annotations.NotTranslated
import dev.kordex.core.checks.types.CheckContext
import dev.kordex.core.i18n.generated.CoreTranslations
import dev.kordex.core.utils.isAbove
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
* Any redistribution must include the specific provision above.
*/

@file:OptIn(NotTranslated::class)

package dev.kordex.core.checks

import dev.kord.common.entity.ChannelType
import dev.kord.core.event.Event
import dev.kordex.core.annotations.NotTranslated
import dev.kordex.core.checks.types.CheckContext
import dev.kordex.core.i18n.generated.CoreTranslations
import dev.kordex.core.utils.translate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
* Any redistribution must include the specific provision above.
*/

@file:OptIn(NotTranslated::class)

package dev.kordex.core.checks

import dev.kord.common.entity.Snowflake
import dev.kord.core.behavior.GuildBehavior
import dev.kord.core.event.Event
import dev.kordex.core.annotations.NotTranslated
import dev.kordex.core.checks.types.CheckContext
import dev.kordex.core.i18n.generated.CoreTranslations
import io.github.oshai.kotlinlogging.KotlinLogging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
* Any redistribution must include the specific provision above.
*/

@file:OptIn(NotTranslated::class)

package dev.kordex.core.checks

import dev.kord.common.entity.Permission
import dev.kord.common.entity.Permissions
import dev.kord.core.entity.channel.GuildChannel
import dev.kord.core.event.Event
import dev.kordex.core.annotations.NotTranslated
import dev.kordex.core.checks.types.CheckContext
import dev.kordex.core.i18n.generated.CoreTranslations
import dev.kordex.core.utils.hasPermission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
*/

@file:Suppress("StringLiteralDuplication")
@file:OptIn(NotTranslated::class)

package dev.kordex.core.checks

import dev.kord.common.entity.ChannelType
import dev.kord.common.entity.NsfwLevel
import dev.kord.core.event.Event
import dev.kordex.core.annotations.NotTranslated
import dev.kordex.core.checks.types.CheckContext
import dev.kordex.core.i18n.generated.CoreTranslations
import dev.kordex.core.utils.compareTo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
*/

@file:Suppress("StringLiteralDuplication")
@file:OptIn(NotTranslated::class)

package dev.kordex.core.checks

import dev.kord.common.entity.Snowflake
import dev.kord.core.behavior.RoleBehavior
import dev.kord.core.event.Event
import dev.kordex.core.annotations.NotTranslated
import dev.kordex.core.checks.types.CheckContext
import dev.kordex.core.i18n.generated.CoreTranslations
import dev.kordex.core.utils.getTopRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
* Any redistribution must include the specific provision above.
*/

@file:OptIn(NotTranslated::class)

package dev.kordex.core.checks

import dev.kord.common.entity.Snowflake
import dev.kord.core.behavior.channel.ChannelBehavior
import dev.kord.core.entity.channel.thread.ThreadChannel
import dev.kord.core.event.Event
import dev.kordex.core.annotations.NotTranslated
import dev.kordex.core.checks.types.CheckContext
import dev.kordex.core.i18n.generated.CoreTranslations
import io.github.oshai.kotlinlogging.KotlinLogging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public suspend fun guildFor(event: Event): GuildBehavior? {
is VoiceStateUpdateEvent -> event.state.getGuildOrNull()
is WebhookUpdateEvent -> event.guild

// TODO: Kord doesn't have the guild yet?
// TODO: Kord doesn't have the guild yet!
// is GuildAuditLogEntryCreateEvent -> event.auditLogEntry.userId

else -> null
Expand Down
Loading

0 comments on commit 17ec3c4

Please sign in to comment.