@API(status=EXPERIMENTAL) public class SlashCommand extends CommandActivity<CommandContext>
Modifier | Constructor and Description |
---|---|
protected |
SlashCommand(java.lang.String slashCommandPattern,
boolean requiresBotMention,
java.util.function.Consumer<CommandContext> callback,
java.lang.String description)
Default protected constructor, new instances from static methods only.
|
Modifier and Type | Method and Description |
---|---|
protected CommandContext |
createContextInstance(V4Initiator initiator,
V4MessageSent event) |
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
protected ActivityInfo |
info()
Build activity info.
|
ActivityMatcher<CommandContext> |
matcher()
Any kind of activity must provide an
ActivityMatcher in order to detect if it can be applied to a certain
user input. |
void |
onActivity(CommandContext context)
Contain the activity business logic.
|
static SlashCommand |
slash(java.lang.String slashCommandPattern,
boolean requiresBotMention,
java.util.function.Consumer<CommandContext> callback)
Returns a new
SlashCommand instance. |
static SlashCommand |
slash(java.lang.String slashCommandPattern,
boolean requiresBotMention,
java.util.function.Consumer<CommandContext> callback,
java.lang.String description)
Returns a new
SlashCommand instance. |
static SlashCommand |
slash(java.lang.String slashCommandPattern,
java.util.function.Consumer<CommandContext> callback)
Returns a new
SlashCommand instance. |
static SlashCommand |
slash(java.lang.String slashCommandPattern,
java.util.function.Consumer<CommandContext> callback,
java.lang.String description)
Returns a new
SlashCommand instance. |
beforeMatcher, bindToRealTimeEventsSource
getInfo, processEvent
protected SlashCommand(@Nonnull java.lang.String slashCommandPattern, boolean requiresBotMention, @Nonnull java.util.function.Consumer<CommandContext> callback, java.lang.String description)
public static SlashCommand slash(@Nonnull java.lang.String slashCommandPattern, @Nonnull java.util.function.Consumer<CommandContext> callback)
SlashCommand
instance.slashCommandPattern
- Pattern of the command (ex: '/gif' or 'gif {option} {@mention}').callback
- Callback to be processed when command is detected.public static SlashCommand slash(@Nonnull java.lang.String slashCommandPattern, boolean requiresBotMention, @Nonnull java.util.function.Consumer<CommandContext> callback)
SlashCommand
instance.slashCommandPattern
- Pattern of the command (ex: '/gif' or 'gif {option} {@mention}').requiresBotMention
- Indicates whether the bot has to be mentioned in order to trigger the command.callback
- Callback to be processed when command is detected.java.lang.IllegalArgumentException
- if command name if empty.public static SlashCommand slash(@Nonnull java.lang.String slashCommandPattern, @Nonnull java.util.function.Consumer<CommandContext> callback, java.lang.String description)
SlashCommand
instance.slashCommandPattern
- Pattern of the command (ex: '/gif' or 'gif {option} {@mention}').callback
- Callback to be processed when command is detected.description
- The summary of the command.SlashCommand
instance.public static SlashCommand slash(@Nonnull java.lang.String slashCommandPattern, boolean requiresBotMention, @Nonnull java.util.function.Consumer<CommandContext> callback, java.lang.String description)
SlashCommand
instance.slashCommandPattern
- Pattern of the command (ex: '/gif' or 'gif {option} {@mention}').requiresBotMention
- Indicates whether the bot has to be mentioned in order to trigger the command.callback
- Callback to be processed when command is detected.description
- The summary of the command.SlashCommand
instance.public ActivityMatcher<CommandContext> matcher()
AbstractActivity
ActivityMatcher
in order to detect if it can be applied to a certain
user input.matcher
in class AbstractActivity<V4MessageSent,CommandContext>
ActivityMatcher
implementation.public void onActivity(CommandContext context)
AbstractActivity
ActivityMatcher.matches(ActivityContext)
returned
a true value.onActivity
in class AbstractActivity<V4MessageSent,CommandContext>
context
- The activity context object.protected ActivityInfo info()
AbstractActivity
info
in class AbstractActivity<V4MessageSent,CommandContext>
protected CommandContext createContextInstance(V4Initiator initiator, V4MessageSent event)
createContextInstance
in class AbstractActivity<V4MessageSent,CommandContext>
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object