From 7edf678a22cec08ad850af289dade1ff6a2ac4e7 Mon Sep 17 00:00:00 2001 From: Shane Madden Date: Mon, 4 Aug 2025 13:38:17 -0600 Subject: [PATCH] Allow loading .wasm files from bots loaded as modules --- lib/utils.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 09daa0f..3432ad8 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -260,10 +260,16 @@ exports.loadBot = function(name) { var files = fs.readdirSync(dir), modules = {}; files.forEach(file => { var m = file.match(/^(.*)\.js$/); - if(!m) { - return; + if(m) { + modules[m[1]] = fs.readFileSync(path.resolve(dir, file), {encoding: 'utf8'}); + } else { + var wm = file.match(/^(.*)\.wasm$/); + if(wm) { + modules[wm[1]] = { + binary: fs.readFileSync(path.resolve(dir, file), {encoding: 'base64'}), + }; + } } - modules[m[1]] = fs.readFileSync(path.resolve(dir, file), {encoding: 'utf8'}); }); return exports.translateModulesToDb(modules); };