11const { SlashCommandBuilder, MessageFlags } = require ( 'discord.js' ) ;
22const { loadConfigVar, loadChnlMap } = require ( './../../backend/loadvar.js' ) ;
3+ const { log } = require ( './../../backend/debug/log.js' ) ;
34const fetch = require ( 'node-fetch' ) ;
45const fs = require ( 'node:fs' ) ;
56const path = require ( 'path' ) ;
6- const { create } = require ( 'node:domain' ) ;
7- const isDocker = require ( 'is-docker' )
7+
8+ const isDocker = require ( 'is-docker' ) ;
89let configPath
910let mappingsPath
1011if ( isDocker ( ) && ! process . env . OVERRIDE ) {
@@ -20,6 +21,8 @@ if (isDocker() && !process.env.OVERRIDE) {
2021 mappingsPath = path . resolve ( __dirname , '../../channelMappings.json' ) ;
2122}
2223
24+ log ( "---- Settings.js Config Paths ----" , configPath , mappingsPath ) ;
25+
2326async function createChannel ( guild , name , categoryid ) {
2427 const discordChannelName = name ;
2528
@@ -130,12 +133,14 @@ module.exports = {
130133 }
131134
132135 config . mudtoken = chatToken ;
133- config . mudtokendate =
136+ // config.mudtokendate =
134137
135138 fs . writeFileSync ( configPath , JSON . stringify ( config , null , 4 ) ) ;
136- console . log ( 'New mudtoken has been set:' , chatToken )
139+ console . log ( 'New mudtoken has been set' ) ;
140+ log ( "---- Settings.js - Auth ----" , `New mudtoken has been set: ${ env . LOG_SENSITIVE_INFO === 'true' ? chatToken : "HIDDEN" } ` , payload , `${ env . LOG_SENSITIVE_INFO === true ? result : "HIDDEN" } ` , config , configPath ) ;
137141 await interaction . reply ( { content : `Config updated successfully! Token has been set.` , flags : MessageFlags . Ephemeral } ) ;
138142 } else {
143+ log ( "---- Settings.js - Auth ----" , 'Failed to update mudtoken' , payload , result ) ;
139144 console . error ( result )
140145 await interaction . reply ( { content : `Failed to update config. Server response: ${ result . msg || 'Unknown error' } ` , flags : MessageFlags . Ephemeral } ) ;
141146 }
@@ -200,9 +205,11 @@ module.exports = {
200205 }
201206
202207 fs . writeFileSync ( mappingsPath , JSON . stringify ( channelMapping , null , 4 ) ) ;
203-
208+
209+ log ( "---- Settings.js - Setup ----" , 'Sucessfully ran setup' , `${ env . LOG_SENSITIVE_INFO === true ? payload : "HIDDEN" } ` , result , channelMapping , mappingsPath ) ;
204210 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 } ) ;
205211 } else {
212+ log ( "---- Settings.js - Setup ----" , 'Failed to run setup' , `${ env . LOG_SENSITIVE_INFO === true ? payload : "HIDDEN" } ` , result ) ;
206213 console . error ( result ) ;
207214 await interaction . reply ( { content : `Failed to run setup. Server response: ${ result . msg || 'Unknown error' } ` , flags : MessageFlags . Ephemeral } ) ;
208215 }
@@ -234,7 +241,8 @@ module.exports = {
234241 }
235242
236243 fs . writeFileSync ( configPath , JSON . stringify ( config , null , 4 ) , 'utf-8' ) ;
237-
244+
245+ log ( "---- Settings.js - Manage Users ----" , 'Successfully updated settings' , username , pullHistory , config , configPath ) ;
238246 await interaction . reply ( { content : `Successfully updated settings for user **${ username } **. Pull history: **${ pullHistory ? 'Enabled' : 'Disabled' } **` , flags : MessageFlags . Ephemeral } ) ;
239247 } catch ( error ) {
240248 console . error ( error ) ;
@@ -255,7 +263,9 @@ module.exports = {
255263 }
256264
257265 fs . writeFileSync ( configPath , JSON . stringify ( config , null , 4 ) , 'utf-8' ) ;
266+ log ( "---- Settings.js - Color ----" , 'Successfully updated setting' , cmdcolorval , config , configPath ) ;
258267 } else {
268+ log ( "---- Settings.js - Color ----" , 'Invalid color value' , cmdcolorval ) ;
259269 await interaction . reply ( { content : 'Invalid color value. Please use a single alphanumeric character or "reset"' , flags : MessageFlags . Ephemeral } ) ;
260270 }
261271 }
@@ -267,6 +277,7 @@ module.exports = {
267277 fs . writeFileSync ( configPath , JSON . stringify ( config , null , 4 ) , 'utf-8' ) ;
268278
269279 await interaction . reply ( { content : `Successfully updated setting. Ping Detection: **${ value ? 'Enabled' : 'Disabled' } **` , flags : MessageFlags . Ephemeral } ) ;
280+ log ( "---- Settings.js - Ping Detection ----" , 'Successfully updated setting' , value , config , configPath ) ;
270281 } catch ( error ) {
271282 console . error ( error ) ;
272283 await interaction . reply ( { content : 'An error occurred while setting this option. Check console for details.' , flags : MessageFlags . Ephemeral } ) ;
0 commit comments