DiscordPHP Documentation

CommandAttributes

Application Command attributes.

Tags
see
CommandBuilder
see
Command
since
7.1.0

Table of Contents

$default_member_permissions  : string|null
$default_permission  : bool|null
$description  : string
$description_localizations  : array<string|int, ?string>|null
$dm_permission  : bool|null
$name  : string
$name_localizations  : array<string|int, ?string>|null
$nsfw  : bool|null
$options  : Collection|array<string|int, Option>|null
$type  : int
addOption()  : $this
Adds an option to the command.
clearOptions()  : $this
Clear all options from the command.
removeOption()  : $this
Removes an option from the command.
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.
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

$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 $description

1-100 character description for CHAT_INPUT commands, 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

Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible.

$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|null $nsfw

Indicates whether the command is age-restricted, defaults to false.

$options

public Collection|array<string|int, Option>|null $options

The parameters for the command, max 25. Only for Slash command (CHAT_INPUT).

Methods

addOption()

Adds an option to the command.

public addOption(Option $option) : $this
Parameters
$option : Option

The option.

Tags
throws
DomainException

Command type is not CHAT_INPUT (1).

throws
OverflowException

Command exceeds maximum 25 options.

Return values
$this

clearOptions()

Clear all options from the command.

public clearOptions() : $this
Return values
$this

removeOption()

Removes an option from the command.

public removeOption(Option $option) : $this
Parameters
$option : Option

Option to remove.

Tags
throws
DomainException

Command type is not CHAT_INPUT (1).

Return values
$this

setDefaultMemberPermissions()

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
$this

setDefaultPermission()

Sets the default permission of the command.

public setDefaultPermission(bool|null $permission) : $this
Parameters
$permission : bool|null

Default permission of the command

Tags
deprecated
7.1.0

See CommandAttributes::setDefaultMemberPermissions().

Return values
$this

setDescription()

Sets the description of the command.

public setDescription(string $description) : $this
Parameters
$description : string

Description of the command

Tags
throws
LengthException

$description is not 1-100 characters long.

Return values
$this

setDescriptionLocalization()

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
throws
LengthException

$description is not 1-100 characters long.

Return values
$this

setDmPermission()

Sets the DM permission of the command.

public setDmPermission(bool $permission) : $this
Parameters
$permission : bool

DM permission of the command.

Return values
$this

setName()

Sets the name of the command.

public setName(string $name) : $this
Parameters
$name : string

Name of the command. Slash command names are lowercase.

Tags
throws
LengthException

$name is not 1-32 characters long.

throws
DomainException

$name contains invalid characters.

Return values
$this

setNameLocalization()

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
throws
LengthException

$name is not 1-32 characters long.

throws
DomainException

$name contains invalid characters.

Return values
$this

setNsfw()

Sets the age restriction of the command.

public setNsfw(bool $restricted) : $this
Parameters
$restricted : bool

Age restriction of the command.

Return values
$this

setType()

Sets the type of the command.

public setType(int $type) : $this
Parameters
$type : int

Type of the command.

Tags
throws
InvalidArgumentException

$type is not 1-3.

Return values
$this

Search results