Class LegacyCommandBuilder

java.lang.Object
com.dianxin.tori.api.commands.LegacyCommandBuilder

public class LegacyCommandBuilder extends Object
A utility builder class designed to construct configurations for any commands. This helps keep the code clean, readable, and manageable during command initialization.
  • Constructor Details

    • LegacyCommandBuilder

      public LegacyCommandBuilder()
  • Method Details

    • setDefer

      public LegacyCommandBuilder setDefer(boolean defer)
      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 - true to automatically defer the reply, false otherwise.
      Returns:
      This builder instance for method chaining.
    • setGuildOnly

      public LegacyCommandBuilder setGuildOnly(boolean guildOnly)
      Restricts the command to be executable only within Discord guilds (servers).
      Parameters:
      guildOnly - true to restrict to guilds, false to allow elsewhere.
      Returns:
      This builder instance for method chaining.
    • setOwnerOnly

      public LegacyCommandBuilder setOwnerOnly(boolean ownerOnly)
      Restricts the command exclusively to the bot owner.
      Parameters:
      ownerOnly - true to restrict to the bot owner, false otherwise.
      Returns:
      This builder instance for method chaining.
    • setPrivateChannelOnly

      public LegacyCommandBuilder setPrivateChannelOnly(boolean privateChannelOnly)
      Restricts the command to be executable only in private channels.
      Parameters:
      privateChannelOnly - true to restrict to private channels, false otherwise.
      Returns:
      This builder instance for method chaining.
    • setDirectMessageOnly

      public LegacyCommandBuilder setDirectMessageOnly(boolean directMessageOnly)
      Restricts the command to be executable only in Direct Messages (DMs).
      Parameters:
      directMessageOnly - true to restrict to DMs, false otherwise.
      Returns:
      This builder instance for method chaining.
    • setDebug

      public LegacyCommandBuilder setDebug(boolean debug)
      Sets whether debug logging should be enabled for this command when it is executed.
      Parameters:
      debug - true to enable debug logging, false otherwise.
      Returns:
      This builder instance for method chaining.
    • addRequiredPermissions

      public LegacyCommandBuilder addRequiredPermissions(net.dv8tion.jda.api.Permission... permissions)
      Adds one or more Discord permissions that the user invoking the command must possess.
      Parameters:
      permissions - The Permission(s) required by the user.
      Returns:
      This builder instance for method chaining.
    • addSelfPermissions

      public LegacyCommandBuilder addSelfPermissions(net.dv8tion.jda.api.Permission... permissions)
      Adds one or more Discord permissions that the bot itself must possess to handle the command.
      Parameters:
      permissions - The Permission(s) required by the bot.
      Returns:
      This builder instance for method chaining.
    • isDefer

      public boolean isDefer()
      Returns:
      true if the command reply is set to be deferred.
    • isGuildOnly

      public boolean isGuildOnly()
      Returns:
      true if the command is restricted to guilds.
    • isOwnerOnly

      public boolean isOwnerOnly()
      Returns:
      true if the command is restricted to the bot owner.
    • isPrivateChannelOnly

      public boolean isPrivateChannelOnly()
      Returns:
      true if the command is restricted to private channels.
    • isDirectMessageOnly

      public boolean isDirectMessageOnly()
      Returns:
      true if the command is restricted to direct messages.
    • isDebug

      public boolean isDebug()
      Returns:
      true if debug logging is enabled for this command.
    • getPermissionsRequired

      public List<net.dv8tion.jda.api.Permission> getPermissionsRequired()
      Returns:
      A list of permissions required by the user.
    • getSelfPermissionsRequired

      public List<net.dv8tion.jda.api.Permission> getSelfPermissionsRequired()
      Returns:
      A list of permissions required by the bot itself.
    • deferAndOnlyGuild

      public static LegacyCommandBuilder 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 LegacyCommandBuilder instance.
    • guildAdminOnly

      public static LegacyCommandBuilder guildAdminOnly()
      A convenience factory method to create a builder pre-configured to require the Permission.ADMINISTRATOR permission from the user.
      Returns:
      A new, pre-configured LegacyCommandBuilder instance.