Skip to content

Commit

Permalink
Translations 2 electric boogaloo
Browse files Browse the repository at this point in the history
  • Loading branch information
NoComment1105 committed Oct 30, 2024
1 parent 5be15f1 commit fd6c8e9
Show file tree
Hide file tree
Showing 14 changed files with 617 additions and 268 deletions.
22 changes: 22 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import dev.kordex.gradle.plugins.kordex.DataCollection
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand All @@ -12,6 +13,7 @@ plugins {
alias(libs.plugins.git.hooks)
alias(libs.plugins.grgit)
alias(libs.plugins.blossom)
alias(libs.plugins.kord.extensions.plugin)
}

group = "org.hyacinthbots.lilybot"
Expand All @@ -32,6 +34,11 @@ repositories {
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}

maven {
name = "Kord Extensions (Releases)"
url = uri("https://releases-repo.kordex.dev")
}

maven {
name = "Kord Extensions (Snapshots)"
url = uri("https://snapshots-repo.kordex.dev")
Expand Down Expand Up @@ -67,6 +74,21 @@ dependencies {
implementation(libs.docgenerator)
}

kordEx {
addDependencies = false
addRepositories = false
kordExVersion = libs.versions.kord.extensions

bot {
dataCollection(DataCollection.None)
}

i18n {
classPackage = "lilybot.i18n"
translationBundle = "lilybot.strings"
}
}

application {
mainClass.set(className)
}
Expand Down
30 changes: 15 additions & 15 deletions docs/commands.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Slash Commands

### Command name: `about copyright`
**Description**: Library, licencing, and copyright information
**Description**: Library, licensing, and copyright information

* **Arguments**:
None
Expand Down Expand Up @@ -724,45 +724,45 @@ None
None
---
### Command name: `blocks`
**Description**: Get a list of the configured blocks
**Description**: Get a list of the configured blocks.

* Arguments:
* `channel` - Channel representing a welcome channel - Channel
* `channel` - Message channel representing a Welcome Channel. - Channel

---
### Command name: `welcome-channels delete`
**Description**: Delete a welcome channel configuration
**Description**: Delete a Welcome Channel configuration.

* **Arguments**:
* `channel` - Channel representing a welcome channel - Channel
* `channel` - Message channel representing a Welcome Channel. - Channel

---
### Command name: `welcome-channels get`
**Description**: Get the url for a welcome channel, if it's configured
**Description**: Get the url for a configured Welcome Channel.

* **Arguments**:
* `channel` - Channel representing a welcome channel - Channel
* `channel` - Message channel representing a Welcome Channel. - Channel

---
### Command name: `welcome-channels refresh`
**Description**: Manually repopulate the given welcome channel
**Description**: Manually repopulate the given Welcome Channel.

* **Arguments**:
* `channel` - Channel representing a welcome channel - Channel
* `clear` - Whether to clear the channel before repopulating it - Defaulting Boolean
* `channel` - Message channel representing a Welcome Channel. - Channel
* `clear` - Whether to clear and repopulate the channel instead of updating it. - Defaulting Boolean

---
### Command name: `welcome-channels set`
**Description**: Set the URL for a welcome channel, and populate it
**Description**: Set the URL for a Welcome Channel and populate it.

* **Arguments**:
* `channel` - Channel representing a welcome channel - Channel
* `url` - Public link to a YAML file used to configure a welcome channel - String
* `clear` - Whether to clear the channel before repopulating it - Defaulting Boolean
* `channel` - Message channel representing a Welcome Channel. - Channel
* `url` - Public link to a Welcome Channel configuration YAML file. - String
* `clear` - Whether to clear and repopulate the channel instead of updating it. - Defaulting Boolean

---
### Command name: `url-safety-check`
**Description**: Check whether a given domain is a known unsafe domain.
**Description**: Check whether a given domain is a known unsafe domain

* Arguments:
* `domain` - Domain to check - String
Expand Down
6 changes: 4 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ grgit = "5.3.0"
blossom = "2.1.0"

# Libraries
kord-extensions = "2.2.1-20241015.125602-7"
kord-extensions = "2.3.0-20241020.143126-1"
kordex-plugin = "1.5.3"
logging = "7.0.0"
logback = "1.5.10"
github-api = "1.326"
kmongo = "5.1.0"
docgenerator = "0.2.2-20241016.171703-3"
docgenerator = "0.3.0-beta.1"

[libraries]
kord-extensions-core = { module = "dev.kordex:kord-extensions", version.ref = "kord-extensions" }
Expand All @@ -38,3 +39,4 @@ detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
git-hooks = { id = "com.github.jakemarsden.git-hooks", version.ref = "git-hooks" }
grgit = { id = "org.ajoberstar.grgit", version.ref = "grgit" }
blossom = { id = "net.kyori.blossom", version.ref = "blossom" }
kord-extensions-plugin = { id = "dev.kordex.gradle.kordex", version.ref = "kordex-plugin"}
10 changes: 10 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()

maven("https://snapshots-repo.kordex.dev")
maven("https://releases-repo.kordex.dev")
}
}

rootProject.name = "LilyBot"
6 changes: 6 additions & 0 deletions src/main/kotlin/org/hyacinthbots/lilybot/LilyBot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import dev.kord.rest.builder.message.actionRow
import dev.kord.rest.builder.message.embed
import dev.kordex.core.ExtensibleBot
import dev.kordex.core.checks.hasPermission
import dev.kordex.core.i18n.SupportedLocales
import dev.kordex.core.time.TimestampType
import dev.kordex.core.time.toDiscord
import dev.kordex.data.api.DataCollection
Expand Down Expand Up @@ -231,6 +232,11 @@ suspend fun main() {
// }
}

