File tree 1 file changed +14
-4
lines changed
1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -47,18 +47,28 @@ module.exports = {
47
47
)
48
48
let dir = '../servers/' + args [ 0 ]
49
49
let dirData = fs . readdirSync ( dir ) // add in all file names that end with .zip
50
- dirData = bubbleSort ( dirData ) ;
50
+
51
+ //sort dirData by date last modified
52
+ dirData = dirData . map ( function ( fileName ) {
53
+ return {
54
+ name : fileName ,
55
+ time : fs . statSync ( dir + '/' + fileName ) . mtime . getTime ( )
56
+ } ;
57
+ } )
58
+ . sort ( function ( a , b ) {
59
+ return a . time - b . time ; } )
60
+ . map ( function ( v ) {
61
+ return v . name ; } ) ;
62
+
63
+
51
64
for ( let i = 0 ; i < 25 ; i ++ ) { // max number of fields in a Discord Embed is 25
52
65
if ( ! dirData [ i ] ) break ;
53
66
if ( dirData [ i ] && dirData [ i ] . endsWith ( '.zip' ) ) {
54
67
let data = fs . statSync ( dir + '/' + dirData [ i ] )
55
68
let date = new Date ( data . birthtimeMs )
56
- dataDic [ dirData [ i ] ] = date . toUTCString ( ) ;
57
69
}
58
70
}
59
71
60
- // somehow sort dirData and date pairs by the newest date
61
-
62
72
choiceEmbed . addField ( `\`${ dirData [ i ] } \`` , `Save created on: ${ date . toUTCString ( ) } ` ) ;
63
73
64
74
return message . channel . send ( choiceEmbed )
You can’t perform that action at this time.
0 commit comments