Class
TextChatCommand
Represents a text chat command.
Represents a text chat command. Can be used to create custom text chat
commands when parented to TextChatService.
Custom commands can have up to two aliases, and the Triggered event fires when
a user's message matches the value of either the
PrimaryAlias or
SecondaryAlias. For an example of
custom commands, see
Custom text chat commands.
To learn more about using TextChatService, see
In-experience text chat.
Properties 4#
AutocompleteVisibleboolean | Determines whether the TextChatCommand is shown as a suggestion in
the chat autocomplete menu.ReadSafe |
Enabledboolean | Determines whether the TextChatCommand is enabled.ReadSafe |
PrimaryAliasstring | A primary alias used to trigger the TextChatCommand.ReadSafe |
SecondaryAliasstring | A secondary alias used to trigger the TextChatCommand.ReadSafe |
AutocompleteVisible: boolean#
ReadSafe
Whether this TextChatCommand appears as a suggestion in the chat
autocomplete menu. Defaults to true.
When true, PrimaryAlias is offered
in the autocomplete list. Set to false to hide it from suggestions; the
command still works when typed in full via
PrimaryAlias or
SecondaryAlias.
Autocomplete itself is controlled by
ChatInputBarConfiguration.AutocompleteEnabled.
Enabled: boolean#
ReadSafe
Determines whether the TextChatCommand is enabled.
When disabled, messages that match the value of
PrimaryAlias or
SecondaryAlias are not sunk and is
sent to other users.
Use this to disable default commands on a case-by-case basis.
PrimaryAlias: string#
ReadSafe
A primary alias used to trigger the TextChatCommand.
If a user sends a message with TextChannel:SendAsync() that
matches the PrimaryAlias, the message
is not sent and instead TextChatCommand.Triggered is fired.
SecondaryAlias: string#
ReadSafe
A secondary alias used to trigger the TextChatCommand, in addition
to its PrimaryAlias.
If a user sends a message with TextChannel:SendAsync() that
matches the SecondaryAlias, the
message is not sent and instead TextChatCommand.Triggered is
fired, exactly as it is for the
PrimaryAlias. Matching is
case-insensitive, and the alias must be followed by the end of the message
or a space, so a SecondaryAlias of
"/e" matches "/e" and "/e dance" but not "/emote".
Defaults to an empty string, in which case only the
PrimaryAlias triggers the command.
Events 1#
| Triggered | An event that developers can bind to execute commands. |
Triggered(originTextSource: TextSource, unfilteredText: string)#
An event that developers can bind to execute commands.
When a user sends a message to the server via
TextChannel:SendAsync(), the message is intercepted by the
TextChatCommand and not replicated to other users if the content
of the message matches the
PrimaryAlias or
SecondaryAlias.
For example, for a TextChatCommand with
TextChatCommand.PrimaryAlias as "mute", if a user sends "/mute
SomeUserName", then the relevant TextChatCommand for mute will
fire its TextChatCommand.Triggered. The message "/mute
SomeUserName" is not replicated to other users.
| Name | Type | Default | Description |
|---|---|---|---|
originTextSource | TextSource | A reference to the TextSource responsible for triggering the
command via TextChannel:SendAsync(). | |
unfilteredText | string | The full, unfiltered text used to trigger the command that can be used to dissect parameters from the command message. |
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild