# TextChannel

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/TextChannel/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/TextChannel

Represents a text chat channel.

## Properties

### AddPlayersOnJoin

```luau
TextChannel.AddPlayersOnJoin: boolean = false
```

- Tags: Read capabilities: Chat

### DirectChatRequester

```luau
TextChannel.DirectChatRequester: Player
```

- Tags: Read only, Read capabilities: Chat, Save only

The [`TextChannel`](https://rapi.sleaze.dev/classes/TextChannel.md) will only deliver messages to users that can send direct messages to the [`DirectChatRequester`](https://rapi.sleaze.dev/classes/TextChannel.md).

### IsDefaultTextChannel

```luau
TextChannel.IsDefaultTextChannel: boolean = false
```

- Tags: Hidden, Roblox script security, Read capabilities: Chat

## Methods

### AddUserAsync

```luau
TextChannel:AddUserAsync(userId: User): ...any
```

- Tags: Yields, Capabilities: Chat

Adds a [`TextSource`](https://rapi.sleaze.dev/classes/TextSource.md) to the [`TextChannel`](https://rapi.sleaze.dev/classes/TextChannel.md) given userId of a [`Player`](https://rapi.sleaze.dev/classes/Player.md).

Parameters:

- `userId`: The userId of the [`Player`](https://rapi.sleaze.dev/classes/Player.md).

Returns: Returns [`TextSource`](https://rapi.sleaze.dev/classes/TextSource.md) and `true` if a new [`TextSource`](https://rapi.sleaze.dev/classes/TextSource.md) is created for the user, [`TextSource`](https://rapi.sleaze.dev/classes/TextSource.md) and `false` if there is an existing [`TextSource`](https://rapi.sleaze.dev/classes/TextSource.md), or `nil` and `false` if the user has chat off or is not in this server.

### DisplaySystemMessage

```luau
TextChannel:DisplaySystemMessage(systemMessage: string, metadata: string? = ""): TextChatMessage
```

- Tags: Capabilities: Chat

Displays a system message to the user.

Parameters:

- `systemMessage`: The system message sent to the [`TextChannel`](https://rapi.sleaze.dev/classes/TextChannel.md).
- `metadata`: Use to identify system message types, such as the default system messages.

Returns: A [`TextChatMessage`](https://rapi.sleaze.dev/classes/TextChatMessage.md) with [`TextChatMessage.Status`](https://rapi.sleaze.dev/classes/TextChatMessage.md) property that indicates the condition of the message.

### SendAsync

```luau
TextChannel:SendAsync(message: string, metadata: string? = ""): TextChatMessage
```

- Tags: Yields, Capabilities: Chat

Sends a [`TextChatMessage`](https://rapi.sleaze.dev/classes/TextChatMessage.md) to the server.

Parameters:

- `message`: The message to send to the [`TextChannel`](https://rapi.sleaze.dev/classes/TextChannel.md).
- `metadata`: Custom metadata to attach to the message.

Returns: A [`TextChatMessage`](https://rapi.sleaze.dev/classes/TextChatMessage.md) with [`TextChatMessage.Status`](https://rapi.sleaze.dev/classes/TextChatMessage.md) property that indicates the condition of the message.

### SendDictatedSpeechAsync

```luau
TextChannel:SendDictatedSpeechAsync(message: string): TextChatMessage
```

- Tags: Yields, Roblox script security, Capabilities: Chat

### SendInternalAsync

```luau
TextChannel:SendInternalAsync(message: string, metadata: string? = ""): TextChatMessage
```

- Tags: Yields, Roblox script security, Capabilities: Chat

### SendPresetAsync

```luau
TextChannel:SendPresetAsync(presetId: string): TextChatMessage
```

- Tags: Yields, Roblox script security, Capabilities: Chat

### SetDirectChatRequester

```luau
TextChannel:SetDirectChatRequester(requester: Player)
```

- Tags: Capabilities: Chat

Sets the [`DirectChatRequester`](https://rapi.sleaze.dev/classes/TextChannel.md) for the [`TextChannel`](https://rapi.sleaze.dev/classes/TextChannel.md). The [`TextChannel`](https://rapi.sleaze.dev/classes/TextChannel.md) will only deliver messages to users that can send direct messages to the [`DirectChatRequester`](https://rapi.sleaze.dev/classes/TextChannel.md).

Parameters:

- `requester`: The [`Player`](https://rapi.sleaze.dev/classes/Player.md) whose direct-message permissions gate the channel; only users who can send direct messages to this player are delivered messages on the channel.

## Events

### MessageReceived

```luau
TextChannel.MessageReceived: RBXScriptSignal<(incomingMessage: TextChatMessage)>
```

- Tags: Capabilities: Chat

Fires when [`TextChannel:DisplaySystemMessage()`](https://rapi.sleaze.dev/classes/TextChannel.md) is invoked on the client, or when the client receives a valid [`TextChannel:SendAsync()`](https://rapi.sleaze.dev/classes/TextChannel.md) response from the server.

## Callbacks

### OnIncomingMessage

```luau
TextChannel.OnIncomingMessage: (message: TextChatMessage) -> ...any
```

- Tags: Capabilities: Chat

Called when [`TextChannel`](https://rapi.sleaze.dev/classes/TextChannel.md) is receiving an incoming message.

Parameters:

- `message`: The incoming [`TextChatMessage`](https://rapi.sleaze.dev/classes/TextChatMessage.md).

Returns: If a [`TextChatMessageProperties`](https://rapi.sleaze.dev/classes/TextChatMessageProperties.md) is returned, those properties are merged with the [`TextChatMessage`](https://rapi.sleaze.dev/classes/TextChatMessage.md) parameter to create a new [`TextChatMessage`](https://rapi.sleaze.dev/classes/TextChatMessage.md) with those properties.

### ShouldDeliverCallback

```luau
TextChannel.ShouldDeliverCallback: (message: TextChatMessage, textSource: TextSource) -> ...any
```

- Tags: Capabilities: Chat

Called for each client when [`TextChannel`](https://rapi.sleaze.dev/classes/TextChannel.md) is receiving an incoming message to determine whether or not it should be delivered to that client.

Parameters:

- `message`: The message being sent, which also contains the sender of the message.
- `textSource`: The [`TextSource`](https://rapi.sleaze.dev/classes/TextSource.md) of the user who will be receiving the message.

Returns: A truthy value (such as `true`, `1`, or a non-empty string) to deliver the message to the given client, or a falsy value (including `nil`) to withhold it from that client.

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
