Add ability to upload modules to the bot via discord

* Remove unused dependencies

* Add basic downloading of modules

* Add valid-url as dependency

* Add loading/reloading of netmodules

* Add support for help on netmodules

* Add whitelist for netmodules
This commit is contained in:
SileNce5k 2021-03-15 23:29:49 +01:00 committed by GitHub
parent 88100600b9
commit d636b39d7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 126 additions and 127 deletions

19
util/loadNetModules.js Normal file
View file

@ -0,0 +1,19 @@
const fs = require('fs')
const netloadDir = 'netload/'
module.exports = function (client) {
if (!fs.existsSync(netloadDir)) fs.mkdirSync(netloadDir);
let commandFiles = fs.readdirSync(netloadDir).filter(file => file.endsWith('.js'));
if (client.netmodules.size != 0) {
for (const i of commandFiles) {
delete require.cache[require.resolve(`../${netloadDir}${i}`)];
}
}
client.netmodules.clear()
for (const file of commandFiles) {
const command = require(`../${netloadDir}${file}`);
client.netmodules.set(command.name, command);
}
}