How to send messages to discord from roblox with heroku

:warning: This may be impossible soon, be weary!

Hiya everyone!

Recently I got a post from @cam, I am a little late to the information, but as you may or may not know discord blocked roblox from using proxies.

I made my own little fix to this via using a webserver running python fastapi and a free Heroku server. (Running on 20 lines of code).

It’s super simple and easy to use.


Tutorial:

Github Repo: Discord To Roblox (github.com)

To get started click the button down below:

Deploy

Once you’ve done that, it should take you to a screen.

Follow these steps:

For App Name, make up a name.

For a region, choose the closest one to you!

In “Discord_Webhook” paste your Discord Webhook URL:

Image from Gyazo

For Website_Api:

Enter a random string, make sure you remember the string.


Deploying and running in roblox.

To deploy your app.

Press the button and scroll down.

When the view button appears click it.

Copy the link:

and add a “/” onto it. (Your URL will be different to me.

This means “https://discordtorobloxwebhook.herokuapp.com” becomes “https://discordtorobloxwebhook.herokuapp.com/”.

Now, to start to run it on ROBLOX:

Add this script to ServerScriptService:

local HttpsSerivce = game:GetService("HttpService")
local Server_Url = "" --Put your App_URL here. 
local Api_Key = "" --API key we made here.
local Complete_Url = Server_Url.. "discord"


local function SendDiscord(DscMsg)
	local Req_Url = Complete_Url .."?Key=" ..Api_Key.. "&Message=" ..DscMsg
	print(Req_Url)
	local Request = HttpsSerivce:GetAsync(Req_Url)
	local data = HttpsSerivce:JSONDecode(Request)
end


SendDiscord("Hello from roblox!") --Send a message, customize by editing the string!

In Server_Url, put the url where you put a “/” onto it.

Remember the Api_Key we made, paste it into the string for Api_Key.

Example script:

local HttpsSerivce = game:GetService("HttpService")
local Server_Url = "https://discordtorobloxwebhook.herokuapp.com/" --Put your App_URL here. 
local Api_Key = "df0ef802efm2m8f2e-8f82e8f028mfe-" --API key we made here.
local Complete_Url = Server_Url.. "discord"


local function SendDiscord(DscMsg)
	local Req_Url = Complete_Url .."?Key=" ..Api_Key.. "&Message=" ..DscMsg
	print(Req_Url)
	local Request = HttpsSerivce:GetAsync(Req_Url)
	local data = HttpsSerivce:JSONDecode(Request)
end


SendDiscord("Hello from roblox!") --Send a message, customize by editing the string!

(Make sure HTTPS requests are on)

Image from Gyazo

Then use the function how you want to send requests!

There you go!

image


I hope you enjoyed this tutorial, if you have any issues feel free to reply down below!

Thanks for reading,

@Noah

3 Likes

Thank you so much cookie, this will help me a ton!

1 Like

Great tutorial! This is really helpful to know.

1 Like

How would you send Embeds with it?

2 Likes

To send an embed you will need to edit the code.

Make your own repo & change (Fork this) & change the main.py to this:

from fastapi import FastAPI
import os
import requests
Discord_Webhook = os.environ.get('Discord_Webhook')
Website_Api = os.environ.get('Website_Api')

def SendMessageToDiscord(Data):
    requests.post(Discord_Webhook, data=Data)

app = FastAPI()

@app.get("/discord")
async def read_items(Key: str, Message: str):
    if Key == Website_Api:
      SendMessageToDiscord(Message)
      return "Success"
    else:
        return "Incorrect key"

Then send a request from roblox:

local data = 
	{
		["content"] = "",
		["embeds"] = {{
			["title"] = "__**Ultimate Title**__",
			["description"] = "blah blah",
			["type"] = "rich",
			["color"] = tonumber(0xffffff),
			["fields"] = {
				{
					["name"] = "__Title__",
					["value"] = "hi",
					["inline"] = true
				},
				{
					["name"] = "__Title__",
					["value"] = "hi",
					["inline"] = true
				}
			}
		}}
	}

local HttpsSerivce = game:GetService("HttpService")
local Server_Url = "https://discordtorobloxwebhook.herokuapp.com/" --Put your App_URL here. 
local Api_Key = "df0ef802efm2m8f2e-8f82e8f028mfe-" --API key we made here.
local Complete_Url = Server_Url.. "discord"


local function SendDiscord(DscMsg)
	local Req_Url = Complete_Url .."?Key=" ..Api_Key.. "&Message=" ..DscMsg
	print(Req_Url)
	local Request = HttpsSerivce:GetAsync(Req_Url)
	local data = HttpsSerivce:JSONDecode(Request)
end


SendDiscord(data) --Send a message, customize by editing the string!


I haven’t tested it so tell me if you encounter any errors!

1 Like

Thank you! I appreciate your help.

1 Like

I got an problem. And it’s on roblox with that script for embdeds. Yes, I did set up everything how it is supposed to be and on the repos and stuff. The problem is in roblox. It can’t concentrate a string to an table or something. Don’t remember the error.

Can you make a #scripting-support post?

Yea, sure. I’ll do that

2 Likes

Works great, thanks @Noah. I am currently modifying a suggestion system with this so I can send suggestions thru my own Heroku link.

(Finally now I don’t need to use this anymore.)

After that how do you do the line? (Sorry for the bump and off topic!)

Sorry, what do you mean by that?

Nvm its fine, I was just asking how to do the horizontal line after what you said, I found out now anyway.

With this @Noah, I was having the same issue as @CrDev and couldn’t find the scripting support post you asked them to create. So do you have any update you can give me on this or what the fix to the error is? Thanks!

Hello & welcome to the cookie tech forums! :hugs:

It looks like @CrDev never made a scripting support post, you can make one to your liking.

Does this have ratelimiting? Because we dont want our proxy’s banned from discord too…

You shouldn’t be concerned of rate limiting. If you’re getting rate limited by discord it means you’re not using a discord webhook properly, if you’re getting rate limited it means you’re overusing the discord API which is unusual, so make sure that if you do get rate limiting issues you stop sending requests to discord & work out what is sending so much.

I suggest you add ratelimiting so only 10 requests per min.

That’s not really how rate limiting works, ask the experts:

image

100 requests for one time might be okay, but 50 requests every so and so might not be okay, there is no point in limiting, if you’re getting rate limits from a discord webhook you’re often using it for the wrong thing - I’m curious, in what scenario would you need to use a discord webhook so that your at the risk of getting rate limited.

I really dont know.

wjhjd