Categories > Coding > Lua >

Send a message to a discord webhook script

Posts: 205

Threads: 9

Joined: Feb, 2023

Reputation: 5

Posted

A simple script that send a message to a discord webhook.

Hoped it helped you guys c:

 

Note:

Works on all exploits that support the request() function. If you use Synapse you need to modify the code to use syn.request instead of request, Read the synapse docs if you don't know how to modify.

function SendMessage(url, message)
    local http = game:GetService("HttpService")
    local headers = {
        ["Content-Type"] = "application/json"
    }
    local data = {
        ["content"] = message
    }
    local body = http:JSONEncode(data)
    local response = request({
        Url = url,
        Method = "POST",
        Headers = headers,
        Body = body
    })
    print("Sent")
end

function SendMessageEMBED(url, embed)
    local http = game:GetService("HttpService")
    local headers = {
        ["Content-Type"] = "application/json"
    }
    local data = {
        ["embeds"] = {
            {
                ["title"] = embed.title,
                ["description"] = embed.description,
                ["color"] = embed.color,
                ["fields"] = embed.fields,
                ["footer"] = {
                    ["text"] = embed.footer.text
                }
            }
        }
    }
    local body = http:JSONEncode(data)
    local response = request({
        Url = url,
        Method = "POST",
        Headers = headers,
        Body = body
    })
    print("Sent")
end


--Examples 
local url = ""
SendMessage(url, "Hello")


local embed = {
    ["title"] = "This is an embedded message",
    ["description"] = "This message has an embed with fields and a footer",
    ["color"] = 65280,
    ["fields"] = {
        {
            ["name"] = "Field 1",
            ["value"] = "This is the first field"
        },
        {
            ["name"] = "Field 2",
            ["value"] = "This is the second field"
        }
    },
    ["footer"] = {
        ["text"] = "This is the footer text"
    }
}
SendMessageEMBED(url, embed)

  • 2

Added

@bennytrt,

 

Thanks Bro :sunglasses:

  • 1

https://media.discordapp.net/attachments/1134643100715855893/1138795549244539011/SiggyOnGod.png

Murz

PixelPenguin

Posts: 237

Threads: 20

Joined: Jul, 2021

Reputation: 28

Replied

Very good, however it has security flaws as every roblox script does that includes webhooks on the client side.

 

I would recommend actually sending messages through an external server that you own.

 

I recommend maybe writing something quickly in php (if you do not know it that is fine! just giving some tips for the future if you didn't know,) that can essentially do the same thing. It will take up less lines if done correctly, while also being more secure, and you can even include a filter to prevent spam!

 

Albeit, this was a great project that you have made. I didn't even think it was possible in Roblox using the HttpGet service as when I tried one time in development for a Roblox game it failed. Keep up the great work!

  • 0

 

Ty for rep: Swiney, Byoke, Lion, Locust, Waves, Weeb, Nickk, darkn, Atari, CubeFaces, Lux14, Rice, Delta, Syraxes, Aeon, Jordan, Pluto, and Hiroku!

P.S, I like cats better too!

Posts: 205

Threads: 9

Joined: Feb, 2023

Reputation: 5

Replied

@Murz, Thanks for your tips and feedback, I'm glad you liked it :)

  • 1

Added

@RealNickk, Ooh, thanks for the idea lmfao

  • 1

Added

@atariXD, I understand but I don't know PHP much, I'm willing to learn though.

  • 0

https://media.discordapp.net/attachments/1134643100715855893/1138795549244539011/SiggyOnGod.png

Posts: 1381

Threads: 71

Joined: May, 2022

Reputation: 17

Replied

@Murz you lost me at "external server"

  • 0

Did I mention I use arch btw?

Murz

PixelPenguin

Posts: 237

Threads: 20

Joined: Jul, 2021

Reputation: 28

Replied

@Whoman,

 

I am sorry... Also hi Whoman, I remember you from a while ago! I used to see you active a lot more but not as much recently. I am glad to see you still actually sometimes visit the site! How have you been, my friend?

  • 0

 

Ty for rep: Swiney, Byoke, Lion, Locust, Waves, Weeb, Nickk, darkn, Atari, CubeFaces, Lux14, Rice, Delta, Syraxes, Aeon, Jordan, Pluto, and Hiroku!

P.S, I like cats better too!

Posts: 1381

Threads: 71

Joined: May, 2022

Reputation: 17

Replied

@Murz yeah there just hasnt been that much on wrd, just "rate this ui" with the most basic ui ever and "omg jjsploit no work im literally gonna die" or crazy code that i dont understand 

  • 0

Did I mention I use arch btw?

Murz

PixelPenguin

Posts: 237

Threads: 20

Joined: Jul, 2021

Reputation: 28

Replied

@Whoman,

 

fair enough, that is true.

  • 0

 

Ty for rep: Swiney, Byoke, Lion, Locust, Waves, Weeb, Nickk, darkn, Atari, CubeFaces, Lux14, Rice, Delta, Syraxes, Aeon, Jordan, Pluto, and Hiroku!

P.S, I like cats better too!

yvneEnvy

<><><<>>><<>

Posts: 298

Threads: 47

Joined: Mar, 2023

Reputation: 3

Replied

Uhh cool, vouch

  • 0

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )