All server plugins will be hidden from the client to prevent exploits from stealing them.
Server plugins can be used to create quick modifications of the system's internals without forking. We're currently open to any suggestions that our users may have, as our API is currently a little bit bland.
This method allows you to quickly register a function to all current players and any players who join in the future.
registerMessageProcessFunction
API:registerMessageProcessFunction(function(messageObject)if messageObject.message =="hideme" thenreturntrue,"This message will be hidden."endreturnfalseend)
This method is called before a message is processed. This will allow you to choose whether or not to hide a specific message. This can be used to filter specific keywords for raids / similar. The provided function is called with a message object that can be explored below. All you need to do is return in the function if you want to hide it with a boolean value and a provided message that'll be shown in the chat. If set to a blank string such as "", it will not send any message when hidden.
The regular chatted event has some security vulnerabilities that are by default fixed. This however can cause certain features to break, such as the event firing in whisper and team channels. You can toggle that option in the "Security" portion of the configuration. This is primarily to prevent exploiters from picking up on conversations that are meant to be private. This event will be fired regardless of the security configuration.
Http Service
This is a custom implementation of the default HttpService but designed for quicker use. It only has a few existing methods so far, I'll most likely add more at a later date.
jsonEncode
local success,result = API.httpService:jsonEncode({message ="hello world"})
This is an error-handled JSON encode, the only way it can error is if you pass an invalid value to it.
jsonDecode
local success,result = API.httpService:jsonDecode("{\"value\": true}")
This is another error-handled JSON system. Instead of erroring, it'll warn out the error and return a false value as the success and an error message. If it goes right, it'll simply return a true value and the newly generated table.
requestAsync
local success,response = API.httpService:requestAsync({ method ="GET", url ="https://pastebin.com/raw/ZdL964XR"})print(response.Body)
This one is quite a bit more complicated, but it's easy to understand once you use it enough. This is an error-handled RequestAsync function, this will help debugging and allow you to easily make HTTP requests. Overall, the system functions like the regular function but with error handling.
HTTP headers let the client and the server pass additional information with an HTTP request or response.
A body field allows you to post data to the specified URL, this is used for example in the discord webhook system.
local success,response = API.httpService:requestAsync({ url ="https://postman-echo.com/post", method ="POST", headers = { ["testing-header"] ="Hello world." }, body ="This is a cool body."})
getAsync
local success,body = API.httpService:getAsync("https://pastebin.com/raw/ZdL964XR")print(success,body) --> true,"hello world"
This one is just a streamlined request to the requestAsync function. Although, it does have some additional arguments that you can use.
Caching allows you to make one request to the specified link and any following requests will return the first response.
local success,body = API.httpService:getAsync("https://pastebin.com/raw/ZdL964XR",true)print(success,body) --> true,"hello world"
HTTP headers let the client and the server pass additional information with an HTTP request or response.
local success,body = API.httpService:getAsync("https://pastebin.com/raw/ZdL964XR",false,{ ["header"] =true})print(success,body) --> true,"hello world"
postAsync
local success,response = API.httpService:postAsync("http://httpbin.org/post","sample data")print(success,response)
This is a simplified requestAsync method. It essentially allows you to make a POST request with extreme ease and simplicity.
This argument will specify the HTTP "Content-Type" header.
local success,response = API.httpService:postAsync("http://httpbin.org/post","{\"value\": true}",Enum.HttpContentType.ApplicationJson)
print(success,response)
This will determine whether or not the data you post is compressed when sent.
local success,response = API.httpService:postAsync("http://httpbin.org/post","{\"value\": true}",Enum.HttpContentType.ApplicationJson,true)
print(success,response)
HTTP headers let the client and the server pass additional information with an HTTP request or response.
local success,response = API.httpService:postAsync("http://httpbin.org/post","{\"value\": true}",Enum.HttpContentType.ApplicationJson,false,{
["header"] =true})print(success,response)
Webhooks
I've created a webhook system nearly identical to discord.js's embed system. This allows you to quickly make webhooks and post them for things like chat logs / similar. Although, chat logs are not advised for large games.
Creating your first webhook
All embed methods are chainable which means multiple functions are called on the same object consecutively. This can result in your code being easier to read / etc.
You shouldn't use this for massive logging purposes at all. Discord does not like when people do that. This can result in webhooks being deleted or your server getting banned. It is not BetterChat's fault if anything happens to your webhook / discord server.
This is the method that'll post the webhook to discord! (Or whatever strange platform you're trying to post it to).
createEmbed
local webhook = API.webhook.new("https://your-webhook.link")local embed = webhook.createEmbed()
There's a maximum of 10 embeds per message. If you've been around on Discord for a bit, chances are you have seen these special messages, often sent by bots. They tend to have a colored border, embedded images, text fields, and other unique properties.
Embed methods
setColor
local webhook = API.webhook.new("https://your-webhook.link")local embed = webhook.createEmbed() .setColor(Color3.fromRGB(255,0,0))webhook:post()
This method will change the embed's color to your choice.
setTitle
local webhook = API.webhook.new("https://your-webhook.link")local embed = webhook.createEmbed() .setColor(Color3.fromRGB(255,0,0)) .setTitle("some title")webhook:post()
The channel system is an object that stores messages and sends them out to the users in the channel. You can control the users you want in specific channels, and more. They currently lack a large amount of features, but that'll be fully implemented later.
cache
local channel = API.channel.cache("testChannel")
The cache function is a function that will return a channel with the existing name or create the channel if it doesn't exist. For example, if you cache "testChannel" and then you run the function again, it'll return the first channel object you created.
getChannel
local channel = API.channel:getChannel("all")
The "getChannel" function is quite indicative of its own name. It'll return the channel you requested if it exists. The difference between this and the "cache" function is that the cache function will create the channel if it doesn't exist.
new
local newChannel = API.channel.new("newChannel")
This will create a channel object that can store messages, keep history, and specify the users you want in it.
Speaker API
Speakers are essentially players for channels. You can place them in specific channels to receive certain messages.
Non-player speaker messages are not filtered.
cache
local speaker = API.speaker.cache("Player1",false)
local speaker = API.speaker:addSpeaker("Player1",false)
This method will create and return a new speaker object with the specified name. The "is player" parameter is used to determine filtering and more player-only methods. This should only be turned on if there's a player with the same name as the speaker.
removeSpeaker
API.speaker:removeSpeaker("Player1")
This method will remove the entire speaker from the game. This disconnects all events and disables all functions.
getSpeaker
local speakerObject = API.speaker:getSpeaker("Player1")
This method will return a speaker object with the specified name if they exist.
Chat System
This is primarily used internally, but it can be accessed by the API to send messages / similar.
filter
If there's no player specified, the message will not filter at all. This is for creating custom speakers with custom messages.
local filterResult = API.chatSystem:filter(game:GetService("Players").Player1,"a message they sent.")
This function will filter a message to be sent publically. If it fails, it'll set a plain string composed of underscores. If there's no player argument sent, it won't filter at all and just return the message.
createMessageObject
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 objectprint(success,result)
This function will create a table that represents a chat message that is used to send messages in channels.