Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I use http requests?

I am trying to make a text box that the player can type in and click submit then it sends it to the discord server via web hooks. I am not asking for a script. I just want some ideas on how to do this and maybe some tutorials with http service. Thanks

1 answer

✓ Accepted answer

Hey, buddy! First Enable Http Service.


This is the discord web Hook:

local WebhookAPI = {}
local WEBHOOK
local GITHOOK
local HTTP = game:GetService("HttpService")

local success = pcall(function()
	if not HTTP.HttpEnabled == true then
		HTTP.HttpEnabled = true
		return true
	end
end)

repeat wait() until success == true

function WebhookAPI.DiscordAddWebhook(url)
	WEBHOOK = url
end
function WebhookAPI.DiscordPost(obj, ttsr, contentr, player)
	local Message = HTTP:JSONEncode({
		username = player.Name.." - (#"..player.UserId..")";
		tts = ttsr;
		content = contentr
	})
	HTTP:PostAsync(WEBHOOK, Message)
	return "Feedback recieved!"
end
function WebhookAPI.DiscordEdit(newcontent)
	local Edition = HTTP:JSONEncode({
		content = newcontent
	})
	HTTP:PostAsync(WEBHOOK, Edition)
end
function WebhookAPI.DiscordThrowError()
	local Message = HTTP:JSONEncode({
		username = "Error";
		content = "Error thrown! Uh oh!"
	})
	HTTP:PostAsync(WEBHOOK, Message)
	return "Feedback recieved!"
end

return WebhookAPI

Now if you'd like to set it to your preferences for your other script, use these commands:

local WebhookAPI = {}
local WEBHOOK
local GITHOOK

Hope this helps a bit, if your having trouble, DM me via roblox and I can be happy to set the api up for you.

This discussion is preserved as it was. New answers, comments, and votes are closed.