Skip to content

Created /locale command to set locale of a guild#105

Open
Wikijito7 wants to merge 5 commits intomasterfrom
feature/60-command-to-set-locale
Open

Created /locale command to set locale of a guild#105
Wikijito7 wants to merge 5 commits intomasterfrom
feature/60-command-to-set-locale

Conversation

@Wikijito7
Copy link
Owner

@Wikijito7 Wikijito7 commented Feb 8, 2026

Solves #60.

📋 Changelist Summary

Created /locale command to set locale of a guild

💬 Description

Created /locale command to set the locale of a given Guild. This locale is saved on a json file inside data. It is read only once when the bot is loaded and kept in memory as a map guildId to locale.

In this PR we update all commands to support this new usage of LocaleService.

@Wikijito7 Wikijito7 requested a review from javdc February 8, 2026 10:38
@Wikijito7 Wikijito7 self-assigned this Feb 8, 2026
@Wikijito7 Wikijito7 linked an issue Feb 8, 2026 that may be closed by this pull request
1 task
# Conflicts:
#	src/main/kotlin/services/lavaplayer/GuildLavaPlayerService.kt
Comment on lines +58 to +65
response.respond {
content = localizationService.getString(
key = LocalizationKeys.ERROR_NO_GUILD,
guildId = null,
discordLocale = discordLocale
)
}
return
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use error managment instead (throw exception)

Comment on lines +71 to +78
response.respond {
content = localizationService.getStringFormat(
key = LocalizationKeys.ERROR_NO_CONTENT_PROVIDED,
guildId = guildId,
discordLocale = discordLocale,
arguments = arrayOf(ARGUMENT_LOCALE)
)
}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error managment (throw)

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 8, 2026

* Map of Discord locale codes to Locale objects.
* Source: https://discord.com/developers/docs/reference#locales
*/
val DISCORD_LOCALE_MAP = mapOf(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd avoid maintaining a list defined manually when we can do something like this:

val DISCORD_LOCALE_MAP = Locale.ALL.associateBy {
    listOfNotNull(it.language, it.country).joinToString("-")
}

Also, I think it would make more sense to do it the other way around (locale as key, code as value)

Comment on lines +126 to +127
guildId: dev.kord.common.entity.Snowflake,
discordLocale: dev.kord.common.Locale?,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use imports (check the rest of the class)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command to set locale

2 participants