Fix error logs

This commit is contained in:
Christopher Cookman 2024-07-22 11:58:04 -06:00
parent 37dfa3d48b
commit 71403ceb0d
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -21,6 +21,20 @@ idBans = {}
ipRaw = ""; ipRaw = "";
idRaw = ""; 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)); const jsonfix = (json) => JSON.parse(JSON.stringify(json));
client.on('ready', async () => { client.on('ready', async () => {
@ -81,7 +95,6 @@ client.on('ready', async () => {
const sendMessages = async (data) => { const sendMessages = async (data) => {
const channel = await client.channels.fetch(process.env.DISCORD_BANLOG_CHANNEL_ID); const channel = await client.channels.fetch(process.env.DISCORD_BANLOG_CHANNEL_ID);
console.log(data)
for (const ban in data.added) { for (const ban in data.added) {
thisBan = data.added[ban] thisBan = data.added[ban]
embed = { embed = {
@ -210,7 +223,6 @@ const watchFiles = () => {
tmp = funcs.makeBansTable(newContents) tmp = funcs.makeBansTable(newContents)
// Do stuff // Do stuff
console.log(`ID Bans changed\nOld Length: ${Object.keys(idBans).length}\nNew Length: ${Object.keys(tmp).length}`) 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 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) { 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") console.log("Too many changes, logging and ignoring")