Channel Object

Methods

getHistory

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.Player1
local 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.

Type

Name

number

userid

addMessage

If the speaker sending the messages is not a player, the messages will not filter.

local channelName = "all" --> Specified channel name
local 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 name
	 nil, --> 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 object

if(success) then
	  channel:addMessage(result,true) --> Add the message and make all players in the channel see it with "true"
else
	  warn("[BETTER CHAT ERROR]:",result) --> Notify of errors that occured when making the message
end

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.

Type

Name

message (dictionary)

message object

boolean

replicate message

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.

Type

Name

speaker (dictionary)

speaker

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.

Type

Name

speaker (dictionary)

speaker

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.

Type

Name

speaker (dictionary)

speaker

Last updated