This is a simple discord module.
I’ll show examples and how you’d use the module to accomplish an API webhook.
Feel free to claim or download it as your own. It is a open module that is built to help you manage the API.
Example Script
local webhookModule = require(game.ReplicatedStorage:WaitForChild("WebhookModule"))
local embed = webhookModule.newEmbed()
local webhookSettings = webhookModule.newWebhookSettings()
local field = webhookModule.newField()
field.name = "Cool Title!"
field.value = "Cool Description!"
embed.title = "abc"
embed.description = "123"
embed.color = webhookModule.colors.red
table.insert(embed.fields, field)
webhookModule.send("https://Cool Discord Webhook", webhookSettings, embed)
Module Src
local httpService = game:GetService("HttpService")
local embedModule = {}
embedModule.colors = {}
embedModule.colors.aqua = 0x00FFFF
embedModule.colors.black = 0x000000
embedModule.colors.blue = 0x0000FF
embedModule.colors.fuchsia = 0xFF00FF
embedModule.colors.grey = 0x808080
embedModule.colors.green = 0x008000
embedModule.colors.lime = 0x00FF00
embedModule.colors.maroon = 0x800000
embedModule.colors.navy = 0x000080
embedModule.colors.olive = 0x808000
embedModule.colors.purple = 0x800080
embedModule.colors.red = 0xFF0000
embedModule.colors.silver = 0xC0C0C0
embedModule.colors.teal = 0x008080
embedModule.colors.white = 0xFFFFFF
embedModule.colors.yellow = 0xFFFF00
function embedModule.getISO8601Timestamp()
-- CREDITS: https://www.roblox.com/users/17828104
-- CREDITS: https://devforum.roblox.com/u/rogchamp
-- MODIFIED: I have modified the origional code.
local osDate = os.date("!*t")
local year = osDate["year"]
local month = string.format("%0" .. 2 .. "i", osDate["month"])
local day = string.format("%0" .. 2 .. "i", osDate["day"])
local hour = string.format("%0" .. 2 .. "i", osDate["hour"])
local min = string.format("%0" .. 2 .. "i", osDate["min"])
local second = string.format("%0" .. 2 .. "i", osDate["sec"])
return year .. "-" .. month .. "-" .. day .. "T" .. hour .. ":" .. min .. ":" .. second .. "Z"
end
function embedModule.newFooter()
return {
iron_url = "";
text = "";
}
end
function embedModule.newThumbnail()
return {
url = "";
}
end
function embedModule.newImage()
return {
url = "";
}
end
function embedModule.newAuthor()
return {
name = "";
url = "";
icon_url = "";
}
end
function embedModule.newField()
return {
name = "";
value = "";
inline = false;
}
end
function embedModule.newEmbed()
return {
title = "";
description = "";
url = "";
color = 0;
timestamp = embedModule.getISO8601Timestamp();
footer = embedModule.newFooter();
thumbnail = embedModule.newThumbnail();
image = embedModule.newImage();
author = embedModule.newAuthor();
fields = {};
}
end
function embedModule.newWebhookSettings()
return {
content = nil;
username = nil;
avatar_url = nil;
tts = false;
}
end
function embedModule.send(url, webhookSettings, embed)
local httpPacket
pcall(function() local _1 = webhookSettings; pcall(function() local _2 = _1; _1 = nil; httpPacket = _2 end) end)
httpPacket.embeds = {embed}
return httpService:PostAsync(url, httpService:JSONEncode(webhookSettings))
end
return embedModule
This module is just a helpful guide. Managing and handling embeds can be hard. This should help simplify it. I’ve programmed it in a way that new users may be able to understand and too. Get used to the discord API.