Skip to content

Commit f56bb1c

Browse files
committed
argument methods added
1 parent 3938ab5 commit f56bb1c

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ All these features have a modular structure and you can edit all of these module
1313
2. [JDA Section](#integration-usage-for-jda)
1414
3. [Javacord Section](#javacord-section)
1515
4. [Command Features](#command-features)
16+
- [Argument Methods](#argument-methods)
1617
- [Possible Handle Methods](#possible-handle-methods)
1718
- [Command Callbacks](#command-callbacks) *(onFalse, ownerOnly, guildOnly, privateOnly, cooldown)*
1819
5. [Cool Features](#cool-features)
@@ -68,7 +69,8 @@ That's it. Now, we need a command.
6869
guildOnly = false, /* false default */
6970
ownerOnly = false, /* false default */
7071
privateOnly = false, /* false default */
71-
sync = false /* false default */ )
72+
sync = false, /* false default */
73+
onlyArguments = false /* false default */)
7274
public class BasicCommand extends JDACommand {
7375

7476
public BasicCommand() {
@@ -82,6 +84,12 @@ public class BasicCommand extends JDACommand {
8284
return true;
8385
// if your command is completed successfully, you must return "true"
8486
}
87+
88+
@Argument(arg = "test")
89+
public boolean test(MessageReceivedEvent e) {
90+
e.getChannel.sendMessage("Test!").queue();
91+
return true;
92+
}
8593
}
8694
```
8795

@@ -126,6 +134,12 @@ public class BasicCommand extends JavacordCommand {
126134
return true;
127135
// if your command is completed successfully, you must return "true"
128136
}
137+
138+
@Argument(arg = "test")
139+
public boolean test(MessageCreateEvent e) {
140+
e.getChannel.sendMessage( "Test!" );
141+
return true;
142+
}
129143
}
130144
```
131145

@@ -141,6 +155,49 @@ boolean handle(<Event> e, String[] args) // CommandType.ARGNEVENT -> 0x02
141155
boolean handle(<Event> e, String[] args, String prefix) // CommandType.PREFIXED -> 0x03
142156
```
143157

158+
### Properties of the args and prefix parameters
159+
Args are splitted by the "space" chars. The 0. index is command text for args parameter but doesn't have the prefix.
160+
```
161+
Entered Command: "!ping test 123"
162+
args[0]: "ping"
163+
args[1]: "test"
164+
args[2]: "123"
165+
166+
prefix: "!"
167+
```
168+
169+
170+
## Argument Methods
171+
Argument methods must be public and boolean. If argument method returns false, the `onFalse` callback is run. Names are not important for argument methods.
172+
173+
If the Commando annotation of command has `onlyArguments = true` the command is only available for pure usage and use with arguments.
174+
There is no limit to using arguments, you can use as many arguments as you want. Arguments __has__ case sensitivity.
175+
176+
The parameters you can use are:
177+
```java
178+
boolean name(<Event> e) // CommandType.EVENT -> 0x01
179+
boolean name(<Event> e, String[] args) // CommandType.ARGNEVENT -> 0x02
180+
boolean name(<Event> e, String[] args, String prefix) // CommandType.PREFIXED -> 0x03
181+
```
182+
183+
#### Example:
184+
185+
```java
186+
@Argument(arg = "jump")
187+
public boolean nameIsNotImportant(<Event> e){
188+
// somethings
189+
if (fail) return false;
190+
return true;
191+
}
192+
193+
@Argument(arg = {"think", "thonk"})
194+
public boolean anotherArgumentMethod(<Event> e){
195+
// somethings
196+
if (fail) return false;
197+
return true;
198+
}
199+
```
200+
144201
## Command Callbacks
145202
**Note:** All lines must be inside the constructor of your command.
146203

0 commit comments

Comments
 (0)