CommandAttributes
Application Command attributes.
Tags
Table of Contents
Properties
- $contexts : ExCollectionInterface|null
- $default_member_permissions : string|null
- $default_permission : bool|null
- $description : string|null
- $dm_permission : bool|null
- $guild_id : int|null
- $handler : int|null
- $integration_types : ExCollectionInterface|null
- $name : string
- $nsfw : bool|null
- $options : ExCollectionInterface|array<string|int, Option>|null
- $type : int
Methods
- addContext() : $this
- Adds a context to the command. (Only for globally-scoped commands)
- addIntegrationType() : $this
- Adds an integration type to the command. (Only for globally-scoped commands)
- addOption() : $this
- Adds an option to the command.
- clearOptions() : $this
- Clear all options from the command.
- removeContext() : $this
- Removes a context from the command. (Only for globally-scoped commands)
- removeIntegrationType() : $this
- Removes an integration type from the command. (Only for globally-scoped commands)
- removeOption() : $this
- Removes an option from the command.
- setContextPermissions() : $this
- Sets the contexts of the command. (Only for globally-scoped commands)
- setDefaultMemberPermissions() : $this
- Sets the default member permissions of the command.
- setDefaultPermission() : $this
- Sets the default permission of the command.
- setDescription() : $this
- Sets the description of the command.
- setDescriptionLocalization() : $this
- Sets the description of the command in another language.
- setDmPermission() : $this
- Sets the DM permission of the command.
- setGuildId() : $this
- Sets the guild ID of the command.
- setHandler() : $this
- Sets the handler for the command.
- setName() : $this
- Sets the name of the command.
- setNameLocalization() : $this
- Sets the name of the command in another language.
- setNsfw() : $this
- Sets the age restriction of the command.
- setType() : $this
- Sets the type of the command.
Properties
$contexts
public
ExCollectionInterface|null
$contexts
Interaction context(s) where the command can be used, only for globally-scoped commands.
$default_member_permissions
public
string|null
$default_member_permissions
Set of permissions represented as a bit set.
$default_permission
public
bool|null
$default_permission
Whether the command is enabled by default when the app is added to a guild. SOON DEPRECATED.
$description
public
string|null
$description
1-100 character description for CHAT_INPUT commands, empty string for USER and MESSAGE commands.
$dm_permission
public
bool|null
$dm_permission
Deprecated (use contexts instead); Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible.
$guild_id
public
int|null
$guild_id
The optional guild ID this command is for. If not set, the command is global.
$handler
public
int|null
$handler
Determines whether the interaction is handled by the app's interactions handler or by Discord
$integration_types
public
ExCollectionInterface|null
$integration_types
Installation contexts where the command is available, only for globally-scoped commands. Defaults to your app's configured contexts
$name
public
string
$name
1-32 character name of the command.
$nsfw
public
bool|null
$nsfw
Indicates whether the command is age-restricted, defaults to false
.
$options
public
ExCollectionInterface|array<string|int, Option>|null
$options
The parameters for the command, max 25. Only for Slash command (CHAT_INPUT).
$type
public
int
$type
The type of the command, defaults 1 if not set.
Methods
addContext()
Adds a context to the command. (Only for globally-scoped commands)
public
addContext(int $context) : $this
Parameters
- $context : int
-
Context to add.
Tags
Return values
$thisaddIntegrationType()
Adds an integration type to the command. (Only for globally-scoped commands)
public
addIntegrationType(int $integration_type) : $this
Parameters
- $integration_type : int
-
The integration type to add. Must be one of GUILD_INSTALL (0) or USER_INSTALL (1).
Tags
Return values
$thisaddOption()
Adds an option to the command.
public
addOption(Option $option) : $this
Parameters
- $option : Option
-
The option.
Tags
Return values
$thisclearOptions()
Clear all options from the command.
public
clearOptions() : $this
Return values
$thisremoveContext()
Removes a context from the command. (Only for globally-scoped commands)
public
removeContext(int $context) : $this
Parameters
- $context : int
-
Context to remove.
Tags
Return values
$thisremoveIntegrationType()
Removes an integration type from the command. (Only for globally-scoped commands)
public
removeIntegrationType(int $integration_type) : $this
Parameters
- $integration_type : int
-
The integration type to remove.
Tags
Return values
$thisremoveOption()
Removes an option from the command.
public
removeOption(Option $option) : $this
Parameters
- $option : Option
-
Option to remove.
Tags
Return values
$thissetContextPermissions()
Sets the contexts of the command. (Only for globally-scoped commands)
public
setContextPermissions(array<string|int, mixed>|null $contexts) : $this
Parameters
- $contexts : array<string|int, mixed>|null
-
Interaction contexts where the command can be used.
Tags
Return values
$thissetDefaultMemberPermissions()
Sets the default member permissions of the command.
public
setDefaultMemberPermissions(string|int $permissions) : $this
Parameters
- $permissions : string|int
-
Default member permission bits of the command.
Return values
$thissetDefaultPermission()
Sets the default permission of the command.
public
setDefaultPermission(bool|null $permission) : $this
See CommandAttributes::setDefaultMemberPermissions()
.
Parameters
- $permission : bool|null
-
Default permission of the command
Return values
$thissetDescription()
Sets the description of the command.
public
setDescription(string $description) : $this
Parameters
- $description : string
-
Description of the command
Tags
Return values
$thissetDescriptionLocalization()
Sets the description of the command in another language.
public
setDescriptionLocalization(string $locale, string|null $description) : $this
Parameters
- $locale : string
-
Discord locale code.
- $description : string|null
-
Localized description of the command.
Tags
Return values
$thissetDmPermission()
Sets the DM permission of the command.
public
setDmPermission(bool $permission) : $this
Parameters
- $permission : bool
-
DM permission of the command.
Return values
$thissetGuildId()
Sets the guild ID of the command.
public
setGuildId(int $guildId) : $this
Parameters
- $guildId : int
-
Guild ID of the command.
Return values
$thissetHandler()
Sets the handler for the command.
public
setHandler(int $handler) : $this
Parameters
- $handler : int
-
Handler to set.
Tags
Return values
$thissetName()
Sets the name of the command.
public
setName(string $name) : $this
Parameters
- $name : string
-
Name of the command. Slash command names are lowercase.
Tags
Return values
$thissetNameLocalization()
Sets the name of the command in another language.
public
setNameLocalization(string $locale, string|null $name) : $this
Parameters
- $locale : string
-
Discord locale code.
- $name : string|null
-
Localized name of the command. Slash command names are lowercase.
Tags
Return values
$thissetNsfw()
Sets the age restriction of the command.
public
setNsfw(bool $restricted) : $this
Parameters
- $restricted : bool
-
Age restriction of the command.
Return values
$thissetType()
Sets the type of the command.
public
setType(int $type) : $this
Parameters
- $type : int
-
Type of the command.