I am almost certain that an actual implementation of this is against ROBLOX TOS, so please keep that in mind.
To set something like this up, you would probably need to:
- Create a Discord Bot which has commands to give the user a join code.
- Create a web server to both issue join codes and receive them from the game.
- Create a database to link to the web server to store the issued join code with the Discord and Roblox user id.
So in a practical use case:
When a user runs the /join-code command in the Discord, a web request is sent to the above mentioned web server with the discord user as a parameter. That web server, generates a code and then stores it in a database with the discord user info. The web server then returns the issued code, and the bot serves it to the user.
When the user puts the code into the game, the game sends a web request to the web server along with the code and the Roblox user info. The web server then looks at the database, attempts to find a code, and if it does it will store the Roblox user info with the discord user info. If the Roblox or Discord user has already generated and used a code it will return a negative response. If it hasn’t, and there is a code, the web server will then return a positive response. Then you’d handle logic in-game for rewards & stuff.
A good place to start for a beginner with web servers, is probably Flask (Update: As @Inkthirsty mentioned, fastapi is another great option. Flask is an older, less streamlined, library, however, I would suggest that it gives better learning opportunity) The freeCodeCamp youtube channel has a good tutorial for learning how it works, on the other hand, Flask has a pretty simple syntax so if you’re firmiliar with programming in general it shouldn’t be hard to pick up.
Because this is a non practical use case you could likely get away with just storing the codes and user info in a json file, however, if you’re interested in learning real world use cases I’d recommend learning how to setup a SQL database, and access it with your web server. I’m not in anyway firmiliar with them, unfortunately, so I can’t offer a tutorial. However, google is a wonderful place to start.
Finally, for learning how to make a discord bot there are two common paths. Discord.js and Discord.py. I personally recommend learning Discord.py, especially if you’re also learning Flask as it will be the same language. While I have no experience with discord.js – unlike discord.py – it is also a really common one and also a great starting point. I’d offer a tutorial similar to Flask, but I cannot find a good one. Docs are always a good starting point but there are plenty of tutorials out there. I’d recommend referencing the docs while watching them, however, as they often don’t follow best practices.
I wish you the best of luck on your journey & feel free to reach out if you’d like any help.