Package com.dianxin.tori.api.commands
Class LegacyCommandBuilder
java.lang.Object
com.dianxin.tori.api.commands.LegacyCommandBuilder
A utility builder class designed to construct configurations for any commands.
This helps keep the code clean, readable, and manageable during command initialization.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddRequiredPermissions(net.dv8tion.jda.api.Permission... permissions) Adds one or more Discord permissions that the user invoking the command must possess.addSelfPermissions(net.dv8tion.jda.api.Permission... permissions) Adds one or more Discord permissions that the bot itself must possess to handle the command.static LegacyCommandBuilderA convenience factory method to create a builder pre-configured to automatically defer the reply and restrict the command execution strictly to Discord guilds.List<net.dv8tion.jda.api.Permission> List<net.dv8tion.jda.api.Permission> static LegacyCommandBuilderA convenience factory method to create a builder pre-configured to require thePermission.ADMINISTRATORpermission from the user.booleanisDebug()booleanisDefer()booleanbooleanbooleanbooleansetDebug(boolean debug) Sets whether debug logging should be enabled for this command when it is executed.setDefer(boolean defer) Sets whether the command reply should be automatically deferred.setDirectMessageOnly(boolean directMessageOnly) Restricts the command to be executable only in Direct Messages (DMs).setGuildOnly(boolean guildOnly) Restricts the command to be executable only within Discord guilds (servers).setOwnerOnly(boolean ownerOnly) Restricts the command exclusively to the bot owner.setPrivateChannelOnly(boolean privateChannelOnly) Restricts the command to be executable only in private channels.
-
Constructor Details
-
LegacyCommandBuilder
public LegacyCommandBuilder()
-
-
Method Details
-
setDefer
Sets whether the command reply should be automatically deferred. Deferring gives the bot up to 15 minutes to process the request before responding.- Parameters:
defer-trueto automatically defer the reply,falseotherwise.- Returns:
- This builder instance for method chaining.
-
setGuildOnly
Restricts the command to be executable only within Discord guilds (servers).- Parameters:
guildOnly-trueto restrict to guilds,falseto allow elsewhere.- Returns:
- This builder instance for method chaining.
-
setOwnerOnly
Restricts the command exclusively to the bot owner.- Parameters:
ownerOnly-trueto restrict to the bot owner,falseotherwise.- Returns:
- This builder instance for method chaining.
-
setPrivateChannelOnly
Restricts the command to be executable only in private channels.- Parameters:
privateChannelOnly-trueto restrict to private channels,falseotherwise.- Returns:
- This builder instance for method chaining.
-
setDirectMessageOnly
Restricts the command to be executable only in Direct Messages (DMs).- Parameters:
directMessageOnly-trueto restrict to DMs,falseotherwise.- Returns:
- This builder instance for method chaining.
-
setDebug
Sets whether debug logging should be enabled for this command when it is executed.- Parameters:
debug-trueto enable debug logging,falseotherwise.- Returns:
- This builder instance for method chaining.
-
addRequiredPermissions
Adds one or more Discord permissions that the user invoking the command must possess.- Parameters:
permissions- ThePermission(s) required by the user.- Returns:
- This builder instance for method chaining.
-
addSelfPermissions
Adds one or more Discord permissions that the bot itself must possess to handle the command.- Parameters:
permissions- ThePermission(s) required by the bot.- Returns:
- This builder instance for method chaining.
-
isDefer
public boolean isDefer()- Returns:
trueif the command reply is set to be deferred.
-
isGuildOnly
public boolean isGuildOnly()- Returns:
trueif the command is restricted to guilds.
-
isOwnerOnly
public boolean isOwnerOnly()- Returns:
trueif the command is restricted to the bot owner.
-
isPrivateChannelOnly
public boolean isPrivateChannelOnly()- Returns:
trueif the command is restricted to private channels.
-
isDirectMessageOnly
public boolean isDirectMessageOnly()- Returns:
trueif the command is restricted to direct messages.
-
isDebug
public boolean isDebug()- Returns:
trueif debug logging is enabled for this command.
-
getPermissionsRequired
- Returns:
- A list of permissions required by the user.
-
getSelfPermissionsRequired
- Returns:
- A list of permissions required by the bot itself.
-
deferAndOnlyGuild
A convenience factory method to create a builder pre-configured to automatically defer the reply and restrict the command execution strictly to Discord guilds.- Returns:
- A new, pre-configured
LegacyCommandBuilderinstance.
-
guildAdminOnly
A convenience factory method to create a builder pre-configured to require thePermission.ADMINISTRATORpermission from the user.- Returns:
- A new, pre-configured
LegacyCommandBuilderinstance.
-