Help with discord webhooks

If I understood you correctly, if someone sends certain message inside a discord server, then an event fires in Roblox?

yeah in a certain admin channel or something like that but yes

I don’t really deal much with that. I believe there might be an API to do that, but I do not know which.

It’s pretty easy, put this script in ServerScriptService and then fill in what you need. If you wanna change so it says “player has said lockdown” or something along those lines, tell me and I’ll gladly help you with it!
I’ve tested this and it works perfectly! Just make sure if this is going to affect something set up permissions so the webhook only gets sent if they are a certain user (ex: An Admin)

local HttpService = game:GetService("HttpService")
local URL = "Discord Webhook URL here"

	local Data = {
		["content"] = "TEXT HERE"
	}
	Data = HttpService:JSONEncode(Data)

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg) 
        if msg == "MESSAGE HERE" then 
         HttpService:PostAsync(url, Data)
        end
    end)
end)

Hopefully this works for you.

Have a great day and Happy Holidays! :santa:

1 Like

I think OP meant the other way around. He wants to listen for a discord message, not a roblox message. They would have to poll Discord every few seconds or so to check if a message was posted, since you can’t really set up event listeners for things happening on other websites.

1 Like

What will happening if your Webhook is accessible on the client

  1. The exploiter will get the link
  2. The exploit will spam the Post request
  3. Discord will delete your Webhook and warn you becose you are sending too many request
    Basically don’t trust the client, do the action on a server script

Also, for what you want to do you don’t need webhooks but Bot

Oh- then that most likely is impossible since Roblox can’t listen to Discord messages like a bot would do, unless a Discord bot does something with HttpServices on Roblox but it seems like that may not work.

1 Like

The exploiter can’t get the link, they can only access localscripts and they can’t see anything inside of ServerScriptService.

Ho yea i don’t see the PlayerAdded I thought it was a local script

@Med367367

I don’t think anyone mentioned anything about this code being on the Roblox players’ client. Local scripts can’t make HTTP requests, anyway.

@uhBlame

In my last reply I said that the only way to detect a message posted in discord would be to send requests regularly to check if there are new messages.

All good brother. We all make mistakes :stuck_out_tongue:

How would you be able to check if there was more messages sent in a Discord channel?

With a discord bot x’)
The problem is, you need to heberge it and get the data with a HttpService request. I would have proposed Glitch except that it no longer accepts discord bot for the moment

That makes more sense, I mean if OP wants to do all that, it’ll be out of ROBLOX devforums for the first part so we most likely couldn’t aid OP for a while.

Check this out.

1 Like

i mean the client can’t send a post request so there shouldn’t be any reason the webhook would be in client reach.
image

Also, Discord doesn’t delete your webhook for sending too many requests.

1 Like

yea, i was not know that but now i know but thx for the information

You can do that with a discord bot, a spreasheet and a roblox script. I did it in past, it’s pretty long to do. Check this.

it never worked, i tried it and went over for a couple hours and it never worked.

Just make a bot that listens for messages in a channel, and if it detects the message yu want it fires an API, roblox can then watch for the API request to be sent, when it is it will fire the event.

These articles MIGHT help you.: