Before you start, make sure that you have enabled HTTP requests in the game settings.
To start, you will need a Discord Webhook. To create one, go into server settings.
Then go into integrations
Then create a webhook.
The channel is the channel the webhook will operate in. (Like sending messages)
Once you have finished, copy your webhook URL and keep it for later.
Once that is done, head into the studio and create a script, and in that script, put your webhook URL in a variable. Make sure to add the HTTP service. It should look something like this:
local WebhookURL = "Webhook url here"
local HTTP = game:GetService("HttpService")
Next, we need to set up something to send data to the Discord webhook.
Create a table called “Data” inside it, add ["content"] = "Hello!"
When you are done, it should look like this:
local Data =
{
["content"] = "Hello!"
}
For more info on how this works, you can go to Discord Developer Portal
Next to convert it to a JSON so our webhook doesnt error do:
Data = HTTP:JSONEncode(Data)
Lastly we need to send our data by:
HTTP:PostAsync(WebhookURL, Data, Enum.HttpContentType.ApplicationJson)
The finished code should look something like:
local WebhookURL = "Webhook url here"
local HTTP = game:GetService("HttpService")
local Data =
{
["content"] = "Hello!"
}
Data = HTTP:JSONEncode(Data)
HTTP:PostAsync(WebhookURL, Data, Enum.HttpContentType.ApplicationJson)
When you run it you should see this:
If so you have finished the tutorial.
Congrats!
Well I hope this helped anybody trying to do this.