File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 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
/**
@@ -82,8 +83,25 @@ const {
82
83
console . error ( "Log channel not found." ) ;
83
84
}
84
85
}
86
+
87
+ let modLogs = { } ;
88
+ if ( fs . existsSync ( logsFilePath ) ) {
89
+ const data = fs . readFileSync ( logsFilePath ) ;
90
+ modLogs = JSON . parse ( data ) ;
91
+ }
92
+
93
+ if ( ! modLogs [ targetUser . id ] ) modLogs [ targetUser . id ] = [ ] ;
94
+
95
+ modLogs [ targetUser . id ] . push ( {
96
+ type : "Ban" ,
97
+ reason : reason ,
98
+ moderator : interaction . user . id ,
99
+ timestamp : Math . floor ( Date . now ( ) / 1000 ) ,
100
+ } ) ;
101
+
102
+ fs . writeFileSync ( logsFilePath , JSON . stringify ( modLogs , null , 2 ) ) ;
85
103
} catch ( error ) {
86
- console . error ( " Error banning user:" , error ) ;
104
+ console . error ( ` Error banning user: ${ error } ` ) ;
87
105
await interaction . editReply ( "An error occurred while trying to ban the user." ) ;
88
106
}
89
107
} ,
You can’t perform that action at this time.
0 commit comments