Class CommandExecutionContext


  • public final class CommandExecutionContext
    extends java.lang.Object
    Represents a generic data about the Command executed.
    • Constructor Summary

      Constructors 
      Constructor Description
      CommandExecutionContext​(@NotNull net.dv8tion.jda.api.entities.Message message, @NotNull java.lang.String alias, boolean fromDispatcher, @NotNull CommandData commandData, @NotNull CommandManager creator)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @NotNull java.lang.String getAlias()
      Returns the alias which triggered command execution.
      @NotNull net.dv8tion.jda.api.entities.User getAuthor()
      Returns the discord User as a whole, author of the command.
      @NotNull net.dv8tion.jda.api.entities.MessageChannel getChannel()
      Returns the MessageChannel where the command was executed.
      @NotNull CommandData getCommandData()
      Returns the data of the command execution triggered.
      @NotNull CommandManager getCommandManagerCreator()
      Returns the CommandManager, whom have initialized this command execution context.
      @Nullable net.dv8tion.jda.api.entities.Guild getGuild()
      Returns the Guild where the getMember() have executed the command if it was executed in a guild.
      @NotNull net.dv8tion.jda.api.JDA getJda()
      Returns the shard from where the command was executed.
      @Nullable net.dv8tion.jda.api.entities.Member getMember()
      Returns the guild Member, author of the command if the command was executed in guild.
      @NotNull net.dv8tion.jda.api.entities.Message getMessage()
      Returns the whole command Message.
      @Nullable net.dv8tion.jda.api.entities.PrivateChannel getPrivateChannel()
      Returns the PrivateChannel if the command was executed in the specified author's DMs.
      @Nullable net.dv8tion.jda.api.entities.TextChannel getTextChannel()
      Returns the TextChannel if the command was executed in a guild.
      boolean isFromDispatcher()
      Returns whenever this context was made from a dispatcher
      boolean wasExecutedInGuild()
      Returns whenever the command was executed in a guild.
      • Methods inherited from class java.lang.Object

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

      • CommandExecutionContext

        public CommandExecutionContext​(@NotNull
                                       @NotNull net.dv8tion.jda.api.entities.Message message,
                                       @NotNull
                                       @NotNull java.lang.String alias,
                                       boolean fromDispatcher,
                                       @NotNull
                                       @NotNull CommandData commandData,
                                       @NotNull
                                       @NotNull CommandManager creator)
    • Method Detail

      • getChannel

        @NotNull
        public @NotNull net.dv8tion.jda.api.entities.MessageChannel getChannel()
        Returns the MessageChannel where the command was executed.
        Returns:
        channel
      • wasExecutedInGuild

        public boolean wasExecutedInGuild()
        Returns whenever the command was executed in a guild.
        Returns:
        true if executed in guild channel, false otherwise
      • getTextChannel

        @Nullable
        public @Nullable net.dv8tion.jda.api.entities.TextChannel getTextChannel()
        Returns the TextChannel if the command was executed in a guild.
        Returns:
        channel or null
      • getPrivateChannel

        @Nullable
        public @Nullable net.dv8tion.jda.api.entities.PrivateChannel getPrivateChannel()
        Returns the PrivateChannel if the command was executed in the specified author's DMs.
        Returns:
        channel or null
      • getMember

        @Nullable
        public @Nullable net.dv8tion.jda.api.entities.Member getMember()
        Returns the guild Member, author of the command if the command was executed in guild.

        Keep in mind this is not the same as getAuthor()

        Returns:
        member
      • getAuthor

        @NotNull
        public @NotNull net.dv8tion.jda.api.entities.User getAuthor()
        Returns the discord User as a whole, author of the command.

        Keep in mind this is not the same as getMember()

        Returns:
        discord user, author
      • getJda

        @NotNull
        public @NotNull net.dv8tion.jda.api.JDA getJda()
        Returns the shard from where the command was executed.
        Returns:
        shard
      • getMessage

        @NotNull
        public @NotNull net.dv8tion.jda.api.entities.Message getMessage()
        Returns the whole command Message. It is discouraged to be used for retrieving the text.
        Returns:
        message
      • getGuild

        @Nullable
        public @Nullable net.dv8tion.jda.api.entities.Guild getGuild()
        Returns the Guild where the getMember() have executed the command if it was executed in a guild.
        Returns:
        guild
      • getAlias

        @NotNull
        public @NotNull java.lang.String getAlias()
        Returns the alias which triggered command execution.
        Returns:
        alias
      • getCommandData

        @NotNull
        public @NotNull CommandData getCommandData()
        Returns the data of the command execution triggered.
        Returns:
        command data
      • getCommandManagerCreator

        @NotNull
        public @NotNull CommandManager getCommandManagerCreator()
        Returns the CommandManager, whom have initialized this command execution context.
        Returns:
        command manager initializer
      • isFromDispatcher

        public boolean isFromDispatcher()
        Returns whenever this context was made from a dispatcher
        Returns:
        true if the command wasn't dispatched the normal way, false otherwise