How can i communicate from discord to roblox?

I want to be able to send command info to Roblox. Basically i have a thing where you can buy in game currency with coins in discord which you get by actively participating in the community.

So I’ve searched around and found some articles. Most tho are about using google sheets. I try using it but so far I’ve had no luck.

i can post the code for the bot tomorrow as i need to head to sleep now.

Can you help me? thanks.

1 Like

You can’t really do that directly.

As long as your Roblox game has at least one server up and running at all times, this is theoretically possible. You could poll for requests in a server script every minute or so, and you could have the discord bot send the request when a user buys currency. Upon receiving the request, IncrementAsync could be called on the user’s currency data.

Use HTTP Service.
Build a PHP server that allows Post and Async, there is so many tutorials on it, it should be easy.

Aslong as a server for your game is open you can control the game through a website, you will need to set up a loop to check the website for changes every so often.

Personally I have a discord bot set up to ban users universally on my game, to do this I have a website that pulls information from a MYSQL server, when a player joins I send a request to the HTTP server I’m hosting and ask for the Database of banned user ids, then I cross check that list of ids against the new player who joined and if they are in the database ill kick them from the game. By simply adding to the SQL database through a discord bot you store bans by yourself which gives you full control over banned players.

I got some spare code somewhere if you need help.

The only way to do this would be to use HttpService like others are mentioning. I wouldn’t recommend Http polling though, instead I would recommend using a different technique which I forgot the name of since its a lot faster.

Basically, your Roblox server can submit a request to your web server (you can host Node JS servers for free with services like Heroku, and, you can have your bot and web server in the same piece of code). Your web server doesn’t respond with anything at all, instead it just puts the request into a list without sending anything back. Then, your Discord bot will go over all of the pending requests and submit a response to each pending request whenever something should happen. This is pretty much instant, its just about as fast as a websocket but you can’t send as many messages as quickly.

The best way is usually to add all of the events you want to send to your Roblox servers into a list and keep track of the time the event was created. Whenever a Roblox server opens a request to your web server it can send the last time it received events (using os.time()) and you can respond with all of the events that happened after that time if there are any, otherwise you can wait for one and once you get one send it back.

After a few seconds, maybe 5 or 6 you can clear out old events from your list.

But, obviously, you don’t have to do all that and make it that complicated if you’re not worried about reliability and don’t plan to potentially send a lot of events in quick succession.

Are you selling in-game currency for real life money? To my knowledge this isn’t allowed. Correct me if I’m wrong.

No, you can see in the post that they said “Discord coins earnt by being active in the community” for in-game money.

1 Like

I don’t really know about communicating from Discord to Roblox anywhere. All I’ve seen is Roblox to Discord

sure can i have some help with that? ill dig into it.

are there any tutorials on this topic?

Well, if I could remember what its called I could probably find one. Its not too difficult to pull off its basically just “don’t close the request and turn off any default time outs”

If you set up a web server with something like express which is an npm module, you can do it pretty easily in express as well. In the callback for the request normally you send data there with .send or something like that. Rather than doing that you just wouldn’t send the data and you’d put the response value into a list like I had mentioned so you can access it for later.

Im using heroku for this but the thing is, You cant save values to a txt since it will get deleted once the app restarts. Any way to get past that?