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.

# Dispatcher

CommandContext.Dispatcher: Dispatcher

The dispatcher that created this command.

# Name

CommandContext.Name: string

The name of the command.

# Alias

CommandContext.Alias: string

The specific alias of this command that was used to trigger this command (may be the same as Name)

# RawText

CommandContext.RawText: string

The raw text that was used to trigger this command.

# 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.

# Executor

CommandContext.Executor: Player

The player who ran this command.

# 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.

Parameters

Name Type Required
index number

Returns

Type
ArgumentContext

# 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: 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(

event: 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(

text: 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
v1.6.0+

# 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
Last Updated: 8/14/2020, 6:42:27 PM