SlashCommands
in package
The slash-command interface — a second, equivalent surface over the same {@see \NHA\Commands} handlers as {@see ChatCommands}. Registered lazily once the application and gateway are both ready.
Global commands are created when missing and PATCHed only when their
definition (name + description + every option/choice/bound) has changed since
the last successful registration, tracked by a signature in var/state.json
so an unchanged boot makes zero rate-limited writes.
Tags
Table of Contents
Constants
- DESTINATIONS : mixed = ['deimos', 'phobos', 'mars', 'venus', 'earth']
- MEDICINES : mixed = ['salve', 'stimpack', 'medkit', 'antidote']
- WEAPONS : mixed = ['kinetic_gun', 'energy_weapon']
- Constrained value sets the server expects verbatim.
Properties
- $commands : Commands
- $existing : GlobalCommandRepository
- $nha : NHA
- $replies : Replies
- $signatures : array<string, string>
- $state : StateStore
Methods
- __construct() : mixed
- register() : void
- Freshen the current command set, then (re)register everything that changed.
- createCommand() : void
- Creates the global command when missing, PATCHes it when its definition signature has changed since the last successful registration, and does nothing when it is already current. Every attempt and outcome is logged.
- dispatchNha() : PromiseInterface
- Routes a `/nha <sub>` interaction to the matching {@see Commands} call.
- option() : Option
- Builds a slash-command option. `$constraints`: - `choices` list (value = label) or [label => value] map, ≤25 - `min`/`max` value bounds for INTEGER/NUMBER, length bounds for STRING
- registerNhaGroup() : void
- registerStandalone() : void
- sub() : Option
- A SUB_COMMAND option carrying its own options.
Constants
DESTINATIONS
private
mixed
DESTINATIONS
= ['deimos', 'phobos', 'mars', 'venus', 'earth']
MEDICINES
private
mixed
MEDICINES
= ['salve', 'stimpack', 'medkit', 'antidote']
WEAPONS
Constrained value sets the server expects verbatim.
private
mixed
WEAPONS
= ['kinetic_gun', 'energy_weapon']
Properties
$commands read-only
private
Commands
$commands
$existing
private
GlobalCommandRepository
$existing
$nha read-only
private
NHA
$nha
$replies read-only
private
Replies
$replies
$signatures
private
array<string, string>
$signatures
= []
command name => last-registered definition sha1
$state read-only
private
StateStore
$state
Methods
__construct()
public
__construct(NHA $nha, Commands $commands, StateStore $state, Replies $replies) : mixed
Parameters
- $nha : NHA
- $commands : Commands
- $state : StateStore
- $replies : Replies
register()
Freshen the current command set, then (re)register everything that changed.
public
register() : void
createCommand()
Creates the global command when missing, PATCHes it when its definition signature has changed since the last successful registration, and does nothing when it is already current. Every attempt and outcome is logged.
private
createCommand(string $name, string $description[, array<string|int, mixed> $options = [] ]) : void
Parameters
- $name : string
- $description : string
- $options : array<string|int, mixed> = []
dispatchNha()
Routes a `/nha <sub>` interaction to the matching {@see Commands} call.
private
dispatchNha(string $sub, array<string|int, mixed> $a, string $userId) : PromiseInterface
Parameters
- $sub : string
- $a : array<string|int, mixed>
- $userId : string
Return values
PromiseInterfaceoption()
Builds a slash-command option. `$constraints`: - `choices` list (value = label) or [label => value] map, ≤25 - `min`/`max` value bounds for INTEGER/NUMBER, length bounds for STRING
private
option(int $type, string $name, string $description[, bool $required = false ][, array<string|int, mixed> $constraints = [] ]) : Option
Parameters
- $type : int
- $name : string
- $description : string
- $required : bool = false
- $constraints : array<string|int, mixed> = []
Return values
OptionregisterNhaGroup()
private
registerNhaGroup() : void
registerStandalone()
private
registerStandalone() : void
sub()
A SUB_COMMAND option carrying its own options.
private
sub(string $name, string $description[, array<string|int, mixed> $options = [] ]) : Option
Parameters
- $name : string
- $description : string
- $options : array<string|int, mixed> = []