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
Modifier and TypeFieldDescriptionprotected String
The permission message used when the bot does not have the required permission.protected net.dv8tion.jda.api.Permission[]
AnyPermissions
the bot must have to use a command.protected int
Anint
number of seconds users must wait before using this command again.protected CooldownScope
TheCooldownScope
of the command.protected boolean
true
if the command may only be used in aGuild
,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 NSFWTextChannel
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[]
AnyPermissions
a Member must have to use this interaction. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionnet.dv8tion.jda.api.Permission[]
Gets thebotPermissions
for the Interaction.int
Gets thecooldown
for the Interaction.Gets thecooldown
for the Interaction.net.dv8tion.jda.api.Permission[]
Gets theuserPermissions
for the Interaction.boolean
Checks whether this is an owner only Interaction, meaning only the owner and co-owners can use it.
-
Field Details
-
guildOnly
protected boolean guildOnlytrue
if the command may only be used in aGuild
,false
if it may be used in both a Guild and a DM.
Defaulttrue
. -
userPermissions
protected net.dv8tion.jda.api.Permission[] userPermissionsAnyPermissions
a Member must have to use this interaction.
These are only checked in aserver
environment.
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[] botPermissionsAnyPermissions
the bot must have to use a command.
These are only checked in aserver
environment. -
ownerCommand
protected boolean ownerCommandtrue
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.
Defaultfalse
. -
cooldown
protected int cooldownAnint
number of seconds users must wait before using this command again. -
cooldownScope
TheCooldownScope
of 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 nsfwOnlytrue
if the command may only be used in an NSFWTextChannel
or DMs.false
if it may be used anywhere
Default:false
-
-
Constructor Details
-
Interaction
public Interaction()
-
-
Method Details
-
getCooldown
public int getCooldown()Gets thecooldown
for the Interaction.- Returns:
- The cooldown for the Interaction
-
getCooldownScope
Gets thecooldown
for the Interaction.- Returns:
- The cooldown for the Interaction
-
getUserPermissions
public net.dv8tion.jda.api.Permission[] getUserPermissions()Gets theuserPermissions
for the Interaction.- Returns:
- The userPermissions for the Interaction
-
getBotPermissions
public net.dv8tion.jda.api.Permission[] getBotPermissions()Gets thebotPermissions
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, otherwisefalse
if it is not
-