Class DefaultMemberPermissions

java.lang.Object
net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions

public class DefaultMemberPermissions extends Object
Represents the default permissions for a Discord Application-Command. These permissions define the type of users that can use this command if no explicit command-specific privileges are set by moderators to control who can and can't use the command within a Guild.

For example, given a command defined with CommandData#setDefaultPermissions as command.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.BAN_MEMBERS)) any user with the Permission.BAN_MEMBERS permission would be able to use the command by default.

  • Field Details

    • ENABLED

      public static final DefaultMemberPermissions ENABLED
      Default permissions of a command with no restrictions applied. (Everyone can see and access this command by default)
    • DISABLED

      public static final DefaultMemberPermissions DISABLED
      "Empty" permissions of a command.
      Only members with the ADMINISTRATOR permission can see and access this command by default.
  • Method Details

    • getPermissionsRaw

      @Nullable public Long getPermissionsRaw()
      Raw permission integer representing the default permissions of a command.
      This returns null if it is of type ENABLED
      If the default member permissions are DISABLED, this returns 0
      Returns:
      Raw permission integer representing the default member permissions of a command
    • enabledFor

      @Nonnull public static DefaultMemberPermissions enabledFor(@Nonnull Collection<Permission> permissions)
      Returns a DefaultMemberPermissions instance with the predefined permissions a member must have to see and access a command.
      If the passed Collection is empty, this returns ENABLED
      Parameters:
      permissions - Collection of Permissions
      Returns:
      DefaultMemberPermissions instance with the predefined permissions
      Throws:
      IllegalArgumentException - If any of the passed Permission is null
    • enabledFor

      @Nonnull public static DefaultMemberPermissions enabledFor(@Nonnull Permission... permissions)
      Returns a DefaultMemberPermissions instance with the predefined permissions a member must have to see and access a command.
      If the passed Array is empty, this returns ENABLED
      Parameters:
      permissions - Vararg of Permissions
      Returns:
      DefaultMemberPermissions instance with the predefined permissions
      Throws:
      IllegalArgumentException - If any of the passed Permission is null
    • enabledFor

      @Nonnull public static DefaultMemberPermissions enabledFor(long permissions)
      Returns a DefaultMemberPermissions instance with the predefined permissions a member must have to see and access a command.
      If the passed permission offset is 0, this returns ENABLED
      Parameters:
      permissions - Raw permission bitset
      Returns:
      DefaultMemberPermissions instance with the predefined permissions