File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -182,13 +182,18 @@ bot.command("users", async (ctx) => {
182182} ) ;
183183
184184bot . command ( "stats" , async ( ctx ) => {
185- const users = await manageUsers ( { } , "read" ) ;
186- const products = await manageProducts ( { } , "read" ) ;
187- let productCount = 0 ;
188- products . result . map ( ( p ) => ( p += item . users . length ) ) ;
189- ctx . reply (
190- `Total Users: ${ users . result . length } \nTotal Products: ${ productCount } `
191- ) ;
185+ try {
186+ const [ users , products ] = await Promise . all ( [ manageUsers , manageProducts ] . map (
187+ async ( func ) => await func ( { } , "read" )
188+ ) ) ;
189+ let prodCount = 0 ;
190+ products . result . map ( prod => prodCount += prod . users . length ) ;
191+ ctx . reply (
192+ `Total Users: ${ users . result . length } \nTotal Products: ${ prodCount } `
193+ ) ;
194+ } catch ( e ) {
195+ console . log ( e )
196+ }
192197} ) ;
193198
194199bot . on ( '::url' , async ctx => {
You can’t perform that action at this time.
0 commit comments