Skip to content

API reference / @jsprismarine/prismarine / command/CommandExecutor

command/CommandExecutor ​

Interfaces ​

CommandExecutor ​

Defined in: packages/prismarine/src/command/CommandExecutor.ts:12

Something that can issue a command and be answered.

A player and the server console have exactly this much in common: a name and somewhere to put a reply. They are not the same kind of thing otherwise - one stands at a position in a world and the other is a terminal attached to the process - so this is an interface rather than a shared base class. Making the console an entity to get these four methods is what forced isPlayer() and isConsole() to exist in the first place.

Extended by ​

Methods ​

getFormattedUsername() ​

getFormattedUsername(): string

Defined in: packages/prismarine/src/command/CommandExecutor.ts:32

Get the formatted username of the executor.

Returns ​

string

The formatted username of the executor.

getName() ​

getName(): string

Defined in: packages/prismarine/src/command/CommandExecutor.ts:26

Get the name of the executor.

Returns ​

string

The name of the executor.

getServer() ​

getServer(): Server

Defined in: packages/prismarine/src/command/CommandExecutor.ts:38

Get the server instance.

Returns ​

Server

The server instance.

sendMessage() ​

sendMessage(message): void | Promise<void>

Defined in: packages/prismarine/src/command/CommandExecutor.ts:20

Send a message to the executor.

Delivery is asynchronous for a player, whose message goes out over the wire, and synchronous for the console, which writes to a terminal. Callers may await either.

Parameters ​
message ​

string

The message to send.

Returns ​

void | Promise<void>

Type Aliases ​

CommandTarget ​

CommandTarget = CommandExecutor | Pick<CommandExecutor, "getName">

Defined in: packages/prismarine/src/command/CommandExecutor.ts:45

Whatever a command can be run as: an executor, or an entity a selector named, which has a name to report but nowhere to put a reply.

Functions ​

isCommandExecutor() ​

isCommandExecutor(target): target is CommandExecutor

Defined in: packages/prismarine/src/command/CommandExecutor.ts:51

Whether a command target can be answered, which is what separates an executor from any other entity. Checks for sendMessage with in, because that member is the whole difference.

Parameters ​

target ​

CommandTarget

Returns ​

target is CommandExecutor