CommandInterface
Interface · Sharkord\Commands\CommandInterface
Interface CommandInterface
Defines the contract that all bot commands must follow.
Methods
Section titled “Methods”getName()
Section titled “getName()”Retrieves the unique name of the command.
This name is used to invoke the command (e.g., “ping” for “!ping”).
Returns string — The command name.
Example
public function getName(): string { return 'ping';}getDescription()
Section titled “getDescription()”Retrieves a brief description of what the command does.
Returns string — The command description.
Example
public function getDescription(): string { return 'Replies with Pong!';}getPattern()
Section titled “getPattern()”A regex pattern match that will trigger the command
Returns string — The command patttern.
Example
public function getPattern(): string { return '/^ping$/i';}handle()
Section titled “handle()”Handles the execution of the command.
Parameters
| Parameter | Type | Description |
|---|---|---|
$sharkord | Sharkord | The main bot instance. |
$message | Message | The message that triggered the command. |
$args | string | The arguments passed with the command. |
$matches | array | Regex capture groups from the command pattern. |
Example
public function handle(Sharkord $sharkord, Message $message, string $args, array $matches): void { $message->reply('Pong!');}