easyWebhook is a ROBLOX based method of creating and posting discord webhooks, in a simpler fashon.
If you don't know how to setup HTTP requests:
- Edit the game you wish to add this to, go into your game settings
- Under Security, check the "Allow HTTP Requests" to make sure it is enabled.
Discord provides a tutorial that helps you create your first webhook.
If you don't want to setup with /client, the settings will be defaulted. Skip to Requiring the Main Module
in /client
- copy main.lua and create a ModuleScript inside of ServerScriptService and name it easyWebhook
- copy easyWebhook Settings.lua and create a ModuleScript inside of easyWebhook (the ModuleScript we created in ServerScriptService) and name it easyWebhook Settings
Your hierarchy should now look like:
- ServerScriptService
- easyWebhook
- easyWebhook Settings
- easyWebhook
Your settings will be sent to the easyWebhook loader in your script, it should look like this;
local settings = {
olddomain = "discord.com",
maindomain = "hooks.hyra.io",
HidePrints = false
}
... We are changing discord.com to hooks.hyra.io because ROBLOX now blocks requests going to the discord.com domain. The code will automatically replace discord.com with hooks.hyra.io
local easyWebhook = require(game.ServerScriptService:WaitForChild("easyWebhook"))
or if you wish to load the module via ROBLOX
local easyWebhook = require(8368541547)
As we now have required the Main Module, (assuming we have our Webhook's URL) we can now send requests.
With the following example
local settings = {
olddomain = "discord.com",
maindomain = "hooks.hyra.io",
HidePrints = false
}
local webhookurl = "https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
local easyWebhook = require(script.Parent.easyWebhook) -- Replace this line with the method you used to require the main module.
local Webhook = easyWebhook(webhookurl, settings)
local Success = Webhook:PostAsync(
{
content = "Hello!",
username = "noob",
avatar_url="http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=150&Format=Png&username=lua_exception",
embeds = {
{
title = "TITLE",
author = {
name = "LOSER",
},
description = "noober"
}
}
}
)
if not Success then
warn("There has been an issue sending the webhook request.")
else
print("Successfully sent webhook!")
end
... we can send content, username, avatar_url and embeds as easy as this block of text.
discord.club for making embeds easier to create