Discord to Roblox API

I want to write a new discord.lua API that you can use on roblox as a bridge between discord and roblox - for example, receiving a message in a text channel on discord will output a (filtered) message in roblox’s chat.

The problem is I have no idea where to start because I have no idea how to add use eventlisteners with HTTPService so connecting a discord.js bot and HTTPService to the same host would be useless. Secondly, I don’t know how to send requests to my roblox game specifically which doesn’t help.

I have tried searching everywhere online for help with this but apparently this has never been done before (or someone wants to keep their secrets).

If you could comment or DM me to help me with this, that would be much appreciated.

Edits:

  • I found a new Database website called restdb.io - it functions just like MongoDB (mlab.com) but it also works with roblox’s http service via an API key unlike MongoDB. One step closer to making discord to roblox a thing.
3 Likes

You will want to use a bot of some sort that detects messages being sent and then you want to pipe them to some off-site (non ROBLOX domain) server that your ROBLOX servers would occasional check. If there is new information then use it.

Here is the discord.js API:

Here is the roblox API:

https://developer.roblox.com/en-us/api-reference/function/HttpService/GetAsync

If you want to setup up a quick server you can use your own network and use port forwarding to your nodejs application. To create a server on your network using node you use the http module and its createServer function.
https://nodejs.org/api/http.html

i wanted to try the same thing a few months ago but i failed
i can give you my concept:
httpservice has a function called :GetAsync() wich will return a JSON encoded value from the api url. then you can use :JSONDecode() to return a table value and work further with the table.
Now to send that code from the bot side i highly recommend using discord.js.
So you just need:

  • a bot that detects the message
  • a JSON api URL
  • a script in game that can decode the given values

Further i wish you good luck!

See, that was my initial approach. But then I thought how do I know when the message is sent? It’s not like I can call it FROM the discord bot’s script.

you can create a script in your bot that can detect if the messaged got processed succesfully or not,

???

You want to detect the message from the Discord server by using the bot to do it. The bot then pipes the information to your middle man server and then the ROBLOX servers will occasioanly check the middle man and will filter and broadcast the data.

To get a message from a discord.js ran bot you can use client.on("message", callback) where callback gets called with a message object with the content, author, and more about the message posted.

So how would I tell roblox that the message has been received.

Upload a message to your server and have the roblox server make occasional requests. If there is a “whoa I received your message” type code then well, you know it was received.

My server meaning? Could I use something like Heroku and use MongoDB as a database; have roblox loop through the database, grab the author name, message content and then remove it from the database?

I’m not familiar with Heroku or MongoDB but those probably would work.

Anything more efficient than that or?

You are required to make a web call in this type of scenario, so probably.

Turns out mongoDB won’t work as they don’t do API keys anymore. No other way to connect to a database. Sad times.

You can use quick.db database.