Skip to content
This repository was archived by the owner on Jun 18, 2020. It is now read-only.

Commit 169c824

Browse files
committed
Cleaned up javadocs
1 parent bbe309f commit 169c824

File tree

3 files changed

+24
-40
lines changed

3 files changed

+24
-40
lines changed

src/main/java/com/darichey/discord/api/Command.java

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,17 @@ public class Command {
2424
BiConsumer<CommandContext, FailureReason> onFailure = (context, failureReason) -> {};
2525

2626
/**
27-
* Initialize with the command's name
28-
*
29-
* @param name The name of the command
27+
* Initialize with the command's name.
28+
* @param name The name of the command.
3029
*/
3130
public Command(String name) {
3231
this.name = name;
3332
}
3433

3534
/**
36-
* The function to execute when the command is successful.
37-
*
38-
* @param function The function to execute
39-
* @return This command instance
35+
* The function to execute when the command is called.
36+
* @param function The function to execute.
37+
* @return This command instance.
4038
*/
4139
public Command onExecuted(Consumer<CommandContext> function) {
4240
this.onExecuted = function;
@@ -45,9 +43,8 @@ public Command onExecuted(Consumer<CommandContext> function) {
4543

4644
/**
4745
* The function to execute when the command fails.
48-
*
49-
* @param function The function to execute
50-
* @return This command instance
46+
* @param function The function to execute.
47+
* @return This command instance.
5148
*/
5249
public Command onFailure(BiConsumer<CommandContext, FailureReason> function) {
5350
this.onFailure = function;
@@ -56,7 +53,6 @@ public Command onFailure(BiConsumer<CommandContext, FailureReason> function) {
5653

5754
/**
5855
* An arbitrary value for the description of the command. This isn't used by the API.
59-
*
6056
* @param description The description.
6157
* @return This command instance.
6258
*/
@@ -65,9 +61,8 @@ public Command withDescription(String description) {
6561
return this;
6662
}
6763

68-
/**
64+
/**
6965
* An arbitrary value for the usage of the command. This isn't used by the API.
70-
*
7166
* @param usage The usage.
7267
* @return This command instance.
7368
*/
@@ -78,7 +73,6 @@ public Command withUsage(String usage) {
7873

7974
/**
8075
* Aliases that will also trigger this command (besides the name). No two commands may have the same alias.
81-
*
8276
* @param aliases The aliases.
8377
* @return This command instance.
8478
*/
@@ -89,7 +83,6 @@ public Command withAliases(Set<String> aliases) {
8983

9084
/**
9185
* Aliases that will also trigger this command (besides the name). No two commands may have the same alias.
92-
*
9386
* @param aliases The aliases.
9487
* @return This command instance.
9588
*/
@@ -100,7 +93,6 @@ public Command withAliases(String... aliases) {
10093

10194
/**
10295
* If true, the command will trigger regardless of case. (i.e. both !ping and !PiNg will trigger the command)
103-
*
10496
* @param caseSensitive Case sensitive or not.
10597
* @return This command instance.
10698
*/
@@ -111,7 +103,6 @@ public Command caseSensitive(boolean caseSensitive) {
111103

112104
/**
113105
* If true, the message that triggered this command will automatically be deleted.
114-
*
115106
* @param deleteCommand To delete or not.
116107
* @return This command instance.
117108
*/
@@ -122,9 +113,8 @@ public Command deleteCommand(boolean deleteCommand) {
122113

123114
/**
124115
* The set of permissions a person requires to execute this command. Failing to meet these requirements will result in {@link FailureReason#AUTHOR_MISSING_PERMISSIONS}
125-
*
126116
* @param requiredPermissions The required permissions.
127-
* @return This commnad instance.
117+
* @return This command instance.
128118
*/
129119
public Command requirePermissions(EnumSet<Permissions> requiredPermissions) {
130120
this.requiredPermissions = requiredPermissions;

src/main/java/com/darichey/discord/api/CommandContext.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,28 @@ public CommandContext(IMessage message) {
3131
}
3232

3333
/**
34-
* @return The message object
34+
* @return The message object.
3535
*/
3636
public IMessage getMessage() {
3737
return this.message;
3838
}
3939

4040
/**
41-
* @return The command's name
41+
* @return The command's name.
4242
*/
4343
public String getName() {
4444
return this.name;
4545
}
4646

4747
/**
48-
* @return The arguments, or an empty array if there aren't any
48+
* @return The arguments, or an empty array if there aren't any.
4949
*/
5050
public String[] getArgs() {
5151
return this.args;
5252
}
5353

5454
/**
55-
* @return The CommandRegistry
55+
* @return The CommandRegistry of the guild this context is for.
5656
*/
5757
public CommandRegistry getRegistry() {
5858
return this.registry;

src/main/java/com/darichey/discord/api/CommandRegistry.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ public class CommandRegistry {
1414

1515
/**
1616
* Get the CommandRegistry associated with the client, or create a new one if not present.
17-
*
18-
* @param client The client object to associate with
19-
* @return The CommandRegistry for the client
17+
* @param client The client object to associate with.
18+
* @return The CommandRegistry for the client.
2019
*/
2120
public static CommandRegistry getForClient(IDiscordClient client) {
2221
if (!registries.containsKey(client)) {
@@ -29,16 +28,14 @@ public static CommandRegistry getForClient(IDiscordClient client) {
2928
/**
3029
* Private so you have to use {@link CommandRegistry#getForClient(IDiscordClient)}
3130
*/
32-
private CommandRegistry() {
33-
}
31+
private CommandRegistry() {}
3432

3533
private List<Command> commands = new ArrayList<>();
3634
private String prefix = "!";
3735

3836
/**
3937
* Register a command.
40-
*
41-
* @param command
38+
* @param command The command.
4239
*/
4340
public void register(Command command) {
4441
if (!commands.stream().filter(cmd -> cmd.getName().equalsIgnoreCase(command.getName())).findFirst().isPresent()) {
@@ -58,10 +55,9 @@ public void registerAll(Command... commands) {
5855

5956
/**
6057
* Get a command by its name.
61-
*
62-
* @param name The command name
63-
* @param includeAlias If aliases can be used to search, otherwise it has to be the original name
64-
* @return The command if present
58+
* @param name The command name.
59+
* @param includeAlias If aliases can be used to search, otherwise it has to be the original name.
60+
* @return An optional value of the command.
6561
*/
6662
public Optional<Command> getCommandByName(String name, boolean includeAlias) {
6763
return commands.stream().filter(c ->
@@ -71,25 +67,23 @@ public Optional<Command> getCommandByName(String name, boolean includeAlias) {
7167

7268
/**
7369
* Get all commands registered.
74-
*
75-
* @return A list of commands
70+
* @return A list of commands.
7671
*/
7772
public List<Command> getCommands() {
7873
return commands;
7974
}
8075

8176
/**
82-
* Set the prefix to use.
83-
*
84-
* @param prefix The new prefix
77+
* Sets the prefix that commands registered to this registry will be activated by.
78+
* @param prefix The new prefix.
8579
*/
8680
public void setPrefix(String prefix) {
8781
if (prefix == null) throw new IllegalArgumentException("The new prefix cannot be null!");
8882
this.prefix = prefix;
8983
}
9084

9185
/**
92-
* @return The prefix
86+
* @return The prefix that commands registered to this registry will be activated by.
9387
*/
9488
public String getPrefix() {
9589
return this.prefix;

0 commit comments

Comments
 (0)