Class ApplicationCommandPermission

java.lang.Object
discord4j.core.object.command.ApplicationCommandPermission
All Implemented Interfaces:
DiscordObject

public class ApplicationCommandPermission extends Object implements DiscordObject
Represents an individual application command permission, allowing you to enable or disable commands for specific users, roles, or channels within a guild.
  • Constructor Details

    • ApplicationCommandPermission

      public ApplicationCommandPermission(GatewayDiscordClient gateway, Snowflake guildId, discord4j.discordjson.json.ApplicationCommandPermissionsData data)
      Constructs an ApplicationCommandPermission with an associated GatewayDiscordClient and Discord data.
      Parameters:
      gateway - the GatewayDiscordClient associated to this object, must be non-null.
      data - the raw data as represented by Discord, must be non-null.
  • Method Details

    • getId

      public Snowflake getId()
      Return the ID of the role, user, or channel. It can also be a permission constant which can be detected by appliesToEveryone() or appliesToAllChannels().
      Returns:
      the permission target as a Snowflake ID
    • appliesToEveryone

      public boolean appliesToEveryone()
      Returns whether this role permission uses a constant representing it applies to everyone.
      Returns:
      true if this permission applies to all members in a guild, false if otherwise
    • appliesToAllChannels

      public boolean appliesToAllChannels()
      Returns whether this channel permission uses a constant representing it applies to all channels.
      Returns:
      true if this permission applies to all channels in a guild, false if otherwise
    • getType

      Returns the type of this permission.
      Returns:
      the type of this permission
    • isAllowed

      public boolean isAllowed()
      Returns whether this permission allows or disallows a command for the target given by getType() and getId().
      Returns:
      true if this permission is allowing the command, false if it disallows it.
    • getClient

      public GatewayDiscordClient getClient()
      Description copied from interface: DiscordObject
      Returns the GatewayDiscordClient that created this object. Methods in it are exclusively based on the entity cache or Store in use. Refer to calling getClient().rest() to access a DiscordClient that is capable of requesting entities directly from the REST API.
      Specified by:
      getClient in interface DiscordObject
      Returns:
      The GatewayDiscordClient associated to this object.
    • toString

      public String toString()
      Overrides:
      toString in class Object