diff --git a/backend/docker/dockerstartup.js b/backend/docker/dockerstartup.js index 5a2f099..f06b68b 100644 --- a/backend/docker/dockerstartup.js +++ b/backend/docker/dockerstartup.js @@ -61,7 +61,7 @@ async function dockerstartup() { } else { console.log("Not running inside a dockers") } - log("---- Docker Startup ----", "-- ENV --", `TOKEN: ${env.LOG_SENSITIVE_INFO === true ? env.TOKEN : "HIDDEN"}`, `CID: ${env.CLIENTID}`, `GID: ${env.GUILDID}`, `MUDTOKEN: ${env.LOG_SENSITIVE_INFO === true ? env.MUDTOKEN : "HIDDEN"}`, `OVERRIDE: ${env.OVERRIDE === true ? "True" : "False"}`, "-- PATHS --", configPath); + log("---- Docker Startup ----", "-- ENV --", `TOKEN: ${env.LOG_SENSITIVE_INFO ? env.TOKEN : "HIDDEN"}`, `CID: ${env.CLIENTID}`, `GID: ${env.GUILDID}`, `MUDTOKEN: ${env.LOG_SENSITIVE_INFO ? env.MUDTOKEN : "HIDDEN"}`, `OVERRIDE: ${!env.OVERRIDE ? "False" : "True"}`, "-- PATHS --", configPath); } module.exports.dockerstartup = dockerstartup; \ No newline at end of file diff --git a/backend/fetchNewMessages.js b/backend/fetchNewMessages.js index ff1c493..4e7cb14 100644 --- a/backend/fetchNewMessages.js +++ b/backend/fetchNewMessages.js @@ -218,7 +218,7 @@ async function fetchNewMessages(client) { }) // Update the last timestamp lastTimestamp = NowToRubyTS()+1; - log("---- Fetched Messages ----", payload, result, lastTimestamp); + log("---- Fetched Messages ----", process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN" , result, lastTimestamp); } else { console.error('Hackmud API error:', result.msg || 'Unknown error'); } diff --git a/backend/loadvar.js b/backend/loadvar.js index 6489a83..34680c6 100644 --- a/backend/loadvar.js +++ b/backend/loadvar.js @@ -38,7 +38,7 @@ async function loadConfigVar(key) { try { const configRaw = await readFile(configPath, 'utf8'); const config = JSON.parse(configRaw); - log(`LoadConfigVar was called, Input: ${key}, Output: ${config[key]}`); + log(`LoadConfigVar was called, Input: ${key}, Output: ${process.env.LOG_SENSITIVE_INFO ? config[key] : 'HIDDEN'}`); return config[key] ?? null; // Return null if key doesn't exist } catch (error) { console.error(`Error loading config variable "${key}":`, error.message); diff --git a/commands/mud/settings.js b/commands/mud/settings.js index 10b2896..b661efc 100644 --- a/commands/mud/settings.js +++ b/commands/mud/settings.js @@ -137,7 +137,7 @@ module.exports = { fs.writeFileSync(configPath, JSON.stringify(config, null, 4)); console.log('New mudtoken has been set'); - log("---- Settings.js - Auth ----", `New mudtoken has been set: ${process.env.LOG_SENSITIVE_INFO === 'true' ? chatToken : "HIDDEN"}`, payload, `${process.env.LOG_SENSITIVE_INFO === true ? result : "HIDDEN"}`, config, configPath); + log("---- Settings.js - Auth ----", `New mudtoken has been set: ${process.env.LOG_SENSITIVE_INFO ? chatToken : "HIDDEN"}`, payload, `${process.env.LOG_SENSITIVE_INFO ? result : "HIDDEN"}`, process.env.LOG_SENSITIVE_INFO ? config : 'HIDDEN', configPath); await interaction.reply({content: `Config updated successfully! Token has been set.`, flags: MessageFlags.Ephemeral }); } else { log("---- Settings.js - Auth ----", 'Failed to update mudtoken', payload, result); @@ -206,10 +206,10 @@ module.exports = { fs.writeFileSync(mappingsPath, JSON.stringify(channelMapping, null, 4)); - log("---- Settings.js - Setup ----", 'Sucessfully ran setup', `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, result, channelMapping, mappingsPath); + log("---- Settings.js - Setup ----", 'Sucessfully ran setup', `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, result, channelMapping, mappingsPath); await interaction.reply({content: 'Server has been set up successfully, and user channels have been created or reused under the "chat" category.', flags: MessageFlags.Ephemeral }); } else { - log("---- Settings.js - Setup ----", 'Failed to run setup', `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, result); + log("---- Settings.js - Setup ----", 'Failed to run setup', `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, result); console.error(result); await interaction.reply({content: `Failed to run setup. Server response: ${result.msg || 'Unknown error'}`, flags: MessageFlags.Ephemeral }); } @@ -242,7 +242,7 @@ module.exports = { fs.writeFileSync(configPath, JSON.stringify(config, null, 4), 'utf-8'); - log("---- Settings.js - Manage Users ----", 'Successfully updated settings', username, pullHistory, config, configPath); + log("---- Settings.js - Manage Users ----", 'Successfully updated settings', username, pullHistory, process.env.LOG_SENSITIVE_INFO ? config : 'HIDDEN', configPath); await interaction.reply({content: `Successfully updated settings for user **${username}**. Pull history: **${pullHistory ? 'Enabled' : 'Disabled'}**`, flags: MessageFlags.Ephemeral }); } catch (error) { console.error(error); @@ -263,7 +263,7 @@ module.exports = { } fs.writeFileSync(configPath, JSON.stringify(config, null, 4), 'utf-8'); - log("---- Settings.js - Color ----", 'Successfully updated setting', cmdcolorval, config, configPath); + log("---- Settings.js - Color ----", 'Successfully updated setting', cmdcolorval, process.env.LOG_SENSITIVE_INFO ? config : 'HIDDEN', configPath); } else { log("---- Settings.js - Color ----", 'Invalid color value', cmdcolorval); await interaction.reply({content: 'Invalid color value. Please use a single alphanumeric character or "reset"', flags: MessageFlags.Ephemeral }); @@ -277,7 +277,7 @@ module.exports = { fs.writeFileSync(configPath, JSON.stringify(config, null, 4), 'utf-8'); await interaction.reply({content: `Successfully updated setting. Ping Detection: **${value ? 'Enabled' : 'Disabled'}**`, flags: MessageFlags.Ephemeral }); - log("---- Settings.js - Ping Detection ----", 'Successfully updated setting', value, config, configPath); + log("---- Settings.js - Ping Detection ----", 'Successfully updated setting', value, process.env.LOG_SENSITIVE_INFO ? config : 'HIDDEN', configPath); } catch(error) { console.error(error); await interaction.reply({content: 'An error occurred while setting this option. Check console for details.', flags: MessageFlags.Ephemeral }); diff --git a/commands/mud/tell.js b/commands/mud/tell.js index 2f4c02d..35ff278 100644 --- a/commands/mud/tell.js +++ b/commands/mud/tell.js @@ -51,7 +51,7 @@ module.exports = { const result = await response.json(); if (result.ok === true) { - log(`---- tell.js ----`, `TellUsr: ${tellusr}`, `TellMsg: ${tellmsg}`, `ChannelName: ${channelName}`, `ChannelId: ${interaction.channelId}`, `Result: ${result.ok}`, `Msg: ${result.msg}`, channelMappings); + log(`---- tell.js ----`, `TellUsr: ${tellusr}`, `TellMsg: ${tellmsg}`, `ChannelName: ${channelName}`, `ChannelId: ${interaction.channelId}`, `Result: ${result.ok}`, `Msg: ${result.msg}`, channelMappings, process.env.LOG_SENSITIVE_INFO ? payload : 'HIDDEN'); interaction.reply({content: `Message sent to ${tellusr} successfully. Message: ${tellmsg}`, flags: MessageFlags.Ephemeral }); } else { console.log(`Failed to send message. Server response: ${result.msg || 'Unknown error'}`); diff --git a/events/messageCreate.js b/events/messageCreate.js index 65f1168..b31959e 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -78,16 +78,16 @@ module.exports = { }); const result = await response.json(); if (result.ok === true) { - log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, result); + log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, result); message.react('✅'); //console.log(`Message sent to ${setChannel} successfully. Message: ${finalMessage}`); } else { - log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, result); + log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, result); message.react('❌'); console.log(`Failed to send message. Server response: ${result.msg || 'Unknown error'}`); } } catch (error) { - log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, error); + log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, error); message.react('❌'); console.log(error); }