Sfoglia il codice sorgente

- Add list of apps

Parad0x 7 anni fa
parent
commit
48cc08e9a8
1 ha cambiato i file con 23 aggiunte e 0 eliminazioni
  1. 23 0
      src/bot/app.js

+ 23 - 0
src/bot/app.js

@@ -87,5 +87,28 @@ function app() {
     }
   });
 
+  cmdRegistry.register("apps", async (ctx) => {
+    try {
+      let apps = await db.App.findAndCountAll({
+        limit: 5
+      });
+      apps = apps.rows;
+      if (apps <= 0) {
+        ctx.reply("No apps to show");
+        return;
+      }
+      let msg = apps.map(el => {
+        return {
+          i: el.id,
+          n: el.name,
+          a: (el.activated ? "Activated" : "Not activated")
+        }
+      }).map(el => `[${el.i}](${el.n})\t${el.a}\n`).join("");
+      return ctx.reply(msg);
+    } catch (e) {
+      ie(5, e);
+    }
+  });
+
 }
 module.exports = app;