Anyone know how to make a discord bot that can ban a player from the game inside of discord?

Hello, I am trying to make a Discord to Roblox Ban system.

Like for example if I type: =gban USERNAME it bans the user in the game.

How do I do this, I have tried making a JSOn hosted on the Web but I dont know how to make the lua script know when it updates etc.

How do I make one?

3 Likes

Well, you’ve got the right idea at least. You’ll need your Discord application (bot accounts are profile representations of an application) to update your server based on when you write out your ban instruction. Once the ban is in your database, you’re done as far as the Discord application goes.

For Roblox, you can’t have your web server send a request to your game server, so you’ll need to poll your server to update the in-game ban list cache, then work from there.

You need to use HttpService:GetAsync to fetch the json from your host i.e. each time a server starts and then i.e. store it in the bans datastore.

The downside of this approach is that you need to either constantly spam your webhost with requests to keep the bans up to date, or fetch it only once a server and enjoy the big big delay in syncing bans.

1 Like

Is there any better way to get a ban without a huge delay or so they are up to date. I dont really mind a 20 seconds delay or 1 minute delay. Or to check if it changed like the Value.Changed feature.

Make a request to your webhost every 20 seconds. But if your game has i.e. 200 servers running, and each of them makes a request every 20 seconds, then your host will receive uh, a lot of requests.

Alright. Thanks for the response.

I made a bot that did this before and made its code open-source. It utilizes @Kiriot22’s method of polling the web server to get the latest bans. If you send these requests at a certain rate, it wouldn’t be as “spammy” as it’s said to be. The project uses a real-time database called RethinkDB but I think you’d be fine with a simple JSON file. Either way, you can see how it works here. In terms of setting up a web server, you can take a look at the REST API file.

8 Likes