Easy-Webhook: Discord Webhooks Integration Module

Hello there everybody, I was messing around with embeds for my bot in NodeJs today and I had the idea to remake the same API inside of Roblox. So here it is, I present to you all:

EASY-WEBHOOK:

Documentation:

Inbuilt functions:
Module.getFromUrl(Url, Parse) - Gets from Url and if Parse is set to true then it decodes the JSON.

Module.postToUrl(Url, Data) - Posts to Data to Url which is also Encoded in JSON.

Module.toHex(number) - Converts number to hex.

Webhook functions:
Webhook.new(Webhook_Url, Message_Content, Embeds, Username, Avatar_Url) - Posts to Webhook_Url and with the content Message_Content if not nil or “”, adds Embeds if not nil, changes the username of the bot to Username if also not nil and changes the Avatar Icon to Avatar_Url if not nil.

Webhook.richEmbed() - Constructs a new Embed.

Embed functions:
Embed.setTimestamp() - Adds a Timestamp to the embed.

Embed.setColor(Color) - Sets the embed’s color to Color.

Embed.setTitle(Text) - Sets the embed’s title to Text.

Embed.setDescription(Text) - Sets the embed’s description to Text.

Embed.setURL(Url) - Sets the embed’s title’s url to Url.

Embed.setThumbnail(Image_Url) - Sets the embed’s thumbnail to Image_Url.

Embed.setImage(Image_Url) - Sets the embed’s image to Image_Url.

Embed.setFooter(Name, Image_Url) – Sets the embed’s footer’s name to Name and Icon url to Image_Url.

Embed.setAuthor(Name, Image_Url, Url) - Sets the embed’s author Name to Name, Icon to Image_Url and Url to Url

Embed.addField(Name, Value, InLine) - Adds a field to the embed with name Name, value Value and optional boolean InLine

Embed.addFields(…) - Adds passed amount of fields to the embed.

Example Code:

local Webhook = require(workspace.MainModule)

local Embed = Webhook.richEmbed()
Embed.setColor(Color3.new(27, 145, 248))
Embed.setTitle('Some title')
Embed.setURL('https://discord.js.org/')
Embed.setAuthor('Some name', 'https://i.imgur.com/wSTFkRM.png', 'https://discord.js.org')
Embed.setDescription('Some description here')
Embed.setThumbnail('https://i.imgur.com/wSTFkRM.png')
Embed.addField('Some title here', 'Some value here', false)
Embed.addFields(
	{
		"Field #1",
		"Value #1",
		true
	},
	{
		"Field #2",
		"Value #2",
		true
	},
	{
		"Field #3",
		"Value #3",
		true
	}
)
Embed.setImage('https://i.imgur.com/wSTFkRM.png')
Embed.setTimestamp()
Embed.setFooter('Some footer text here', 'https://i.imgur.com/wSTFkRM.png');

Webhook.new("Webhook", "Lorem Ipsum.", Embed, "Discord.js", "https://i.imgur.com/wSTFkRM.png")

Model:
https://www.roblox.com/library/4955339544/Easy-Webhook-API

I am looking forward for suggestions and bug reports, please message me them or reply with them, I’ll try my best to fix or add them as soon as possible.

21 Likes

This is very good, but the skidded exploiters will use this to make a log system for a server sided executor (fe executor) but thanks for this i will use it for my game C:

2 Likes

You can reduce the length of your code by using assert. Assert is an error throwing function and outputs an error based on the state of the first parameter passed to it.

assert(condition, message) is functionally equivalent to

if (not condition) then
    error(message)
end

So you could reduce some of the code in the image above into:

assert(type(Width) == "number", "Unable to create Rich Embed, Thumbnail Width must be a number.")

and so on

I have already used assert before and the results did not satisfy me. I would rather prefer to warn instead of error.

But you’re calling error not warn? This throws an error not a warning and so does assert

Thanks for this! This is really useful if you are short on time and don’t know how embeds work. I will add this to my game to log banned exploiters. Thanks!

UPDATE: Now you can use Color3.new in setColor function to set the color for your Embeds and now you just need to return the Embed instead of Embed.Embed

Please update your module to include api limits for api requests, fields and embeds.

Also note that height and width fields are not available for webhooks.

Please take a look at my module here

My bad I’ll definitely keep what you said in mind and update my module as soon as possible. Thank you so much for letting me know.

1 Like

UPDATE: Rewrote the whole module, now it has limit checks and it also added a new method.

1 Like

Embed.setAuthor() is not working. No error, it just doesn’t set the Author in the embed.

1 Like