Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guild settings getter in command events #65

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Matyrobbrt
Copy link

@Matyrobbrt Matyrobbrt commented Apr 20, 2022

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.

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.
  • My PR is for the command module 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

@Chew
Copy link
Owner

Chew commented Apr 20, 2022

How does this differ from event.getClient().getSettingsFor(event.getGuild())?

@Chew Chew added the module: command Commands module label Apr 20, 2022
@Matyrobbrt
Copy link
Author

Matyrobbrt commented Apr 20, 2022

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.

@Chew
Copy link
Owner

Chew commented Jun 10, 2024

Can this be added to the Interactions class? Unless I'm missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: command Commands module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants