Add random last say command

master
Talon 2021-07-12 18:03:45 +02:00
parent 82d5cbc758
commit c33d35689b
1 changed files with 9 additions and 0 deletions

View File

@ -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);
});
}