Discord Integration: A guide on using Discord through Roblox [UPDATED]

This is a good thing, but the one this is that Discord dont like you uploading too many logs and data to the servers.

I’ve recently made a module for this. It contains many features including webhook creation and utilization, API status updates, embed formatting, and more!

Feel free to check it out
https://www.roblox.com/library/3427317493/Dicxord-API
Here’s an example script I made real quick.

local Discord = require(3427317493)
local Webhook = Discord:GetWebhook("URL")

Webhook:Post({
    Content = "Hello World!"
})

Webhook:Post({
    Embeds = {
        Discord:CreateEmbed({
            Title = "Hello";
            Type = Discord.EmbedTypes.Rich;
            Color = Color3.fromRGB(0, 0, 200); -- will be converted
            Description = "Hello from ROBLOX!";
        });
    };
})

Discord.StatusChanged:Connect(function(oldStatus, newStatus)
    if not NewStatus == Discord.StatusTypes.Operatioal then
        print("Discord's API isn't operational")
    end
end)
3 Likes

Discord webhooks have a certain limit, you can use them, but if too many requests are sent from ROBLOX to Discord you can get your ip blocked from using Webhooks.

To bypass this you can try and make it be sent through a discord bot.

I don’t know if this was when Discord blocked requests from roblox but if it was then that was the reason.

1 Like

To make a ordering system you’d need a gui I’m assuming which is firing a function (with the arguements you require) and in a server script you’d find out when it was fired (and the arguements) and send that to a discord webhook. If you need the code let me know.

Hi, I don’t know much about discord webhooks, but it seems pretty easy in the tutorial.
I have also never used textboxes.

I would like to make a textbox that people can click on and leave feedback for my game and have it sent to discord. (I really don’t care if it is sent to discord or saves some other way, but this seemed like the best way to do it.)

Any advice on how to get started?

I am assuming I would do something like this:

local http = game:GetService("HttpService")
local textBox = script.Parent
local function onFocusLost(enterPressed)
    if enterPressed then
        local Data = {["feedback"] = textBox.Text}
        Data = http:JSONEncode(Data)
        http:PostAsync(" ", Data)
    end
end
textBox.FocusLost:Connect(onFocusLost)

with my webhook link in the quotes?

Change [“feedback”] to [“content”] otherwise yes

1 Like

I got the player added one to work, but I couldn’t get the feedback to work.
I think it is because I have a script running in StarterGui because a local script won’t work.
I think I have to make a remote event fire with a local script and then execute the code in a regular script.
I have having a little trouble. Any ideas?

Here is the script in serverscriptstorage that is throwing an error that says HTTP 400 bad request in line 8:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local feedbackEvent = ReplicatedStorage:WaitForChild("FeedbackEvent")
local http = game:GetService("HttpService")

local function onFeedbackFired(plr)
    local Data = {["content"] = plr.PlayerGui.Feedback.TextBox.Text}
    Data = http:JSONEncode(Data)
    http:PostAsync("[discord link]", Data)  -- error is here but i have actual discord link in there
end

feedbackEvent.OnServerEvent:Connect(onFeedbackFired)

and here is the local script:

local textBox = script.Parent
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local feedbackEvent = ReplicatedStorage:WaitForChild("FeedbackEvent")

local function onFocusLost(enterPressed)
	if enterPressed then
		feedbackEvent:FireServer()	
    end
end
textBox.FocusLost:Connect(onFocusLost)
1 Like

The issue is you are reading the .Text property on the server. Any input in the TextBox from the client does not replicate over to the server. I would recommend passing the .Text property’s as an argument when you’re calling the :FireServer() function.

1 Like

Thanks.

I tried this

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local feedbackEvent = ReplicatedStorage:WaitForChild("FeedbackEvent")
local http = game:GetService("HttpService")

local function onFeedbackFired(textdata)
    local Data = {["content"] = textdata}
    Data = http:JSONEncode(Data)
    http:PostAsync("[discord link]", Data)
end

feedbackEvent.OnServerEvent:Connect(onFeedbackFired)

with this in the local script

local textBox = script.Parent
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local feedbackEvent = ReplicatedStorage:WaitForChild("FeedbackEvent")

local function onFocusLost(enterPressed)
	if enterPressed then
		feedbackEvent:FireServer(textBox.Text)	
    end
end
textBox.FocusLost:Connect(onFocusLost)

I feel like should be returning the value instead maybe? This is not working. Sorry I am new to remote events and functions.

The first parameter of the .OnClientEvent is always the player who fired it then every parameter after is what you set through the function. So you should be doing onFeedbackFired(plr,textdata).

1 Like

ah okay, I took that out and didn’t know it was plr by default.

This works perfect. I am going to add a debounce so it can’t be spammed, but it will really help take notes while play testing and to get feedback from new players.

Final code if anyone needs it:
This is the script in serverscriptservice

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local feedbackEvent = ReplicatedStorage:WaitForChild("FeedbackEvent")
local http = game:GetService("HttpService")

local function onFeedbackFired(plr, textdata)
    local Data = {["content"] = plr.Name.." said "..textdata}
    Data = http:JSONEncode(Data)
    http:PostAsync("[discord webhook]", Data)
end

feedbackEvent.OnServerEvent:Connect(onFeedbackFired)

Here is the local script inside a textbox:

local textBox = script.Parent
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local feedbackEvent = ReplicatedStorage:WaitForChild("FeedbackEvent")
local debounce = false

local function onFocusLost(enterPressed)
	if enterPressed and debounce == false then
		feedbackEvent:FireServer(textBox.Text)
		debounce = true
		wait(5)
		debounce = false	
    end
end
textBox.FocusLost:Connect(onFocusLost)
2 Likes

Awesome! I am glad you got it working. Also, I would recommend adding some more checks on the server-side because right now someone can spam the remote and cause the webhook to be deleted, your server to be deleted, and/or your Discord account to be deleted.

1 Like

Do you think it would be against the Discord rules if I made the bot just post every single message in my game to my discord, so I have like a chatlogs channel on my discord?
@Cinema_Sin

Well yes, Discord webhooks aren’t supposed to be used as a logging system. There are plenty of services out there which are intended to be used for logging purposes.

3 Likes

This definitely isn’t true. I believe that Roblox’s chat filter tags “Discord” as they want to be able to audit the servers that the community is being funneled to, should it come to that.

You are able to select a “Discord” server as one of your group’s three linked social media sites, so they clearly haven’t “banned” it.

1 Like

Hey there! Great tutorial! One question about webhooks. Do you know if there is a way to report a webhook? I believe it is frowned upon to make a player join counter because it spams the API, and has gotten the Roblox API banned from using webhooks. Anyways, there is a server I have found doing this, and I wondered if there is a way to report it and not ruin it for the rest of us. Does anyone know if there is a way?

This is only for account <13. Discord links have always been allowed, just limited due to COPPA.

That is handled on Discord. The first time was kind of Discord’s fault due to not planing for that.

1 Like
local http = game:GetService("HttpService")
local Data = {
	["content"] = ("player: " ..game.Players.LocalPlayer.Name)
}

Data = http:JSONEncode(Data)

http:PostAsync("", Data) --Put the link you saved between the two quotes.

what player will this show up as

You can not use HttpService on the client.