TextChannel
Represents a text chat channel.
Memory category | Instances |
---|
Member index 8
Description
Represents a text chat channel. Contains TextSources as descendants.
To send a chat message to the TextChannel, call
TextChannel:SendAsync() from a LocalScript. The corresponding
TextSource of the user with TextSource.CanSend = true
must be in
that channel.
Messages from different TextChannels can be separated into different tabs in the chat window using ChannelTabsConfiguration.
To learn more, see In-Experience Text Chat.
History 15
- 651 Add SetDirectChatRequester
- 651 Add DirectChatRequester
- 549 Add ShouldDeliverCallback
- 533 Change Tags of TextChannel from [NotBrowsable] to []
- 528 Change Tags of SendAsync from [] to [Yields]
- 514 Add OnIncomingMessage
- 514 Change Parameters of MessageReceived from (textChatMessage: TextChatMessage) to (incomingMessage: TextChatMessage)
- 514 Add SendAsync
- 514 Change Tags of TextChannel from [] to [NotBrowsable]
- 513 Change Parameters of MessageReceived from (textChatMessage: TextChatMessage) to (textChatMessage: TextChatMessage)
- 513 Change ReturnType of DisplaySystemMessage from TextChatMessage to TextChatMessage
- 504 Add MessageReceived
- 504 Add DisplaySystemMessage
- 504 Add AddUserAsync
- 496 Add TextChannel
Members 8
AddUserAsync
Parameters (1) | ||
---|---|---|
userId | int64 | |
Returns (1) | ||
Tuple |
Adds a TextSource to the TextChannel given userId of the user (with Player.UserId). Can only be used in a Script.
If a TextSource representing the user does not exist, this adds a TextSource.
If a TextSource representing the user does exist, this returns the TextSource.
If the user has chat off or isn't in the server, this returns a tuple
nil
, false
.
Thread safety | Unsafe |
---|
History 1
- 504 Add AddUserAsync
DirectChatRequester
Type | Default | |
---|---|---|
Player |
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false/true |
History 1
DisplaySystemMessage
Parameters (2) | Default | |
---|---|---|
systemMessage | string | |
metadata | string | |
Returns (1) | ||
TextChatMessage |
Displays a system message to user. Can only be used in a LocalScript, or in a Script with RunContext of RunContext.Client. Messages are only visible to that user and aren't automatically filtered or localized.
Thread safety | Unsafe |
---|
History 2
- 513 Change ReturnType of DisplaySystemMessage from TextChatMessage to TextChatMessage
- 504 Add DisplaySystemMessage
MessageReceived
Parameters (1) | |
---|---|
incomingMessage | TextChatMessage |
Like TextChatService.MessageReceived, fires when TextChannel:DisplaySystemMessage() is invoked on the client, or when the client receives a valid TextChannel:SendAsync() response from the server. This event is only fired on the client.
If the server's TextChannel.ShouldDeliverCallback property is
bound and returns false
, the client will not fire
TextChannel.MessageReceived.
Use the TextChatMessage parameter to get the TextSource and the text of the message (with TextChatMessage.Text).
The TextChatMessage parameter is the final result of any functions bound to TextChatService.OnIncomingMessage or TextChannel.OnIncomingMessage.
Thread safety | Unsafe |
---|
History 3
- 514 Change Parameters of MessageReceived from (textChatMessage: TextChatMessage) to (incomingMessage: TextChatMessage)
- 513 Change Parameters of MessageReceived from (textChatMessage: TextChatMessage) to (textChatMessage: TextChatMessage)
- 504 Add MessageReceived
OnIncomingMessage
Parameters (1) | ||
---|---|---|
Returns (1) | ||
Tuple |
Called when TextChannel is receiving an incoming message. Can only be implemented on the client.
Use this to decorate TextChatMessages. If this callback returns a TextChatMessageProperties, those properties are merged with the TextChatMessage parameter to create a new TextChatMessage.
When bound to the client sending a message, this callback is run twice; first when the message is initially sent and received locally, and again when the client receives the result of the filtered message from the server.
TextChannel.OnIncomingMessage callbacks always run after the TextChatService.OnIncomingMessage callback.
This should be defined only once per TextChannel in the source code. Multiple bindings to the same channel will override one another in a nondeterministic manner.
When TextChatService:CreateDefaultTextChannels() is true, those default TextChannels have their TextChannel.OnIncomingMessage callbacks assigned internally in order to exhibit special default behavior.
Thread safety | Unsafe |
---|
History 1
- 514 Add OnIncomingMessage
SendAsync
Parameters (2) | Default | |
---|---|---|
metadata | string | |
Returns (1) | ||
TextChatMessage |
Sends a TextChatMessage to the server. Can only be used in a LocalScript, or in a Script with RunContext of RunContext.Client.
Thread safety | Unsafe |
---|
SetDirectChatRequester
Parameters (1) | ||
---|---|---|
requester | Player | |
Returns (1) | ||
null |
Thread safety | Unsafe |
---|
History 1
ShouldDeliverCallback
Parameters (2) | ||
---|---|---|
textSource | TextSource | |
Returns (1) | ||
Tuple |
Called for each client when TextChannel is receiving an incoming message to determine whether or not it should be delivered to that client. Can only be defined on the server.
Once defined, this callback needs to return a truthy value such as true
,
1
, or "hello"
to deliver the message to said client. If the callback
returns anything else (including nil
), the message won't be delivered to
that client, although the sender will see the message regardless.
The sender can be referenced by TextChatMessage.TextSource.
Thread safety | Unsafe |
---|