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

    Constructors
    Constructor
    Description
    UnrecognizedCommandEvent(String command, net.dv8tion.jda.api.entities.User author)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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
     
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UnrecognizedCommandEvent

      public UnrecognizedCommandEvent(String command, net.dv8tion.jda.api.entities.User author)
  • Method Details

    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Specified by:
      getHandlers in class org.bukkit.event.Event
    • getHandlerList

      public static org.bukkit.event.HandlerList getHandlerList()
    • getCommand

      public String 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

      public String getReply()
      Gets the current reply to the unknown command. By default this value is getAuthorAsMention() + ", that is not a valid command."
      Returns:
      the reply that will be sent.
    • setReply

      public void setReply(@Nonnull String reply)
      Sets a new reply to be sent to the author. This will set handled to true
      Parameters:
      reply - the new reply to send.
      Throws:
      IllegalArgumentException - if reply 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 to false.
    • getAuthorAsTag

      public String getAuthorAsTag()
      Gets the tag for the author. Equivalent to calling getAuthor().getAsTag() For those who do not want to reference JDA's library.
      Returns:
      the tag of the author.
    • getAuthorAsMention

      public String getAuthorAsMention()
      Gets the mention string for the author. Equivalent to calling getAuthor().getAsMention() For those who do not want to reference JDA's library.
      Returns:
      the mention string of the author.