Skip to content

Commit 04b7e9e

Browse files
committed
Fix stats command
1 parent e87a855 commit 04b7e9e

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

bot.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,18 @@ bot.command("users", async (ctx) => {
182182
});
183183

184184
bot.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

194199
bot.on('::url', async ctx => {

0 commit comments

Comments
 (0)