Server

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.

Methods

quickMessage

API:quickMessage("Player1","Hello world!",Color3.fromRGB(255,0,0),Color3.fromRGB(255,255,0));

Messages created with this function are NOT filtered.

This method allows you to quickly forge a message from the server and have it replicate to all clients.

playerCallback

API:playerCallback(function(player)
    print(player)
end)

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" then
        return true,"This message will be hidden."
    end
    return false
end)

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.

Events

Chatted

API.Chatted:Connect(function(player,messageObject)
    print(player,messageObject)
end)

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.

local success,response = API.httpService:requestAsync({
	 url = "https://postman-echo.com/get",
	 method = "GET",
	 headers = {
		  ["testing-header"] = "Hello world."
	 }
})
	
local decodeHeaders = function(...)
	  local success,result = API.httpService:jsonDecode(...)
	  return result.headers
end
	
print(success and decodeHeaders(response.Body)["testing-header"] or "something went wrong.")

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"

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)

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.

local webhook = API.webhook.new("https://your-webhook.link")
local embed = webhook.createEmbed()
			.setTitle("Hello")
			.setColor(Color3.fromRGB(255,0,0))
			.setAuthor("author name")
			
webhook:post()

Methods

  • new

local webhook = API.webhook.new("https://your-webhook.link")

The "new" function allows you to create as many webhooks as you need using the API. Each webhook has its own personalized functionalities.

Webhook methods

  • setContent

local webhook = API.webhook.new("https://your-webhook.link")
webhook.setContent("webhook text")
webhook:post()

Want to keep it simple and not use any embeds? Go ahead! This allows you to set your webhook's message text with a maximum of 2000 characters.

  • getJSON

local webhook = API.webhook.new("https://your-webhook.link")
webhook.setContent("example")
print(webhook:getJSON())

Do you for some reason need your webhook's JSON? You can simply retrieve it by using the specified function!

  • post

local webhook = API.webhook.new("https://your-webhook.link")
local embed = webhook.createEmbed()
			.setTitle("Hello")
			.setColor(Color3.fromRGB(255,0,0))
			.setAuthor("author name")
			
webhook:post()

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()

This method will set the embed's title.

  • setURL

local webhook = API.webhook.new("https://your-webhook.link")
local embed = webhook.createEmbed()
    .setColor(Color3.fromRGB(255,0,0))
    .setTitle("some title")
    .setURL("https://roblox.com")
    
webhook:post()

This method will turn the specified title into a clickable hyperlink.

  • setAuthor

local webhook = API.webhook.new("https://your-webhook.link")
local embed = webhook.createEmbed()
    .setColor(Color3.fromRGB(255,0,0))
    .setTitle("some title")
    .setURL("https://roblox.com")
    .setAuthor("author name","https://your-authors.logo","https://your-authors.profile")
    
webhook:post()T
  • setDescription

local webhook = API.webhook.new("https://your-webhook.link")
local embed = webhook.createEmbed()
    .setColor(Color3.fromRGB(255,0,0))
    .setTitle("some title")
    .setURL("https://roblox.com")
    .setAuthor("author name","https://your-authors.logo","https://your-authors.profile")
    .setDescription("webhook description")
    
webhook:post()
  • setThumbnail

local webhook = API.webhook.new("https://your-webhook.link")
local embed = webhook.createEmbed()
    .setColor(Color3.fromRGB(255,0,0))
    .setTitle("some title")
    .setURL("https://roblox.com")
    .setAuthor("author name","https://your-authors.logo","https://your-authors.profile")
    .setDescription("webhook description")
    .setThumbnail("https://your-thumbnail.here")
    
webhook:post()
  • addFields

local webhook = API.webhook.new("https://your-webhook.link")
local embed = webhook.createEmbed()
    .setColor(Color3.fromRGB(255,0,0))
    .setTitle("some title")
    .setURL("https://roblox.com")
    .setAuthor("author name","https://your-authors.logo","https://your-authors.profile")
    .setDescription("webhook description")
    .setThumbnail("https://your-thumbnail.here")
    .addFields(
        {name = "example field name",value = "example field value",inline = false}
    )
    
webhook:post()
  • addField

local webhook = API.webhook.new("https://your-webhook.link")
local embed = webhook.createEmbed()
    .setColor(Color3.fromRGB(255,0,0))
    .setTitle("some title")
    .setURL("https://roblox.com")
    .setAuthor("author name","https://your-authors.logo","https://your-authors.profile")
    .setDescription("webhook description")
    .setThumbnail("https://your-thumbnail.here")
    .addFields(
        {name = "example field name",value = "example field value",inline = false}
    )
    .addField("name","value",false)
    
webhook:post()
  • setImage

local webhook = API.webhook.new("https://your-webhook.link")
local embed = webhook.createEmbed()
    .setColor(Color3.fromRGB(255,0,0))
    .setTitle("some title")
    .setURL("https://roblox.com")
    .setAuthor("author name","https://your-authors.logo","https://your-authors.profile")
    .setDescription("webhook description")
    .setThumbnail("https://your-thumbnail.here")
    .addFields(
        {name = "example field name",value = "example field value",inline = false}
    )
    .addField("name","value",false)
    .setImage("https://your.image")
    
webhook:post()
  • setTimestamp

local webhook = API.webhook.new("https://your-webhook.link")
local embed = webhook.createEmbed()
    .setColor(Color3.fromRGB(255,0,0))
    .setTitle("some title")
    .setURL("https://roblox.com")
    .setAuthor("author name","https://your-authors.logo","https://your-authors.profile")
    .setDescription("webhook description")
    .setThumbnail("https://your-thumbnail.here")
    .addFields(
        {name = "example field name",value = "example field value",inline = false}
    )
    .addField("name","value",false)
    .setImage("https://your.image")
    .setTimestamp()
    
webhook:post()
  • setFooter

local webhook = API.webhook.new("https://your-webhook.link")
local embed = webhook.createEmbed()
    .setColor(Color3.fromRGB(255,0,0))
    .setTitle("some title")
    .setURL("https://roblox.com")
    .setAuthor("author name","https://your-authors.logo","https://your-authors.profile")
    .setDescription("webhook description")
    .setThumbnail("https://your-thumbnail.here")
    .addFields(
        {name = "example field name",value = "example field value",inline = false}
    )
    .addField("name","value",false)
    .setImage("https://your.image")
    .setTimestamp()
    .setFooter("footer text","https://your-other.image")
    
webhook:post()

Channel API

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)

This method will create a speaker object if it doesn't exist, or return the existing speaker object.

addSpeaker

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 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
print(success,result)

This function will create a table that represents a chat message that is used to send messages in channels.

Last updated