Class Interaction

java.lang.Object
com.jagrosh.jdautilities.command.Interaction
Direct Known Subclasses:
Command, ContextMenu

public abstract class Interaction extends Object
A class that represents an interaction with a user. This is all information used for all forms of interactions. Namely, permissions and cooldowns. Any content here is safely functionality equivalent regardless of the source of the interaction.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    The permission message used when the bot does not have the required permission.
    protected net.dv8tion.jda.api.Permission[]
    Any Permissions the bot must have to use a command.
    protected int
    An int number of seconds users must wait before using this command again.
    protected CooldownScope
    The CooldownScope of the command.
    protected boolean
    true if the command may only be used in a Guild, false if it may be used in both a Guild and a DM.
    protected boolean
    true if the command may only be used in an NSFW TextChannel or DMs.
    protected boolean
    true if the interaction may only be used by a User with an ID matching the Owners or any of the CoOwners.
    If enabled for a Slash Command, only owners (owner + up to 9 co-owners) will be added to the SlashCommand.
    protected String
    The permission message used when the user does not have the required permission.
    protected net.dv8tion.jda.api.Permission[]
    Any Permissions a Member must have to use this interaction.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.dv8tion.jda.api.Permission[]
    Gets the botPermissions for the Interaction.
    int
    Gets the cooldown for the Interaction.
    Gets the cooldown for the Interaction.
    net.dv8tion.jda.api.Permission[]
    Gets the userPermissions for the Interaction.
    boolean
    Checks whether this is an owner only Interaction, meaning only the owner and co-owners can use it.

    Methods inherited from class java.lang.Object

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

    • guildOnly

      protected boolean guildOnly
      true if the command may only be used in a Guild, false if it may be used in both a Guild and a DM.
      Default true.
    • userPermissions

      protected net.dv8tion.jda.api.Permission[] userPermissions
      Any Permissions a Member must have to use this interaction.
      These are only checked in a server environment.
      To disable the command for everyone (for interactions), set this to null.
      Keep in mind, commands may still show up if the channel permissions are updated in settings. Otherwise, commands will automatically be hidden unless a user has these perms. However, permissions are always checked, just in case. A user must have these permissions regardless.
    • botPermissions

      protected net.dv8tion.jda.api.Permission[] botPermissions
      Any Permissions the bot must have to use a command.
      These are only checked in a server environment.
    • ownerCommand

      protected boolean ownerCommand
      true if the interaction may only be used by a User with an ID matching the Owners or any of the CoOwners.
      If enabled for a Slash Command, only owners (owner + up to 9 co-owners) will be added to the SlashCommand. All other permissions will be ignored.
      Default false.
    • cooldown

      protected int cooldown
      An int number of seconds users must wait before using this command again.
    • cooldownScope

      protected CooldownScope cooldownScope
      The CooldownScope of the command. This defines how far the scope the cooldowns have.
      Default CooldownScope.USER.
    • botMissingPermMessage

      protected String botMissingPermMessage
      The permission message used when the bot does not have the required permission. Requires 3 "%s", first is user mention, second is the permission needed, third is type, e.g. server.
    • userMissingPermMessage

      protected String userMissingPermMessage
      The permission message used when the user does not have the required permission. Requires 3 "%s", first is user mention, second is the permission needed, third is type, e.g. server.
    • nsfwOnly

      protected boolean nsfwOnly
      true if the command may only be used in an NSFW TextChannel or DMs. false if it may be used anywhere
      Default: false
  • Constructor Details

    • Interaction

      public Interaction()
  • Method Details

    • getCooldown

      public int getCooldown()
      Gets the cooldown for the Interaction.
      Returns:
      The cooldown for the Interaction
    • getCooldownScope

      public CooldownScope getCooldownScope()
      Gets the cooldown for the Interaction.
      Returns:
      The cooldown for the Interaction
    • getUserPermissions

      public net.dv8tion.jda.api.Permission[] getUserPermissions()
      Gets the userPermissions for the Interaction.
      Returns:
      The userPermissions for the Interaction
    • getBotPermissions

      public net.dv8tion.jda.api.Permission[] getBotPermissions()
      Gets the botPermissions for the Interaction.
      Returns:
      The botPermissions for the Interaction
    • isOwnerCommand

      public boolean isOwnerCommand()
      Checks whether this is an owner only Interaction, meaning only the owner and co-owners can use it.
      Returns:
      true if the command is an owner interaction, otherwise false if it is not