Discord Bot Checking A Player's In-Game Stats

Does anybody know how I would create a Discord bot where it can check a player’s in-game stats, if it is even possible.

I have looked on the Developer Hub but I have found nothing.

1 Like

This is Possible with http requests, and I have no idea how you would do that, but a third party site reading into roblox info is a bad thing and MIGHT be against the rules.

1 Like

Some people have created a bot like this before tho.

1 Like

You might want to look into these:

If you mean checking whether or not a player is in-game, you could use this API endpoint:
https://api.roblox.com/users/{userid}/onlinestatus/

If you’re talking about in-game things like currency, you would want to check these out:

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

https://discordpy.readthedocs.io/en/latest/api.html

1 Like

Ok. I will certainly check those articles out.

1 Like

I don’t know about the webhooks article as it uses web hooks which only send data. I need to store data until the data changes when it is then updated and stored again.

1 Like

You could create a new discord application (discord bot)

In order for the bot to stay online, you would have to either host it from your computer or purchase a hosting service.

For the data store, i’m not sure about that but you could possibly just store the data on Roblox’s servers and when your game is about to update it, just send an HTTP request to the server you want. You could always store it on external servers but that would require learning a whole new language or purchasing a service

hmm. Ok. Thanks for your response.
I will probably create an api that will update a datastore which the bot will use GET method to retrieve the data.

Hello phyouthcenter1, i created something like this.

First you got to understand how http works on roblox,
Roblox can send post/get requests but cant receive any post/get requests.

So you need to have roblox sending data to your discord bot every 30 seconds(or whaterver time you like) as your bot cant make a request to roblox.

You need to receive a request on your bot, im gonna make a rest api to connect roblox and my discord bot.

I use glitch for hosting my discord bot.
(make sure to have express and discord.js on your project)

Discord bot on glitch: (javascript)

//services
const express = require("express"); // getting express
const app = express();
const discord = require("discord.js"); // getting discord api
let client = new discord.Client();

var datatable = {}   // or use a database for this


// when a new message is sent
client.on('message', message =>{
  const args = message.content.slice(prefix.length).split(" "); // getting arguments of the message
  if (args[0].toLowerCase() == "!get"){                         // if the first part of the argument is: !get (ex: !get itsredstonepro)
    var scope = datatable[args[1]]                              // search for player, (ex: !get itsredstonepro (we are searching for the player itsredstonepro))
    if (scope) {                                                // checking if player exists
      message.reply("player " + args[1] + " has " + scope.money + " money")
    } else {                                                    // if player doesnt exist
      message.reply("player " + args[1] + " doesnt exists in data")
    }
  }
})
// when roblox send a data update

app.get("/update", function(request,response){
  var player = request.query.player                        // getting the player
  var money = request.query.money                          // getting the players money
  if (datatable[player]){
    datatable[player].money = money                         //setting the money
  } else {
    local a = datatable[player] = {}
    a.money = money
  }
})

Roblox server side: (lua roblox)

local money = "10" -- the money
local player = "itsredstonepro" -- the player

while wait(30) do
   local httpservice = game:GetService("HtppService") -- getting service
   local data = "?player="..player.."&money="..money -- the data
   local url = "https://yourwebsite.anything/update" -- the glitch rest api
   httpservice:PostAsync(url..data) -- making request
end

hope it helped a bit

1 Like

Thanks for this!
I will try it out ASAP!

np

This is some text so i can send some short words

XD LOL.

" This is some text so i can send some short words"

@Roblox we found a way to bypass the word count filter. :slight_smile: