local channel = API.channel.cache("testing channel")local channelHistory = channel:getHistory()
This function will return the channel's message history. Messages can only be added to the channels using the "addMessage" function.
getHistoryForUser
local player = game.Players.Player1local channel = API.channel.cache("testing channel")local channelHistoryForUser = channel:getHistoryForUser(player.UserId)
This function will return the channel's filtered message history. When a message is generally sent, it's filtered differently for each user. This also follows the same rule and filters the message history for the specific user that you request.
addMessage
If the speaker sending the messages is not a player, the messages will not filter.
local channelName ="all" --> Specified channel namelocal speaker = API.speaker.cache("Player1",false) --> Get speaker for "Player1"local channel = API.channel.cache(channelName) --> Get channel for "all"channel:addSpeaker(speaker) --> Add the speaker to channel "all"local arguments = {"Player1", --> Speaker name"Message", --> Speaker message channelName, --> Channel namenil, --> Speaker's player object (used for filtering + other things)"default" --> Message type (do not change)}local success,result = API.chatSystem:createMessageObject(unpack(arguments)) --> Create the message objectif(success) then channel:addMessage(result,true) --> Add the message and make all players in the channel see it with "true"elsewarn("[BETTER CHAT ERROR]:",result) --> Notify of errors that occured when making the messageend
This method will add a message to the chat's history. If you add a "true" value to it, it'll make the message display in all connected user's chats.
isSpeakerInChannel
local chatChannel = API.channel.cache("all")local speaker = API.speaker.cache("Player1")local isPlayerInChannel = chatChannel:isSpeakerInChannel(speaker)print(isPlayerInChannel)
This method will return if the specified speaker is in the specific chat channel.
getSpeakers
local chatChannel = API.channel.cache("all")local speakersList = chatChannel:getSpeakers()print(speakersList)
This method will return a table of players who are in the specified channel.
addSpeaker
local channelName ="all"local speaker = API.speaker.cache("Player1",false)local channel = API.channel.cache(channelName)channel:addSpeaker(speaker)
This method will add the specified speaker to the specified channel.
removeSpeaker
local channelName ="all"local speaker = API.speaker.cache("Player1",false)local channel = API.channel.cache(channelName)channel:addSpeaker(speaker)wait(1)channel:removeSpeaker(speaker)
This method will remove the specified speaker from the specified channel.