Fix error logs
This commit is contained in:
parent
37dfa3d48b
commit
71403ceb0d
16
index.js
16
index.js
|
@ -21,6 +21,20 @@ idBans = {}
|
|||
ipRaw = "";
|
||||
idRaw = "";
|
||||
|
||||
|
||||
// Setup
|
||||
// if process.env.CONFIG_PATH is not set or it doesnt exist, exit 1
|
||||
if (!process.env.CONFIG_PATH || !fs.existsSync(process.env.CONFIG_PATH)) {
|
||||
console.error("CONFIG_PATH is not set or does not exist. Exiting.")
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// if ./errors/ doesnt exist, create it
|
||||
if (!fs.existsSync("errors")) {
|
||||
fs.mkdirSync("errors")
|
||||
}
|
||||
|
||||
|
||||
const jsonfix = (json) => JSON.parse(JSON.stringify(json));
|
||||
|
||||
client.on('ready', async () => {
|
||||
|
@ -81,7 +95,6 @@ client.on('ready', async () => {
|
|||
|
||||
const sendMessages = async (data) => {
|
||||
const channel = await client.channels.fetch(process.env.DISCORD_BANLOG_CHANNEL_ID);
|
||||
console.log(data)
|
||||
for (const ban in data.added) {
|
||||
thisBan = data.added[ban]
|
||||
embed = {
|
||||
|
@ -210,7 +223,6 @@ const watchFiles = () => {
|
|||
tmp = funcs.makeBansTable(newContents)
|
||||
// Do stuff
|
||||
console.log(`ID Bans changed\nOld Length: ${Object.keys(idBans).length}\nNew Length: ${Object.keys(tmp).length}`)
|
||||
console.log(JSON.stringify(funcs.diff(idBans, tmp), null, 2))
|
||||
// if the number of adds or removes is over 40 ignore it
|
||||
if (Object.keys(funcs.diff(idBans, tmp).added).length > 40 || Object.keys(funcs.diff(idBans, tmp).removed).length > 40) {
|
||||
console.log("Too many changes, logging and ignoring")
|
||||
|
|
Loading…
Reference in a new issue