gamedig / node-gamedig

Query game servers and not only! Node.JS/Deno or Bash (via the CLI).
https://www.npmjs.com/package/gamedig
MIT License
587 stars 143 forks source link

feat: custom info to add to the embeds #533

Closed Dr3nz4r closed 4 months ago

Dr3nz4r commented 4 months ago

What is this feature about? I'd like to add additional info (like a server PW/admin list) to the embeds in e.g. discord

Vito0912 commented 4 months ago

What is your goal? Are you expecting the server's response to include either the server's password or a list of users with admin rights on the server?

If that's the case, it's important to realize that GameDig relies entirely on the server's response. It's highly unlikely that any server would include its password in a response that's accessible. However, for retrieving a list of admins, you can refer to the state.raw attribute. Some servers may include one.

Should you wish to introduce custom fields, you can do so in a straightforward manner. Below is an example from a Discord bot I developed (ofc it will not work without the prior code):

            let game: any = await GameDig.query({
                type: gameObject.type,
                host: gameObject.ip,
                port: gameObject.port,
            });
            game.raw!.test = "test";
            console.log(game.raw);

It will look something like:

{
... game response ...
test: 'test'
}

If I misunderstood you, please say so :) You are welcome

Dr3nz4r commented 4 months ago

No I think you got it spot on. I think I just didn't find the custom field part thx!