Channel
A channel is a location where speakers can exchange messages, this page covers how to create them and their methods.
The default chat channel name is 'Main'.
The server API allows you to access channels and manage them from there.
Fetching Channels
--> :getByName(<string:name>)
This method fetches a channel by it's name, it will return nil if there's no channel found.
Creating a channel
--> .new(<string:name>,<boolean:autojoin>
This method creates a channel object with the specified name, and if it's marked as 'autojoin', speakers will automatically be assigned to it.
Channel events, properties & methods
Properties
--> .name <string>
The '.name' property represents the channel's name.
--> .messageCount <integer>
The amount of messages in the channel thus far.
--> .speakers <table>
The speakers associated with the channel in a table.
Events
--> .chatted <table:message>
This event is fired with a raw message object when a message is sent in the channel.
--> .speakerAdded <table:speaker>
This event is fired when a speaker is added to the channel.
--> .speakerRemoved <string:speakerName>
This event is fired when a speaker is removed from the channel.
Methods
--> :registerMessageProcess(<string:name>,<function:callback>)
The function passed will be called with a message object twice (before filtering, and after filtering). You can make changes to the message before it's filtered to add data to the message or remove data.
--> :unregisterMessageProcess(<string:name>)
Was the quackify function too overpowered? We have the power to undo that now!
--> :canSpeakerTalk(<table:speaker>) -> <boolean>
This method returns a boolean determining whether or not a speaker is in the specified channel.
--> :sendMessage(<table:speaker>,<string:text>,(?<table:replyTo>)) --> <table:message>
This method is used internally from speaker:say(), and can be used as such:
-->:editMessage(<integer:id>,<string:text>)
This method can be used to edit an existing message by ID.
--> :getMessageById(<integer:id>)
This method can be used to fetch a message by it's ID.
--> :Destroy(<void>)
This method destroys the channel and disconnects everything.
Last updated