Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
)
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();
}
}
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();
}
}
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();
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})`
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();
}
}
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)
},