-
-
Notifications
You must be signed in to change notification settings - Fork 25
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 a way to provide/use own interfaces/classes/... for SlashCommands #66
Comments
Would you like a ISlashCommand interface that you can implement, as long as it has whatever the library requires? |
Could be a solution. |
My personal goal is just a way to have Chewtils handle the SlashCommandEvent in one central place and then execute a method for the respective command class that would have stuff... If I understand interfaces correctly do I currently have a setup like this:
|
It'd be something like this: Chewtils has a ISlashCommand Then you have your own Impl, (SlashCommand will be an impl as well) Maybe like this: public class MyCustomSlashCommand implements ISlashCommand {
public void handle(SlashCommandEvent event) {
// the cool stuff
run(); // method in interface
}
} Then in your own bot: public class SuperCommand extends MyCustomSlashCommand {
// code like normal
} This is merely a theory, I'm sure something like it is possible. |
Issue Checklist
Affected Modules
Command
Description
It would be useful, if there was a sort of SlashCommandPreProcess method or alike that would allow me (and probably many others) to do the most common checks on a slash command such as if it was from a guild.
What could be somewhat problematic is to decide how stuff is returned... Should it stay a SlashCommandEvent, or should it already be handled (
deferReply()
?) and then the InteractionHook returned?I personally would find it cool, if we could "override" the default
execute
method to have our own instead.To explain what I mean with that, I want to quickly show an example of what I'm currently using in my bot with message-based commands.
I'm using a different library for those commands called JDA-Command, which provides and uses an interface called
AbstractCommand<T>
. Since my commands are always with JDA Message objects and only work in Guilds did I "override" it by extending aCommand
interface I made with it to then override the method with my own:https://github.com/purrbot-site/PurrBot/blob/2f44f14757bbbd6d82ca29bffa41bb53d42da232/src/main/java/site/purrbot/bot/commands/Command.java
This basically allowed me to reduce commonly made checks and actions and have a bit more safety about things (i.e. that
Guild
andMember
are always present)Having a similar way in Chewtils would help a lot, because then I could check if the command is from a Guild, obtain user/member and the textchannel instance and if they are null return an error before processing it further...
I hope you get what I mean... I'm not the best at explaining stuff...
The text was updated successfully, but these errors were encountered: