UI Transitioning To A Discord API/Webhook

Hello Everyone! In my game, it’s a generic Roleplaying Game. I would like to make a Function where inside a UI you can enter text and then it will send to a webhook/embedded message inside the Discord Server.


So far I have an amount of script to tell the Webhook to send a message and the webhook set up inside of the Discord Server. I am a little bit confused on how to make a certain type of UI (For Example TextBox) translate into a script telling the Webhook to make a message including the person who submitted that request and also any information inputted into the UI that is required. If anyone can please help me it would be greatly appreciated.

The Current Script That Is Here
local webHook = {}
webHook.__index = webHook

local Http = game:GetService("HttpService")
local url = Nope
--
function webHook.new(id,key) 
	local mt = setmetatable({id=id,key=key}, webHook) 
	return mt
end
function webHook:post(config,host)
	local data = nil
	local success = pcall(function()
		data = Http:JSONEncode(config)
	end)
	if not success then warn("Cannot convert WebHook to JSON!") return end
	Http:PostAsync(url, data)
end
return webHook
local http = game:GetService("HttpService")
game:GetService("Players").PlayerAdded:Connect(function(player)
end)
local url = Nope
local http = game:GetService("HttpService")

You better change that webhook if it is the real one.

1 Like

Thank you. I was thinking of screenshots and then I said no due to that… and I totally forgot. Now I must… change the webhook before someone starts doing… some stuff.

I believe that you want to get input from the Player and post it in Discord.
You’ll have to use RemoteEvents and TextBoxes for this. Here are some simple examples:
Local Script:

local InputEvent = PathToRemoteEvent
local TextBox = PathToTextBox

-- You can use different events for this, I'm going to use .FocusLost

TextBox.FocusLost:Connect(function()
local Text = TextBox.Text
InputEvent:FireServer(Text)
end)

Server Script:


local Webhook = require(WebhookModuleHere)

local InputEvent = PathToRemoteEvent

InputEvent.OnServerEvent:Connect(function(Player, Text)

-- Making a simple table for posting data, you can change this
local Data = {
["content"] = Player.Name.." has requested a Post! Here is the content: "..Text
}

Webhook:post(Data)

end)