i18n {
interactionUserLocaleResolver()
applicationCommandLocale(SupportedLocales.ENGLISH, SupportedLocales.GERMAN)
}

docsGenerator {
enabled = true
fileFormat = SupportedFileFormat.MARKDOWN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.hyacinthbots.lilybot.extensions.config
import dev.kordex.core.extensions.Extension
import dev.kordex.core.extensions.ephemeralSlashCommand
import dev.kordex.modules.dev.unsafe.annotations.UnsafeAPI
import lilybot.i18n.Translations
import org.hyacinthbots.lilybot.extensions.config.commands.configClearCommand
import org.hyacinthbots.lilybot.extensions.config.commands.configViewCommand
import org.hyacinthbots.lilybot.extensions.logging.config.loggingCommand
Expand All @@ -15,8 +16,8 @@ class ConfigExtension : Extension() {
@OptIn(UnsafeAPI::class)
override suspend fun setup() {
ephemeralSlashCommand {
name = "config"
description = "Configure Lily's settings"
name = Translations.Config.name
description = Translations.Config.name

loggingCommand()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import dev.kordex.core.commands.application.slash.EphemeralSlashCommandContext
import dev.kordex.core.commands.application.slash.SlashCommand
import dev.kordex.core.commands.application.slash.converters.impl.stringChoice
import dev.kordex.core.commands.application.slash.ephemeralSubCommand
import lilybot.i18n.Translations
import org.hyacinthbots.lilybot.database.collections.LoggingConfigCollection
import org.hyacinthbots.lilybot.database.collections.ModerationConfigCollection
import org.hyacinthbots.lilybot.database.collections.UtilityConfigCollection
Expand All @@ -18,8 +19,8 @@ import org.hyacinthbots.lilybot.extensions.config.ConfigType
import org.hyacinthbots.lilybot.utils.getLoggingChannelWithPerms

suspend fun SlashCommand<*, *, *>.configClearCommand() = ephemeralSubCommand(::ClearArgs) {
name = "clear"
description = "Clear a config type"
name = Translations.Config.Clear.name
description = Translations.Config.Clear.description

requirePermission(Permission.ManageGuild)

Expand All @@ -42,12 +43,12 @@ suspend fun SlashCommand<*, *, *>.configClearCommand() = ephemeralSubCommand(::C
respond {
embed {
title = if (arguments.config == ConfigType.ALL.name) {
"All configs cleared"
Translations.Config.Clear.all.translate()
} else {
"Config cleared: ${arguments.config}"
Translations.Config.Clear.Embed.title.translate(arguments.config)
}
footer {
text = "Config cleared by ${user.asUserOrNull()?.username}"
text = Translations.Config.configuredBy.translate(user.asUserOrNull()?.username)
icon = user.asUserOrNull()?.avatar?.cdnUrl?.toUrl()
}
}
Expand All @@ -64,11 +65,12 @@ suspend fun SlashCommand<*, *, *>.configClearCommand() = ephemeralSubCommand(::C
* @since 5.0.0
*/
private suspend fun EphemeralSlashCommandContext<*, *>.clearConfig(type: ConfigType, args: ClearArgs) {
val obj = Translations.Config.Clear
when (type) {
ConfigType.MODERATION -> {
ModerationConfigCollection().getConfig(guild!!.id) ?: run {
respond {
content = "No moderation configuration exists to clear"
content = obj.noConfigMod.translate()
}
return
}
Expand All @@ -79,7 +81,7 @@ private suspend fun EphemeralSlashCommandContext<*, *>.clearConfig(type: ConfigT
ConfigType.LOGGING -> {
LoggingConfigCollection().getConfig(guild!!.id) ?: run {
respond {
content = "No logging configuration exists to clear"
content = obj.noConfigLogging.translate()
}
}
logClear(args)
Expand All @@ -89,7 +91,7 @@ private suspend fun EphemeralSlashCommandContext<*, *>.clearConfig(type: ConfigT
ConfigType.UTILITY -> {
UtilityConfigCollection().getConfig(guild!!.id) ?: run {
respond {
content = "No utility configuration exists to clear"
content = obj.noConfigUtility.translate()
}
}
logClear(args)
Expand Down Expand Up @@ -118,33 +120,35 @@ suspend fun EphemeralSlashCommandContext<*, *>.logClear(arguments: ClearArgs) {

if (utilityLog == null) {
respond {
content = "Consider setting a utility config to log changes to configurations."
content = Translations.Config.considerUtility.translate()
}
return
}

utilityLog.createMessage {
embed {
title = "Configuration Cleared: ${arguments.config[0]}${
title = Translations.Config.Clear.Embed.title.translate(
arguments.config[0] +
arguments.config.substring(1, arguments.config.length).lowercase()
}"
)
footer {
text = "Config cleared by ${user.asUserOrNull()?.username}"
text = Translations.Config.Clear.footer.translate(user.asUserOrNull()?.username)
icon = user.asUserOrNull()?.avatar?.cdnUrl?.toUrl()
}
}
}
}

class ClearArgs : Arguments() {
private val choiceObj = Translations.Config.Arguments.Clear.Choice
val config by stringChoice {
name = "config-type"
description = "The type of config to clear"
name = Translations.Config.Arguments.Clear.name
description = Translations.Config.Arguments.Clear.description
choices = mutableMapOf(
"moderation" to ConfigType.MODERATION.name,
"logging" to ConfigType.LOGGING.name,
"utility" to ConfigType.UTILITY.name,
"all" to ConfigType.ALL.name
choiceObj.moderation to ConfigType.MODERATION.name,
choiceObj.logging to ConfigType.LOGGING.name,
choiceObj.utility to ConfigType.UTILITY.name,
choiceObj.all to ConfigType.ALL.name
)
}
}
Loading

0 comments on commit fd6c8e9

Please sign in to comment.