Package com.jagrosh.jdautilities.command
Class Interaction
java.lang.Object
com.jagrosh.jdautilities.command.Interaction
- Direct Known Subclasses:
Command,ContextMenu
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
FieldsModifier and TypeFieldDescriptionprotected StringThe permission message used when the bot does not have the required permission.protected net.dv8tion.jda.api.Permission[]AnyPermissionsthe bot must have to use a command.protected intAnintnumber of seconds users must wait before using this command again.protected CooldownScopeTheCooldownScopeof the command.protected booleantrueif the command may only be used in aGuild,falseif it may be used in both a Guild and a DM.protected booleantrueif the command may only be used in an NSFWTextChannelor DMs.protected booleantrueif 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 StringThe permission message used when the user does not have the required permission.protected net.dv8tion.jda.api.Permission[]AnyPermissionsa Member must have to use this interaction. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnet.dv8tion.jda.api.Permission[]Gets thebotPermissionsfor the Interaction.intGets thecooldownfor the Interaction.Gets thecooldownfor the Interaction.net.dv8tion.jda.api.Permission[]Gets theuserPermissionsfor the Interaction.booleanChecks whether this is an owner only Interaction, meaning only the owner and co-owners can use it.
-
Field Details
-
guildOnly
protected boolean guildOnlytrueif the command may only be used in aGuild,falseif it may be used in both a Guild and a DM.
Defaulttrue. -
userPermissions
protected net.dv8tion.jda.api.Permission[] userPermissionsAnyPermissionsa Member must have to use this interaction.
These are only checked in aserverenvironment.
To disable the command for everyone (for interactions), set this tonull.
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[] botPermissionsAnyPermissionsthe bot must have to use a command.
These are only checked in aserverenvironment. -
ownerCommand
protected boolean ownerCommandtrueif 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.
Defaultfalse. -
cooldown
protected int cooldownAnintnumber of seconds users must wait before using this command again. -
cooldownScope
TheCooldownScopeof the command. This defines how far the scope the cooldowns have.
DefaultCooldownScope.USER. -
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
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 nsfwOnlytrueif the command may only be used in an NSFWTextChannelor DMs.falseif it may be used anywhere
Default:false
-
-
Constructor Details
-
Interaction
public Interaction()
-
-
Method Details
-
getCooldown
public int getCooldown()Gets thecooldownfor the Interaction.- Returns:
- The cooldown for the Interaction
-
getCooldownScope
Gets thecooldownfor the Interaction.- Returns:
- The cooldown for the Interaction
-
getUserPermissions
public net.dv8tion.jda.api.Permission[] getUserPermissions()Gets theuserPermissionsfor the Interaction.- Returns:
- The userPermissions for the Interaction
-
getBotPermissions
public net.dv8tion.jda.api.Permission[] getBotPermissions()Gets thebotPermissionsfor 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:
trueif the command is an owner interaction, otherwisefalseif it is not
-