diff --git a/.github/workflows/qodana_code_quality.yml b/.github/workflows/qodana_code_quality.yml index 0ab44ee..6256ed0 100644 --- a/.github/workflows/qodana_code_quality.yml +++ b/.github/workflows/qodana_code_quality.yml @@ -23,7 +23,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 - name: 'Qodana Scan' - uses: JetBrains/qodana-action@v2024.2.2 + uses: JetBrains/qodana-action@v2024.3.3 env: QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} with: diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b4c77f8..1540db9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,15 +1,15 @@ [versions] detekt = "1.23.7" # Note: Plugin versions must be updated in the settings.gradle.kts too -kotlin = "2.0.20" # Note: Plugin versions must be updated in the settings.gradle.kts too +kotlin = "2.1.0" # Note: Plugin versions must be updated in the settings.gradle.kts too -groovy = "3.0.22" +groovy = "3.0.23" jansi = "2.4.1" -kx-ser = "1.7.2" -logback = "1.5.8" +kx-ser = "1.7.3" +logback = "1.5.15" logback-groovy = "1.14.5" -logging = "7.0.0" +logging = "7.0.3" kord-emoji = "0.5.0" -unleash = "9.2.4" +unleash = "9.2.6" kmongo-coroutine = "5.1.0" links-detektor = "1.0.1" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0aaefbc..cea7a79 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle.kts b/settings.gradle.kts index 4cdf2c2..b37fd39 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,8 +1,8 @@ pluginManagement { plugins { // Update this in libs.version.toml when you change it here. - kotlin("jvm") version "2.0.20" - kotlin("plugin.serialization") version "2.0.20" + kotlin("jvm") version "2.1.0" + kotlin("plugin.serialization") version "2.1.0" // Update this in libs.version.toml when you change it here. id("io.gitlab.arturbosch.detekt") version "1.23.7" @@ -10,8 +10,17 @@ pluginManagement { id("com.github.jakemarsden.git-hooks") version "0.0.2" id("com.github.johnrengelman.shadow") version "8.1.1" - id("dev.kordex.gradle.docker") version "1.4.2" - id("dev.kordex.gradle.kordex") version "1.4.2" + id("dev.kordex.gradle.docker") version "1.6.0" + id("dev.kordex.gradle.kordex") version "1.6.0" + } + + repositories { + gradlePluginPortal() + mavenCentral() + + maven("https://snapshots-repo.kordex.dev") + maven("https://releases-repo.kordex.dev") + maven("https://oss.sonatype.org/content/repositories/snapshots") } } diff --git a/src/main/kotlin/troy/commands/config/InviteLink.kt b/src/main/kotlin/troy/commands/config/InviteLink.kt index 78e7fdd..a036009 100644 --- a/src/main/kotlin/troy/commands/config/InviteLink.kt +++ b/src/main/kotlin/troy/commands/config/InviteLink.kt @@ -6,6 +6,7 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.string import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import org.koin.core.component.inject import troy.data.repository.GlobalGuildRepository import troy.utils.bold @@ -18,16 +19,16 @@ class InviteLink : Extension() { inner class InviteLinkArgument : Arguments() { val inviteLink by string { - name = "url" - description = "Provide Permanent invite link for this server." + name = "url".toKey() + description = "Provide Permanent invite link for this server.".toKey() } } override suspend fun setup() { val globalGuildRepository: GlobalGuildRepository by inject() publicSlashCommand(::InviteLinkArgument) { - name = "invite-link" - description = "Setup invite link for this server" + name = "invite-link".toKey() + description = "Setup invite link for this server".toKey() check { hasPermission(Permission.Administrator) } action { val guildId = guild?.id?.toString().orEmpty() diff --git a/src/main/kotlin/troy/commands/funstuff/Burn.kt b/src/main/kotlin/troy/commands/funstuff/Burn.kt index 220d59c..f6ee629 100644 --- a/src/main/kotlin/troy/commands/funstuff/Burn.kt +++ b/src/main/kotlin/troy/commands/funstuff/Burn.kt @@ -5,6 +5,7 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.user import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import org.koin.core.component.inject import troy.utils.DataProvider import troy.utils.isGirlfriend @@ -19,15 +20,15 @@ class Burn : Extension() { class BurnArguments : Arguments() { val user by user { - name = "user" - description = "Which user do you want to light on fire?" + name = "user".toKey() + description = "Which user do you want to light on fire?".toKey() } } override suspend fun setup() { publicSlashCommand(Burn::BurnArguments) { - name = "burn" - description = "Lights fire to mentioned user." + name = "burn".toKey() + description = "Lights fire to mentioned user.".toKey() action { val burnList = DataProvider.getBurnData() val randomBurn = burnList[kotlin.math.floor(Math.random() * burnList.size).toInt()] diff --git a/src/main/kotlin/troy/commands/funstuff/Dictionary.kt b/src/main/kotlin/troy/commands/funstuff/Dictionary.kt index cee4a26..9f05ca2 100644 --- a/src/main/kotlin/troy/commands/funstuff/Dictionary.kt +++ b/src/main/kotlin/troy/commands/funstuff/Dictionary.kt @@ -6,20 +6,15 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.string import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import dev.kordex.core.utils.env -import io.ktor.client.call.body -import io.ktor.client.request.get -import io.ktor.client.request.headers -import io.ktor.http.HttpHeaders -import io.ktor.http.HttpStatusCode +import io.ktor.client.call.* +import io.ktor.client.request.* +import io.ktor.http.* import kotlinx.datetime.Clock import org.koin.core.component.inject import troy.apiModels.OwlDictModel -import troy.utils.Environment -import troy.utils.commonLogger -import troy.utils.getEmbedFooter -import troy.utils.httpClient -import troy.utils.requestAndCatch +import troy.utils.* class Dictionary : Extension() { @@ -30,15 +25,15 @@ class Dictionary : Extension() { class DictionaryArguments : Arguments() { val word by string { - name = "word" - description = "Which word do you wanna search?" + name = "word".toKey() + description = "Which word do you wanna search?".toKey() } } override suspend fun setup() { publicSlashCommand(Dictionary::DictionaryArguments) { - name = "dictionary" - description = "Finds definition for given word with image, emoji and examples." + name = "dictionary".toKey() + description = "Finds definition for given word with image, emoji and examples.".toKey() action { val url = "https://owlbot.info/api/v4/dictionary/" + arguments.word httpClient.requestAndCatch({ diff --git a/src/main/kotlin/troy/commands/funstuff/Doggo.kt b/src/main/kotlin/troy/commands/funstuff/Doggo.kt index a7ca677..c326853 100644 --- a/src/main/kotlin/troy/commands/funstuff/Doggo.kt +++ b/src/main/kotlin/troy/commands/funstuff/Doggo.kt @@ -6,9 +6,10 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.defaultingString import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand -import io.ktor.client.call.body -import io.ktor.client.request.get -import io.ktor.http.HttpStatusCode +import dev.kordex.core.i18n.toKey +import io.ktor.client.call.* +import io.ktor.client.request.* +import io.ktor.http.* import kotlinx.datetime.Clock import org.koin.core.component.inject import troy.apiModels.DoggoModel @@ -27,16 +28,16 @@ class Doggo : Extension() { class DoggoArguments : Arguments() { val breed by defaultingString { - name = "breed" - description = "Which breed of good boi you want to see?" + name = "breed".toKey() + description = "Which breed of good boi you want to see?".toKey() defaultValue = "random" } } override suspend fun setup() { publicSlashCommand(Doggo::DoggoArguments) { - name = "doggo" - description = "Finds some cute doggo images." + name = "doggo".toKey() + description = "Finds some cute doggo images.".toKey() action { val url = if (arguments.breed == "random") { "https://dog.ceo/api/breeds/image/random" diff --git a/src/main/kotlin/troy/commands/funstuff/Emoji.kt b/src/main/kotlin/troy/commands/funstuff/Emoji.kt index bfcb492..74986ab 100644 --- a/src/main/kotlin/troy/commands/funstuff/Emoji.kt +++ b/src/main/kotlin/troy/commands/funstuff/Emoji.kt @@ -4,6 +4,7 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.coalescingString import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import kotlinx.coroutines.flow.count import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first @@ -15,15 +16,15 @@ class Emoji : Extension() { inner class EmojiArguments : Arguments() { val emoji by coalescingString { - name = "emoji-name" - description = "Which emoji would you like me to send? PS: Animated emoji are supported." + name = "emoji-name".toKey() + description = "Which emoji would you like me to send? PS: Animated emoji are supported.".toKey() } } override suspend fun setup() { publicSlashCommand(::EmojiArguments) { - name = "emoji" - description = "Sends server custom emoji, Also supports animated emojis." + name = "emoji".toKey() + description = "Sends server custom emoji, Also supports animated emojis.".toKey() action { if ( guild?.emojis?.filter { it.name == arguments.emoji }?.count() != 0 diff --git a/src/main/kotlin/troy/commands/funstuff/Fact.kt b/src/main/kotlin/troy/commands/funstuff/Fact.kt index c72cf83..35100cc 100644 --- a/src/main/kotlin/troy/commands/funstuff/Fact.kt +++ b/src/main/kotlin/troy/commands/funstuff/Fact.kt @@ -4,8 +4,9 @@ import dev.kord.core.Kord import dev.kord.rest.builder.message.embed import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand -import io.ktor.client.call.body -import io.ktor.client.request.get +import dev.kordex.core.i18n.toKey +import io.ktor.client.call.* +import io.ktor.client.request.* import kotlinx.datetime.Clock import org.koin.core.component.inject import troy.apiModels.FactModel @@ -23,8 +24,8 @@ class Fact : Extension() { override suspend fun setup() { publicSlashCommand { - name = "fact" - description = "Finds some useless facts." + name = "fact".toKey() + description = "Finds some useless facts.".toKey() action { val url = "https://uselessfacts.jsph.pl/random.json?language=en" httpClient.requestAndCatch({ diff --git a/src/main/kotlin/troy/commands/funstuff/Flip.kt b/src/main/kotlin/troy/commands/funstuff/Flip.kt index afd2a11..ff76493 100644 --- a/src/main/kotlin/troy/commands/funstuff/Flip.kt +++ b/src/main/kotlin/troy/commands/funstuff/Flip.kt @@ -2,6 +2,7 @@ package troy.commands.funstuff import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import kotlin.math.floor class Flip : Extension() { @@ -11,8 +12,8 @@ class Flip : Extension() { override suspend fun setup() { publicSlashCommand { - name = "flip" - description = "Flips a coin for you." + name = "flip".toKey() + description = "Flips a coin for you.".toKey() action { respond { val result = if (floor(Math.random() * 2).toInt() == 0) { diff --git a/src/main/kotlin/troy/commands/funstuff/ItsOur.kt b/src/main/kotlin/troy/commands/funstuff/ItsOur.kt index dfd0b41..90037d6 100644 --- a/src/main/kotlin/troy/commands/funstuff/ItsOur.kt +++ b/src/main/kotlin/troy/commands/funstuff/ItsOur.kt @@ -4,6 +4,7 @@ import dev.kord.core.Kord import dev.kord.rest.builder.message.embed import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import kotlinx.datetime.Clock import org.koin.core.component.inject import troy.utils.getEmbedFooter @@ -19,8 +20,8 @@ class ItsOur : Extension() { override suspend fun setup() { publicSlashCommand { - name = "our" - description = "Firmly states that it is ours in this soviet soil." + name = "our".toKey() + description = "Firmly states that it is ours in this soviet soil.".toKey() action { respond { embed { diff --git a/src/main/kotlin/troy/commands/funstuff/Poll.kt b/src/main/kotlin/troy/commands/funstuff/Poll.kt index 3a8d72a..de90f86 100644 --- a/src/main/kotlin/troy/commands/funstuff/Poll.kt +++ b/src/main/kotlin/troy/commands/funstuff/Poll.kt @@ -17,6 +17,7 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.string import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import org.koin.core.component.inject import troy.utils.getEmbedFooter @@ -42,19 +43,19 @@ class Poll : Extension() { inner class PollArguments : Arguments() { val title by string { - name = "title" - description = "Title for poll" + name = "title".toKey() + description = "Title for poll".toKey() } val options by string { - name = "options" - description = "Options for poll separated by comma" + name = "options".toKey() + description = "Options for poll separated by comma".toKey() } } override suspend fun setup() { publicSlashCommand(::PollArguments) { - name = "poll" - description = "Gives a poll for provided options" + name = "poll".toKey() + description = "Gives a poll for provided options".toKey() action { val optionList = arguments.options.split(",") respond { diff --git a/src/main/kotlin/troy/commands/funstuff/Pun.kt b/src/main/kotlin/troy/commands/funstuff/Pun.kt index 1eb1de0..e887c54 100644 --- a/src/main/kotlin/troy/commands/funstuff/Pun.kt +++ b/src/main/kotlin/troy/commands/funstuff/Pun.kt @@ -2,8 +2,9 @@ package troy.commands.funstuff import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand -import io.ktor.client.call.body -import io.ktor.client.request.get +import dev.kordex.core.i18n.toKey +import io.ktor.client.call.* +import io.ktor.client.request.* import troy.apiModels.PunsModel import troy.utils.commonLogger import troy.utils.httpClient @@ -18,8 +19,8 @@ class Pun : Extension() { override suspend fun setup() { publicSlashCommand { - name = "pun" - description = "Sends a pun" + name = "pun".toKey() + description = "Sends a pun".toKey() action { val url = "https://icanhazdadjoke.com/" httpClient.requestAndCatch( diff --git a/src/main/kotlin/troy/commands/funstuff/SarcasticCatNo.kt b/src/main/kotlin/troy/commands/funstuff/SarcasticCatNo.kt index 59c0c4a..6745774 100644 --- a/src/main/kotlin/troy/commands/funstuff/SarcasticCatNo.kt +++ b/src/main/kotlin/troy/commands/funstuff/SarcasticCatNo.kt @@ -4,6 +4,7 @@ import dev.kord.core.Kord import dev.kord.rest.builder.message.embed import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import kotlinx.datetime.Clock import org.koin.core.component.inject import troy.utils.getEmbedFooter @@ -19,8 +20,8 @@ class SarcasticCatNo : Extension() { override suspend fun setup() { publicSlashCommand { - name = "sarno" - description = "Summons a sarcastic catto to say no." + name = "sarno".toKey() + description = "Summons a sarcastic catto to say no.".toKey() action { respond { embed { diff --git a/src/main/kotlin/troy/commands/funstuff/Sike.kt b/src/main/kotlin/troy/commands/funstuff/Sike.kt index 4db2455..8e5850e 100644 --- a/src/main/kotlin/troy/commands/funstuff/Sike.kt +++ b/src/main/kotlin/troy/commands/funstuff/Sike.kt @@ -2,6 +2,7 @@ package troy.commands.funstuff import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey class Sike : Extension() { @@ -10,8 +11,8 @@ class Sike : Extension() { override suspend fun setup() { publicSlashCommand { - name = "sike" - description = "Sends sike whenever someone requests for it." + name = "sike".toKey() + description = "Sends sike whenever someone requests for it.".toKey() action { respond { content = "** _S I K E_ **" } } diff --git a/src/main/kotlin/troy/commands/funstuff/SorryDidi.kt b/src/main/kotlin/troy/commands/funstuff/SorryDidi.kt index a6c051a..c99c099 100644 --- a/src/main/kotlin/troy/commands/funstuff/SorryDidi.kt +++ b/src/main/kotlin/troy/commands/funstuff/SorryDidi.kt @@ -4,6 +4,7 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.optionalUser import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey class SorryDidi : Extension() { @@ -12,15 +13,15 @@ class SorryDidi : Extension() { inner class SorryDidiArguments : Arguments() { val user by optionalUser { - name = "user" - description = "Which woke didi you want to apologise to?." + name = "user".toKey() + description = "Which woke didi you want to apologise to?.".toKey() } } override suspend fun setup() { publicSlashCommand(::SorryDidiArguments) { - name = "sorry-didi" - description = "Apologizes to woke didis out there." + name = "sorry-didi".toKey() + description = "Apologizes to woke didis out there.".toKey() action { if (arguments.user == null) { respond { diff --git a/src/main/kotlin/troy/commands/funstuff/Tereko.kt b/src/main/kotlin/troy/commands/funstuff/Tereko.kt index 4e8e304..3443c6e 100644 --- a/src/main/kotlin/troy/commands/funstuff/Tereko.kt +++ b/src/main/kotlin/troy/commands/funstuff/Tereko.kt @@ -4,6 +4,7 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.optionalUser import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey class Tereko : Extension() { @@ -12,15 +13,15 @@ class Tereko : Extension() { inner class TerekoArgument : Arguments() { val user by optionalUser { - name = "user" - description = "hmm? :thinking:" + name = "user".toKey() + description = "hmm? :thinking:".toKey() } } override suspend fun setup() { publicSlashCommand(::TerekoArgument) { - name = "tereko" - description = "Returns tereko lagta hai." + name = "tereko".toKey() + description = "Returns tereko lagta hai.".toKey() action { if (arguments.user == null) { respond { diff --git a/src/main/kotlin/troy/commands/funstuff/Understandable.kt b/src/main/kotlin/troy/commands/funstuff/Understandable.kt index a0006ae..a44e44d 100644 --- a/src/main/kotlin/troy/commands/funstuff/Understandable.kt +++ b/src/main/kotlin/troy/commands/funstuff/Understandable.kt @@ -4,6 +4,7 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.optionalUser import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey class Understandable : Extension() { @@ -12,15 +13,15 @@ class Understandable : Extension() { inner class UnderstandableArgument : Arguments() { val user by optionalUser { - name = "user" - description = "Which user you want to wish great day." + name = "user".toKey() + description = "Which user you want to wish great day.".toKey() } } override suspend fun setup() { publicSlashCommand(::UnderstandableArgument) { - name = "understandable" - description = "Sends understandable have a great day on request." + name = "understandable".toKey() + description = "Sends understandable have a great day on request.".toKey() action { if (arguments.user == null) { respond { diff --git a/src/main/kotlin/troy/commands/funstuff/UrbanDictionary.kt b/src/main/kotlin/troy/commands/funstuff/UrbanDictionary.kt index d035a93..04f739c 100644 --- a/src/main/kotlin/troy/commands/funstuff/UrbanDictionary.kt +++ b/src/main/kotlin/troy/commands/funstuff/UrbanDictionary.kt @@ -7,18 +7,15 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.string import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand -import io.ktor.client.call.body -import io.ktor.client.request.get -import io.ktor.http.HttpStatusCode +import dev.kordex.core.i18n.toKey +import io.ktor.client.call.* +import io.ktor.client.request.* +import io.ktor.http.* import kotlinx.datetime.Clock import org.koin.core.component.inject import troy.apiModels.UrbanDictItem import troy.apiModels.UrbanDictModel -import troy.utils.commonLogger -import troy.utils.encodeQuery -import troy.utils.getEmbedFooter -import troy.utils.httpClient -import troy.utils.requestAndCatch +import troy.utils.* class UrbanDictionary : Extension() { @@ -31,15 +28,15 @@ class UrbanDictionary : Extension() { class UrbanDictArguments : Arguments() { val search by string { - name = "query" - description = "What do you want to search at UrbanDictionary?" + name = "query".toKey() + description = "What do you want to search at UrbanDictionary?".toKey() } } override suspend fun setup() { publicSlashCommand(UrbanDictionary::UrbanDictArguments) { - name = "urban" - description = "Returns a definition from Urban Dictionary" + name = "urban".toKey() + description = "Returns a definition from Urban Dictionary".toKey() action { var urbanDictModel: UrbanDictModel? = null val search = arguments.search.encodeQuery() @@ -63,8 +60,8 @@ class UrbanDictionary : Extension() { if (definitionCount + exampleCount + authorCount > MAX_CHARS) { this.respond { content = "Can not send the response since it is too long, " + - "Here is the link to that page for you instead.\n" + - urbanDictItem.permalink + "Here is the link to that page for you instead.\n" + + urbanDictItem.permalink } } else { this.respond { diff --git a/src/main/kotlin/troy/commands/misc/Avatar.kt b/src/main/kotlin/troy/commands/misc/Avatar.kt index 9570376..5854d94 100644 --- a/src/main/kotlin/troy/commands/misc/Avatar.kt +++ b/src/main/kotlin/troy/commands/misc/Avatar.kt @@ -6,6 +6,7 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.optionalUser import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import kotlinx.datetime.Clock import org.koin.core.component.inject import troy.utils.getEmbedFooter @@ -19,15 +20,15 @@ class Avatar : Extension() { inner class AvatarArguments : Arguments() { val user by optionalUser { - name = "user" - description = "Get avatar of mentioned user or yours if no user is mentioned." + name = "user".toKey() + description = "Get avatar of mentioned user or yours if no user is mentioned.".toKey() } } override suspend fun setup() { publicSlashCommand(::AvatarArguments) { - name = "avatar" - description = "Get the avatar URL of the tagged user, or your own avatar." + name = "avatar".toKey() + description = "Get the avatar URL of the tagged user, or your own avatar.".toKey() action { if (arguments.user == null) { val memberAvatarUrl = member?.asUser()?.avatar?.cdnUrl?.toUrl() diff --git a/src/main/kotlin/troy/commands/misc/InviteTroy.kt b/src/main/kotlin/troy/commands/misc/InviteTroy.kt index d7d7448..3eed6d9 100644 --- a/src/main/kotlin/troy/commands/misc/InviteTroy.kt +++ b/src/main/kotlin/troy/commands/misc/InviteTroy.kt @@ -2,6 +2,7 @@ package troy.commands.misc import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey class InviteTroy : Extension() { @@ -10,8 +11,8 @@ class InviteTroy : Extension() { override suspend fun setup() { publicSlashCommand { - name = "inviteTroy" - description = "Returns invite link for Troy." + name = "inviteTroy".toKey() + description = "Returns invite link for Troy.".toKey() action { respond { content = diff --git a/src/main/kotlin/troy/commands/misc/Repo.kt b/src/main/kotlin/troy/commands/misc/Repo.kt index de0f56e..1cdebfa 100644 --- a/src/main/kotlin/troy/commands/misc/Repo.kt +++ b/src/main/kotlin/troy/commands/misc/Repo.kt @@ -2,6 +2,7 @@ package troy.commands.misc import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey class Repo : Extension() { @@ -10,12 +11,12 @@ class Repo : Extension() { override suspend fun setup() { publicSlashCommand { - name = "repo" - description = "Returns Troy's GitLab repo url." + name = "repo".toKey() + description = "Returns Troy's Github repo url.".toKey() action { respond { - content = "https://gitlab.com/technowolf/troy" + - "\nNote: Please checkout develop branch if you want to contribute." + content = "https://github.com/daksh7011/troy" + + "\nNote: Please checkout develop branch if you want to contribute." } } } diff --git a/src/main/kotlin/troy/commands/misc/Steam.kt b/src/main/kotlin/troy/commands/misc/Steam.kt index 95c21e0..90bafd7 100644 --- a/src/main/kotlin/troy/commands/misc/Steam.kt +++ b/src/main/kotlin/troy/commands/misc/Steam.kt @@ -8,20 +8,17 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.coalescingString import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand -import io.ktor.client.call.body -import io.ktor.client.request.get -import io.ktor.http.HttpStatusCode +import dev.kordex.core.i18n.toKey +import io.ktor.client.call.* +import io.ktor.client.request.* +import io.ktor.http.* import kotlinx.datetime.Clock import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonObject import org.koin.core.component.inject import troy.apiModels.SteamGameModel import troy.apiModels.SteamSearchModel -import troy.utils.commonLogger -import troy.utils.encodeQuery -import troy.utils.getEmbedFooter -import troy.utils.httpClient -import troy.utils.requestAndCatch +import troy.utils.* class Steam : Extension() { @@ -34,15 +31,15 @@ class Steam : Extension() { class SteamSearchArguments : Arguments() { val gameName by coalescingString { - name = "game-name" - description = "Which game do you want to search for?" + name = "game-name".toKey() + description = "Which game do you want to search for?".toKey() } } override suspend fun setup() { publicSlashCommand(Steam::SteamSearchArguments) { - name = "steam" - description = "Searches Steam for your query." + name = "steam".toKey() + description = "Searches Steam for your query.".toKey() action { var steamSearchModel: SteamSearchModel? = null var steamGameJsonObject: JsonObject? = null diff --git a/src/main/kotlin/troy/commands/mod/Ban.kt b/src/main/kotlin/troy/commands/mod/Ban.kt index 7dc6a64..29c72e7 100644 --- a/src/main/kotlin/troy/commands/mod/Ban.kt +++ b/src/main/kotlin/troy/commands/mod/Ban.kt @@ -11,6 +11,7 @@ import dev.kordex.core.commands.converters.impl.coalescingString import dev.kordex.core.commands.converters.impl.user import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import kotlinx.datetime.Clock import org.koin.core.component.inject import troy.data.repository.BanLogsRepository @@ -26,20 +27,20 @@ class Ban : Extension() { inner class BanArguments : Arguments() { val user by user { - name = "user" - description = "Which user do you want to ban?" + name = "user".toKey() + description = "Which user do you want to ban?".toKey() } val reason by coalescingString { - name = "reason" - description = "Reason for the ban" + name = "reason".toKey() + description = "Reason for the ban".toKey() } } override suspend fun setup() { val banLogsRepository: BanLogsRepository by inject() publicSlashCommand(::BanArguments) { - name = "ban" - description = "Bans user with reason." + name = "ban".toKey() + description = "Bans user with reason.".toKey() check { hasPermission(Permission.Administrator) requireBotPermissions(Permission.BanMembers) @@ -69,7 +70,7 @@ class Ban : Extension() { } catch (exception: Exception) { respond { content = "Could not ban the user. Please check my hierarchy in guild roles." + - " If everything looks in order, Please contact the bot developers." + " If everything looks in order, Please contact the bot developers." } } } diff --git a/src/main/kotlin/troy/commands/mod/Kick.kt b/src/main/kotlin/troy/commands/mod/Kick.kt index 1dc1a57..0b9ad85 100644 --- a/src/main/kotlin/troy/commands/mod/Kick.kt +++ b/src/main/kotlin/troy/commands/mod/Kick.kt @@ -10,6 +10,7 @@ import dev.kordex.core.commands.converters.impl.string import dev.kordex.core.commands.converters.impl.user import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import kotlinx.datetime.Clock import org.koin.core.component.inject import troy.data.repository.KickLogsRepository @@ -25,20 +26,20 @@ class Kick : Extension() { inner class KickArguments : Arguments() { val user by user { - name = "user" - description = "Which user do you want to kick?" + name = "user".toKey() + description = "Which user do you want to kick?".toKey() } val reason by string { - name = "reason" - description = "Reason for the kick" + name = "reason".toKey() + description = "Reason for the kick".toKey() } } override suspend fun setup() { val kickLogsRepository: KickLogsRepository by inject() publicSlashCommand(::KickArguments) { - name = "kick" - description = "Kicks user with reason." + name = "kick".toKey() + description = "Kicks user with reason.".toKey() check { hasPermission(Permission.Administrator) requireBotPermissions(Permission.KickMembers) @@ -67,7 +68,7 @@ class Kick : Extension() { } catch (exception: Exception) { respond { content = "Could not kick the user. Please check my hierarchy in guild roles." + - " If everything looks in order, Please contact the bot developers." + " If everything looks in order, Please contact the bot developers." } } } diff --git a/src/main/kotlin/troy/commands/mod/Prune.kt b/src/main/kotlin/troy/commands/mod/Prune.kt index 6e0fc8f..55a2021 100644 --- a/src/main/kotlin/troy/commands/mod/Prune.kt +++ b/src/main/kotlin/troy/commands/mod/Prune.kt @@ -6,6 +6,7 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.string import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.chatCommand +import dev.kordex.core.i18n.toKey import kotlinx.coroutines.flow.take class Prune : Extension() { @@ -15,15 +16,14 @@ class Prune : Extension() { class PurgeArguments : Arguments() { val amount by string { - name = "number" - description = "How many messages you want to purge?" + name = "number".toKey() + description = "How many messages you want to purge?".toKey() } } override suspend fun setup() { chatCommand(Prune::PurgeArguments) { - name = "purge" - aliases = arrayOf("purge", "bulk", "clean") + name = "purge".toKey() check { hasPermission(Permission.Administrator) requireBotPermissions(Permission.ManageMessages) diff --git a/src/main/kotlin/troy/commands/mod/Reboot.kt b/src/main/kotlin/troy/commands/mod/Reboot.kt index 44cae44..2b89625 100644 --- a/src/main/kotlin/troy/commands/mod/Reboot.kt +++ b/src/main/kotlin/troy/commands/mod/Reboot.kt @@ -1,8 +1,10 @@ package troy.commands.mod import dev.kord.core.Kord +import dev.kordex.core.annotations.NotTranslated import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import org.koin.core.component.inject import troy.utils.isOwner @@ -13,10 +15,11 @@ class Reboot : Extension() { override val name: String get() = "reboot" + @OptIn(NotTranslated::class) override suspend fun setup() { publicSlashCommand { - name = "reboot" - description = "Reboots bot" + name = "reboot".toKey() + description = "Reboots bot".toKey() check { failIf(!event.interaction.user.id.isOwner(), message = "This is owner only command.") } action { respond { diff --git a/src/main/kotlin/troy/commands/mod/ResetWarnings.kt b/src/main/kotlin/troy/commands/mod/ResetWarnings.kt index 012385b..54f4542 100644 --- a/src/main/kotlin/troy/commands/mod/ResetWarnings.kt +++ b/src/main/kotlin/troy/commands/mod/ResetWarnings.kt @@ -7,6 +7,7 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.user import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import org.koin.core.component.inject import troy.data.repository.WarningLogsRepository @@ -19,16 +20,16 @@ class ResetWarnings : Extension() { inner class WarnResetArguments : Arguments() { val user by user { - name = "user" - description = "Which user do you want to reset warnings for?" + name = "user".toKey() + description = "Which user do you want to reset warnings for?".toKey() } } override suspend fun setup() { val warningLogsRepository: WarningLogsRepository by inject() publicSlashCommand(::WarnResetArguments) { - name = "reset-warnings" - description = "Resets warnings for mentioned user." + name = "reset-warnings".toKey() + description = "Resets warnings for mentioned user.".toKey() check { hasPermission(Permission.Administrator) requireBotPermissions(Permission.KickMembers) diff --git a/src/main/kotlin/troy/commands/mod/Warn.kt b/src/main/kotlin/troy/commands/mod/Warn.kt index 81b6646..184ab33 100644 --- a/src/main/kotlin/troy/commands/mod/Warn.kt +++ b/src/main/kotlin/troy/commands/mod/Warn.kt @@ -11,6 +11,7 @@ import dev.kordex.core.commands.converters.impl.coalescingString import dev.kordex.core.commands.converters.impl.user import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import kotlinx.datetime.Clock import org.koin.core.component.inject import troy.commands.mod.Ban.Companion.setupBannedEmbed @@ -32,12 +33,12 @@ class Warn : Extension() { inner class WarnArguments : Arguments() { val warnedUser by user { - name = "user" - description = "Which user do you want to warn?" + name = "user".toKey() + description = "Which user do you want to warn?".toKey() } val reason by coalescingString { - name = "reason" - description = "Reason for the warning." + name = "reason".toKey() + description = "Reason for the warning.".toKey() } } @@ -48,8 +49,8 @@ class Warn : Extension() { val banLogsRepository: BanLogsRepository by inject() publicSlashCommand(::WarnArguments) { - name = "warn" - description = "Warns the user with a reason." + name = "warn".toKey() + description = "Warns the user with a reason.".toKey() check { hasPermission(Permission.Administrator) requireBotPermissions(Permission.KickMembers) @@ -92,7 +93,7 @@ class Warn : Extension() { } catch (exception: Exception) { respond { content = "Could not kick the user. Please check my hierarchy in guild roles." + - " If everything looks in order, Please contact the bot developers." + " If everything looks in order, Please contact the bot developers." } } is WarningMode.Ban -> try { @@ -110,7 +111,7 @@ class Warn : Extension() { } catch (exception: Exception) { respond { content = "Could not ban the user. Please check my hierarchy in guild roles." + - " If everything looks in order, Please contact the bot developers." + " If everything looks in order, Please contact the bot developers." } } is WarningMode.None -> embed { @@ -164,8 +165,8 @@ class Warn : Extension() { private suspend fun EmbedBuilder.setupEmbedForNoneWarningMode(userMention: String) { title = "Warning Event" description = "$userMention exceeded maximum warnings but warning mode is set to **None** for this guild. " + - "Hence no action is taken. To modify this behaviour, Please change the warning mode for automated " + - "Kick or Bans when user exceeds max number of warnings." + "Hence no action is taken. To modify this behaviour, Please change the warning mode for automated " + + "Kick or Bans when user exceeds max number of warnings." timestamp = Clock.System.now() footer = kordClient.getEmbedFooter() } diff --git a/src/main/kotlin/troy/commands/nsfw/Nudes.kt b/src/main/kotlin/troy/commands/nsfw/Nudes.kt index fb6f827..b6e8a80 100644 --- a/src/main/kotlin/troy/commands/nsfw/Nudes.kt +++ b/src/main/kotlin/troy/commands/nsfw/Nudes.kt @@ -6,6 +6,7 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.defaultingString import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand +import dev.kordex.core.i18n.toKey import kotlinx.datetime.Clock import net.dean.jraw.models.SubredditSort import org.koin.core.component.inject @@ -25,16 +26,16 @@ class Nudes : Extension() { class NudesArguments : Arguments() { val category by defaultingString { - name = "category" - description = "What will tickle your pickle?" + name = "category".toKey() + description = "What will tickle your pickle?".toKey() defaultValue = "random" } } override suspend fun setup() { publicSlashCommand(Nudes::NudesArguments) { - name = "nudes" - description = "Finds some spicy noods." + name = "nudes".toKey() + description = "Finds some spicy noods.".toKey() action { if (kordClient.getChannel(channel.id)?.data?.nsfw?.orElse(false) == false) { this@action.respond { @@ -46,7 +47,7 @@ class Nudes : Extension() { if (nudeUrl.isNullOrBlank()) { val randomCategoryList = nudesCatalog.random().value content = "Can not find nude for given category. Try different category.\n" + - "Maybe try anything form this: ${randomCategoryList.take(2).joinToString()}" + "Maybe try anything form this: ${randomCategoryList.take(2).joinToString()}" } else { embed { title = "Go. Enjoy those 10 seconds." diff --git a/src/main/kotlin/troy/commands/nsfw/Rule34.kt b/src/main/kotlin/troy/commands/nsfw/Rule34.kt index 1d1bef2..dec05c7 100644 --- a/src/main/kotlin/troy/commands/nsfw/Rule34.kt +++ b/src/main/kotlin/troy/commands/nsfw/Rule34.kt @@ -6,8 +6,9 @@ import dev.kordex.core.commands.Arguments import dev.kordex.core.commands.converters.impl.string import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.publicSlashCommand -import io.ktor.client.call.body -import io.ktor.client.request.get +import dev.kordex.core.i18n.toKey +import io.ktor.client.call.* +import io.ktor.client.request.* import kotlinx.datetime.Clock import org.koin.core.component.inject import troy.apiModels.Rule34Model @@ -23,15 +24,15 @@ class Rule34 : Extension() { class Rule34Arguments : Arguments() { val search by string { - name = "search" - description = "What do you want to see?" + name = "search".toKey() + description = "What do you want to see?".toKey() } } override suspend fun setup() { publicSlashCommand(Rule34::Rule34Arguments) { - name = "rule34" - description = "Provides Rule34 content for given search query." + name = "rule34".toKey() + description = "Provides Rule34 content for given search query.".toKey() action { if (kordClient.getChannel(channel.id)?.data?.nsfw?.orElse(false) == false) { respond { diff --git a/src/main/kotlin/troy/utils/Extensions.kt b/src/main/kotlin/troy/utils/Extensions.kt index a6f3385..f801fe3 100644 --- a/src/main/kotlin/troy/utils/Extensions.kt +++ b/src/main/kotlin/troy/utils/Extensions.kt @@ -21,7 +21,7 @@ import io.ktor.serialization.kotlinx.json.json import kotlinx.serialization.json.Json import java.net.URLEncoder -fun Message.isBot(): Boolean = author?.isBot ?: true +fun Message.isBot(): Boolean = author?.isBot != false fun Message.isNotBot(): Boolean = isBot().not() fun Message.containsF(): Boolean = content.lowercase() == "f" fun Message.containsNigga(): Boolean = content.lowercase().contains("nigga")