DiscordPHP Documentation

RegisteredCommand
in package

RegisteredCommand represents a command that has been registered with the Discord servers and has a handler to handle when the command is triggered.

https://discord.com/developers/docs/interactions/application-commands

Tags
since
7.0.0
author

David Cole david.cole1340@gmail.com

Table of Contents

$discord  : Discord
The Discord client.
$autocomplete_callback  : callable
The callback to be called when the auto complete is triggered.
$callback  : callable
The callback to be called when the command is triggered.
$name  : string
The name of the command.
$subCommands  : array<string|int, RegisteredCommand>
Array of sub-commands.
__construct()  : mixed
RegisteredCommand represents a command that has been registered with the Discord servers and has a handler to handle when the command is triggered.
addSubCommand()  : static
Adds a sub-command to the command.
execute()  : bool
Executes the command. Will search for a sub-command if given, otherwise executes the callback, if given.
getName()  : string
Get command name.
getSubCommand()  : RegisteredCommand|null
Tries to get a sub-command if exists.
getSubCommands()  : array<string|int, RegisteredCommand>|null
Get sub commands.
setAutoCompleteCallback()  : mixed
Sets the callback for the auto complete suggestion.
setCallback()  : mixed
Sets the callback for the command.
suggest()  : bool
Executes the command. Will search for a sub-command if given, otherwise executes the callback, if given.

Properties

$autocomplete_callback

The callback to be called when the auto complete is triggered.

private callable $autocomplete_callback

$callback

The callback to be called when the command is triggered.

private callable $callback

Methods

__construct()

RegisteredCommand represents a command that has been registered with the Discord servers and has a handler to handle when the command is triggered.

public __construct(Discord $discord, string $name[, callable $callback = null ][, callable|null $autocomplete_callback = null ]) : mixed
Parameters
$discord : Discord
$name : string
$callback : callable = null
$autocomplete_callback : callable|null = null
Return values
mixed

addSubCommand()

Adds a sub-command to the command.

public addSubCommand(string|array<string|int, mixed> $name[, callable $callback = null ][, callable|null $autocomplete_callback = null ]) : static
Parameters
$name : string|array<string|int, mixed>
$callback : callable = null
$autocomplete_callback : callable|null = null
Tags
throws
LogicException
Return values
static

execute()

Executes the command. Will search for a sub-command if given, otherwise executes the callback, if given.

public execute(array<string|int, mixed> $options, Interaction $interaction) : bool
Parameters
$options : array<string|int, mixed>
$interaction : Interaction
Return values
bool

Whether the command successfully executed.

getName()

Get command name.

public getName() : string
Return values
string

setAutoCompleteCallback()

Sets the callback for the auto complete suggestion.

public setAutoCompleteCallback(callable $autocomplete_callback) : mixed
Parameters
$autocomplete_callback : callable
Return values
mixed

setCallback()

Sets the callback for the command.

public setCallback(callable $callback) : mixed
Parameters
$callback : callable
Return values
mixed

suggest()

Executes the command. Will search for a sub-command if given, otherwise executes the callback, if given.

public suggest(Interaction $interaction) : bool
Parameters
$interaction : Interaction
Return values
bool

Whether the command successfully executed.

Search results