MTA Discord Webhook Library
An open-source Lua library for Multi Theft Auto: San Andreas that simplifies sending Discord webhooks directly from in-game events, with both OOP and non-OOP syntax. My first time creating a library, learning that code is just code, not magic, designed to make writing more code easier.
Technologies Used
This project was created in 2020 as a utility library for Multi Theft Auto: San Andreas (MTA:SA) scripting using Lua.
At the time, integrating Discord webhooks required manually crafting HTTP requests to the Discord API, which was not as straightforward or well-documented as it is today. This library aimed to abstract that complexity and provide a clean, simple syntax for developers.
It supported both OOP and non-OOP syntax and was my first experience creating a library, helping me understand that programming is not magic, but just code designed to make creating more code easier.
OOP Example:
local myWebhook = Webhook.new("Webhook_url", "MYH") myWebhook:setAvatar( "<image_url>" ) myWebhook:setContent("My Webhook Library Example.") local myWHEmbed = myWebhook:setEmbed("My Library's Embed") myWHEmbed:setColor("15281718") myWHEmbed:setDescription("Some Text") myWHEmbed:setField("Some Field", "Text", false) myWHEmbed:setField("Some Field", "Text", true) myWHEmbed:setField("Some Field", "Text", true) myWHEmbed:setImage( "<image_url>" ) myWebhook:Send(false)
Non-OOP Example:
local myWebhook = Webhook("Webhook_url", "MYH") myWebhook = WHSetAvatar( myWebhook, "<image_url>" ) myWebhook = WHSetContent(myWebhook, "My Webhook Library Example.") myWebhook = WHSetEmbed(myWebhook, "My Library's Embed") myWebhook = WHESetColor(myWebhook, "15281718") myWebhook = WHESetField(myWebhook, "Some Field", "Text", false) myWebhook = WHESetField(myWebhook, "Some Field", "Text", true) myWebhook = WHESetField(myWebhook, "Some Field", "Text", true) myWebhook = WHESetImage( myWebhook, "<image_url>" ) WHSend(myWebhook, false)
This library made it easy for developers to share in-game events to Discord with just a few lines of Lua code.