@@ -9,6 +9,7 @@ const fs = require("fs");
9
9
const path = require ( "path" ) ;
10
10
11
11
const logChannelsPath = path . join ( __dirname , "../logChannels.json" ) ;
12
+ const logsFilePath = path . join ( __dirname , "../modlogs.json" ) ;
12
13
13
14
module . exports = {
14
15
/**
@@ -33,7 +34,7 @@ module.exports = {
33
34
}
34
35
35
36
const userId = interaction . options . getString ( "userid" ) ;
36
- const reason = interaction . options . getString ( "reason" ) || "No reason provided " ;
37
+ const reason = interaction . options . getString ( "reason" ) || "N/A " ;
37
38
38
39
const user = await client . users . fetch ( userId ) . catch ( ( ) => null ) ;
39
40
const targetMember = await interaction . guild . members . fetch ( userId ) . catch ( ( ) => null ) ;
@@ -90,6 +91,23 @@ module.exports = {
90
91
console . error ( "Log channel not found." ) ;
91
92
}
92
93
}
94
+
95
+ let modLogs = { } ;
96
+ if ( fs . existsSync ( logsFilePath ) ) {
97
+ const data = fs . readFileSync ( logsFilePath ) ;
98
+ modLogs = JSON . parse ( data ) ;
99
+ }
100
+
101
+ if ( ! modLogs [ targetUser . id ] ) modLogs [ targetUser . id ] = [ ] ;
102
+
103
+ modLogs [ targetUser . id ] . push ( {
104
+ type : "Moderated-Nickname" ,
105
+ reason : reason ,
106
+ moderator : interaction . user . id ,
107
+ timestamp : Math . floor ( Date . now ( ) / 1000 ) ,
108
+ } ) ;
109
+
110
+ fs . writeFileSync ( logsFilePath , JSON . stringify ( modLogs , null , 2 ) ) ;
93
111
} catch ( error ) {
94
112
console . error ( "Error moderating nickname:" , error ) ;
95
113
await interaction . reply ( {
0 commit comments