Class UnrecognizedCommandEvent
java.lang.Object
org.bukkit.event.Event
io.github.starsdown64.minecord.api.UnrecognizedCommandEvent
public class UnrecognizedCommandEvent
extends org.bukkit.event.Event
Allows external plugins to handle commands sent to Minecord in Discord that are not part of Minecord's commands.
isHandled()
should be checked and made sure to be false
before using the command.
handled
cannot be set to false
, should be set to true
using declareHandled()
, and is automatically updated to true
once setReply(String)
is run.- Since:
- 1.3.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result
-
Constructor Summary
ConstructorDescriptionUnrecognizedCommandEvent
(String command, net.dv8tion.jda.api.entities.User author) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Declares this unknown command has been handled.net.dv8tion.jda.api.entities.User
Gets the user that sent the command.Gets the mention string for the author.Gets the tag for the author.Gets the command that was sent by the user.static org.bukkit.event.HandlerList
@NotNull org.bukkit.event.HandlerList
getReply()
Gets the current reply to the unknown command.boolean
Checks if the command has been handled by an external plugin yet.void
Sets a new reply to be sent to the author.Methods inherited from class org.bukkit.event.Event
getEventName, isAsynchronous
-
Constructor Details
-
UnrecognizedCommandEvent
-
-
Method Details
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()- Specified by:
getHandlers
in classorg.bukkit.event.Event
-
getHandlerList
public static org.bukkit.event.HandlerList getHandlerList() -
getCommand
Gets the command that was sent by the user.- Returns:
- the command that was used.
-
getAuthor
public net.dv8tion.jda.api.entities.User getAuthor()Gets the user that sent the command.- Returns:
- the user that executed the command.
-
getReply
Gets the current reply to the unknown command. By default this value isgetAuthorAsMention() + ", that is not a valid command."
- Returns:
- the reply that will be sent.
-
setReply
Sets a new reply to be sent to the author. This will sethandled
totrue
- Parameters:
reply
- the new reply to send.- Throws:
IllegalArgumentException
- ifreply
is blank.
-
isHandled
public boolean isHandled()Checks if the command has been handled by an external plugin yet.- Returns:
- if the command has been handled yet.
-
declareHandled
public void declareHandled()Declares this unknown command has been handled. For nearly all cases, plugins should declare it if they recognize the command.handled
cannot be set back tofalse
. -
getAuthorAsTag
Gets the tag for the author. Equivalent to callinggetAuthor().getAsTag()
For those who do not want to reference JDA's library.- Returns:
- the tag of the author.
-
getAuthorAsMention
Gets the mention string for the author. Equivalent to callinggetAuthor().getAsMention()
For those who do not want to reference JDA's library.- Returns:
- the mention string of the author.
-