How to use the gamedig.query function in gamedig

To help you get started, we’ve selected a few gamedig examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Androz2091 / AtlantaBot / commands / General / minecraft.js View on Github external
options = {
                type: "minecraft",
                host: ip.split(":")[0],
                port: ip.split(":")[1]
            };
        }

        let json = null;
        
        await gamedig.query(options).then((res) => {
            json = res;
        }).catch((err) => {});

        if(!json){
            options.type = "minecraftpe";
            await gamedig.query(options).then((res) => {
                json = res;
            }).catch((err) => {});
        }

        if(!json){
            return message.channel.send(message.language.get("MINECRAFT_ERR_OFFLINE"));
        }

        let imgRes = await fetch("https://www.minecraftskinstealer.com/achievement/a.php?i=2&h=Success&t="+ip);
        let imgAttachment = new Discord.MessageAttachment(await imgRes.buffer(), "success.png");

        let mcEmbed = new Discord.MessageEmbed()
            .setAuthor(message.language.get("MINECRAFT_HEADINGS", ip)[0])
            .addField(message.language.get("MINECRAFT_HEADINGS", ip)[1],
                json.raw.version.name || json.raw.server_engine
            )
github dice-discord / bot / src / commands / games / garrys-mod-server-status.js View on Github external
exec(msg, { host, port }) {
    try {
      msg.channel.startTyping();
      const options = {
        host,
        type: "garrysmod"
      };

      if (port) {
        options.port = port;
      }

      gamedig
        .query(options)
        .then(data => {
          const embed = gameDigHelper(data);
          embed.setThumbnail("https://steamcdn-a.akamaihd.net/steam/apps/4000/header.jpg");
          return msg.replyEmbed(embed);
        })
        .catch(error => {
          if (error === "UDP Watchdog Timeout") return msg.reply("Server timed out, it's probably offline.");

          logger.error(error);
          return msg.reply("An unknown error occured.");
        });
    } finally {
      msg.channel.stopTyping();
    }
  }
github dice-discord / bot / src / commands / games / rust-server-status.js View on Github external
exec(msg, { host, port }) {
    try {
      msg.channel.startTyping();
      const options = {
        host,
        type: "rust"
      };

      if (port) {
        options.port = port;
      }

      gamedig
        .query(options)
        .then(data =>
          msg.replyEmbed(
            gameDigHelper(data).setThumbnail("https://steamcdn-a.akamaihd.net/steam/apps/252490/header.jpg")
          )
        )
        .catch(error => {
          if (error === "UDP Watchdog Timeout") return msg.reply("Server timed out, it's probably offline.");

          logger.error(error);
          return msg.reply("An unknown error occured.");
        });
    } finally {
      msg.channel.stopTyping();
    }
  }
github dice-discord / bot / src / commands / games / insurgency-server-status.js View on Github external
exec(msg, { host, port }) {
    try {
      msg.channel.startTyping();
      const options = {
        host,
        type: "insurgency"
      };

      if (port) {
        options.port = port;
      }

      gamedig
        .query(options)
        .then(data =>
          msg.replyEmbed(
            gameDigHelper(data)
              .setThumbnail("https://steamcdn-a.akamaihd.net/steam/apps/222880/header.jpg")
              .addField("Friendly Fire", parseInt(data.raw.rules.mp_friendlyfire, 10) ? "Yes" : "No")
          )
        )
        .catch(error => {
          if (error === "UDP Watchdog Timeout") return msg.reply("Server timed out, it's probably offline.");

          logger.error(error);
          return msg.reply("An unknown error occured.");
        });
    } finally {
      msg.channel.stopTyping();
github dice-discord / bot / src / commands / games / starbound-server-status.js View on Github external
exec(msg, { host, port }) {
    try {
      msg.channel.startTyping();
      const options = {
        host,
        type: "starbound"
      };

      if (port) {
        options.port = port;
      }

      gamedig
        .query(options)
        .then(data => {
          const curr = data.raw.numplayers;
          const max = data.maxplayers;

          return msg.replyEmbed(
            new MessageEmbed({
              title: data.name,
              thumbnail: {
                url: "https://steamcdn-a.akamaihd.net/steam/apps/211820/header.jpg"
              },
              footer: { text: `Took ${ms(data.query.duration)} to complete` },
              fields: [
                {
                  name: "IP Address",
                  value: `${data.query.address} (port ${data.query.port})`
github dice-discord / bot / src / commands / games / csgo-server-status.js View on Github external
exec(msg, { host, port }) {
    try {
      msg.channel.startTyping();
      const options = {
        host,
        type: "csgo"
      };

      if (port) {
        options.port = port;
      }

      gamedig
        .query(options)
        .then(data => {
          const embed = gameDigHelper(data);
          embed.setThumbnail("https://steamcdn-a.akamaihd.net/steam/apps/730/header.jpg");
          return msg.replyEmbed(embed);
        })
        .catch(error => {
          if (error === "UDP Watchdog Timeout") return msg.reply("Server timed out, it's probably offline.");

          logger.error(error);
          return msg.reply("An unknown error occured.");
        });
    } finally {
      msg.channel.stopTyping();
    }
  }
github dice-discord / bot / src / commands / games / 7-days-to-die-server-status.js View on Github external
exec(msg, { host, port }) {
    try {
      msg.channel.startTyping();
      const options = {
        host,
        type: "7d2d"
      };

      if (port) {
        options.port = port;
      }

      gamedig
        .query(options)
        .then(data => {
          const cur = data.raw.numplayers;
          const max = data.maxplayers;

          const embed = new MessageEmbed({
            title: data.name,
            thumbnail: {
              url: "https://steamcdn-a.akamaihd.net/steam/apps/251570/header.jpg"
            },
            footer: { text: `Took ${ms(data.query.duration)} to complete` },
            fields: [
              {
                name: "Map",
                value: Util.escapeMarkdown(data.map)
              },

gamedig

Query for the status of any game server in Node.JS

MIT
Latest version published 1 month ago

Package Health Score

81 / 100
Full package analysis

Popular gamedig functions