public final class UnionArgument extends Argument<UnionArgument,IArgument>
It will try to parse arguments in the same order they're added. The first success will be the Value of this argument.
Make sure to use instanceof to check what of Argument was the valid one.
IArgument| Constructor and Description |
|---|
UnionArgument(@NotNull String name,
@NotNull String prompt)
Creates an instance of this Argument implementation
|
| Modifier and Type | Method and Description |
|---|---|
UnionArgument |
addArgumentType(IArgument argument)
Adds a new type of argument accepted by the UnionArgument
|
UnionArgument |
clone()
An argument clone is required to prevent a value traveling through different Command calls.
|
@NotNull List<IArgument> |
getArguments() |
@NotNull IArgument |
parse(@NotNull net.dv8tion.jda.api.events.message.MessageReceivedEvent event,
String arg)
To be called if all validations passed.
|
IArgument |
parse(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event,
String arg)
To be called if all validations passed.
|
@Nullable String |
validate(@NotNull net.dv8tion.jda.api.events.message.MessageReceivedEvent event,
@NotNull String arg)
Validates if the argument input by the user is a valid value.
|
String |
validate(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event,
String arg)
Validates if the argument input by the user is a valid value.
|
addValidValues, clone, getDefaultValue, getMax, getMin, getName, getPrompt, getPrompt, getPromptRaw, getType, getValidValues, getValue, inRange, inRange, inRange, inRange, inRange, inRange, isRequired, oneOf, setDefaultValue, setDefaultValue, setMax, setMax, setMax, setMax, setMin, setMin, setMin, setMin, setPromptParser, setRequired, setSlashValue, setValue, validateNullpublic UnionArgument addArgumentType(IArgument argument)
argument - IArgument Object@Nullable public @Nullable String validate(@NotNull @NotNull net.dv8tion.jda.api.events.message.MessageReceivedEvent event, @NotNull @NotNull String arg)
IArgumentevent - Discord event that triggered this function call.arg - argument input by the user.public String validate(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event, String arg)
IArgumentevent - Discord event that triggered this function call.arg - argument input by the user.@NotNull public @NotNull IArgument parse(@NotNull @NotNull net.dv8tion.jda.api.events.message.MessageReceivedEvent event, String arg) throws Exception
IArgumentevent - Discord event that triggered this function call.arg - argument input by the user.Exception - The method should NEVER throw an exception, any possible exceptions
should be checked in the validate method.IArgument.validate(MessageReceivedEvent, String)public IArgument parse(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event, String arg) throws Exception
IArgumentevent - Discord event that triggered this function call.arg - argument input by the user.Exception - The method should NEVER throw an exception, any possible exceptions
should be checked in the validate method.IArgument.validate(MessageReceivedEvent, String)public UnionArgument clone()
Argument
If your Argument child doesn't have additional attribute, you may just do
return clone(new MyArgument(getName(), getPrompt()));
clone in interface IArgument<UnionArgument,IArgument>clone in class Argument<UnionArgument,IArgument>