Roblox to Discord Bot

how do I create timestamps in webhooks?

1 Like

You can send that information to the webhook when you make a POST request to it.

You can do it with a bot, You would need to create a backend server to recieve the data and then send it.

1 Like

Webhooks are absolutely not the only way to achieve that.

There are several ways to create a Discord bot, but you’ll need a computer (or a virtual instance) running it. You’ll also need a basic understanding of networking and http requests.

I personally recommend Discord.js, a JavaScript library to help you write your bot, w3’s introduction to Node’s http servers to learn how to enable your Roblox game to communicate with your bot and OVH services if you need an affordable virtual instance running the bot.

3 Likes

You would need something like an express server to send the data in the headers, which then you can send the Embed / message with them headers to that certain channel. its just more work to be done.

Next time, please don’t ask people to create entire systems for you.

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category. - About the Scripting Support category


There are a couple ways on how to have a Roblox game server communicate with Discord.

First, you can use webhooks to post data from the game server via HttpService
to post data from the Roblox server to the Discord webhook. There’s a guide on the DevForum to help you get started on it.

Another way is to use a Discord bot via an HTTP server. Using HttpService, the game server sends a request with the data as headers, as @HmmBilly said.

I’d recommend using webhooks instead of a Discord bot, which is much easier to setup. You don’t have to setup an HTTP server so that you can send data to the bot.

2 Likes

If your running your bot on a Node.js vps i suggest you make a request using HttpService to your server and handle it with express.

So I am hosting my bot on heroku. how do I send http requests to heroku?
@spicychilly2 @Jaguar515_YT @HmmBilly @incapaxx @Flubberlutsch

It’s hard to make Discord bot to handle your game requests. I highly recommend you use webhook to get started go here Click here

I have never used heroku before.

I already have a webhook for the hatchings system. But if I want other server to see what pets I hatched then I could just invite the bot.

Use HttpService to send a request to Heroku.

-- This is a little example of how to send a GET request to the Heroku server. It should be used as a reference.
-- If you want to send more than GET requests, you can use HttpService:RequestAsync(). Check out the documentation of it for more details.
-- https://developer.roblox.com/en-us/api-reference/function/HttpService/RequestAsync

local HttpService = game:GetService("HttpService")
local url = "" -- your heroku url here

local response

local success, err = pcall(function()
      response = HttpService:GetAsync(url)
end)

if success then
   print("success")
   print(response)
else
  warn(err)
end

May I just ask what heroku url?

Like this:

[appname].heroku.com (appname will be different since you created an app with a different name)

its says Application Error ? will it still receive http requests

Application Error means that there is an error in your Heroku app code. See this article for more details.

Its not hard to make one, as i said before. Its just not needed work.

The solution u sent didnt work! so my quesions is that can u see send http request to the heroku url? and how would I receive the msg in node.js

If you mean being sending HTTP requests to the Heroku App URL, then yes.

If you want to receive a message from your Node.js server, then here’s how you can do it.

You’ll need to utilize a POST HTTP request in order to receive messages. POST requests send data to a server.

There are many ways you can recieve POST requests, however, I usually do it like this. You’ll need to install two npm packages - express.js and body-parser.

From the command line, initialize a project if you haven’t already:

npm init

Then, execute these two commands (make sure npm is installed!)

npm install express
npm install body-parser

Now, enter in this code in a .js file:

const express = require('express')
const bodyparser = require('body-parser')

const app = express()
var port = 8000

app.use(bodyparser.text())

app.post('/post', (request, response) => {
    response.send("Gotten POST request")
    console.log(request.body)
})

app.listen(port, function(){
    console.log(`started server at http://localhost:${port}`)
})

Start the server via node index.js (or whatever your file name is).

Test it out by sending a POST request from Roblox:

local HttpService = game:GetService("HttpService")

local options = {
	Url = "http://localhost:8000/post", -- or whatever url. this is mainly for example purposes.
	Method = "POST",
	Headers = {
		["Content-Type"] = "text/plain"
	},
	Body = "Hello world!"
}

local success, msg = pcall(function()
	local response = HttpService:RequestAsync(options)
	
	if response.Success then
		print("Status code:", response.StatusCode, response.StatusMessage)
		print("Response body:\n", response.Body)
	else
		print("The request failed:", response.StatusCode, response.StatusMessage)
	end
end)

if not success then
	print(msg)
end

6 Likes

The roblox can send http requests. But the thing is in node.js how do I receive it? I am a custom domain, is there any different I have to do?