DiscordPHP Documentation

Command
in package

A message based command that the Command Client will listen for.

Tags
since
4.0.0

Table of Contents

$callable  : callable
$client  : DiscordCommandClient
$command  : string
The trigger for the command.
$cooldown  : int
The cooldown of the command in milliseconds.
$cooldownMessage  : string
The cooldown message to show when a cooldown is in effect.
$cooldowns  : array<string|int, mixed>
An array of cooldowns for commands.
$description  : string
The short description of the command.
$longDescription  : string
The long description of the command.
$showHelp  : bool
Help visibility.
$subCommandAliases  : array<string|int, mixed>
A map of sub-command aliases.
$subCommands  : array<string|int, mixed>
A map of sub-commands.
$usage  : string
The usage of the command.
__construct()  : mixed
Creates a command instance.
__get()  : mixed
Handles dynamic get calls to the class.
getCommand()  : Command|null
Attempts to get a sub command.
getHelp()  : array<string|int, mixed>
Gets help for the command.
handle()  : mixed
Executes the command.
registerSubCommand()  : Command
Registers a new command.
registerSubCommandAlias()  : void
Registers a sub-command alias.
unregisterSubCommand()  : void
Unregisters a sub-command.
unregisterSubCommandAlias()  : void
Unregisters a sub-command alias.

Properties

$callable

protected callable $callable

$command

The trigger for the command.

protected string $command

Command trigger.

$cooldown

The cooldown of the command in milliseconds.

protected int $cooldown

Command cooldown.

$cooldownMessage

The cooldown message to show when a cooldown is in effect.

protected string $cooldownMessage

Command cooldown message.

$cooldowns

An array of cooldowns for commands.

protected array<string|int, mixed> $cooldowns = []

Cooldowns.

$description

The short description of the command.

protected string $description

Description.

$longDescription

The long description of the command.

protected string $longDescription

Long description.

$showHelp

Help visibility.

protected bool $showHelp

wether visible in help or not.

$subCommandAliases

A map of sub-command aliases.

protected array<string|int, mixed> $subCommandAliases = []

Sub-Command aliases.

$subCommands

A map of sub-commands.

protected array<string|int, mixed> $subCommands = []

Sub-Commands.

$usage

The usage of the command.

protected string $usage

Command usage.

Methods

__construct()

Creates a command instance.

public __construct(DiscordCommandClient $client, string $command, callable $callable, string $description, string $longDescription, string $usage, int $cooldown, string $cooldownMessage[, bool $showHelp = true ]) : mixed
Parameters
$client : DiscordCommandClient

The Discord Command Client.

$command : string

The command trigger.

$callable : callable

The callable function.

$description : string

The short description of the command.

$longDescription : string

The long description of the command.

$usage : string

The usage of the command.

$cooldown : int

The cooldown of the command in milliseconds.

$cooldownMessage : string

The cooldown message to show when a cooldown is in effect.

$showHelp : bool = true

The visibility in help of the command.

Return values
mixed

__get()

Handles dynamic get calls to the class.

public __get(string $variable) : mixed
Parameters
$variable : string

The variable to get.

Return values
mixed

The value.

getCommand()

Attempts to get a sub command.

public getCommand(string $command[, bool $aliases = true ]) : Command|null
Parameters
$command : string

The command to get.

$aliases : bool = true

WHether to search aliases as well.

Return values
Command|null

getHelp()

Gets help for the command.

public getHelp(string $prefix) : array<string|int, mixed>
Parameters
$prefix : string

The prefix of the bot.

Return values
array<string|int, mixed>

The help.

handle()

Executes the command.

public handle(Message $message, array<string|int, mixed> $args) : mixed
Parameters
$message : Message

The message.

$args : array<string|int, mixed>

An array of arguments.

Return values
mixed

The response.

registerSubCommand()

Registers a new command.

public registerSubCommand(string $command, callable|string $callable[, array<string|int, mixed> $options = [] ]) : Command
Parameters
$command : string

The command name.

$callable : callable|string

The function called when the command is executed.

$options : array<string|int, mixed> = []

An array of options.

Tags
throws
Exception
Return values
Command

The command instance.

registerSubCommandAlias()

Registers a sub-command alias.

public registerSubCommandAlias(string $alias, string $command) : void
Parameters
$alias : string

The alias to add.

$command : string

The command.

Return values
void

unregisterSubCommand()

Unregisters a sub-command.

public unregisterSubCommand(string $command) : void
Parameters
$command : string

The command name.

Tags
throws
Exception
Return values
void

unregisterSubCommandAlias()

Unregisters a sub-command alias.

public unregisterSubCommandAlias(string $alias) : void
Parameters
$alias : string

The alias name.

Tags
throws
Exception
Return values
void

Search results