import { encode } from "html-entities"; function execute(client, event, args) { var name = args.toLowerCase(); var command = client.commands.filter(c=>(c.name.toLowerCase()==name || c.command.toLowerCase()==name))[0]; var module = client.modules.filter(m=>m.name.toLowerCase()==name)[0]; var specific = command ?? module ?? false; var config = client.cache.get(event.sender.roomId) ?? {}; if(args != "") { if(!module) { client.reply(event, `Module "${args}" not found.\nRun "${process.env.PREFIX}help" for a list of commands and modules.`); return; } if(config[module.name] !== undefined) config[module.name] = !config[module.name]; else config[module.name] = false; var state = (config[module.name] ? "En" : "Dis") + "abled"; var reply = state + " " + module.name; var replyHTML = `${state} ${encode(module.name)}`; client.cache.set(event.sender.roomId, config); client.reply(event, reply, replyHTML); return; } var modules = client.modules.map(m=>m.name); var enabled = modules.filter(m=>config[m]!==false); var reply = `enabled modules:\n${enabled.join(", ")}`; var replyHTML = `enabled modules:
${enabled.join(", ")}`; reply += `\navailable modules:\n${modules.join(", ")}`; replyHTML += `
available modules:
${modules.join(", ")}`; client.reply(event, reply, replyHTML); } export default { command: "toggle", name: "toggle", usage: "", minPwr: 50, desc: "toggle a module on or off in current channel", execute }