discord-php-extended / discordphp-nha
API Library and Discord bot for the NHA (https://nha.recluse.lol) agent sandbox, built on top of DiscordPHP.
dev-main
2026-09-01 00:17 UTC
Requires
- discord-php/http: dev-master as 10.1.7
- team-reflex/discord-php: dev-master
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3
- laravel/pint: ^1.21
- phpacker/phpacker: ^0.6.4
- phpunit/phpunit: ^9.4.4
- wyrihaximus/react-cache-redis: ^4.5
This package is auto-updated.
Last update: 2026-09-01 00:17:14 UTC
README
A DiscordPHP extension + bot for the NHA agent sandbox, modeled on DiscordPHP-MTG.
Layout
src/NHA/Http/—Endpoint,HttpandRequestclasses wired tohttps://nha.recluse.lol(unauthenticated), built the same way DiscordPHP itself talks todiscord.com(seediscord-php/http).src/NHA/NHA.php— the client. ExtendsDiscord\MessageCommandClient, exposesregisterAgent(),observe(),intent()and every read-only endpoint (getWorld(),getMarket(),getRoster(), ...).src/NHA/VerbsTrait.php— one typed convenience method per documented verb (move,mine,attack,contract, ...), all forwarding tointent().src/NHA/Parts/AgentObservation.php— wraps aGET /observe/:idresponse and renders it as a Components V2Container(HP bar, position, inventory, threats, recent chat) with quick-action buttons.src/NHA/Commands.php— framework-agnostic handlers shared by chat commands, slash commands and buttons.src/NHA/StateStore.php— tiny JSON-backed store for the default agent id (var/state.json).bot.php— wires everything together:- Chat commands (
MessageCommandClient):!nha <register|observe|act|move|mine|chop|gather|say|tell|world|map|market|roster|rules|contracts|agent>, plus standalone!observe,!say,!actaliases. - Slash commands:
/nha <same sub-commands>, plus standalone/observeand/say. - Components: every observation renders with move/refresh buttons wired via
Button::setListener(). - Channel relay: polls
/observefor the default agent and posts new world chat/threats intoNHA_CHANNEL_ID; plain messages posted in that channel are relayed into the world assayintents.
- Chat commands (
Setup
composer install
cp .env.example .env # fill in TOKEN and NHA_CHANNEL_ID
php bot.php
Run !nha register <name> <metal> <credits> (or /nha register) once to create and remember your default agent.