Hey, I'm running into an issue while working on a discord integration for the gmod server npcsv-- for whatever reason, despite the server being online and listening (nmap confirms) at the port and ip I'm checking, I still get a response timeout. IP is us1.npcs.gg, port is currently set to default. Here's my code:
const fs = require("fs");
const { Server } = require("@fabricio-191/valve-server-query");
const { Client, Intents, MessageEmbed } = require("discord.js");
const DELAY = 1000;
const TARGET_CHANNEL = "773333968858251268";
class StatusEmbed extends MessageEmbed {
constructor(data) {
if (!data.offline) {
super({
type: "rich",
title: `us1.npcs.gg status`,
description: "",
color: 0x00ffff,
fields: [
{
name: `Status`,
value: "Online",
inline: true,
},
{
name: `Players`,
value: data.players,
inline: true,
},
{
name: `Map`,
value: data.map,
inline: true,
},
{
name: `Uptime`,
value: data.time,
inline: true,
},
],
});
} else {
super({
type: "rich",
title: `us1.npcs.gg status`,
description: "",
color: 0x00ffff,
fields: [
{
name: `Status`,
value: "Offline",
inline: true,
},
],
});
}
}
}
async function start() {
try {
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});
client.once("ready", onReady);
client.on("error", (e) => {
console.error(`Error: ${e}`);
});
client.login(fs.readFileSync("token.txt").toString().replace(/\s/g, ""));
function onReady() {
let uptime = 0;
console.log("Ready!");
const channel = client.channels.cache.get(TARGET_CHANNEL);
setInterval(async () => {
try {
console.log("Getting data");
const server = await Server({
ip: "135.148.136.143",
});
const info = await server.getInfo();
const embed = new StatusEmbed({
players: `${info.players.online}/${info.players.max}`,
map: info.map,
uptime: `${Math.floor(uptime / 1000 / 60 / 60)}:${
Math.floor(uptime / 1000 / 60) % 60
}`,
});
uptime += DELAY;
channel.send(embed);
} catch (e) {
const embed = new StatusEmbed({ offline: true });
uptime = 0;
channel.send(embed);
console.error(e);
}
}, DELAY);
}
} catch (e) {
console.error("Error: " + e);
start();
}
}
start();
Ready!
Getting data
Getting data
Getting data
Getting data
Getting data
Getting data
Error: Response timeout.
at /home/oranderr/code/miscjs/discintegration/node_modules/@fabricio-191/valve-server-query/lib/main/connection.js:132:62
at new Promise (<anonymous>)
at Connection.awaitResponse (/home/oranderr/code/miscjs/discintegration/node_modules/@fabricio-191/valve-server-query/lib/main/connection.js:118:10)
at Connection.query (/home/oranderr/code/miscjs/discintegration/node_modules/@fabricio-191/valve-server-query/lib/main/connection.js:153:21)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async _getInfo (/home/oranderr/code/miscjs/discintegration/node_modules/@fabricio-191/valve-server-query/lib/main/server.js:174:15)
at async init (/home/oranderr/code/miscjs/discintegration/node_modules/@fabricio-191/valve-server-query/lib/main/server.js:140:15)
at async Timeout._onTimeout (/home/oranderr/code/miscjs/discintegration/index.js:73:26)
^C