BotCommands
BotCommands copied to clipboard
Add module for typesafe messages
Please see the readme for details about this feature.
- [x] Add enum
LocaleScope- Values:
-
PREFER_USER: Use the user locale if available -
GUILD: Use the guild locale
-
- Values:
- [x] Add
@PreferLocaleScope, warn if both a preferred scope and a required locale parameter exists-
value:LocaleScope
-
- [x] Support first parameter being
DiscordLocale/Locale,null= use initial locale - [x] Convert
camelCaseparameters tosnake_case - [x] Throw if a formattable parameter is nullable or the argument is null at runtime (Use
Objects.requireNonNull(T, String)to simplify) - [x] (Breaking) Add
LocalizableTemplate#arguments: List<FormattableArgument> - [ ] ~~Add
FormattableArgument#canFormat(Class<?>)~~- ~~Return
trueby default, document that in unknown cases, it should returntrueand just let it fail at runtime~~ - ~~Make sure to pass the final type (after conversion)~~
- ~~Return
Future work can include:
- Add
FormattableArgumentConverter/ArgumentFormatter, maybe extend onParameterResolver- Examples of built-ins:
- Do not add
Durationunless the user is able to localize those -
IMentionables where any mentionable entity is transformed into its mention
- Do not add
- Add
@FormatWithto force usage of a specific formatter, for example the defaultIMentionableformatter could be overridden forMemberand instead insert the member's effective name
- Examples of built-ins: