Package discord4j.core.object.command
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ApplicationCommandPermission.Type
Represents the various types of application command permissions.
-
Constructor Summary
Constructors Constructor Description ApplicationCommandPermission(GatewayDiscordClient gateway, Snowflake guildId, discord4j.discordjson.json.ApplicationCommandPermissionsData data)
Constructs anApplicationCommandPermission
with an associatedGatewayDiscordClient
and Discord data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
appliesToAllChannels()
Returns whether this channel permission uses a constant representing it applies to all channels.boolean
appliesToEveryone()
Returns whether this role permission uses a constant representing it applies to everyone.GatewayDiscordClient
getClient()
Returns theGatewayDiscordClient
that created this object.Snowflake
getId()
Return the ID of the role, user, or channel.ApplicationCommandPermission.Type
getType()
Returns the type of this permission.boolean
isAllowed()
String
toString()
-
-
-
Constructor Detail
-
ApplicationCommandPermission
public ApplicationCommandPermission(GatewayDiscordClient gateway, Snowflake guildId, discord4j.discordjson.json.ApplicationCommandPermissionsData data)
Constructs anApplicationCommandPermission
with an associatedGatewayDiscordClient
and Discord data.- Parameters:
gateway
- theGatewayDiscordClient
associated to this object, must be non-null.data
- the raw data as represented by Discord, must be non-null.
-
-
Method Detail
-
getId
public Snowflake getId()
Return the ID of the role, user, or channel. It can also be a permission constant which can be detected byappliesToEveryone()
orappliesToAllChannels()
.- 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
public ApplicationCommandPermission.Type 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 bygetType()
andgetId()
.- Returns:
true
if this permission is allowing the command,false
if it disallows it.
-
getClient
public GatewayDiscordClient getClient()
Description copied from interface:DiscordObject
Returns theGatewayDiscordClient
that created this object. Methods in it are exclusively based on the entity cache orStore
in use. Refer to callinggetClient().rest()
to access aDiscordClient
that is capable of requesting entities directly from the REST API.- Specified by:
getClient
in interfaceDiscordObject
- Returns:
- The
GatewayDiscordClient
associated to this object.
-
-