Add guild settings getter in command events
Pull Request
Pull Request Checklist
Please follow the following steps before opening this PR.
PRs that do not complete the checklist will be subject to denial for
missing information.
- [x] I have checked the pull request page for upcoming or merged features/bug fixes.
- [x] I have read JDA's contributing guidelines.
Pull Request Information
Check and fill in the blanks for all that apply:
- [ ] My PR fixes a bug, error, or other issue with the library's codebase.
- [x] My PR is for the
commandmodule of the JDA-Utilities library. - [ ] My PR creates a new module for the JDA-Utilities library:
______.
Description
Describe your PR here. This PR adds 2 utility methods in the command and interaction events for getting the settings of the guild, using the class of the settings. Those methods will do the following checks:
- the command was run in a guild
- the settings manager is not null
- the settings manager does not return null settings
- the settings returned by the manager are instances of the specified settings class
How does this differ from event.getClient().getSettingsFor(event.getGuild())?
That method uses a generic argument which can't be inferred as it has no parameters using it. As such, it needs the type declared like .<Config>getSettingsFor(), which is annoying both to type and to look at. Plus, providing the wrong generic argument throws a class cast exception.
Can this be added to the Interactions class? Unless I'm missing something.