CommandAttributes
Application Command attributes.
Tags
Table of Contents
Properties
- $contexts : ?array<string|int, int>|null
- $default_member_permissions : ?string
- $default_permission : ?bool
- $description : ?string
- $description_localizations : ?array<string|int, string>|null
- $dm_permission : ?bool|null
- $guild_id : ?int|null
- $handler : ?int|null
- $integration_types : ?array<string|int, int>
- $name : string
- $name_localizations : ?array<string|int, string>|null
- $nsfw : ?bool
- $options : ?ExCollectionInterface<string|int, Option>|array<string|int, Option>
- $type : int
Methods
- addContext() : self
- Adds a context to the command. (Only for globally-scoped commands).
- addIntegrationType() : self
- Adds an integration type to the command. (Only for globally-scoped commands).
- addOption() : self
- Adds an option to the command.
- clearOptions() : self
- Clear all options from the command.
- removeContext() : self
- Removes a context from the command. (Only for globally-scoped commands).
- removeIntegrationType() : self
- Removes an integration type from the command. (Only for globally-scoped commands).
- removeOption() : self
- Removes an option from the command.
- setContext() : self
- Sets the contexts of the command. (Only for globally-scoped commands).
- setDefaultMemberPermissions() : self
- Sets the default member permissions of the command.
- setDefaultPermission() : self
- Sets the default permission of the command.
- setDescription() : self
- Sets the description of the command.
- setDescriptionLocalization() : self
- Sets the description of the command in another language.
- setDmPermission() : self
- Sets the DM permission of the command.
- setGuildId() : self
- Sets the guild ID of the command.
- setHandler() : self
- Sets the handler for the command.
- setName() : self
- Sets the name of the command.
- setNameLocalization() : self
- Sets the name of the command in another language.
- setNsfw() : self
- Sets the age restriction of the command.
- setType() : self
- Sets the type of the command.
Properties
$contexts
public
?array<string|int, int>|null
$contexts
Interaction context(s) where the command can be used, only for globally-scoped commands.
$default_member_permissions
public
?string
$default_member_permissions
Set of permissions represented as a bit set.
$default_permission
public
?bool
$default_permission
Deprecated (use default_member_permissions instead); Whether the command is enabled by default when the app is added to a guild, defaults to true. SOON DEPRECATED.
$description
public
?string
$description
For CHAT_INPUT and PRIMARY_ENTRY_POINT commands, 1-100 characters. Empty string for USER and MESSAGE commands.
$description_localizations
public
?array<string|int, string>|null
$description_localizations
Localization dictionary for the description field. Values follow the same restrictions as description.
$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
?array<string|int, int>
$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.
$name_localizations
public
?array<string|int, string>|null
$name_localizations
Localization dictionary for the name field. Values follow the same restrictions as name.
$nsfw
public
?bool
$nsfw
Indicates whether the command is age-restricted, defaults to false.
$options
public
?ExCollectionInterface<string|int, Option>|array<string|int, Option>
$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) : self
Parameters
- $context : int
-
Context to add.
Tags
Return values
selfaddIntegrationType()
Adds an integration type to the command. (Only for globally-scoped commands).
public
addIntegrationType(int $integration_type) : self
Parameters
- $integration_type : int
-
The integration type to add. Must be one of GUILD_INSTALL (0) or USER_INSTALL (1).
Tags
Return values
selfaddOption()
Adds an option to the command.
public
addOption(Option $option) : self
Parameters
- $option : Option
-
The option.
Tags
Return values
selfclearOptions()
Clear all options from the command.
public
clearOptions() : self
Return values
selfremoveContext()
Removes a context from the command. (Only for globally-scoped commands).
public
removeContext(int $context) : self
Parameters
- $context : int
-
Context to remove.
Tags
Return values
selfremoveIntegrationType()
Removes an integration type from the command. (Only for globally-scoped commands).
public
removeIntegrationType(int $integration_type) : self
Parameters
- $integration_type : int
-
The integration type to remove.
Tags
Return values
selfremoveOption()
Removes an option from the command.
public
removeOption(Option $option) : self
Parameters
- $option : Option
-
Option to remove.
Tags
Return values
selfsetContext()
Sets the contexts of the command. (Only for globally-scoped commands).
public
setContext(array<string|int, mixed>|null $contexts) : self
Parameters
- $contexts : array<string|int, mixed>|null
-
Interaction contexts where the command can be used.
Tags
Return values
selfsetDefaultMemberPermissions()
Sets the default member permissions of the command.
public
setDefaultMemberPermissions(string|int $permissions) : self
Parameters
- $permissions : string|int
-
Default member permission bits of the command.
Return values
selfsetDefaultPermission()
Sets the default permission of the command.
public
setDefaultPermission(?bool $permission) : self
See CommandAttributes::setDefaultMemberPermissions().
Parameters
- $permission : ?bool
-
Default permission of the command
Return values
selfsetDescription()
Sets the description of the command.
public
setDescription(string $description) : self
Parameters
- $description : string
-
Description of the command
Tags
Return values
selfsetDescriptionLocalization()
Sets the description of the command in another language.
public
setDescriptionLocalization(string $locale, string|null $description) : self
Parameters
- $locale : string
-
Discord locale code.
- $description : string|null
-
Localized description of the command.
Tags
Return values
selfsetDmPermission()
Sets the DM permission of the command.
public
setDmPermission(bool $permission) : self
Parameters
- $permission : bool
-
DM permission of the command.
Return values
selfsetGuildId()
Sets the guild ID of the command.
public
setGuildId(int $guildId) : self
Parameters
- $guildId : int
-
Guild ID of the command.
Return values
selfsetHandler()
Sets the handler for the command.
public
setHandler(int $handler) : self
Parameters
- $handler : int
-
Handler to set.
Tags
Return values
selfsetName()
Sets the name of the command.
public
setName(string $name) : self
Parameters
- $name : string
-
Name of the command. Slash command names are lowercase.
Tags
Return values
selfsetNameLocalization()
Sets the name of the command in another language.
public
setNameLocalization(string $locale, string|null $name) : self
Parameters
- $locale : string
-
Discord locale code.
- $name : string|null
-
Localized name of the command. Slash command names are lowercase.
Tags
Return values
selfsetNsfw()
Sets the age restriction of the command.
public
setNsfw(bool $restricted) : self
Parameters
- $restricted : bool
-
Age restriction of the command.
Return values
selfsetType()
Sets the type of the command.
public
setType(int $type) : self
Parameters
- $type : int
-
Type of the command.