How do you get all the game's job ids?

I want to use MessageingService to collect all the game’s job ids and send it over to a Discord server, but the problem is that I don’t know how to implement that, is there a way for me to code MessageingService to update an array sent via PublishAsync() and then send it over in one request, or is that just not possible?

1 Like

I can think of two ways off the top of my head.
The more complicated one involves using a API so that whever a server starts you send a POST request to it with the jobid(Such as sending a POST request to a Discord webhook)

If you want it all in one message though the only way that I can think of off the top of my head is have someone go into a server and type something into a chat that will send a message to all the servers via messaging service and then will return the JobId to the main server that can then send it to a Discord webhook.

Also I do not recommend using a webhook for this as doing this could be considered as abusing a Discord webhook which could get your account banned.

It’s command based

How would I do that?

You could do something like this:
Player runs a command
Main server sends a message out to every other server with some arguments such as the original jobid and tell them to send theres back
Those servers will then send a message back out and send args with there jobid and the original
When another server receives this one it will check to see if the original jobid matches that servers jobid if it does it will store the jobid that was returned in a table

I dont recommend doing this, I would just make a small API with Flask and https://repl.it/ that would store all active servers when they start and would remove them from a table when they shutdown, then you can have a Discord bot that will send a get request to the server to get all the jobids and put them into a message.

Is there a way to detect when messaging service sends data to all the servers?

What do you mean by that, you can wrap it in a Pcall to make sure it doesn’t fail.

I mean like is there a way to tell when MessagingService finished sending something to all the servers?

I don’t believe there is, the best option I can think of is making an API like I mentioned earlier.

Okay, is there a way to get how many servers there are in a game with Node.js?

I don’t know JavaScript sorry, I really only know Python.

1 Like

Eh, it’s fine, I can most likely convert what the Python code is trying to do for JS as I know some Python as well

Edit: I need to get dinner atm, so I most likely won’t reply for an hour

Well you could do something with Flask where every time a server starts it will store that server into a database and when the server ends it removes it from the database.
You can detect when a server is about to close by detecting how many players are left when one leaves and if its 0 then you tell the server to delete it from the DB.

Im assuming your in another timezone because its 1am where I live, and unless your like me you dont eat diner at 1am.

It’s 12:22 for me, I’m a late nighter

I ate my diner at 11:30 scripters do be like that

1 Like

Remember lads programmers never sleep and if they are they most likely sleep at 4:04 AM

4 Likes

That is true not going to lie

1 Like

I might trying doing a datastore approach to the getting the job ids, but will they get limited? I’m asking this cause I might make it where there’s a key called “jobids” where at first, it’s an empty array, then it adds the current job id to the array, and saves it. Then, I’ll use PubishAsync() to send the request over to all the other servers, where then, the other servers will do the same thing, and since I’m assuming the thread will pause until PubishAsync() is finished, I’ll just send the array over to Discord

I wouldnt do datastores as I had issues with them while trying to make a game hub and it didn’t work right, I would just use an external API.