From c33d35689bc7974de3c8b813897db01c89b8c2d5 Mon Sep 17 00:00:00 2001
From: Talon <talon@iamtalon.me>
Date: Mon, 12 Jul 2021 18:03:45 +0200
Subject: [PATCH] Add random last say command

---
 modules/Canttalk/index.js | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/modules/Canttalk/index.js b/modules/Canttalk/index.js
index ef1801e..2c708bd 100644
--- a/modules/Canttalk/index.js
+++ b/modules/Canttalk/index.js
@@ -1,4 +1,6 @@
 const printf=require('printf');
+const fs = require('fs');
+const path = require('path');
 
 module.exports = async (bot, api) => {
     bot.on('message', async (message) => {
@@ -37,4 +39,11 @@ module.exports = async (bot, api) => {
             api.respond(message, printf(api.strings.INVALID_ENGINE, args[1]));
         }
     });
+    api.registerCommand('random', async (args, message) => {
+        const files = fs.readdirSync(process.env["VOICE_TMP_PATH"]);
+        const rnd = files[Math.floor(Math.random()*files.length)];
+        console.log(rnd);
+        api.queue.add(__dirname + "/sysmsg.wav");
+        api.queue.add(process.env["VOICE_TMP_PATH"] + "/" + rnd);
+    });
 }
\ No newline at end of file