added offline support
This commit is contained in:
+11
-2
@@ -7,7 +7,8 @@ const express = require("express"),
|
||||
fs = require("fs"),
|
||||
config = require("./config.json"),
|
||||
app = express(),
|
||||
db = new sqlite3.Database("./servers.db");
|
||||
db = new sqlite3.Database("./servers.db"),
|
||||
offline = new sqlite3.Database("./offline.db");
|
||||
|
||||
const createWebhook = url => new Discord.Webhook(url).setUsername("TaxenHeimer").setAvatar("https://cdn.discordapp.com/attachments/999167321631363126/999495738943868928/nn.png")
|
||||
const countrify = e => require("./countrycode.json")[e]
|
||||
@@ -48,7 +49,10 @@ db.exec(`CREATE TABLE IF NOT EXISTS servers (
|
||||
motd text not null,
|
||||
timestamp text not null
|
||||
)`)
|
||||
|
||||
offline.exec(`CREATE TABLE IF NOT EXISTS servers (
|
||||
host text not null,
|
||||
timestamp text not null
|
||||
)`)
|
||||
app.post("/server", async (req, res) => {
|
||||
var Server = req.body.server
|
||||
if (!Server) return res.send("specify a server")
|
||||
@@ -56,6 +60,11 @@ app.post("/server", async (req, res) => {
|
||||
if (fs.readFileSync(`${__dirname}/ip.txt`).toString().includes(Server)) return
|
||||
var Minecraft = await mc.status(Server, 25565, {
|
||||
enableSRV: true
|
||||
}).catch(e => {
|
||||
offline.exec(`INSERT INTO servers VALUES (
|
||||
'${Server}',
|
||||
'${new Date().toLocaleDateString("en-US")}'
|
||||
)`)
|
||||
})
|
||||
fs.appendFileSync(`${__dirname}/ip.txt`, `${Server}\n`)
|
||||
Minecraft.ip = geoIP.lookup(Server)
|
||||
|
||||
Reference in New Issue
Block a user