Interface CommandInteraction

    • Method Detail

      • getName

        @Nonnull
        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
        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
        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
      • 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 String getCommandId()
        The command id
        Returns:
        The command id
      • getOptions

        @Nonnull
        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
      • getOption

        @Nullable
        default OptionMapping getOption​(@Nonnull
                                        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:
        IllegalArgumentException - If the name is null
      • getCommandString

        @Nonnull
        default 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