@@ -13,24 +13,43 @@ const files = {
13
13
fileName : true ,
14
14
origFileName : true ,
15
15
mimetype : true ,
16
- uploadedAt : true
16
+ uploadedAt : true ,
17
+ userId : true
17
18
}
18
19
} ) ;
20
+ const pages : MessageEmbed [ ] = [ ] ;
19
21
for ( let i = 0 ; i < all . length ; i += 4 ) {
20
22
const files = all . slice ( i , i + 4 ) ;
21
23
const embed = new MessageEmbed ( )
22
24
. setTitle ( 'Files' )
23
- . setColor ( '#B794F4' ) ;
24
- files . forEach ( file => {
25
- embed . addField ( `${ file . fileName } ` ,
25
+ . setColor ( '#B794F4' )
26
+ . setFooter ( `Page ${ i / 4 + 1 } /${ Math . ceil ( all . length / 4 ) } | Total: ${ all . length } ` ) ;
27
+ files . forEach ( file =>
28
+ embed . addField ( file . fileName ,
26
29
`ID: ${ file . id }
27
30
Original file name: ${ file . origFileName }
28
31
Mimetype: ${ file . mimetype }
29
32
Uploaded at: ${ new Date ( file . uploadedAt ) . toLocaleString ( ) } ` )
30
- . setFooter ( `Page ${ i / 4 + 1 } /${ Math . ceil ( all . length / 4 ) } ` ) ;
31
- } ) ;
32
- msg . channel . send ( embed ) ;
33
+ ) ;
34
+ pages . push ( embed ) ;
33
35
}
36
+ // https://stackoverflow.com/a/60693028
37
+ msg . channel . send ( pages [ 0 ] ) . then ( message => {
38
+ if ( pages . length <= 1 ) return ;
39
+ message . react ( '➡️' ) ;
40
+ const collector = message . createReactionCollector (
41
+ ( reaction , user ) => [ '⬅️' , '➡️' ] . includes ( reaction . emoji . name ) && user . id === msg . author . id ,
42
+ { time : 60000 }
43
+ ) ;
44
+ let i = 0 ;
45
+ collector . on ( 'collect' , async reaction => {
46
+ await message . reactions . removeAll ( ) ;
47
+ reaction . emoji . name === '⬅️' ? i -= 1 : i += 1 ;
48
+ await message . edit ( pages [ i ] ) ;
49
+ if ( i !== 0 ) await message . react ( '⬅️' ) ;
50
+ if ( i + 1 < pages . length ) await message . react ( '➡️' ) ;
51
+ } ) ;
52
+ } ) ;
34
53
}
35
54
} ;
36
55
0 commit comments