Skip to content

Commit 7f81ef1

Browse files
committed
Improved everything.
1 parent 28f48f7 commit 7f81ef1

12 files changed

Lines changed: 38 additions & 30 deletions

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ dependencies {
7777
bootstrap("org.mangorage:mangobotbootstrap:1.0.84")
7878
launchtarget("org.mangorage:mangobotlaunchtarget:0.1.8")
7979

80-
plugin('org.mangorage:mangobot:12.0.103')
80+
plugin('org.mangorage:mangobot:12.0.105')
8181

8282
library('org.slf4j:slf4j-simple:2.0.13') // Use a recent version)
8383
library('org.luaj:luaj-jme:3.0.1')

src/main/java/org/mangorage/mangobotplugin/commands/internal/homedepot/HomeDepotCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.mangorage.mangobotplugin.commands.internal.homedepot;
22

33
import net.dv8tion.jda.api.entities.Message;
4+
import org.mangorage.mangobotcore.api.command.v1.CommandContext;
45
import org.mangorage.mangobotcore.api.command.v1.CommandParseResult;
56
import org.mangorage.mangobotcore.api.jda.command.v2.AbstractJDACommand;
67
import org.mangorage.mangobotcore.api.jda.command.v2.JDACommandResult;
@@ -17,8 +18,7 @@ public HomeDepotCommand(String name) {
1718
}
1819

1920
@Override
20-
public JDACommandResult run(Message message, String[] strings, CommandParseResult commandParseResult) throws Throwable {
21-
21+
public JDACommandResult run(Message message, CommandContext commandContext, CommandParseResult commandParseResult) throws Throwable {
2222
return JDACommandResult.PASS;
2323
}
2424
}

src/main/java/org/mangorage/mangobotplugin/commands/internal/homedepot/HomeDepotScanQRSubCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
88
import com.google.zxing.common.HybridBinarizer;
99
import net.dv8tion.jda.api.entities.Message;
10+
import org.mangorage.mangobotcore.api.command.v1.CommandContext;
1011
import org.mangorage.mangobotcore.api.command.v1.CommandParseResult;
1112
import org.mangorage.mangobotcore.api.jda.command.v2.AbstractJDACommand;
1213
import org.mangorage.mangobotcore.api.jda.command.v2.JDACommandResult;
@@ -22,7 +23,7 @@ public HomeDepotScanQRSubCommand() {
2223
}
2324

2425
@Override
25-
public JDACommandResult run(Message message, String[] strings, CommandParseResult commandParseResult) throws Throwable {
26+
public JDACommandResult run(Message message, CommandContext commandContext, CommandParseResult commandParseResult) throws Throwable {
2627
final var attachment = message.getAttachments().getFirst();
2728
if (attachment != null) {
2829
message.reply(

src/main/java/org/mangorage/mangobotplugin/commands/internal/homedepot/HomeDepotSendAlertSubCommand.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.mangorage.mangobotplugin.commands.internal.homedepot;
22

33
import net.dv8tion.jda.api.entities.Message;
4+
import org.mangorage.mangobotcore.api.command.v1.CommandContext;
45
import org.mangorage.mangobotcore.api.command.v1.CommandParseResult;
56
import org.mangorage.mangobotcore.api.command.v1.argument.RequiredArg;
67
import org.mangorage.mangobotcore.api.command.v1.argument.types.StringArgumentType;
@@ -26,8 +27,8 @@ public HomeDepotSendAlertSubCommand() {
2627
}
2728

2829
@Override
29-
public JDACommandResult run(Message message, String[] argument, CommandParseResult commandParseResult) throws Throwable {
30-
final var taskId = taskIdArg.get(argument, commandParseResult);
30+
public JDACommandResult run(Message message, CommandContext commandContext, CommandParseResult commandParseResult) throws Throwable {
31+
final var taskId = commandContext.getArgument(taskIdArg, commandParseResult);
3132
message.reply(
3233
createAssociateTask(taskId)
3334
).queue();

src/main/java/org/mangorage/mangobotplugin/commands/misc/HelpCommand.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
package org.mangorage.mangobotplugin.commands.misc;
22

33
import net.dv8tion.jda.api.entities.Message;
4+
import org.mangorage.mangobotcore.api.command.v1.CommandContext;
45
import org.mangorage.mangobotcore.api.command.v1.CommandParseResult;
56
import org.mangorage.mangobotcore.api.command.v1.ICommandDispatcher;
7+
import org.mangorage.mangobotcore.api.command.v1.argument.OptionalFlagArg;
68
import org.mangorage.mangobotcore.api.command.v1.argument.RequiredArg;
79
import org.mangorage.mangobotcore.api.command.v1.argument.types.StringArgumentType;
810
import org.mangorage.mangobotcore.api.jda.command.v2.AbstractJDACommand;
911
import org.mangorage.mangobotcore.api.jda.command.v2.JDACommandResult;
1012

1113
public class HelpCommand extends AbstractJDACommand {
1214
private final ICommandDispatcher<Message, JDACommandResult> commandDispatcher;
13-
private final RequiredArg<String> commandArg;
15+
private final OptionalFlagArg advancedFlag = registerFlagArgument("--advanced", "Shows advanced information");
16+
private final RequiredArg<String> commandArg = registerRequiredArgument("command", "The command to get help for", StringArgumentType.single());
1417

1518
public HelpCommand(String name, ICommandDispatcher<Message, JDACommandResult> commandDispatcher) {
1619
super(name);
1720
this.commandDispatcher = commandDispatcher;
18-
this.commandArg = registerRequiredArgument(
19-
"command",
20-
"The command to get help for",
21-
StringArgumentType.single()
22-
);
2321
}
2422

2523
@Override
26-
public JDACommandResult run(Message message, String[] arguments, CommandParseResult commandParseResult) throws Throwable {
27-
final String commandName = commandArg.get(arguments, commandParseResult);
24+
public JDACommandResult run(Message message, CommandContext commandContext, CommandParseResult commandParseResult) throws Throwable {
25+
final boolean advanced = commandContext.getArgument(advancedFlag, commandParseResult);
26+
final String commandName = commandContext.getArgument(commandArg, commandParseResult);
2827
var command = commandDispatcher.getCommand(commandName);
2928
if (command == null) {
3029
message.reply("Command `" + commandName + "` not found.").queue();
3130
} else {
3231
message.reply(
33-
String.join("\n", command.buildUsage())
32+
String.join("\n", command.buildUsage(advanced))
3433
).queue();
3534
}
3635
return JDACommandResult.PASS;

src/main/java/org/mangorage/mangobotplugin/commands/misc/PingCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.mangorage.mangobotplugin.commands.misc;
22

33
import net.dv8tion.jda.api.entities.Message;
4+
import org.mangorage.mangobotcore.api.command.v1.CommandContext;
45
import org.mangorage.mangobotcore.api.command.v1.CommandParseResult;
56
import org.mangorage.mangobotcore.api.jda.command.v2.AbstractJDACommand;
67
import org.mangorage.mangobotcore.api.jda.command.v2.JDACommandResult;
@@ -12,7 +13,7 @@ public PingCommand(String name) {
1213
}
1314

1415
@Override
15-
public JDACommandResult run(Message message, String[] arguments, CommandParseResult commandParseResult) {
16+
public JDACommandResult run(Message message, CommandContext commandContext, CommandParseResult commandParseResult) {
1617
message.reply("Pong!").queue();
1718
return JDACommandResult.PASS;
1819
}

src/main/java/org/mangorage/mangobotplugin/commands/misc/PingsCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import net.dv8tion.jda.api.entities.Message;
55
import net.dv8tion.jda.api.entities.MessageEmbed;
66

7+
import org.mangorage.mangobotcore.api.command.v1.CommandContext;
78
import org.mangorage.mangobotcore.api.command.v1.CommandParseResult;
89
import org.mangorage.mangobotcore.api.jda.command.v2.AbstractJDACommand;
910
import org.mangorage.mangobotcore.api.jda.command.v2.JDACommandResult;
@@ -27,7 +28,7 @@ public PingsCommand(String name) {
2728
}
2829

2930
@Override
30-
public JDACommandResult run(Message message, String[] arguments, CommandParseResult commandParseResult) {
31+
public JDACommandResult run(Message message, CommandContext commandContext, CommandParseResult commandParseResult) {
3132
var referenced = message.getReferencedMessage();
3233
if (referenced == null) {
3334
message.getChannel().sendMessageEmbeds(EMBED).queue();

src/main/java/org/mangorage/mangobotplugin/commands/trick/impl/TrickAddSubCommand.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package org.mangorage.mangobotplugin.commands.trick.impl;
22

33
import net.dv8tion.jda.api.entities.Message;
4+
import org.mangorage.mangobotcore.api.command.v1.CommandContext;
45
import org.mangorage.mangobotcore.api.command.v1.CommandParseResult;
6+
import org.mangorage.mangobotcore.api.command.v1.argument.OptionalFlagArg;
57
import org.mangorage.mangobotcore.api.command.v1.argument.RequiredArg;
6-
import org.mangorage.mangobotcore.api.command.v1.argument.types.BooleanArgumentType;
78
import org.mangorage.mangobotcore.api.command.v1.argument.types.EnumArgumentType;
89
import org.mangorage.mangobotcore.api.command.v1.argument.types.StringArgumentType;
910
import org.mangorage.mangobotcore.api.jda.command.v2.AbstractJDACommand;
@@ -16,7 +17,7 @@ public final class TrickAddSubCommand extends AbstractJDACommand {
1617
private final TrickManager trickManager;
1718
private final RequiredArg<String> trickArg = registerRequiredArgument("trick", "The trick to add", StringArgumentType.single());
1819
private final RequiredArg<TrickType> trickTypeArg = registerRequiredArgument("type", "The trick type", EnumArgumentType.of(TrickType.class));
19-
private final RequiredArg<Boolean> trickSuppressArg = registerRequiredArgument("suppress", "Whether to suppress output", BooleanArgumentType.INSTANCE);
20+
private final OptionalFlagArg trickSuppressArg = registerFlagArgument("--suppress", "Whether to suppress output");
2021
private final RequiredArg<String> trickDataArg = registerRequiredArgument("data", "The trick data", StringArgumentType.quote());
2122

2223
public TrickAddSubCommand(String name, TrickManager trickManager) {
@@ -25,11 +26,11 @@ public TrickAddSubCommand(String name, TrickManager trickManager) {
2526
}
2627

2728
@Override
28-
public JDACommandResult run(Message context, String[] arguments, CommandParseResult commandParseResult) throws Throwable {
29-
final var trickName = trickArg.get(arguments, commandParseResult);
30-
final var trickType = trickTypeArg.get(arguments, commandParseResult);
31-
final var trickSuppress = trickSuppressArg.get(arguments, commandParseResult);
32-
final var trickData = trickDataArg.get(arguments, commandParseResult);
29+
public JDACommandResult run(Message context, CommandContext commandContext, CommandParseResult commandParseResult) throws Throwable {
30+
final var trickName = commandContext.getArgument(trickArg, commandParseResult);
31+
final var trickType = commandContext.getArgument(trickTypeArg, commandParseResult);
32+
final var trickSuppress = commandContext.getArgument(trickSuppressArg, commandParseResult);
33+
final var trickData = commandContext.getArgument(trickDataArg, commandParseResult);
3334

3435
final var trick = new Trick(trickName, context.getGuildIdLong());
3536

src/main/java/org/mangorage/mangobotplugin/commands/trick/impl/TrickCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.mangorage.mangobotplugin.commands.trick.impl;
22

33
import net.dv8tion.jda.api.entities.Message;
4+
import org.mangorage.mangobotcore.api.command.v1.CommandContext;
45
import org.mangorage.mangobotcore.api.command.v1.CommandParseResult;
56
import org.mangorage.mangobotcore.api.jda.command.v2.AbstractJDACommand;
67
import org.mangorage.mangobotcore.api.jda.command.v2.JDACommandResult;
@@ -50,7 +51,7 @@ public void onCommandEvent(CommandEvent event) {
5051
}
5152

5253
@Override
53-
public JDACommandResult run(Message context, String[] arguments, CommandParseResult commandParseResult) throws Throwable {
54+
public JDACommandResult run(Message context, CommandContext commandContext, CommandParseResult commandParseResult) throws Throwable {
5455
return JDACommandResult.PASS;
5556
}
5657
}

src/main/java/org/mangorage/mangobotplugin/commands/trick/impl/TrickListSubCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import net.dv8tion.jda.api.entities.Message;
44
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion;
55
import net.dv8tion.jda.api.interactions.components.buttons.Button;
6+
import org.mangorage.mangobotcore.api.command.v1.CommandContext;
67
import org.mangorage.mangobotcore.api.command.v1.CommandParseResult;
78
import org.mangorage.mangobotcore.api.jda.command.v2.AbstractJDACommand;
89
import org.mangorage.mangobotcore.api.jda.command.v2.JDACommandResult;
@@ -29,7 +30,7 @@ public TrickListSubCommand(String name, TrickManager trickManager) {
2930
}
3031

3132
@Override
32-
public JDACommandResult run(Message context, String[] arguments, CommandParseResult commandParseResult) throws Throwable {
33+
public JDACommandResult run(Message context, CommandContext commandContext, CommandParseResult commandParseResult) throws Throwable {
3334
int length = 5;
3435

3536
MessageChannelUnion channel = context.getChannel();

0 commit comments

Comments
 (0)