Open Andre601 opened 4 months ago
Description definitely works and is working for me
I suppose make sure your Discord is set to Discord UK, but I haven't tested two things you're doing
this.help
Yeah, I didn't had the client on english... Tho I thought that having a default locale set would actually make it use that on any language not set, tho that was bad thinking on my end I guess...
Yeah I'm inclined to believe the descriptionLocalization requires this.help to be set but I'm unsure. Perhaps I can set this.help if you set a descriptionLocalization if it's blank to prevent that. I'm not sure how the fallbacks work on Discord or JDA's end.
Looking a bit into this, the localization is applied within the SlashCommand
class by first creating the SlashCommandData
instance and then applying the map using SlashCommandData#setNameLocalizations(Map<DiscordLocale, String>)
and SlashCommandData#setDescriptionLocalizatuions(Map<DiscordLocale, String>)
.
I believe the main problem here is, that Discord defaults to whatever text you gave for name and description when it can't find a locale entry, and since Chewtils here is creating this data using getName()
and getHelp()
does it result in what we encounter here.
So perhaps it would be a good idea to check at the start, if localization was set, and if yes, retrieve the default lang values for name and description. And if those aren't null, use them as the command values, else default to the getters.
I'll try and work out something here to then PR, as it doesn't seem too complicated. Tho, maybe at least for command we should force a command name to be set? Or do we really want to allow a default locale value to be used? Because iirc does the command name itself not allow non-latin characters... So we should ensure this to be the case.
Issue Checklist
Affected Modules
Command
Description
I'm unsure what exactly the issue here is, if it is an issue at all, but it seems like that translations from a properties file using the TranslateUtil are not applied?
To give some context, I have this properties file named
commands_en-GB.properties
:Then in my main Bot class am I doing this:
Finally, I override the SlashCommand class to implement some own stuff, including a central command handling. One thing I do there too is set the
nameLocalization
anddescriptionLocalization
values like this:When I now run the bot does it report to have resolved 1 translation, but when typing the command - in my case /blush - does it show this:
This makes me believe that the localizations aren't applied and only the name and value are set...