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

i need help with Discord webhook?

Asked by 4 years ago

before i ask, yes i have a proxy for the discord webhook already, i have made an anti exploit and its fully working but i need help so if a player gets caught by the anti cheat the discord webhook will log it on discord using a remote event i just dont know how to do it, i would appreciate the help!

0
Please show a script so we can ACTUALLY help you. harstud 218 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

I can maybe help! Add me on discord and i will help you making the anti-exploit webhook logs. I am good at those parts.

My discord: Pegasus#7160

Thank you!

Ad
Log in to vote
0
Answered by
Nefarioum 162
4 years ago

Hey, in order to communicate with the discord you shouldn't need to use a proxy. As far as I am aware, the communication between ROBLOX and Discord can be done directly so you can use the webhook provided by the webhooks section of Discord.

As to your question, to begin with you will need to have a webhook linked to a channel and you will require the URL for that webhook. You can do this by creating your own server or simply asking for administrator privileges on a server. You then would go into the server settings and then head to the Webhooks tab.

Create a new webhook, choose a name and then you can pick an image if you wish and what channel you would like it to be posting to. Then you'll need the most important part; the URL. Copy this URL and store it on a notepad or somewhere safe as you'll need it to communicate to your discord server. Do not share this URL as anyone with it would be able to spam your server with notifications.

Now, moving onto the scripting part, you mentioned you want to do this through remote events however I would highly not recommend this as an exploiter can fire the remote and spam your discord server. If you really want to use discord for logging people exploiting, you'll need to migrate or make your anti-cheat function on the server.

Anywho, you'll need the following code which you can create as a function and then call if you want to make life easier and I'll showcase how this would be done as well if you would like to take that route of doing things:

Note: Please make sure that HTTP Requests are turned on in Game Settings in order for this to work!

local HTTPService = game:GetService("HttpService") -- This is calling the HTTPSerivce which is used to handle requests 
local DiscordURL = "https://discordapp.com/api/webhooks/-/-" -- Paste the URL you got from the discord webhooks page here. Make sure this is not shared with anyone!

local DataToSend = {
    ["content"] = "A player has just been banned!"} -- The message content would go in here which you'd be sending to your server

DataToSend = HTTPService:JSONEncode(DataToSend) -- Discord will only accept data which is in the JSON format and therefore we encode it to a JSON before sending it
HTTPService:PostAsync(DiscordURL, DataToSend) -- Finally, we post the JSON we made to the webhook URL.

However, with the code above it would just send the message once when the server is ran and it will not run again. Therefore, I would recommend making a function and passing through the player and the reason they were banned from the anti-cheat and then running the function to give you a better understanding of who and why they were banned.

function DiscordLog(name, banreason)
    local HTTPService = game:GetService("HttpService")
    local DiscordURL = "https://discordapp.com/api/webhooks/-/-"

    local DataToSend = {
        ["content"] = "The server has just banned **"..name.."** for "..banreason.."."} -- This time, we are sending the name of the player as well as a reason

    DataToSend = HTTPService:JSONEncode(DataToSend)
    HTTPService:PostAsync(DiscordURL, DataToSend)
end


DiscordLog(player.Name, "hacking") -- This would be called right before the player is banned.

That is all I have to show, you can go even further by sending out Embeds with a snapshot of the exploiters avatar and links to their profile and even what they exploited however without any code provided it would be hard to properly assist with this plus it is out of the scope of the question. Hope this helps!

Answer this question