Need help with roblox to discord send messages with a discord BOT, no webhook

local function sendMessage(content)
    local baseUrl = "https://discord.com/api/v9"
    local endpoint = string.format("/channels/%s/messages", channelId)
    local url = baseUrl .. endpoint

    local headers = {
        ["Authorization"] = "Bot " .. botToken,
        ["Content-Type"] = "application/json"
    }

    local payload = {
        content = content
    }

    local success, response = pcall(function()
        return HttpService:RequestAsync({
            Url = url,
            Method = "POST",
            Headers = headers,
            Body = HttpService:JSONEncode(payload)
        })
    end)

    if success and response.Success then
        print("Bericht succesvol verzonden naar Discord!")
    else
        warn("Fout bij het verzenden van bericht naar Discord:", response and response.Body)
    end
end
		sendMessage("Test")

In studio it works but in a roblox game not, http/api is on!

1 Like

Discord doesn’t allow http requests from roblox (Yes it works in studio, not in-game though.)

1 Like

When in play test http requests are sent from your pc since your pc runs the server and client.
When in an actual game you are connected to a server. Since HTTPService only works on the server the http request is sent from a roblox ip.
Discord doesn’t allow HTTP requests from roblox since people used to spam it. Search up how to use proxy servers to work around this.

Ahh, but how can i fix it? Because i know some persons who have this and sends this with a discord bot

Yes because discord bots are usually controlled by people’s custom servers which are not blocked by discord’s API. If you want to make your own bot you can but it would be a lot more challenging.

Instead I believe using a proxy website to send your webhook. A proxy website works by sending what webhook you want to another website, and then that website sends the data to discord and since that website isn’t blocked by discord it will work. There a few proxies and a few tutorials so you can simply search them up on the dev forum.

I have managed to achieve what you wish to accomplish by using a method described by @legs_v. The webhook request gets sent to a web server I have hosted, and that web server processes and sends the request to my discord bot. From there my discord bot does what it needs to!