Hi! I noticed that many people are paying too much money for a simple thing which is Discord Webhooks
So I decided to make a module to help people out!
This module is basically used to send discord webhooks through roblox, it is simple to use and helpful.
How can I use it?
-
Create your Webhook
To create your webhook, go to the channel you want the webhook to be sent into!
And then click on channel settings button!
Then choose integrations
Click on “Webhooks” and then “Create New Webhook”
Set your webhook up,
Click on “Copy Webhook url”, you will need the url later.
-
Now Let’s set the module up
MAKE SURE HTTPS REQUESTS ARE ENABLED IN STUDIO SETTINGS
Go to studio, and create a module script in ServerScriptService and name it “Discord”
And paste the following inside it
local Https = game:GetService("HttpService")
local module = {}
module.Send = function(Webhook, Data)
print(Data)
local NewData
local success, errormessage = pcall(function()
NewData = Https:JSONEncode(Data)
end)
if success then
print("Successfully Encoded Data")
else
error("Failed to encode data, Are you sure it is a table?")
end
local success1, errormessage1 = pcall(function()
print(NewData)
Https:PostAsync(Webhook, NewData)
end)
if success1 then
print("Successfully Sent Data")
else
error("Error: Failed to Send Data, Double Check your webhook url and your data.")
end
end
return module
Now we are done with the setup!
Now to use it through a script, you have to require the module by doing
local Discord = require(game.ServerScriptService.Discord)
To send something through it, you must make a table with the information you want to send like so.
Make sure to read this discord document about webhook structure first
local Data = {
content = "Hi",
embeds = {
{
title = "Discord Webhook",
description = "This is a discord webhook, it is excecuted through roblox!",
color = 255
}
}
}
Then you would want to send it by doing so.
Discord.Send("WEBHOOK URL", Data)
At the end the script would be like this
local Discord = require(game.ServerScriptService.Discord)
local Data = {
content = "Hi",
embeds = {
{
title = "Discord Webhook",
description = "This is a discord wbehook, it is excecuted through roblox!",
color = 255
}
}
}
Discord.Send("https://discord.com/api/webhooks/784193771356160021/oTZ2ZU_I4B9reQzg3UxU7HEIhDlDJZwXjUBBP-B4S9l-gcRr27q8wyEt0G9LjTOrAKCv", Data)
and the message would look like this
Example Usage:
local Discord = require(game.ServerScriptService.Discord)
game.Players.PlayerAdded:Connect(function(Player)
local Data = {
embeds = {
{
title = "A Player has joined!",
color = 255,
fields = {
{
name = "Player Name",
value = Player.Name
},
{
name = "Player Id",
value = Player.UserId
}
}
}
}
}
Discord.Send("https://discord.com/api/webhooks/784193771356160021/oTZ2ZU_I4B9reQzg3UxU7HEIhDlDJZwXjUBBP-B4S9l-gcRr27q8wyEt0G9LjTOrAKCv", Data)
end)
That will send a message when a player joins the game!
You have reached the end, enjoy the module
I know it is simple but many people need it
If you have any questions, reply to this topic and I will be happy to answer!