TextChatCommand

顯示已棄用項目

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

表示一個文字聊天指令。可以用來在父物件為 TextChatService 時創建自定義的文字聊天指令。

自定義指令最多可以有兩個別名,當用戶的訊息與以下任何一個值匹配時,會觸發事件:

PrimaryAliasSecondaryAlias。有關自定義指令的範例,請參見 自定義文字聊天指令

要了解更多有關使用 TextChatService 的信息,請參見 體驗內文字聊天

屬性

AutocompleteVisible

平行讀取

Enabled

平行讀取

確定 TextChatCommand 是否啟用。

當禁用時,匹配 PrimaryAliasSecondaryAlias 的消息不會被發送到其他用戶。

可逐條禁用預設指令。

PrimaryAlias

平行讀取

用於觸發 TextChatCommand 的主要別名。

如果用戶使用 TextChannel:SendAsync() 發送的消息與 PrimaryAlias 匹配,則該消息不會發送,反而會觸發 TextChatCommand.Triggered

SecondaryAlias

平行讀取

用於觸發 TextChatCommand 的次要別名。

方法

活動

Triggered

開發人員可以綁定以執行命令的事件。

當用戶通過 TextChannel:SendAsync() 向服務器發送消息時,TextChatCommand 會攔截此消息,如果消息的內容與以下任一項匹配,則不會傳播給其他用戶:

PrimaryAliasSecondaryAlias

例如,對於一個 TextChatCommandTextChatCommand.PrimaryAlias 為 "mute",如果用戶發送 "/mute SomeUserName",則靜音的相關 TextChatCommand 將觸發它的 TextChatCommand.Triggered。消息 "/mute SomeUserName" 不會傳播給其他用戶。

參數

originTextSource: TextSource

一個參考,指向通過 TextChannel:SendAsync() 觸發命令的 TextSource

unfilteredText: string

用於觸發命令的完整、未過濾的文本,可以用來解析命令消息中的參數。