DiscordPHP-NHA Documentation

Replies
in package

FinalYes

Shared plumbing for turning a {@see \NHA\Commands} promise into a chat or slash-command response, with a uniform `❌ <error>` on rejection.

Tags
since
3.1.27

Table of Contents

Properties

$nha  : NHA

Methods

__construct()  : mixed
flattenOptions()  : array<string|int, mixed>
Flattens an interaction's (sub)command options into a plain assoc array.
text()  : Container
A container carrying one line of text (quick confirmations / errors).
toInteraction()  : PromiseInterface
Defers the interaction (world calls are network round-trips), then sends the work's result — or the error — as the original response.
toMessage()  : void
Sends a `Commands::` promise's result (a MessageBuilder) back to a chat message.

Properties

Methods

__construct()

public __construct(NHA $nha) : mixed
Parameters
$nha : NHA

flattenOptions()

Flattens an interaction's (sub)command options into a plain assoc array.

public static flattenOptions(iterable<string|int, mixed>|null $options) : array<string|int, mixed>
Parameters
$options : iterable<string|int, mixed>|null
Return values
array<string|int, mixed>

text()

A container carrying one line of text (quick confirmations / errors).

public text(string $content) : Container
Parameters
$content : string
Return values
Container

toInteraction()

Defers the interaction (world calls are network round-trips), then sends the work's result — or the error — as the original response.

public toInteraction(Interaction $interaction, PromiseInterface|callable(): PromiseInterface $work[, bool $ephemeral = false ]) : PromiseInterface
Parameters
$interaction : Interaction
$work : PromiseInterface|callable(): PromiseInterface

An already-started promise, or a callable run only after the defer lands.

$ephemeral : bool = false

Whether the response is private to the caller.

Return values
PromiseInterface

toMessage()

Sends a `Commands::` promise's result (a MessageBuilder) back to a chat message.

public toMessage(Message $message, PromiseInterface $promise) : void
Parameters
$message : Message
$promise : PromiseInterface
On this page

Search results