How to send a Discord webhook through Roblox

Introduction
Recently, Discord have blocked any Roblox related server IPs (Internet Protocols) from being able to send webhooks to Discord channels. You are still able to send them in studio since your own IP is being used when use press the play button on roblox studio. The reason that they have decided to do this is that most commonly webhooks are used for things such as to relay chats, and if a big game such as Adopt Me were to do this (which they were), a channel could be receiving over 10,000 chats a second.

Tutorial Requirements
For this tutorial, you will need to know how to use the Discord webhook API (Application Program Interface) and how to send a basic HTTP POST request using Roblox Studio.

If you do not know how to do this, you can find out how using the links below:

[Discord Webhook API]
[Roblox Post Documentation]

Send Webhook
To send a webhook from a Roblox server, you’ll have to use the Bloxrank API. The URL to send a webhook from roblox is: https://bloxrank.com/api/webhook

Now we know the URL we need to use, lets get straight to specifying our parameters. This API has two fields WebhookURL and WebhookData. We’ll specify these fields later on in the tutorial.

Since we’ve learnt the fundamentals, we’re ready to start building our code. You’ll want to create a table below such as the following. In my webhook I’ll be sending a webhook of me saying Hello!.

local data = {
    ['WebhookURL'] = 'https://discord.com/webhook/blahblahblah'
    ['WebhookData'] = {['username']='xG_andalf', ['content']='Hello!'}
}

Now we have the table, we’ll need to encode it ready to be sent to the Bloxrank servers. We’ll need to add a new variable called https

local data = {
    ['WebhookURL'] = 'https://discord.com/webhook/blahblahblah'
    ['WebhookData'] = {['username']='xG_andalf', ['content']='Hello!'}
}
local https = game:GetService('HttpService')
local data = https:JSONEncode(data)

Lastly, we’ll need to send our webhook, we can do this by using the https:PostAsync function. We’ll need to make sure that our content type is set to application/json. I’ve gone ahead and added a pcall function, which will catch any errors in the request which won’t spam your console or break your script.

local data = {
    ['WebhookURL'] = 'https://discord.com/webhook/blahblahblah'
    ['WebhookData'] = {['username']='xG_andalf', ['content']='Hello!'}
}
local https = game:GetService('HttpService')
local data = https:JSONEncode(data)

local success,errorm = pcall(function()
    https:PostAsync('https://bloxrank.com/api/webhook/', data, content_type=Enum.HttpContentType.ApplicationJson)
end)
Finished Result

If this helped you, please leave a like on this post. If you’d like to use Bloxrank for ranking users from Discord, you can invite it at: https://bloxrank.com/

34 Likes

Sweet! This is a very good method!

2 Likes

Thank you for your feedback, it’s appreciated!

1 Like

Thanks, this is very helpful :slightly_smiling_face:

2 Likes

I already knew how to do Webhooks, but this is a good tutorial! It goes in far more depth then any other sources I found. Good Job!

2 Likes

Thank you for your feedback! It’s very much appreciated.

2 Likes

Heya, this is an awesome workaround! It really does save loads of time and money, as otherwise developers would have to set up their and pay for their own proxy servers

2 Likes

Thank you! Are you aware that using the raw discord API will send a 403 (Access Error)?

1 Like

Thank you very much, I appreciate it!

1 Like

Please leave a like on the post if you found it helpful :happy1:

1 Like

API is up 24/7 so you shouldn’t encounter any issues and no rate limit is set in place. Highly recommend using this for your game/project.

1 Like

Developers are really obsessed with abusing Discord webhooks, huh? :tired_face:

I understand there are some good intentioned uses of them but I know for a fact that a lot of developers are just going to use them for logging that they should otherwise be doing through DataStores or proper services/software rather than a chat room.

I hope you have rate limiting there. It’s the very least you could do if you’re going to make a proxy assuming Discord doesn’t ban your proxy server when developers start abusing them again as usual. Gets old after a while to tell people they shouldn’t misuse features.

5 Likes

I beg to differ, in fact logging through discord offers a lot of advantages, such as staff being able to see them through channels. Yes, it can be abused in big games, but the servers are proxied through cloudflare. I appreciated your concern and I will take your feedback to heart and add a partial rate limit of 100 per second. Before a 5 minute timeout.

Thank you for your concern though, it’s very much appreciated.

1 Like

I’ll leave these two here (out of many other similar posts I’ve made, they’re just the most recent ones) and won’t comment further. It gets tiring after a while to keep telling people that perceived advantages of misusing webhooks to log are not real advantages and are just signs of complacency and laziness. This is why Roblox’s UserAgent got banned again to begin with.

3 Likes

UPDATE: Status codes now return for requests. On a successful request, a status code of 200 will return, etc.

1 Like

Does anyone have any suggestions on things I could make better? I am currently adding an API where you can add multiple embeds to the webhook.

1 Like

Hmm… This link doesn’t work.

1 Like

Overall, seems really good! Thank you!

Thank you! If it helped please leave a like. Also in your previous post, thank you for alerting me that the link didn’t work.

RobloxStudioBeta_skABpqjPbo
It shows red syntax on content_type
That’s obviously because it’s written in Lua format, but it’s supposed to be in JSON format
Can anyone help me please?
(Im new to this)