DiscordPHP-NHA Documentation

AgentContext
in package

FinalYes

Identifies which agent a command runs as, and with which NHA action token.

A null $token means "use whatever token is configured on the NHA client" — i.e. the bot's own default agent. A non-null token is an explicit per-Discord-user credential and is sent verbatim on POST /intent, so the same handler can act as the bot or as the caller without any other code path changing.

Build one through ActorTrait::actor() rather than by hand.

Tags
since
3.0.0

Table of Contents

Properties

$agentId  : int
$label  : string
$token  : string|null

Methods

__construct()  : mixed
bot()  : self
Context for the bot's own default agent (its ambient token is used).
user()  : self
Context for a Discord user's linked agent, carrying that user's token.

Properties

Methods

__construct()

public __construct(int $agentId[, string|null $token = null ][, string $label = 'the agent' ]) : mixed
Parameters
$agentId : int

The acting agent's id.

$token : string|null = null

The agent's NHA token, or null to use the bot's ambient token.

$label : string = 'the agent'

Short human label ("you", "the bot", "agent #12") for confirmations.

bot()

Context for the bot's own default agent (its ambient token is used).

public static bot(int $agentId) : self
Parameters
$agentId : int
Return values
self

user()

Context for a Discord user's linked agent, carrying that user's token.

public static user(int $agentId, string $token) : self
Parameters
$agentId : int
$token : string
Return values
self
On this page

Search results