CommandContext
Properties
# Cmdr
CommandContext.Cmdr:
Cmdr | CmdrClient
A reference to Cmdr. This may either be the server or client version of Cmdr depending on where the command is running.
# Alias
CommandContext.Alias:
string
The specific alias of this command that was used to trigger this command (may be the same as Name
)
# Group
CommandContext.Group:
The group this command is a part of. Defined in command definitions, typically a string.
# State
CommandContext.State:
table
A blank table that can be used to store user-defined information about this command's current execution. This could potentially be used with hooks to add information to this table which your command or other hooks could consume.
# Aliases
CommandContext.Aliases:
array<string>
Any aliases that can be used to also trigger this command in addition to its name.
# Description
CommandContext.Description:
string
The description for this command from the command definition.
# RawArguments
CommandContext.RawArguments:
array<string>
An array of strings which is the raw value for each argument.
# Arguments
CommandContext.Arguments:
array<ArgumentContext>
An array of ArgumentContext objects, the parsed equivalent to RawArguments.
# Response
CommandContext.Response:
string?
The command output, if the command has already been run. Typically only accessible in the AfterRun hook.
Instance Methods
# GetArgument
CommandContext.
GetArgument(index:
number
) →
ArgumentContext
Returns the ArgumentContext for the given index.
# GetData
CommandContext.
GetData() →
Returns the command data that was sent along with the command. This is the return value of the Data function from the command definition.
Returns
Type |
---|
# GetStore
CommandContext.
GetStore(name:
string
) →
table
Returns a table of the given name. Always returns the same table on subsequent calls. Useful for storing things like ban information. Same as Registry.GetStore.
Parameters
Name | Type | Required | |
---|---|---|---|
name |
string
| ✔ |
Returns
Type | |
---|---|
table
|
# SendEvent
CommandContext.
SendEvent(
Player
,
event: string
Sends a network event of the given name to the given player. See Network Event Handlers.
Parameters
Name | Type | Required | |
---|---|---|---|
player |
Player
| ✔ | |
event |
string
| ✔ |
Returns
Type |
---|
# BroadcastEvent
CommandContext.
BroadcastEvent(
string
,
...: any
Broadcasts a network event to all players. See Network Event Handlers.
Parameters
Name | Type | Required | |
---|---|---|---|
event |
string
| ✔ | |
... |
any
| ✔ |
Returns
Type |
---|
# Reply
CommandContext.
Reply(
string
,
color?: Color3?
Prints the given text in the user's console. Useful for when a command needs to print more than one message or is long-running. You should still return
a string from the command implementation when you are finished, Reply
should only be used to send additional messages before the final message.
Parameters
Name | Type | Required | |
---|---|---|---|
text |
string
| ✔ | |
color |
Color3?
| ✘ |
Returns
Type |
---|
# HasImplementation
CommandContext.
HasImplementation() →
boolean
Returns true
if the command has an implementation on this machine. For example, this function will return false
from the client if you call it on a command that only has a server-side implementation.
Note that commands can potentially run on both the client and the server, so what this property returns on the server is not related to what it returns on the client, and vice versa. Likewise, receiving a return value of true
on the client does not mean that the command won't run on the server, because Cmdr commands can run a first part on the client and a second part on the server.
This function only answers one question if you run the command; does it run any code as a result of that on this machine?
Returns
Type | |
---|---|
boolean
|
← CmdrClient Dispatcher →