Interface CommandInteraction

    • Method Detail

      • getName

        @Nonnull
        java.lang.String getName()
        The command name.
        This can be useful for abstractions.

        Note that commands can have these following structures:

        • /name subcommandGroup subcommandName
        • /name subcommandName
        • /name
        You can use getCommandPath() to simplify your checks.
        Returns:
        The command name
      • getSubcommandName

        @Nullable
        java.lang.String getSubcommandName()
        The subcommand name.
        This can be useful for abstractions.

        Note that commands can have these following structures:

        • /name subcommandGroup subcommandName
        • /name subcommandName
        • /name
        You can use getCommandPath() to simplify your checks.
        Returns:
        The subcommand name, or null if this is not a subcommand
      • getSubcommandGroup

        @Nullable
        java.lang.String getSubcommandGroup()
        The subcommand group name.
        This can be useful for abstractions.

        Note that commands can have these following structures:

        • /name subcommandGroup subcommandName
        • /name subcommandName
        • /name
        You can use getCommandPath() to simplify your checks.
        Returns:
        The subcommand group name, or null if this is not a subcommand group
      • getCommandPath

        @Nonnull
        default java.lang.String getCommandPath()
        Combination of getName(), getSubcommandGroup(), and getSubcommandName().
        This will format the command into a path such as mod/mute where mod would be the getName() and mute the getSubcommandName().

        Examples:

        • /mod ban -> "mod/ban"
        • /admin config owner -> "admin/config/owner"
        • /ban -> "ban"
        Returns:
        The command path
      • getChannel

        @Nonnull
        MessageChannel getChannel()
        Description copied from interface: Interaction
        The channel this interaction happened in.
        This is currently never null, but might be nullable in the future.
        Specified by:
        getChannel in interface Interaction
        Returns:
        The channel or null if this interaction is not from a channel context
      • getCommandIdLong

        long getCommandIdLong()
        The command id
        Returns:
        The command id
      • getCommandId

        @Nonnull
        default java.lang.String getCommandId()
        The command id
        Returns:
        The command id
      • getOptions

        @Nonnull
        java.util.List<OptionMapping> getOptions()
        The options provided by the user when this command was executed.
        Each option has a name and value.
        Returns:
        The options passed for this command
      • getOptionsByName

        @Nonnull
        default java.util.List<OptionMapping> getOptionsByName​(@Nonnull
                                                               java.lang.String name)
        Gets all options for the specified name.
        Parameters:
        name - The option name
        Returns:
        The list of options
        Throws:
        java.lang.IllegalArgumentException - If the provided name is null
        See Also:
        getOption(String)
      • getOptionsByType

        @Nonnull
        default java.util.List<OptionMapping> getOptionsByType​(@Nonnull
                                                               OptionType type)
        Gets all options for the specified type.
        Parameters:
        type - The option type
        Returns:
        The list of options
        Throws:
        java.lang.IllegalArgumentException - If the provided type is null
      • getOption

        @Nullable
        default OptionMapping getOption​(@Nonnull
                                        java.lang.String name)
        Finds the first option with the specified name.
        Parameters:
        name - The option name
        Returns:
        The option with the provided name, or null if that option is not provided
        Throws:
        java.lang.IllegalArgumentException - If the name is null
      • getCommandString

        @Nonnull
        default java.lang.String getCommandString()
        Gets the slash command String for this slash command.
        This is similar to the String you see when clicking the interaction name in the client.

        Example return for an echo command: /say echo phrase: Say this

        Returns:
        The command String for this slash command