Repository navigation
Conversation
Added ExampleCommand so starting with developing becomes easier.
|
Just curious, why an abstract class and not an interface? |
|
I too don't see the benefit of using an abstract class over an interface here. |
|
You didn't look at my code in that case. Like with permissions, instead of forcing you to add a method and return null |
|
How does an interface prevent us from adding optional options? |
|
There's no way to have a default method that can be overridden? |
|
Well if you take the example of |
|
I'm confused? Can you show me an example if how it should be implemented. |
|
You can override it just by including that method in the implementing class. It works just like abstract methods from an abstract class. https://www.tutorialspoint.com/can-we-override-default-methods-in-java |
I meant that, say you have this code interface AnInterface{
boolean booleanMethod();
}
class ExtendingClass implements AnInterface{
}Obviously, this won't compile. On IntelliJ, it will directly give the option to add unimplemented methods. Once you click on it, this is what the class will look like. class ExtendingClass implements AnInterface{
public boolean booleanMethod(){
return false;
}
} |
|
Howly fuck, my mind just exploded. On that note, fields might end up being useful. |
|
and @java-coding-prodigy, I meant having default methods that can be overriden. |
|
If we add fields, then yes an abstract class would make more sense. |
|
It is possible to have fields in interfaces, just that they will be the same throughout all implementing classes, either that or we could have a method in the interface called |
|
I'm not sure whenever we will actually add fields, so if we eventually end up not using fields this will be changed to a interface. And yes, an interface allows constants, but not non-public or non-static variables. |
|
Will create a new PR from feature/command-system to develop. |
There was a problem hiding this comment.
I think we should have a basic story for menus / selects / buttons. How do they fit in here, if the command can only be triggered by a SlashCommandEvent? Are they a separate system? How could a button in message trigger a command? How could we edit the message if a button is clicked?
| * Look at {@link org.togetherjava.tjbot.commands.example.ExampleCommand} for an example. | ||
| * A second example will come for sub-commands. | ||
| */ | ||
| public abstract class AbstractCommand { |
There was a problem hiding this comment.
This might be able to be an interface if we never need local state:
| public abstract class AbstractCommand { | |
| public interface Command |
There was a problem hiding this comment.
Before this gets merged to develop, we will look back and change to an interface if no features of abstract classes will be used.
My last message
| public boolean isGuildOnly() { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
| public boolean isGuildOnly() { | |
| return false; | |
| } | |
| default isGuildOnly() { | |
| return false; | |
| } |
We can also make all execute methods optional. This way everything can be done with extending 1 class. We could also separate it, not sure what everyone thinks. |
|
Thought I merged it, mistake on my side |
Will be the PR for the command handler and more.
Currently this is only the Command class, open for feedback!
Issue #10