Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I use http requests?

Asked by 7 years ago

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

Log in to vote
0
Answered by 7 years ago

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.

Ad

Answer this question