♻️ Reformat + Update .editorconfig
This commit is contained in:
parent
8bdec87a74
commit
2aac3980d5
169 changed files with 4261 additions and 2448 deletions
|
|
@ -48,9 +48,11 @@ public class JavacordCommand<C> implements MessageCreateListener {
|
|||
private final CommandArgument<C, ?> command;
|
||||
private final cloud.commandframework.Command<C> cloudCommand;
|
||||
|
||||
JavacordCommand(final cloud.commandframework.@NonNull Command<C> cloudCommand,
|
||||
final @NonNull CommandArgument<C, ?> command,
|
||||
final @NonNull JavacordCommandManager<C> manager) {
|
||||
JavacordCommand(
|
||||
final cloud.commandframework.@NonNull Command<C> cloudCommand,
|
||||
final @NonNull CommandArgument<C, ?> command,
|
||||
final @NonNull JavacordCommandManager<C> manager
|
||||
) {
|
||||
this.command = command;
|
||||
this.manager = manager;
|
||||
this.cloudCommand = cloudCommand;
|
||||
|
|
@ -85,70 +87,78 @@ public class JavacordCommand<C> implements MessageCreateListener {
|
|||
final String finalContent = messageContent;
|
||||
//noinspection unchecked
|
||||
if (((StaticArgument<C>) command).getAliases()
|
||||
.stream()
|
||||
.map(String::toLowerCase)
|
||||
.noneMatch(commandAlias -> finalContent.toLowerCase().startsWith(commandAlias))) {
|
||||
.stream()
|
||||
.map(String::toLowerCase)
|
||||
.noneMatch(commandAlias -> finalContent.toLowerCase().startsWith(commandAlias))) {
|
||||
return;
|
||||
}
|
||||
|
||||
manager.executeCommand(sender, finalContent)
|
||||
.whenComplete(((commandResult, throwable) -> {
|
||||
if (throwable == null) {
|
||||
return;
|
||||
}
|
||||
.whenComplete(((commandResult, throwable) -> {
|
||||
if (throwable == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (throwable instanceof CompletionException) {
|
||||
throwable = throwable.getCause();
|
||||
}
|
||||
if (throwable instanceof CompletionException) {
|
||||
throwable = throwable.getCause();
|
||||
}
|
||||
|
||||
if (throwable instanceof NoSuchCommandException) {
|
||||
//Ignore, should never happen
|
||||
return;
|
||||
}
|
||||
if (throwable instanceof NoSuchCommandException) {
|
||||
//Ignore, should never happen
|
||||
return;
|
||||
}
|
||||
|
||||
if (throwable instanceof InvalidSyntaxException) {
|
||||
manager.handleException(sender,
|
||||
InvalidSyntaxException.class,
|
||||
(InvalidSyntaxException) throwable,
|
||||
(c, e) -> commandSender.sendErrorMessage(
|
||||
"Invalid Command Syntax. Correct command syntax is: `"
|
||||
+ e.getCorrectSyntax()
|
||||
+ "`")
|
||||
);
|
||||
if (throwable instanceof InvalidSyntaxException) {
|
||||
manager.handleException(
|
||||
sender,
|
||||
InvalidSyntaxException.class,
|
||||
(InvalidSyntaxException) throwable,
|
||||
(c, e) -> commandSender.sendErrorMessage(
|
||||
"Invalid Command Syntax. Correct command syntax is: `"
|
||||
+ e.getCorrectSyntax()
|
||||
+ "`")
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (throwable instanceof InvalidCommandSenderException) {
|
||||
manager.handleException(sender,
|
||||
InvalidCommandSenderException.class,
|
||||
(InvalidCommandSenderException) throwable,
|
||||
(c, e) -> commandSender.sendErrorMessage(e.getMessage()));
|
||||
if (throwable instanceof InvalidCommandSenderException) {
|
||||
manager.handleException(
|
||||
sender,
|
||||
InvalidCommandSenderException.class,
|
||||
(InvalidCommandSenderException) throwable,
|
||||
(c, e) -> commandSender.sendErrorMessage(e.getMessage())
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (throwable instanceof NoPermissionException) {
|
||||
manager.handleException(sender,
|
||||
NoPermissionException.class,
|
||||
(NoPermissionException) throwable,
|
||||
(c, e) -> commandSender.sendErrorMessage(MESSAGE_NO_PERMS));
|
||||
if (throwable instanceof NoPermissionException) {
|
||||
manager.handleException(
|
||||
sender,
|
||||
NoPermissionException.class,
|
||||
(NoPermissionException) throwable,
|
||||
(c, e) -> commandSender.sendErrorMessage(MESSAGE_NO_PERMS)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (throwable instanceof ArgumentParseException) {
|
||||
manager.handleException(sender,
|
||||
ArgumentParseException.class,
|
||||
(ArgumentParseException) throwable,
|
||||
(c, e) -> commandSender.sendErrorMessage(
|
||||
"Invalid Command Argument: `" + e.getCause().getMessage() + "`"));
|
||||
if (throwable instanceof ArgumentParseException) {
|
||||
manager.handleException(
|
||||
sender,
|
||||
ArgumentParseException.class,
|
||||
(ArgumentParseException) throwable,
|
||||
(c, e) -> commandSender.sendErrorMessage(
|
||||
"Invalid Command Argument: `" + e.getCause().getMessage() + "`")
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
commandSender.sendErrorMessage(throwable.getMessage());
|
||||
throwable.printStackTrace();
|
||||
}));
|
||||
commandSender.sendErrorMessage(throwable.getMessage());
|
||||
throwable.printStackTrace();
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,15 +59,17 @@ public class JavacordCommandManager<C> extends CommandManager<C> {
|
|||
* @param commandPermissionMapper Function used to check if a command sender has the permission to execute a command
|
||||
* @throws Exception If the construction of the manager fails
|
||||
*/
|
||||
public JavacordCommandManager(final @NonNull DiscordApi discordApi,
|
||||
final @NonNull Function<@NonNull CommandTree<C>,
|
||||
@NonNull CommandExecutionCoordinator<C>> commandExecutionCoordinator,
|
||||
final @NonNull Function<@NonNull JavacordCommandSender, @NonNull C> commandSenderMapper,
|
||||
final @NonNull Function<@NonNull C,
|
||||
@NonNull JavacordCommandSender> backwardsCommandSenderMapper,
|
||||
final @NonNull Function<@NonNull C, @NonNull String> commandPrefixMapper,
|
||||
final @Nullable BiFunction<@NonNull C,
|
||||
@NonNull String, @NonNull Boolean> commandPermissionMapper)
|
||||
public JavacordCommandManager(
|
||||
final @NonNull DiscordApi discordApi,
|
||||
final @NonNull Function<@NonNull CommandTree<C>,
|
||||
@NonNull CommandExecutionCoordinator<C>> commandExecutionCoordinator,
|
||||
final @NonNull Function<@NonNull JavacordCommandSender, @NonNull C> commandSenderMapper,
|
||||
final @NonNull Function<@NonNull C,
|
||||
@NonNull JavacordCommandSender> backwardsCommandSenderMapper,
|
||||
final @NonNull Function<@NonNull C, @NonNull String> commandPrefixMapper,
|
||||
final @Nullable BiFunction<@NonNull C,
|
||||
@NonNull String, @NonNull Boolean> commandPermissionMapper
|
||||
)
|
||||
throws Exception {
|
||||
super(commandExecutionCoordinator, new JavacordRegistrationHandler<>());
|
||||
((JavacordRegistrationHandler<C>) this.getCommandRegistrationHandler()).initialize(this);
|
||||
|
|
@ -81,7 +83,8 @@ public class JavacordCommandManager<C> extends CommandManager<C> {
|
|||
|
||||
@Override
|
||||
public final boolean hasPermission(
|
||||
final @NonNull C sender, final @NonNull String permission) {
|
||||
final @NonNull C sender, final @NonNull String permission
|
||||
) {
|
||||
if (permission.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -131,4 +134,5 @@ public class JavacordCommandManager<C> extends CommandManager<C> {
|
|||
public @NonNull DiscordApi getDiscordApi() {
|
||||
return this.discordApi;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,38 +26,40 @@ package cloud.commandframework.javacord;
|
|||
import cloud.commandframework.Command;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.internal.CommandRegistrationHandler;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
final class JavacordRegistrationHandler<C> implements CommandRegistrationHandler {
|
||||
|
||||
private final Map<CommandArgument<?, ?>, JavacordCommand<C>> registeredCommands = new HashMap<>();
|
||||
private final Map<CommandArgument<?, ?>, JavacordCommand<C>> registeredCommands = new HashMap<>();
|
||||
|
||||
private JavacordCommandManager<C> javacordCommandManager;
|
||||
private JavacordCommandManager<C> javacordCommandManager;
|
||||
|
||||
JavacordRegistrationHandler() {
|
||||
}
|
||||
|
||||
void initialize(final @NonNull JavacordCommandManager<C> javacordCommandManager) {
|
||||
this.javacordCommandManager = javacordCommandManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerCommand(final @NonNull Command<?> command) {
|
||||
/* We only care about the root command argument */
|
||||
final CommandArgument<?, ?> commandArgument = command.getArguments().get(0);
|
||||
if (this.registeredCommands.containsKey(commandArgument)) {
|
||||
return false;
|
||||
JavacordRegistrationHandler() {
|
||||
}
|
||||
|
||||
void initialize(final @NonNull JavacordCommandManager<C> javacordCommandManager) {
|
||||
this.javacordCommandManager = javacordCommandManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerCommand(final @NonNull Command<?> command) {
|
||||
/* We only care about the root command argument */
|
||||
final CommandArgument<?, ?> commandArgument = command.getArguments().get(0);
|
||||
if (this.registeredCommands.containsKey(commandArgument)) {
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("unchecked") final JavacordCommand<C> javacordCommand = new JavacordCommand<>(
|
||||
(Command<C>) command,
|
||||
(CommandArgument<C, ?>) commandArgument,
|
||||
this.javacordCommandManager
|
||||
);
|
||||
this.registeredCommands.put(commandArgument, javacordCommand);
|
||||
this.javacordCommandManager.getDiscordApi().addMessageCreateListener(javacordCommand);
|
||||
return true;
|
||||
}
|
||||
@SuppressWarnings("unchecked") final JavacordCommand<C> javacordCommand = new JavacordCommand<>(
|
||||
(Command<C>) command,
|
||||
(CommandArgument<C, ?>) commandArgument,
|
||||
this.javacordCommandManager);
|
||||
this.registeredCommands.put(commandArgument, javacordCommand);
|
||||
this.javacordCommandManager.getDiscordApi().addMessageCreateListener(javacordCommand);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@ public class JavacordPrivateSender extends JavacordCommandSender {
|
|||
@NonNull
|
||||
public PrivateChannel getPrivateChannel() {
|
||||
return getEvent().getPrivateChannel()
|
||||
.orElseThrow(() -> new UnsupportedOperationException(
|
||||
"PrivateTextChannel not present even though message was sent in a private channel"));
|
||||
.orElseThrow(() -> new UnsupportedOperationException(
|
||||
"PrivateTextChannel not present even though message was sent in a private channel"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ public class JavacordServerSender extends JavacordCommandSender {
|
|||
@NonNull
|
||||
public ServerChannel getServerChannel() {
|
||||
return getEvent().getServerTextChannel()
|
||||
.orElseThrow(() -> new UnsupportedOperationException(
|
||||
"ServerTextChannel not present even though message was sent in a server channel"));
|
||||
.orElseThrow(() -> new UnsupportedOperationException(
|
||||
"ServerTextChannel not present even though message was sent in a server channel"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -59,7 +59,8 @@ public class JavacordServerSender extends JavacordCommandSender {
|
|||
@NonNull
|
||||
public Server getServer() {
|
||||
return getEvent().getServer()
|
||||
.orElseThrow(() -> new UnsupportedOperationException(
|
||||
"Server not present even though message was sent on a server"));
|
||||
.orElseThrow(() -> new UnsupportedOperationException(
|
||||
"Server not present even though message was sent on a server"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,51 +75,58 @@ public class JDACommandListener<C> extends ListenerAdapter {
|
|||
content = content.substring(prefix.length());
|
||||
|
||||
commandManager.executeCommand(sender, content)
|
||||
.whenComplete((commandResult, throwable) -> {
|
||||
if (throwable == null) {
|
||||
return;
|
||||
}
|
||||
.whenComplete((commandResult, throwable) -> {
|
||||
if (throwable == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (throwable instanceof InvalidSyntaxException) {
|
||||
this.commandManager.handleException(sender,
|
||||
InvalidSyntaxException.class,
|
||||
(InvalidSyntaxException) throwable, (c, e) -> {
|
||||
this.sendMessage(event,
|
||||
MESSAGE_INVALID_SYNTAX + prefix + ((InvalidSyntaxException) throwable)
|
||||
.getCorrectSyntax());
|
||||
});
|
||||
} else if (throwable instanceof InvalidCommandSenderException) {
|
||||
this.commandManager.handleException(sender,
|
||||
InvalidCommandSenderException.class,
|
||||
(InvalidCommandSenderException) throwable, (c, e) ->
|
||||
this.sendMessage(event, throwable.getMessage())
|
||||
);
|
||||
} else if (throwable instanceof NoPermissionException) {
|
||||
this.commandManager.handleException(sender,
|
||||
NoPermissionException.class,
|
||||
(NoPermissionException) throwable, (c, e) ->
|
||||
this.sendMessage(event, MESSAGE_NO_PERMS)
|
||||
);
|
||||
} else if (throwable instanceof NoSuchCommandException) {
|
||||
this.commandManager.handleException(sender,
|
||||
NoSuchCommandException.class,
|
||||
(NoSuchCommandException) throwable, (c, e) ->
|
||||
this.sendMessage(event, MESSAGE_UNKNOWN_COMMAND)
|
||||
);
|
||||
} else if (throwable instanceof ArgumentParseException) {
|
||||
this.commandManager.handleException(sender, ArgumentParseException.class,
|
||||
(ArgumentParseException) throwable, (c, e) -> {
|
||||
this.sendMessage(event,
|
||||
"Invalid Command Argument: " + throwable.getCause()
|
||||
.getMessage());
|
||||
});
|
||||
} else {
|
||||
this.sendMessage(event, throwable.getMessage());
|
||||
}
|
||||
});
|
||||
if (throwable instanceof InvalidSyntaxException) {
|
||||
this.commandManager.handleException(sender,
|
||||
InvalidSyntaxException.class,
|
||||
(InvalidSyntaxException) throwable, (c, e) -> {
|
||||
this.sendMessage(
|
||||
event,
|
||||
MESSAGE_INVALID_SYNTAX + prefix + ((InvalidSyntaxException) throwable)
|
||||
.getCorrectSyntax()
|
||||
);
|
||||
}
|
||||
);
|
||||
} else if (throwable instanceof InvalidCommandSenderException) {
|
||||
this.commandManager.handleException(sender,
|
||||
InvalidCommandSenderException.class,
|
||||
(InvalidCommandSenderException) throwable, (c, e) ->
|
||||
this.sendMessage(event, throwable.getMessage())
|
||||
);
|
||||
} else if (throwable instanceof NoPermissionException) {
|
||||
this.commandManager.handleException(sender,
|
||||
NoPermissionException.class,
|
||||
(NoPermissionException) throwable, (c, e) ->
|
||||
this.sendMessage(event, MESSAGE_NO_PERMS)
|
||||
);
|
||||
} else if (throwable instanceof NoSuchCommandException) {
|
||||
this.commandManager.handleException(sender,
|
||||
NoSuchCommandException.class,
|
||||
(NoSuchCommandException) throwable, (c, e) ->
|
||||
this.sendMessage(event, MESSAGE_UNKNOWN_COMMAND)
|
||||
);
|
||||
} else if (throwable instanceof ArgumentParseException) {
|
||||
this.commandManager.handleException(sender, ArgumentParseException.class,
|
||||
(ArgumentParseException) throwable, (c, e) -> {
|
||||
this.sendMessage(
|
||||
event,
|
||||
"Invalid Command Argument: " + throwable.getCause()
|
||||
.getMessage()
|
||||
);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.sendMessage(event, throwable.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sendMessage(final @NonNull MessageReceivedEvent event, final @NonNull String message) {
|
||||
event.getChannel().sendMessage(message).queue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import java.util.function.Function;
|
|||
* @param <C> Command sender type
|
||||
*/
|
||||
public class JDACommandManager<C> extends CommandManager<C> {
|
||||
|
||||
private final long botId;
|
||||
|
||||
private final Function<@NonNull C, @NonNull String> prefixMapper;
|
||||
|
|
@ -63,12 +64,14 @@ public class JDACommandManager<C> extends CommandManager<C> {
|
|||
* @param backwardsCommandSenderMapper Function that maps the command sender type to {@link MessageReceivedEvent}
|
||||
* @throws InterruptedException If the jda instance does not ready correctly
|
||||
*/
|
||||
public JDACommandManager(final @NonNull JDA jda,
|
||||
final @NonNull Function<@NonNull C, @NonNull String> prefixMapper,
|
||||
final @Nullable BiFunction<@NonNull C, @NonNull String, @NonNull Boolean> permissionMapper,
|
||||
final @NonNull Function<CommandTree<C>, CommandExecutionCoordinator<C>> commandExecutionCoordinator,
|
||||
final @NonNull Function<@NonNull MessageReceivedEvent, @NonNull C> commandSenderMapper,
|
||||
final @NonNull Function<@NonNull C, @NonNull MessageReceivedEvent> backwardsCommandSenderMapper)
|
||||
public JDACommandManager(
|
||||
final @NonNull JDA jda,
|
||||
final @NonNull Function<@NonNull C, @NonNull String> prefixMapper,
|
||||
final @Nullable BiFunction<@NonNull C, @NonNull String, @NonNull Boolean> permissionMapper,
|
||||
final @NonNull Function<CommandTree<C>, CommandExecutionCoordinator<C>> commandExecutionCoordinator,
|
||||
final @NonNull Function<@NonNull MessageReceivedEvent, @NonNull C> commandSenderMapper,
|
||||
final @NonNull Function<@NonNull C, @NonNull MessageReceivedEvent> backwardsCommandSenderMapper
|
||||
)
|
||||
throws InterruptedException {
|
||||
super(commandExecutionCoordinator, CommandRegistrationHandler.nullCommandRegistrationHandler());
|
||||
this.prefixMapper = prefixMapper;
|
||||
|
|
@ -130,4 +133,5 @@ public class JDACommandManager<C> extends CommandManager<C> {
|
|||
public final @NonNull CommandMeta createDefaultCommandMeta() {
|
||||
return SimpleCommandMeta.empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||
* Wrapper for {@link MessageReceivedEvent}
|
||||
*/
|
||||
public class JDACommandSender {
|
||||
|
||||
private final MessageReceivedEvent event;
|
||||
|
||||
/**
|
||||
|
|
@ -42,15 +43,6 @@ public class JDACommandSender {
|
|||
this.event = event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link MessageReceivedEvent}
|
||||
*
|
||||
* @return Message Received Event
|
||||
*/
|
||||
public @NonNull MessageReceivedEvent getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a JDA Command Sender from a {@link MessageReceivedEvent}
|
||||
*
|
||||
|
|
@ -64,4 +56,14 @@ public class JDACommandSender {
|
|||
|
||||
return new JDAGuildSender(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link MessageReceivedEvent}
|
||||
*
|
||||
* @return Message Received Event
|
||||
*/
|
||||
public @NonNull MessageReceivedEvent getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,4 +34,5 @@ public class JDAGuildSender extends JDACommandSender {
|
|||
JDAGuildSender(final @NonNull MessageReceivedEvent event) {
|
||||
super(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,4 +34,5 @@ public class JDAPrivateSender extends JDACommandSender {
|
|||
JDAPrivateSender(final @NonNull MessageReceivedEvent event) {
|
||||
super(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,10 +43,13 @@ import java.util.Queue;
|
|||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public final class UserArgument<C> extends CommandArgument<C, User> {
|
||||
|
||||
private final List<ParserMode> modes;
|
||||
|
||||
private UserArgument(final boolean required, final @NonNull String name,
|
||||
final @NonNull JDA jda, final @NonNull List<ParserMode> modes) {
|
||||
private UserArgument(
|
||||
final boolean required, final @NonNull String name,
|
||||
final @NonNull JDA jda, final @NonNull List<ParserMode> modes
|
||||
) {
|
||||
super(required, name, new UserParser<>(jda, modes), User.class);
|
||||
this.modes = modes;
|
||||
}
|
||||
|
|
@ -105,6 +108,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
|
||||
|
||||
public static final class Builder<C> extends CommandArgument.Builder<C, User> {
|
||||
|
||||
private final JDA jda;
|
||||
private List<ParserMode> modes = new ArrayList<>();
|
||||
|
||||
|
|
@ -138,6 +142,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
|
||||
|
||||
public static final class UserParser<C> implements ArgumentParser<C, User> {
|
||||
|
||||
private final JDA jda;
|
||||
private final List<ParserMode> modes;
|
||||
|
||||
|
|
@ -149,7 +154,8 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
@Override
|
||||
public @NonNull ArgumentParseResult<User> parse(
|
||||
final @NonNull CommandContext<C> commandContext,
|
||||
final @NonNull Queue<@NonNull String> inputQueue) {
|
||||
final @NonNull Queue<@NonNull String> inputQueue
|
||||
) {
|
||||
final String input = inputQueue.peek();
|
||||
if (input == null) {
|
||||
return ArgumentParseResult.failure(new NullPointerException("No input was provided"));
|
||||
|
|
@ -218,6 +224,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
return ArgumentParseResult.success(user);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -242,10 +249,12 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
public final @NonNull String getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static final class TooManyUsersFoundParseException extends UserParseException {
|
||||
|
||||
/**
|
||||
* Construct a new UUID parse exception
|
||||
*
|
||||
|
|
@ -259,10 +268,12 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
public @NonNull String getMessage() {
|
||||
return String.format("Too many users found for '%s'.", getInput());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static final class UserNotFoundParseException extends UserParseException {
|
||||
|
||||
/**
|
||||
* Construct a new UUID parse exception
|
||||
*
|
||||
|
|
@ -276,5 +287,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
public @NonNull String getMessage() {
|
||||
return String.format("User not found for '%s'.", getInput());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue